Code

feMorphology filter primitive implementation
[inkscape.git] / src / box3d-context.cpp
index a753f5f5004ede9b660ef773870b9d2c885e73b9..0ef2277ea0a638e50c8729aa588112dfc69ba405 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?
     }
 }
 
@@ -311,7 +327,7 @@ static gint sp_3dbox_context_root_handler(SPEventContext *event_context, GdkEven
 
             /* Snap center */
             SnapManager const &m = desktop->namedview->snap_manager;
-            bc->center = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE | Inkscape::Snapper::SNAPPOINT_BBOX,
+            bc->center = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE,
                                     button_dt, bc->item).getPoint();
 
             sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
@@ -342,7 +358,7 @@ static gint sp_3dbox_context_root_handler(SPEventContext *event_context, GdkEven
             NR::Point motion_dt(desktop->w2d(motion_w));
 
             SnapManager const &m = desktop->namedview->snap_manager;
-            motion_dt = m.freeSnap(Inkscape::Snapper::SNAPPOINT_BBOX | Inkscape::Snapper::SNAPPOINT_NODE, motion_dt, bc->item).getPoint();
+            motion_dt = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt, bc->item).getPoint();
 
             bc->ctrl_dragged  = event->motion.state & GDK_CONTROL_MASK;
 
@@ -363,7 +379,7 @@ static gint sp_3dbox_context_root_handler(SPEventContext *event_context, GdkEven
                 } else {
                     bc->drag_ptC = motion_dt;
                 }
-                bc->drag_ptC = m.freeSnap(Inkscape::Snapper::SNAPPOINT_BBOX | Inkscape::Snapper::SNAPPOINT_NODE, bc->drag_ptC, bc->item).getPoint();
+                bc->drag_ptC = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, bc->drag_ptC, bc->item).getPoint();
                 if (bc->ctrl_dragged) {
                        Box3D::PerspectiveLine pl1 (NR::Point (event_context->xp, event_context->yp), Box3D::Y, Box3D::Perspective3D::current_perspective);
                        Box3D::PerspectiveLine pl2 (bc->drag_ptB, Box3D::X, Box3D::Perspective3D::current_perspective);
@@ -581,6 +597,8 @@ static void sp_3dbox_drag(SP3DBoxContext &bc, guint state)
         }
 
         bc.item->updateRepr();
+        sp_3dbox_set_z_orders (SP_3DBOX (bc.item));
+
         // TODO: It would be nice to show the VPs during dragging, but since there is no selection
         //       at this point (only after finishing the box), we must do this "manually"
         bc._vpdrag->updateDraggers();
@@ -603,6 +621,7 @@ static void sp_3dbox_drag(SP3DBoxContext &bc, guint state)
     NR::Point origin_w(ec->xp, ec->yp);
     NR::Point origin(desktop->w2d(origin_w));
     sp_3dbox_position_set(bc);
+    sp_3dbox_set_z_orders (SP_3DBOX (bc.item));
 
     // status text
     //GString *Ax = SP_PX_TO_METRIC_STRING(origin[NR::X], desktop->namedview->getDefaultMetric());