From: Diederik van Lierop Date: Sat, 25 Sep 2010 13:01:50 +0000 (+0200) Subject: Implement snapping of vanishing points (LP #629333) X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d4c22f866f0c9262e780b7bcbce4c790308e311c;p=inkscape.git Implement snapping of vanishing points (LP #629333) --- diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index 78ceec467..5ee158234 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -22,6 +22,8 @@ #include "xml/repr.h" #include "perspective-line.h" #include "shape-editor.h" +#include "snap.h" +#include "sp-namedview.h" namespace Box3D { @@ -76,7 +78,7 @@ have_VPs_of_same_perspective (VPDragger *dr1, VPDragger *dr2) } static void -vp_knot_moved_handler (SPKnot */*knot*/, Geom::Point const *ppointer, guint state, gpointer data) +vp_knot_moved_handler (SPKnot *knot, Geom::Point const *ppointer, guint state, gpointer data) { VPDragger *dragger = (VPDragger *) data; VPDrag *drag = dragger->parent; @@ -170,10 +172,20 @@ vp_knot_moved_handler (SPKnot */*knot*/, Geom::Point const *ppointer, guint stat return; } } - } + // We didn't snap to another dragger, so we'll try a regular snap + SPDesktop *desktop = inkscape_active_desktop(); + SnapManager &m = desktop->namedview->snap_manager; + m.setup(desktop); + Inkscape::SnappedPoint s = m.freeSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE)); + m.unSetup(); + if (s.getSnapped()) { + p = s.getPoint(); + sp_knot_moveto(knot, p); + } + } - dragger->point = p; // FIXME: Brauchen wir dragger->point überhaupt? + dragger->point = p; // FIXME: Is dragger->point being used at all? dragger->updateVPs(p); dragger->updateBoxDisplays();