diff options
| author | Diederik van Lierop <mail@diedenrezi.nl> | 2009-08-23 13:55:47 +0000 |
|---|---|---|
| committer | dvlierop2 <dvlierop2@users.sourceforge.net> | 2009-08-23 13:55:47 +0000 |
| commit | b3f3d7ad268f67e27792ecfbcebab1bbbe646b74 (patch) | |
| tree | e75486df75974b5787a3072fe70baaac2909947b /src/knot-holder-entity.cpp | |
| parent | patch from 416549 (diff) | |
| download | inkscape-b3f3d7ad268f67e27792ecfbcebab1bbbe646b74.tar.gz inkscape-b3f3d7ad268f67e27792ecfbcebab1bbbe646b74.zip | |
When dragging a knot along a constraint line, then allow snapping the position of the mouse pointer instead of its projection onto the constraint line (for this a check box has been added to the preferences dialog)
(bzr r8523)
Diffstat (limited to 'src/knot-holder-entity.cpp')
| -rw-r--r-- | src/knot-holder-entity.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp index 4225dd9e3..bf7505f3c 100644 --- a/src/knot-holder-entity.cpp +++ b/src/knot-holder-entity.cpp @@ -91,9 +91,12 @@ KnotHolderEntity::snap_knot_position(Geom::Point const &p) { Geom::Matrix const i2d (sp_item_i2d_affine(item)); Geom::Point s = p * i2d; + SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, true, item); + m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, s, Inkscape::SNAPSOURCE_HANDLE); + return s * i2d.inverse(); } @@ -102,10 +105,28 @@ KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape: { Geom::Matrix const i2d (sp_item_i2d_affine(item)); Geom::Point s = p * i2d; - Inkscape::Snapper::ConstraintLine transformed_constraint = Inkscape::Snapper::ConstraintLine(constraint.getPoint() * i2d, (constraint.getPoint() + constraint.getDirection()) * i2d - constraint.getPoint() * i2d); + SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, true, item); - m.constrainedSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, s, Inkscape::SNAPSOURCE_HANDLE, transformed_constraint); + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if ((prefs->getBool("/options/snapmousepointer/value", false))) { // legacy behavior (pre v0.47) + // Snapping the mouse pointer instead of the constrained position of the knot allows to snap to + // things which don't intersect with the constraint line. This should be handled by the + // smart dynamic guides which are yet to be implemented, making this behavior more clean and + // transparent. With the current implementation it leads to unexpected results, and it doesn't + // allow accurately controlling what is being snapped to. + + // 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); + } 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); + } + return s * i2d.inverse(); } |
