Code

Update current perspective when selection changes
authorcilix42 <cilix42@users.sourceforge.net>
Tue, 7 Aug 2007 14:44:02 +0000 (14:44 +0000)
committercilix42 <cilix42@users.sourceforge.net>
Tue, 7 Aug 2007 14:44:02 +0000 (14:44 +0000)
src/box3d-context.cpp

index 388e2037d89578bf91877e5d6202fbef818a53c7..de1a4e2bf5e2f884922674c4e4b4bee5a60740c0 100644 (file)
@@ -191,6 +191,22 @@ void sp_3dbox_context_selection_changed(Inkscape::Selection *selection, gpointer
             Inkscape::GC::anchor(shape_repr);
             sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
         }
+        if (SP_IS_3DBOX (item)) {
+            Box3D::Perspective3D::current_perspective = Box3D::get_persp_of_box (SP_3DBOX (item));
+        }
+    } else {
+        /* If several boxes sharing the same perspective are selected,
+           we can still set the current selection accordingly */
+        std::set<Box3D::Perspective3D *> perspectives;
+        for (GSList *i = (GSList *) selection->itemList(); i != NULL; i = i->next) {
+            if (SP_IS_3DBOX (i->data)) {
+                perspectives.insert (Box3D::get_persp_of_box (SP_3DBOX (i->data)));
+            }
+        }
+        if (perspectives.size() == 1) {
+            Box3D::Perspective3D::current_perspective = *(perspectives.begin());
+        }
+        // TODO: What to do if several boxes with different perspectives are selected?
     }
 }