From c4c42ebb66d55ca883ed93b2a72d26cd8a759a6d Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 30 May 2015 20:27:42 +0200 Subject: Snapping in node tool now also works when: - when double clicking to insert a node on a path - when dragging a part of the path to deform it Fixed bugs: - https://launchpad.net/bugs/1448859 (bzr r14189) --- src/snap.cpp | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 30441ca0b..5a308777c 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -121,7 +121,8 @@ void SnapManager::freeSnapReturnByRef(Geom::Point &p, } Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapCandidatePoint const &p, - Geom::OptRect const &bbox_to_snap) const + Geom::OptRect const &bbox_to_snap, + bool to_paths_only) const { if (!someSnapperMightSnap()) { return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, Geom::infinity(), 0, false, false, false); @@ -134,16 +135,16 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapCandidatePoint const (*i)->freeSnap(isr, p, bbox_to_snap, &_items_to_ignore, _unselected_nodes); } - return findBestSnap(p, isr, false); + return findBestSnap(p, isr, false, false, to_paths_only); } -void SnapManager::preSnap(Inkscape::SnapCandidatePoint const &p) +void SnapManager::preSnap(Inkscape::SnapCandidatePoint const &p, bool to_paths_only) { // setup() must have been called before calling this method! if (_snapindicator) { _snapindicator = false; // prevent other methods from drawing a snap indicator; we want to control this here - Inkscape::SnappedPoint s = freeSnap(p); + Inkscape::SnappedPoint s = freeSnap(p, Geom::OptRect(), to_paths_only); g_assert(_desktop != NULL); if (s.getSnapped()) { _desktop->snapindicator->set_new_snaptarget(s, true); @@ -855,7 +856,8 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapRotate(std::vector::iterator i = sp_list.begin(); + + while (i != sp_list.end()) { + Inkscape::SnapTargetType t = (*i).getTarget(); + if (t == Inkscape::SNAPTARGET_LINE_MIDPOINT || + t == Inkscape::SNAPTARGET_PATH || + t == Inkscape::SNAPTARGET_PATH_PERPENDICULAR || + t == Inkscape::SNAPTARGET_PATH_TANGENTIAL || + t == Inkscape::SNAPTARGET_PATH_INTERSECTION || + t == Inkscape::SNAPTARGET_PATH_GUIDE_INTERSECTION || + t == Inkscape::SNAPTARGET_PATH_CLIP || + t == Inkscape::SNAPTARGET_PATH_MASK || + t == Inkscape::SNAPTARGET_ELLIPSE_QUADRANT_POINT) { + ++i; + } else { + i = sp_list.erase(i); + } + } + } + // now let's see which snapped point gets a thumbs up Inkscape::SnappedPoint bestSnappedPoint(p.getPoint()); // std::cout << "Finding the best snap..." << std::endl; -- cgit v1.2.3