From 224a99dc216119d34eb3ed13d12f123158acfe3c Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Fri, 4 Nov 2011 22:30:19 +0100 Subject: 1) Cycle to the next-closest-snap-source when pressing tab, if the snap-closest-point-only-option has been activated. Works for the selector tool, but also when scaling/stretching/skewing a selection of nodes in the node tool 2) Cleanup and simplification of the code that finds the closest snapsource (bzr r10720) --- src/snap.cpp | 53 +++++++++++++++-------------------------------------- 1 file changed, 15 insertions(+), 38 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 5f4872bba..853268b4b 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -736,7 +736,7 @@ Inkscape::SnappedPoint SnapManager::freeSnapTranslate(std::vectorgetBool("/options/snapclosestonly/value")) { Inkscape::SnapSourceType t = p.getSourceType(); bool p_is_a_node = t & Inkscape::SNAPSOURCE_NODE_CATEGORY; bool p_is_a_bbox = t & Inkscape::SNAPSOURCE_BBOX_CATEGORY; - bool p_is_other = t & Inkscape::SNAPSOURCE_OTHERS_CATEGORY || t & Inkscape::SNAPSOURCE_DATUMS_CATEGORY; + bool p_is_other = (t & Inkscape::SNAPSOURCE_OTHERS_CATEGORY) || (t & Inkscape::SNAPSOURCE_DATUMS_CATEGORY); g_assert(_desktop != NULL); if (snapprefs.getSnapEnabledGlobally() && (p_is_other || (p_is_a_node && snapprefs.getSnapModeNode()) || (p_is_a_bbox && snapprefs.getSnapModeBBox()))) { @@ -1126,34 +1131,6 @@ void SnapManager::_displaySnapsource(Inkscape::SnapCandidatePoint const &p) cons } } } - -void SnapManager::keepClosestPointOnly(std::vector &points, const Geom::Point &reference) const -{ - if (points.size() == 0) { - return; - } - - if (points.size() == 1) { - points.front().setSourceNum(-1); // Just in case - return; - } - - Inkscape::SnapCandidatePoint closest_point = Inkscape::SnapCandidatePoint(Geom::Point(Geom::infinity(), Geom::infinity()), Inkscape::SNAPSOURCE_UNDEFINED, Inkscape::SNAPTARGET_UNDEFINED); - Geom::Coord closest_dist = Geom::infinity(); - - for(std::vector::const_iterator i = points.begin(); i != points.end(); i++) { - Geom::Coord dist = Geom::L2((*i).getPoint() - reference); - if (i == points.begin() || dist < closest_dist) { - closest_point = *i; - closest_dist = dist; - } - } - - closest_point.setSourceNum(-1); - points.clear(); - points.push_back(closest_point); -} - /* Local Variables: mode:c++ -- cgit v1.2.3