Code

Fix self-snapping when dragging the transformation center of a selection containing...
[inkscape.git] / src / knot-holder-entity.cpp
index bf7505f3c0afc64c6003f62d30bbf83906929107..0a449771e9e95b395045392049b37eb58845560a 100644 (file)
@@ -94,14 +94,14 @@ KnotHolderEntity::snap_knot_position(Geom::Point const &p)
 
     SnapManager &m = desktop->namedview->snap_manager;
     m.setup(desktop, true, item);
-
-    m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, s, Inkscape::SNAPSOURCE_HANDLE);
+    m.freeSnapReturnByRef(s, Inkscape::SNAPSOURCE_NODE_HANDLE);
+    m.unSetup();
 
     return s * i2d.inverse();
 }
 
 Geom::Point
-KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::ConstraintLine const &constraint)
+KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint)
 {
     Geom::Matrix const i2d (sp_item_i2d_affine(item));
     Geom::Point s = p * i2d;
@@ -119,13 +119,14 @@ KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape:
 
         // freeSnap() will try snapping point p. This will not take into account the constraint, which
         // is therefore to be enforced after snap_knot_position_constrained() has finished
-        m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, s, Inkscape::SNAPSOURCE_HANDLE);
+        m.freeSnapReturnByRef(s, Inkscape::SNAPSOURCE_NODE_HANDLE);
     } else {
         // constrainedSnap() will first project the point p onto the constraint line and then try to snap along that line.
         // This way the constraint is already enforced, no need to worry about that later on
-        Inkscape::Snapper::ConstraintLine transformed_constraint = Inkscape::Snapper::ConstraintLine(constraint.getPoint() * i2d, (constraint.getPoint() + constraint.getDirection()) * i2d - constraint.getPoint() * i2d);
-        m.constrainedSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, s, Inkscape::SNAPSOURCE_HANDLE, transformed_constraint);
+        Inkscape::Snapper::SnapConstraint transformed_constraint = Inkscape::Snapper::SnapConstraint(constraint.getPoint() * i2d, (constraint.getPoint() + constraint.getDirection()) * i2d - constraint.getPoint() * i2d);
+        m.constrainedSnapReturnByRef(s, Inkscape::SNAPSOURCE_NODE_HANDLE, transformed_constraint);
     }
+    m.unSetup();
 
     return s * i2d.inverse();
 }