From 77dc5f1acd4a6b66b2d6fc5c81f7e5c61ef95785 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 5 Aug 2010 02:49:51 +0200 Subject: Wholesale cruft removal part 4; fix crash when rendering guides (bzr r9508.1.48) --- src/snap.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index c47f93ff1..718700103 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -201,7 +201,7 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapCandidatePoint const Geom::OptRect const &bbox_to_snap) const { if (!someSnapperMightSnap()) { - return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false); + return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, Geom::infinity(), 0, false, false, false); } SnappedConstraints sc; @@ -257,7 +257,7 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c if (_desktop && _desktop->gridsEnabled()) { bool success = false; Geom::Point nearest_multiple; - Geom::Coord nearest_distance = NR_HUGE; + Geom::Coord nearest_distance = Geom::infinity(); Inkscape::SnappedPoint bestSnappedPoint(t); // It will snap to the grid for which we find the closest snap. This might be a different @@ -551,10 +551,10 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( /* The current best transformation */ Geom::Point best_transformation = transformation; - /* The current best metric for the best transformation; lower is better, NR_HUGE + /* The current best metric for the best transformation; lower is better, Geom::infinity() ** means that we haven't snapped anything. */ - Geom::Point best_scale_metric(NR_HUGE, NR_HUGE); + Geom::Point best_scale_metric(Geom::infinity(), Geom::infinity()); Inkscape::SnappedPoint best_snapped_point; g_assert(best_snapped_point.getAlwaysSnap() == false); // Check initialization of snapped point g_assert(best_snapped_point.getAtIntersection() == false); @@ -643,7 +643,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( break; case SCALE: { - result = Geom::Point(NR_HUGE, NR_HUGE); + result = Geom::Point(Geom::infinity(), Geom::infinity()); // If this point *i is horizontally or vertically aligned with // the origin of the scaling, then it will scale purely in X or Y // We can therefore only calculate the scaling in this direction @@ -654,7 +654,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( if (fabs(fabs(a[index]/b[index]) - fabs(transformation[index])) > 1e-12) { // if SNAPPING DID occur in this direction result[index] = a[index] / b[index]; // then calculate it! } - // we might leave result[1-index] = NR_HUGE + // we might leave result[1-index] = Geom::infinity() // if scaling didn't occur in the other direction } } @@ -666,13 +666,13 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( } } // Compare the resulting scaling with the desired scaling - Geom::Point scale_metric = Geom::abs(result - transformation); // One or both of its components might be NR_HUGE + Geom::Point scale_metric = Geom::abs(result - transformation); // One or both of its components might be Geom::infinity() snapped_point.setSnapDistance(std::min(scale_metric[0], scale_metric[1])); snapped_point.setSecondSnapDistance(std::max(scale_metric[0], scale_metric[1])); break; } case STRETCH: - result = Geom::Point(NR_HUGE, NR_HUGE); + result = Geom::Point(Geom::infinity(), Geom::infinity()); if (fabs(b[dim]) > 1e-6) { // if STRETCHING will occur for this point result[dim] = a[dim] / b[dim]; result[1-dim] = uniform ? result[dim] : 1; @@ -684,14 +684,14 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( } // Store the metric for this transformation as a virtual distance snapped_point.setSnapDistance(std::abs(result[dim] - transformation[dim])); - snapped_point.setSecondSnapDistance(NR_HUGE); + snapped_point.setSecondSnapDistance(Geom::infinity()); break; case SKEW: result[0] = (snapped_point.getPoint()[dim] - ((*i).getPoint())[dim]) / (((*i).getPoint())[1 - dim] - origin[1 - dim]); // skew factor result[1] = transformation[1]; // scale factor // Store the metric for this transformation as a virtual distance snapped_point.setSnapDistance(std::abs(result[0] - transformation[0])); - snapped_point.setSecondSnapDistance(NR_HUGE); + snapped_point.setSecondSnapDistance(Geom::infinity()); break; default: g_assert_not_reached(); @@ -708,10 +708,10 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( Geom::Coord best_metric; if (transformation_type == SCALE) { - // When scaling, don't ever exit with one of scaling components set to NR_HUGE + // When scaling, don't ever exit with one of scaling components set to Geom::infinity() for (int index = 0; index < 2; index++) { - if (best_transformation[index] == NR_HUGE) { - if (uniform && best_transformation[1-index] < NR_HUGE) { + if (best_transformation[index] == Geom::infinity()) { + if (uniform && best_transformation[1-index] < Geom::infinity()) { best_transformation[index] = best_transformation[1-index]; } else { best_transformation[index] = transformation[index]; @@ -722,9 +722,9 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( best_metric = best_snapped_point.getSnapDistance(); best_snapped_point.setTransformation(best_transformation); - // Using " < 1e6" instead of " < NR_HUGE" for catching some rounding errors + // Using " < 1e6" instead of " < Geom::infinity()" for catching some rounding errors // These rounding errors might be caused by NRRects, see bug #1584301 - best_snapped_point.setSnapDistance(best_metric < 1e6 ? best_metric : NR_HUGE); + best_snapped_point.setSnapDistance(best_metric < 1e6 ? best_metric : Geom::infinity()); return best_snapped_point; } -- cgit v1.2.3 From 795d604aaf9c1c8146d513fbdcf21ac442a0d1a0 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 12 Mar 2011 00:01:04 +0100 Subject: Snap while rotating: fix removal of points too close to the rotation center (bzr r10093) --- src/snap.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index f13b02b46..fb8f70c49 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -760,16 +760,6 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( dedicated_constraint = Inkscape::Snapper::SnapConstraint(origin, b); } else if (transformation_type == ROTATE) { Geom::Coord r = Geom::L2(b); // the radius of the circular constraint - if (r < 1e-9) { // points too close to the rotation center will not move. Don't try to snap these - // as they will always yield a perfect snap result if they're already snapped beforehand (e.g. - // when the transformation center has been snapped to a grid intersection in the selector tool) - continue; // skip this SnapCandidate and continue with the next one - // PS1: Apparently we don't have to do this for skewing, but why? - // PS2: We cannot easily filter these points upstream, e.g. in the grab() method (seltrans.cpp) - // because the rotation center will change when pressing shift, and grab() won't be recalled. - // Filtering could be done in handleRequest() (again in seltrans.cpp), by iterating through - // the snap candidates. But hey, we're iterating here anyway. - } dedicated_constraint = Inkscape::Snapper::SnapConstraint(origin, b, r); } else if (transformation_type == STRETCH) { // when non-uniform stretching { dedicated_constraint = Inkscape::Snapper::SnapConstraint((*i).getPoint(), component_vectors[dim]); @@ -895,8 +885,18 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( // a is vector to snapped point; b is vector to original point; now lets calculate angle between a and b result[0] = atan2(Geom::dot(Geom::rot90(b), a), Geom::dot(b, a)); result[1] = result[1]; // how else should we store an angle in a point ;-) - // Store the metric for this transformation as a virtual distance (we're storing an angle) - snapped_point.setSnapDistance(std::abs(result[0] - transformation[0])); + if (Geom::L2(b) < 1e-9) { // points too close to the rotation center will not move. Don't try to snap these + // as they will always yield a perfect snap result if they're already snapped beforehand (e.g. + // when the transformation center has been snapped to a grid intersection in the selector tool) + snapped_point.setSnapDistance(NR_HUGE); + // PS1: Apparently we don't have to do this for skewing, but why? + // PS2: We cannot easily filter these points upstream, e.g. in the grab() method (seltrans.cpp) + // because the rotation center will change when pressing shift, and grab() won't be recalled. + // Filtering could be done in handleRequest() (again in seltrans.cpp), by iterating through + // the snap candidates. But hey, we're iterating here anyway. + } else { + snapped_point.setSnapDistance(std::abs(result[0] - transformation[0])); + } snapped_point.setSecondSnapDistance(NR_HUGE); break; default: -- cgit v1.2.3 From ab143333746e25648b253f13c0539adff089b1b6 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 24 Jun 2011 00:22:07 +0200 Subject: Remove more of libnr (bzr r10347.1.2) --- src/snap.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index f8fe8e3fa..922dfd530 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -19,6 +19,7 @@ */ #include +#include <2geom/transforms.h> #include "sp-namedview.h" #include "snap.h" @@ -293,7 +294,7 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c // use getSnapDistance() instead of getWeightedDistance() here because the pointer's position // doesn't tell us anything about which node to snap success = true; - nearest_multiple = s.getPoint() - to_2geom(grid->origin); + nearest_multiple = s.getPoint() - grid->origin; nearest_distance = s.getSnapDistance(); bestSnappedPoint = s; } -- cgit v1.2.3 From bdf703831ff93438d49324ab842052ccaf390a5d Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 26 Jun 2011 22:00:36 +0200 Subject: =?UTF-8?q?-=20Add=20a=20third=20group=20of=20snap=20sources/targe?= =?UTF-8?q?ts,=20called=20=C2=A8others=C2=A8=20(before=20we=20had=20only?= =?UTF-8?q?=20=C2=A8bounding=20box=C2=A8=20and=20nodes=20(see=20bug=20#788?= =?UTF-8?q?178)=20-=20Fix=20the=20display=20of=20the=20snap=20source=20-?= =?UTF-8?q?=20Fix=20snapping=20of=20guides=20to=20other=20guides=20&=20gri?= =?UTF-8?q?ds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (bzr r10372) --- src/snap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index f8fe8e3fa..bf1613d2c 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -916,7 +916,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( // We might still need to apply a constraint though, if we tried a constrained snap. And // in case of a free snap we might have use for the transformed point, so let's return that // point, whether it's constrained or not - if (best_snapped_point.isOtherSnapBetter(snapped_point, true)) { + if (best_snapped_point.isOtherSnapBetter(snapped_point, true) || points.size() == 1) { // .. so we must keep track of the best non-snapped constrained point best_transformation = result; best_snapped_point = snapped_point; @@ -1440,7 +1440,7 @@ void SnapManager::_displaySnapsource(Inkscape::SnapCandidatePoint const &p) cons if (prefs->getBool("/options/snapclosestonly/value")) { bool p_is_a_node = p.getSourceType() & Inkscape::SNAPSOURCE_NODE_CATEGORY; bool p_is_a_bbox = p.getSourceType() & Inkscape::SNAPSOURCE_BBOX_CATEGORY; - bool p_is_other = p.getSourceType() & Inkscape::SNAPSOURCE_OTHER_CATEGORY; + bool p_is_other = p.getSourceType() & Inkscape::SNAPSOURCE_OTHERS_CATEGORY; g_assert(_desktop != NULL); if (snapprefs.getSnapEnabledGlobally() && (p_is_other || (p_is_a_node && snapprefs.getSnapModeNode()) || (p_is_a_bbox && snapprefs.getSnapModeBBox()))) { -- cgit v1.2.3 From f412e210814555e34cd2a6d1bb86cd2c153d60a0 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 16 Jul 2011 00:51:02 +0200 Subject: Fix scaling error when snapping, caused by rev. #10326 Fixed bugs: - https://launchpad.net/bugs/808558 (bzr r10458) --- src/snap.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 3e79a221e..d556a751a 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -746,6 +746,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( // std::cout << std::endl; bool first_free_snap = true; + for (std::vector::const_iterator i = points.begin(); i != points.end(); i++) { /* Snap it */ @@ -850,6 +851,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( result[0] = result[1]; } } + // Compare the resulting scaling with the desired scaling Geom::Point scale_metric = Geom::abs(result - transformation); // One or both of its components might be NR_HUGE if (scale_metric[0] == NR_HUGE || scale_metric[1] == NR_HUGE) { @@ -930,10 +932,10 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( Geom::Coord best_metric; if (transformation_type == SCALE) { - // When scaling, don't ever exit with one of scaling components set to Geom::infinity() + // When scaling, don't ever exit with one of scaling components uninitialized for (int index = 0; index < 2; index++) { - if (best_transformation[index] == Geom::infinity()) { - if (uniform && best_transformation[1-index] < Geom::infinity()) { + if (fabs(best_transformation[index]) >= 1e12) { + if (uniform && fabs(best_transformation[1-index]) < 1e12) { best_transformation[index] = best_transformation[1-index]; } else { best_transformation[index] = transformation[index]; -- cgit v1.2.3 From 0621c6d7ff695fca923ff3aa3003f25fccf94b32 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 18 Jul 2011 22:07:56 +0200 Subject: Replace NR_HUGE by Geom:infinity() in some snapping code (bzr r10469) --- src/snap.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index d556a751a..a3015e576 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -375,7 +375,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint // First project the mouse pointer onto the constraint Geom::Point pp = constraint.projection(p.getPoint()); - Inkscape::SnappedPoint no_snap = Inkscape::SnappedPoint(pp, p.getSourceType(), p.getSourceNum(), Inkscape::SNAPTARGET_CONSTRAINT, NR_HUGE, 0, false, true, false); + Inkscape::SnappedPoint no_snap = Inkscape::SnappedPoint(pp, p.getSourceType(), p.getSourceNum(), Inkscape::SNAPTARGET_CONSTRAINT, Geom::infinity(), 0, false, true, false); if (!someSnapperMightSnap()) { // Always return point on constraint @@ -437,7 +437,7 @@ Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandi Geom::OptRect const &bbox_to_snap) const { - Inkscape::SnappedPoint no_snap = Inkscape::SnappedPoint(p.getPoint(), p.getSourceType(), p.getSourceNum(), Inkscape::SNAPTARGET_CONSTRAINT, NR_HUGE, 0, false, true, false); + Inkscape::SnappedPoint no_snap = Inkscape::SnappedPoint(p.getPoint(), p.getSourceType(), p.getSourceNum(), Inkscape::SNAPTARGET_CONSTRAINT, Geom::infinity(), 0, false, true, false); if (constraints.size() == 0) { return no_snap; } @@ -829,7 +829,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( break; case SCALE: { - result = Geom::Point(NR_HUGE, NR_HUGE); + result = Geom::Point(Geom::infinity(), Geom::infinity()); // If this point *i is horizontally or vertically aligned with // the origin of the scaling, then it will scale purely in X or Y // We can therefore only calculate the scaling in this direction @@ -840,7 +840,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( if (fabs(fabs(a[index]/b[index]) - fabs(transformation[index])) > 1e-12) { // if SNAPPING DID occur in this direction result[index] = a[index] / b[index]; // then calculate it! } - // we might have left result[1-index] = NR_HUGE + // we might have left result[1-index] = Geom::infinity() // if scaling didn't occur in the other direction } } @@ -853,17 +853,17 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( } // Compare the resulting scaling with the desired scaling - Geom::Point scale_metric = Geom::abs(result - transformation); // One or both of its components might be NR_HUGE - if (scale_metric[0] == NR_HUGE || scale_metric[1] == NR_HUGE) { + Geom::Point scale_metric = Geom::abs(result - transformation); // One or both of its components might be Geom::infinity() + if (scale_metric[0] == Geom::infinity() || scale_metric[1] == Geom::infinity()) { snapped_point.setSnapDistance(std::min(scale_metric[0], scale_metric[1])); } else { snapped_point.setSnapDistance(Geom::L2(scale_metric)); } - snapped_point.setSecondSnapDistance(NR_HUGE); + snapped_point.setSecondSnapDistance(Geom::infinity()); break; } case STRETCH: - result = Geom::Point(NR_HUGE, NR_HUGE); + result = Geom::Point(Geom::infinity(), Geom::infinity()); if (fabs(b[dim]) > 1e-6) { // if STRETCHING will occur for this point result[dim] = a[dim] / b[dim]; result[1-dim] = uniform ? result[dim] : 1; @@ -875,14 +875,14 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( } // Store the metric for this transformation as a virtual distance snapped_point.setSnapDistance(std::abs(result[dim] - transformation[dim])); - snapped_point.setSecondSnapDistance(NR_HUGE); + snapped_point.setSecondSnapDistance(Geom::infinity()); break; case SKEW: result[0] = (snapped_point.getPoint()[dim] - ((*i).getPoint())[dim]) / b[1 - dim]; // skew factor result[1] = transformation[1]; // scale factor // Store the metric for this transformation as a virtual distance snapped_point.setSnapDistance(std::abs(result[0] - transformation[0])); - snapped_point.setSecondSnapDistance(NR_HUGE); + snapped_point.setSecondSnapDistance(Geom::infinity()); break; case ROTATE: // a is vector to snapped point; b is vector to original point; now lets calculate angle between a and b @@ -891,7 +891,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( if (Geom::L2(b) < 1e-9) { // points too close to the rotation center will not move. Don't try to snap these // as they will always yield a perfect snap result if they're already snapped beforehand (e.g. // when the transformation center has been snapped to a grid intersection in the selector tool) - snapped_point.setSnapDistance(NR_HUGE); + snapped_point.setSnapDistance(Geom::infinity()); // PS1: Apparently we don't have to do this for skewing, but why? // PS2: We cannot easily filter these points upstream, e.g. in the grab() method (seltrans.cpp) // because the rotation center will change when pressing shift, and grab() won't be recalled. @@ -900,7 +900,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( } else { snapped_point.setSnapDistance(std::abs(result[0] - transformation[0])); } - snapped_point.setSecondSnapDistance(NR_HUGE); + snapped_point.setSecondSnapDistance(Geom::infinity()); break; default: g_assert_not_reached(); @@ -934,8 +934,8 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( if (transformation_type == SCALE) { // When scaling, don't ever exit with one of scaling components uninitialized for (int index = 0; index < 2; index++) { - if (fabs(best_transformation[index]) >= 1e12) { - if (uniform && fabs(best_transformation[1-index]) < 1e12) { + if (fabs(best_transformation[index]) == Geom::infinity()) { + if (uniform && fabs(best_transformation[1-index]) < Geom::infinity()) { best_transformation[index] = best_transformation[1-index]; } else { best_transformation[index] = transformation[index]; @@ -1458,8 +1458,8 @@ void SnapManager::keepClosestPointOnly(std::vector { if (points.size() < 2) return; - Inkscape::SnapCandidatePoint closest_point = Inkscape::SnapCandidatePoint(Geom::Point(NR_HUGE, NR_HUGE), Inkscape::SNAPSOURCE_UNDEFINED, Inkscape::SNAPTARGET_UNDEFINED); - Geom::Coord closest_dist = NR_HUGE; + 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); -- cgit v1.2.3 From babb7a67749cb691674bdd9758f0568d4b094b56 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 22 Aug 2011 20:27:53 +0200 Subject: Refactoring of the snapping preferences; mainly about storing all toggles in a single array, instead of each having its own member variable (bzr r10569) --- src/snap.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index a3015e576..8d3103122 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -97,7 +97,7 @@ SnapManager::getGridSnappers() const { SnapperList s; - if (_desktop && _desktop->gridsEnabled() && snapprefs.getSnapToGrids()) { + if (_desktop && _desktop->gridsEnabled() && snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GRID)) { for ( GSList const *l = _named_view->grids; l != NULL; l = l->next) { Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data; s.push_back(grid->snapper); @@ -577,7 +577,7 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, return; } - if (!(object.ThisSnapperMightSnap() || snapprefs.getSnapToGuides())) { + if (!(object.ThisSnapperMightSnap() || snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE))) { return; } @@ -624,7 +624,7 @@ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) return; } - if (!(object.ThisSnapperMightSnap() || snapprefs.getSnapToGuides())) { + if (!(object.ThisSnapperMightSnap() || snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE))) { return; } @@ -1202,7 +1202,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co } } - if (snapprefs.getSnapIntersectionCS()) { + if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION)) { // search for the closest snapped intersection of curves Inkscape::SnappedPoint closestCurvesIntersection; if (getClosestIntersectionCS(sc.curves, p.getPoint(), closestCurvesIntersection, _desktop->dt2doc())) { @@ -1247,7 +1247,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co } // search for the closest snapped intersection of grid with guide lines - if (snapprefs.getSnapIntersectionGG()) { + if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GRID_GUIDE_INTERSECTION)) { Inkscape::SnappedPoint closestGridGuidePoint; if (getClosestIntersectionSL(sc.grid_lines, sc.guide_lines, closestGridGuidePoint)) { closestGridGuidePoint.setSource(p.getSourceType()); -- cgit v1.2.3 From 458c1a2a8f34a342d2728b144592110a65b4c2d1 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 22 Aug 2011 22:27:25 +0200 Subject: Fix snap bug #816044 Fixed bugs: - https://launchpad.net/bugs/816044 (bzr r10572) --- src/snap.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 8d3103122..30fc5387e 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1456,7 +1456,14 @@ void SnapManager::_displaySnapsource(Inkscape::SnapCandidatePoint const &p) cons void SnapManager::keepClosestPointOnly(std::vector &points, const Geom::Point &reference) const { - if (points.size() < 2) return; + 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(); -- cgit v1.2.3 From 906805aab186df9a92048a28962852921a50d334 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 22 Aug 2011 22:41:46 +0200 Subject: Fix another snapping bug (could occur when scaling an object using the selector tool) (bzr r10573) --- src/snap.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 30fc5387e..8c96cdfa1 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -853,7 +853,9 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( } // Compare the resulting scaling with the desired scaling - Geom::Point scale_metric = Geom::abs(result - transformation); // One or both of its components might be Geom::infinity() + Geom::Point scale_metric = result - transformation; // One or both of its components might be Geom::infinity() + scale_metric[0] = fabs(scale_metric[0]); + scale_metric[1] = fabs(scale_metric[1]); if (scale_metric[0] == Geom::infinity() || scale_metric[1] == Geom::infinity()) { snapped_point.setSnapDistance(std::min(scale_metric[0], scale_metric[1])); } else { -- cgit v1.2.3 From bc41980c93b8627b286daeb51bc29806a6c2b0f0 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Tue, 23 Aug 2011 21:17:19 +0200 Subject: 1) Use the "snap guides" button both for guides being snap sources, as well as for guides being snap targets 2) Remove some redundant guide-snapping code from the object snapper, (bzr r10576) --- src/snap.cpp | 42 ++++++------------------------------------ 1 file changed, 6 insertions(+), 36 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 8c96cdfa1..c4ca32364 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -560,11 +560,7 @@ Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandida } /** - * \brief Try to snap a point of a guide to another guide or to a node - * - * Try to snap a point of a guide to another guide or to a node in two degrees- - * of-freedom, i.e. snap in any direction on the two dimensional canvas to the - * nearest snap target. This method is used when dragging or rotating a guide + * \brief Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code) * * PS: SnapManager::setup() must have been called before calling this method, * @@ -573,11 +569,7 @@ Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandida */ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, SPGuideDragType drag_type) const { - if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally()) { - return; - } - - if (!(object.ThisSnapperMightSnap() || snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE))) { + if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() || !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE)) { return; } @@ -586,15 +578,8 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, candidate = Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_GUIDE); } - // Snap to nodes SnappedConstraints sc; - if (object.ThisSnapperMightSnap()) { - object.guideFreeSnap(sc, p, guide_normal); - } - - // Snap to guides & grid lines - SnapperList snappers = getGridSnappers(); - snappers.push_back(&guide); + SnapperList snappers = getSnappers(); for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { (*i)->freeSnap(sc, candidate, Geom::OptRect(), NULL, NULL); } @@ -605,12 +590,7 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, } /** - * \brief Try to snap a point on a guide to the intersection with another guide or a path - * - * Try to snap a point on a guide to the intersection of that guide with another - * guide or with a path. The snapped point will lie somewhere on the guide-line, - * making this is a constrained snap, i.e. in only one degree-of-freedom. - * This method is used when dragging the origin of the guide along the guide itself. + * \brief Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code) * * PS: SnapManager::setup() must have been called before calling this method, * @@ -620,26 +600,16 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) const { - if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally()) { - return; - } - - if (!(object.ThisSnapperMightSnap() || snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE))) { + if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() || !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE)) { return; } Inkscape::SnapCandidatePoint candidate(p, Inkscape::SNAPSOURCE_GUIDE_ORIGIN, Inkscape::SNAPTARGET_UNDEFINED); - // Snap to nodes or paths SnappedConstraints sc; Inkscape::Snapper::SnapConstraint cl(guideline.point_on_line, Geom::rot90(guideline.normal_to_line)); - if (object.ThisSnapperMightSnap()) { - object.constrainedSnap(sc, candidate, Geom::OptRect(), cl, NULL, NULL); - } - // Snap to guides & grid lines - SnapperList snappers = getGridSnappers(); - snappers.push_back(&guide); + SnapperList snappers = getSnappers(); for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { (*i)->constrainedSnap(sc, candidate, Geom::OptRect(), cl, NULL, NULL); } -- cgit v1.2.3 From 3da0fd8b645937bcdd26d2ab3db716982030fc19 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Thu, 25 Aug 2011 22:08:16 +0200 Subject: Fix "snap guides" toggle Fixed bugs: - https://launchpad.net/bugs/814457 (bzr r10582) --- src/snap.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index c4ca32364..7647341fe 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1413,9 +1413,10 @@ void SnapManager::_displaySnapsource(Inkscape::SnapCandidatePoint const &p) cons Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/options/snapclosestonly/value")) { - bool p_is_a_node = p.getSourceType() & Inkscape::SNAPSOURCE_NODE_CATEGORY; - bool p_is_a_bbox = p.getSourceType() & Inkscape::SNAPSOURCE_BBOX_CATEGORY; - bool p_is_other = p.getSourceType() & Inkscape::SNAPSOURCE_OTHERS_CATEGORY; + 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; g_assert(_desktop != NULL); if (snapprefs.getSnapEnabledGlobally() && (p_is_other || (p_is_a_node && snapprefs.getSnapModeNode()) || (p_is_a_bbox && snapprefs.getSnapModeBBox()))) { -- cgit v1.2.3 From d6af1140ee108cc7d7fb6e0ba89ff7e30bb7ad3a Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 27 Aug 2011 18:05:32 +0200 Subject: Completely remove NRRect, NRRectL, in-svg-plane.h (bzr r10582.1.6) --- src/snap.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 7647341fe..1756e7dd2 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -734,7 +734,8 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( Geom::Coord r = Geom::L2(b); // the radius of the circular constraint dedicated_constraint = Inkscape::Snapper::SnapConstraint(origin, b, r); } else if (transformation_type == STRETCH) { // when non-uniform stretching { - dedicated_constraint = Inkscape::Snapper::SnapConstraint((*i).getPoint(), component_vectors[dim]); + Geom::Point cvec; cvec[dim] = 1.; + dedicated_constraint = Inkscape::Snapper::SnapConstraint((*i).getPoint(), cvec); } else if (transformation_type == TRANSLATE) { // When doing a constrained translation, all points will move in the same direction, i.e. // either horizontally or vertically. The lines along which they move are therefore all @@ -751,7 +752,8 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( // When scaling, a point aligned either horizontally or vertically with the origin can only // move in that specific direction; therefore it should only snap in that direction, otherwise // we will get snapped points with an invalid transformation - dedicated_constraint = Inkscape::Snapper::SnapConstraint(origin, component_vectors[c1]); + Geom::Point cvec; cvec[c1] = 1.; + dedicated_constraint = Inkscape::Snapper::SnapConstraint(origin, cvec); snapped_point = constrainedSnap(*j, dedicated_constraint, bbox); } else { // If we have a collection of SnapCandidatePoints, with mixed constrained snapping and free snapping -- cgit v1.2.3 From e5c85aa8478032ebecd8c586dc27afcaf77e4314 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 27 Aug 2011 22:54:42 +0200 Subject: Allow snapping to path intersections without snapping to the paths themselves (bzr r10585) --- src/snap.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 7647341fe..67630399f 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -288,7 +288,7 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c // Find the best snap for this grid, including intersections of the grid-lines bool old_val = _snapindicator; _snapindicator = false; - Inkscape::SnappedPoint s = findBestSnap(Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH), sc, false, false, true); + Inkscape::SnappedPoint s = findBestSnap(Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH), sc, false, true); _snapindicator = old_val; if (s.getSnapped() && (s.getSnapDistance() < nearest_distance)) { // use getSnapDistance() instead of getWeightedDistance() here because the pointer's position @@ -584,7 +584,7 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, (*i)->freeSnap(sc, candidate, Geom::OptRect(), NULL, NULL); } - Inkscape::SnappedPoint const s = findBestSnap(candidate, sc, false, false); + Inkscape::SnappedPoint const s = findBestSnap(candidate, sc, false); s.getPointIfSnapped(p); } @@ -1135,7 +1135,6 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapRotate(std::vector Date: Sun, 28 Aug 2011 15:03:49 +0200 Subject: Fix bug related to snapping to path intersections (bzr r10587) --- src/snap.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 67630399f..5779e59b0 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1149,7 +1149,6 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co /* std::cout << "Type and number of snapped constraints: " << std::endl; std::cout << " Points : " << sc.points.size() << std::endl; - // std::cout << " Lines : " << sc.lines.size() << std::endl; std::cout << " Grid lines : " << sc.grid_lines.size()<< std::endl; std::cout << " Guide lines : " << sc.guide_lines.size()<< std::endl; std::cout << " Curves : " << sc.curves.size()<< std::endl; -- cgit v1.2.3 From 59259f0cabfa0205acc3229c281169e8406570b3 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Fri, 2 Sep 2011 22:14:29 +0200 Subject: Rename the struct "SnappedConstraints" to the more meaningfull "IntermSnapResults" (bzr r10612) --- src/snap.cpp | 64 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 9020b82a3..5f65b643d 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -210,14 +210,14 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapCandidatePoint const return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, Geom::infinity(), 0, false, false, false); } - SnappedConstraints sc; + IntermSnapResults isr; SnapperList const snappers = getSnappers(); for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { - (*i)->freeSnap(sc, p, bbox_to_snap, &_items_to_ignore, _unselected_nodes); + (*i)->freeSnap(isr, p, bbox_to_snap, &_items_to_ignore, _unselected_nodes); } - return findBestSnap(p, sc, false); + return findBestSnap(p, isr, false); } void SnapManager::preSnap(Inkscape::SnapCandidatePoint const &p) @@ -282,13 +282,13 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c // only if the origin of the grid is at (0,0). If it's not then compensate for this // in the translation t Geom::Point const t_offset = t + grid->origin; - SnappedConstraints sc; + IntermSnapResults isr; // Only the first three parameters are being used for grid snappers - snapper->freeSnap(sc, Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH),Geom::OptRect(), NULL, NULL); + snapper->freeSnap(isr, Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH),Geom::OptRect(), NULL, NULL); // Find the best snap for this grid, including intersections of the grid-lines bool old_val = _snapindicator; _snapindicator = false; - Inkscape::SnappedPoint s = findBestSnap(Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH), sc, false, true); + Inkscape::SnappedPoint s = findBestSnap(Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH), isr, false, true); _snapindicator = old_val; if (s.getSnapped() && (s.getSnapDistance() < nearest_distance)) { // use getSnapDistance() instead of getWeightedDistance() here because the pointer's position @@ -403,13 +403,13 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint return no_snap; } - SnappedConstraints sc; + IntermSnapResults isr; SnapperList const snappers = getSnappers(); for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { - (*i)->constrainedSnap(sc, p, bbox_to_snap, constraint, &_items_to_ignore, _unselected_nodes); + (*i)->constrainedSnap(isr, p, bbox_to_snap, constraint, &_items_to_ignore, _unselected_nodes); } - result = findBestSnap(p, sc, true); + result = findBestSnap(p, isr, true); if (result.getSnapped()) { // only change the snap indicator if we really snapped to something @@ -442,7 +442,7 @@ Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandi return no_snap; } - SnappedConstraints sc; + IntermSnapResults isr; SnapperList const snappers = getSnappers(); std::vector projections; bool snapping_is_futile = !someSnapperMightSnap() || dont_snap; @@ -471,11 +471,11 @@ Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandi // Try to snap to the constraint if (!snapping_is_futile) { for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { - (*i)->constrainedSnap(sc, p, bbox_to_snap, *c, &_items_to_ignore,_unselected_nodes); + (*i)->constrainedSnap(isr, p, bbox_to_snap, *c, &_items_to_ignore,_unselected_nodes); } } } - result = findBestSnap(p, sc, true); + result = findBestSnap(p, isr, true); } if (result.getSnapped()) { @@ -578,13 +578,13 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, candidate = Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_GUIDE); } - SnappedConstraints sc; + IntermSnapResults isr; SnapperList snappers = getSnappers(); for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { - (*i)->freeSnap(sc, candidate, Geom::OptRect(), NULL, NULL); + (*i)->freeSnap(isr, candidate, Geom::OptRect(), NULL, NULL); } - Inkscape::SnappedPoint const s = findBestSnap(candidate, sc, false); + Inkscape::SnappedPoint const s = findBestSnap(candidate, isr, false); s.getPointIfSnapped(p); } @@ -606,15 +606,15 @@ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) Inkscape::SnapCandidatePoint candidate(p, Inkscape::SNAPSOURCE_GUIDE_ORIGIN, Inkscape::SNAPTARGET_UNDEFINED); - SnappedConstraints sc; + IntermSnapResults isr; Inkscape::Snapper::SnapConstraint cl(guideline.point_on_line, Geom::rot90(guideline.normal_to_line)); SnapperList snappers = getSnappers(); for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { - (*i)->constrainedSnap(sc, candidate, Geom::OptRect(), cl, NULL, NULL); + (*i)->constrainedSnap(isr, candidate, Geom::OptRect(), cl, NULL, NULL); } - Inkscape::SnappedPoint const s = findBestSnap(candidate, sc, false); + Inkscape::SnappedPoint const s = findBestSnap(candidate, isr, false); s.getPointIfSnapped(p); } @@ -1135,14 +1135,14 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapRotate(std::vectordt2doc())) { + if (getClosestIntersectionCS(isr.curves, p.getPoint(), closestCurvesIntersection, _desktop->dt2doc())) { closestCurvesIntersection.setSource(p.getSourceType()); sp_list.push_back(closestCurvesIntersection); } @@ -1184,13 +1184,13 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co // search for the closest snapped grid line Inkscape::SnappedLine closestGridLine; - if (getClosestSL(sc.grid_lines, closestGridLine)) { + if (getClosestSL(isr.grid_lines, closestGridLine)) { sp_list.push_back(Inkscape::SnappedPoint(closestGridLine)); } // search for the closest snapped guide line Inkscape::SnappedLine closestGuideLine; - if (getClosestSL(sc.guide_lines, closestGuideLine)) { + if (getClosestSL(isr.guide_lines, closestGuideLine)) { sp_list.push_back(Inkscape::SnappedPoint(closestGuideLine)); } @@ -1203,7 +1203,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co if (!constrained) { // search for the closest snapped intersection of grid lines Inkscape::SnappedPoint closestGridPoint; - if (getClosestIntersectionSL(sc.grid_lines, closestGridPoint)) { + if (getClosestIntersectionSL(isr.grid_lines, closestGridPoint)) { closestGridPoint.setSource(p.getSourceType()); closestGridPoint.setTarget(Inkscape::SNAPTARGET_GRID_INTERSECTION); sp_list.push_back(closestGridPoint); @@ -1211,7 +1211,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co // search for the closest snapped intersection of guide lines Inkscape::SnappedPoint closestGuidePoint; - if (getClosestIntersectionSL(sc.guide_lines, closestGuidePoint)) { + if (getClosestIntersectionSL(isr.guide_lines, closestGuidePoint)) { closestGuidePoint.setSource(p.getSourceType()); closestGuidePoint.setTarget(Inkscape::SNAPTARGET_GUIDE_INTERSECTION); sp_list.push_back(closestGuidePoint); @@ -1220,7 +1220,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co // search for the closest snapped intersection of grid with guide lines if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GRID_GUIDE_INTERSECTION)) { Inkscape::SnappedPoint closestGridGuidePoint; - if (getClosestIntersectionSL(sc.grid_lines, sc.guide_lines, closestGridGuidePoint)) { + if (getClosestIntersectionSL(isr.grid_lines, isr.guide_lines, closestGridGuidePoint)) { closestGridGuidePoint.setSource(p.getSourceType()); closestGridGuidePoint.setTarget(Inkscape::SNAPTARGET_GRID_GUIDE_INTERSECTION); sp_list.push_back(closestGridGuidePoint); -- cgit v1.2.3 From ee17bac8a5d9b6bf840272885c1eda57c45fb4ad Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 17 Sep 2011 01:00:05 +0200 Subject: Node tool, transforming a set of nodes: Fix crashes, and finish implementation of snapping Fixed bugs: - https://launchpad.net/bugs/590261 (bzr r10633) --- src/snap.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 5f65b643d..ac2abd63b 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -411,6 +411,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint result = findBestSnap(p, isr, true); + if (result.getSnapped()) { // only change the snap indicator if we really snapped to something if (_snapindicator && _desktop) { -- cgit v1.2.3 From f0fa8577f48a7b0ddb285764404be316855d2e83 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 17 Sep 2011 14:08:49 +0200 Subject: Make "snap page border" toggle independent of "snap paths" toggle Fixed bugs: - https://launchpad.net/bugs/850982 (bzr r10635) --- src/snap.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index ac2abd63b..631704b5c 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1167,11 +1167,9 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co } // search for the closest snapped curve - if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_PATH)) { // We might have been looking for path intersections only, and not for the paths themselves - Inkscape::SnappedCurve closestCurve; - if (getClosestCurve(isr.curves, closestCurve)) { - sp_list.push_back(Inkscape::SnappedPoint(closestCurve)); - } + Inkscape::SnappedCurve closestCurve; + if (getClosestCurve(isr.curves, closestCurve)) { + sp_list.push_back(Inkscape::SnappedPoint(closestCurve)); } if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION)) { -- cgit v1.2.3 From 344d9e8077c05b86e7d423b5db163b3e3e541032 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 18 Sep 2011 19:09:29 +0200 Subject: Snap to guide-path intersections, and don't snap to paths when only path intersections are asked for Fixed bugs: - https://launchpad.net/bugs/847457 - https://launchpad.net/bugs/850982 (bzr r10639) --- src/snap.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 631704b5c..eeca66d74 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1168,19 +1168,13 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co // search for the closest snapped curve Inkscape::SnappedCurve closestCurve; - if (getClosestCurve(isr.curves, closestCurve)) { + // We might have collected the paths only to snap to their intersection, without the intention to snap to the paths themselves + // Therefore we explicitly check whether the paths should be considered as snap targets themselves + bool exclude_paths = !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_PATH); + if (getClosestCurve(isr.curves, closestCurve, exclude_paths)) { sp_list.push_back(Inkscape::SnappedPoint(closestCurve)); } - if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION)) { - // search for the closest snapped intersection of curves - Inkscape::SnappedPoint closestCurvesIntersection; - if (getClosestIntersectionCS(isr.curves, p.getPoint(), closestCurvesIntersection, _desktop->dt2doc())) { - closestCurvesIntersection.setSource(p.getSourceType()); - sp_list.push_back(closestCurvesIntersection); - } - } - // search for the closest snapped grid line Inkscape::SnappedLine closestGridLine; if (getClosestSL(isr.grid_lines, closestGridLine)) { @@ -1200,6 +1194,24 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co // the grid/guide/path we're snapping to. This snappoint is therefore fully constrained, so there's // no need to look for additional intersections if (!constrained) { + if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION)) { + // search for the closest snapped intersection of curves + Inkscape::SnappedPoint closestCurvesIntersection; + if (getClosestIntersectionCS(isr.curves, p.getPoint(), closestCurvesIntersection, _desktop->dt2doc())) { + closestCurvesIntersection.setSource(p.getSourceType()); + sp_list.push_back(closestCurvesIntersection); + } + } + + if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_PATH_GUIDE_INTERSECTION)) { + // search for the closest snapped intersection of a guide with a curve + Inkscape::SnappedPoint closestCurveGuideIntersection; + if (getClosestIntersectionCL(isr.curves, isr.guide_lines, p.getPoint(), closestCurveGuideIntersection, _desktop->dt2doc())) { + closestCurveGuideIntersection.setSource(p.getSourceType()); + sp_list.push_back(closestCurveGuideIntersection); + } + } + // search for the closest snapped intersection of grid lines Inkscape::SnappedPoint closestGridPoint; if (getClosestIntersectionSL(isr.grid_lines, closestGridPoint)) { -- cgit v1.2.3 From 122894f12a4f8214207f533ed26569fbab5ac9f7 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 2 Oct 2011 01:26:17 -0700 Subject: Warning cleanup. (bzr r10655) --- src/snap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index eeca66d74..b2c5a5a10 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -568,7 +568,7 @@ Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandida * \param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred * \param guide_normal Vector normal to the guide line */ -void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, SPGuideDragType drag_type) const +void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &/*guide_normal*/, SPGuideDragType drag_type) const { if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() || !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE)) { return; -- cgit v1.2.3 From 20097d47e6945bceb57d2335d23fe764f493ab59 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 2 Oct 2011 20:44:17 -0700 Subject: Another minor pass of Doxygen cleanup. (bzr r10659) --- src/snap.cpp | 264 +++++++++++++++++++++++++++-------------------------------- 1 file changed, 120 insertions(+), 144 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index b2c5a5a10..fb6f120ec 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1,8 +1,6 @@ -#define __SP_DESKTOP_SNAP_C__ - /** * \file snap.cpp - * \brief SnapManager class. + * SnapManager class. * * Authors: * Lauris Kaplinski @@ -58,7 +56,7 @@ SnapManager::SnapManager(SPNamedView const *v) : } /** - * \brief Return a list of snappers + * Return a list of snappers. * * Inkscape snaps to objects, grids, and guides. For each of these snap targets a * separate class is used, which has been derived from the base Snapper class. The @@ -67,10 +65,9 @@ SnapManager::SnapManager(SPNamedView const *v) : * class, but any number of grid snappers (because each grid has its own snapper * instance) * - * \return List of snappers that we use. + * @return List of snappers that we use. */ -SnapManager::SnapperList -SnapManager::getSnappers() const +SnapManager::SnapperList SnapManager::getSnappers() const { SnapManager::SnapperList s; s.push_back(&guide); @@ -83,17 +80,16 @@ SnapManager::getSnappers() const } /** - * \brief Return a list of gridsnappers + * Return a list of gridsnappers. * * Each grid has its own instance of the snapper class. This way snapping can * be enabled per grid individually. A list will be returned containing the * pointers to these instances, but only for grids that are being displayed * and for which snapping is enabled. * - * \return List of gridsnappers that we use. + * @return List of gridsnappers that we use. */ -SnapManager::SnapperList -SnapManager::getGridSnappers() const +SnapManager::SnapperList SnapManager::getGridSnappers() const { SnapperList s; @@ -108,14 +104,14 @@ SnapManager::getGridSnappers() const } /** - * \brief Return true if any snapping might occur, whether its to grids, guides or objects + * Return true if any snapping might occur, whether its to grids, guides or objects. * * Each snapper instance handles its own snapping target, e.g. grids, guides or * objects. This method iterates through all these snapper instances and returns * true if any of the snappers might possible snap, considering only the relevant * snapping preferences. * - * \return true if one of the snappers will try to snap to something. + * @return true if one of the snappers will try to snap to something. */ bool SnapManager::someSnapperMightSnap() const @@ -153,7 +149,7 @@ bool SnapManager::gridSnapperMightSnap() const } /** - * \brief Try to snap a point to grids, guides or objects. + * Try to snap a point to grids, guides or objects. * * Try to snap a point to grids, guides or objects, in two degrees-of-freedom, * i.e. snap in any direction on the two dimensional canvas to the nearest @@ -172,11 +168,10 @@ bool SnapManager::gridSnapperMightSnap() const * 2) Only to be used when a single source point is to be snapped; it assumes * that source_num = 0, which is inefficient when snapping sets our source points * - * \param p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred - * \param source_type Detailed description of the source type, will be used by the snap indicator - * \param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation + * @param p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred + * @param source_type Detailed description of the source type, will be used by the snap indicator + * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation */ - void SnapManager::freeSnapReturnByRef(Geom::Point &p, Inkscape::SnapSourceType const source_type, Geom::OptRect const &bbox_to_snap) const @@ -187,7 +182,7 @@ void SnapManager::freeSnapReturnByRef(Geom::Point &p, /** - * \brief Try to snap a point to grids, guides or objects. + * Try to snap a point to grids, guides or objects. * * Try to snap a point to grids, guides or objects, in two degrees-of-freedom, * i.e. snap in any direction on the two dimensional canvas to the nearest @@ -197,12 +192,10 @@ void SnapManager::freeSnapReturnByRef(Geom::Point &p, * PS: SnapManager::setup() must have been called before calling this method, * but only once for a set of points * - * \param p Source point to be snapped - * \param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation - * \return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics + * @param p Source point to be snapped + * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation + * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics */ - - Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap) const { @@ -238,7 +231,7 @@ void SnapManager::preSnap(Inkscape::SnapCandidatePoint const &p) } /** - * \brief Snap to the closest multiple of a grid pitch + * Snap to the closest multiple of a grid pitch. * * When pasting, we would like to snap to the grid. Problem is that we don't know which * nodes were aligned to the grid at the time of copying, so we don't know which nodes @@ -252,10 +245,9 @@ void SnapManager::preSnap(Inkscape::SnapCandidatePoint const &p) * PS2: When multiple grids are present then the result will become ambiguous. There is no * way to control to which grid this method will snap. * - * \param t Vector that represents the offset of the pasted copy with respect to the original - * \return Offset vector after snapping to the closest multiple of a grid pitch + * @param t Vector that represents the offset of the pasted copy with respect to the original + * @return Offset vector after snapping to the closest multiple of a grid pitch */ - Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point const &origin) { if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally()) @@ -312,7 +304,7 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c } /** - * \brief Try to snap a point along a constraint line to grids, guides or objects. + * Try to snap a point along a constraint line to grids, guides or objects. * * Try to snap a point to grids, guides or objects, in only one degree-of-freedom, * i.e. snap in a specific direction on the two dimensional canvas to the nearest @@ -335,12 +327,11 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c * that source_num = 0, which is inefficient when snapping sets our source points * - * \param p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred - * \param source_type Detailed description of the source type, will be used by the snap indicator - * \param constraint The direction or line along which snapping must occur - * \param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation + * @param p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred + * @param source_type Detailed description of the source type, will be used by the snap indicator + * @param constraint The direction or line along which snapping must occur + * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation */ - void SnapManager::constrainedSnapReturnByRef(Geom::Point &p, Inkscape::SnapSourceType const source_type, Inkscape::Snapper::SnapConstraint const &constraint, @@ -351,7 +342,7 @@ void SnapManager::constrainedSnapReturnByRef(Geom::Point &p, } /** - * \brief Try to snap a point along a constraint line to grids, guides or objects. + * Try to snap a point along a constraint line to grids, guides or objects. * * Try to snap a point to grids, guides or objects, in only one degree-of-freedom, * i.e. snap in a specific direction on the two dimensional canvas to the nearest @@ -363,11 +354,10 @@ void SnapManager::constrainedSnapReturnByRef(Geom::Point &p, * PS: If there's nothing to snap to or if snapping has been disabled, then this * method will still apply the constraint (but without snapping) * - * \param p Source point to be snapped - * \param constraint The direction or line along which snapping must occur - * \param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation + * @param p Source point to be snapped + * @param constraint The direction or line along which snapping must occur + * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation */ - Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint const &p, Inkscape::Snapper::SnapConstraint const &constraint, Geom::OptRect const &bbox_to_snap) const @@ -512,18 +502,17 @@ Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandi } /** - * \brief Try to snap a point to something at a specific angle + * Try to snap a point to something at a specific angle. * * When drawing a straight line or modifying a gradient, it will snap to specific angle increments * if CTRL is being pressed. This method will enforce this angular constraint (even if there is nothing * to snap to) * - * \param p Source point to be snapped - * \param p_ref Optional original point, relative to which the angle should be calculated. If empty then + * @param p Source point to be snapped + * @param p_ref Optional original point, relative to which the angle should be calculated. If empty then * the angle will be calculated relative to the y-axis - * \param snaps Number of angular increments per PI radians; E.g. if snaps = 2 then we will snap every PI/2 = 90 degrees + * @param snaps Number of angular increments per PI radians; E.g. if snaps = 2 then we will snap every PI/2 = 90 degrees */ - Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandidatePoint const &p, boost::optional const &p_ref, Geom::Point const &o, @@ -561,12 +550,12 @@ Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandida } /** - * \brief Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code) + * Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code). * * PS: SnapManager::setup() must have been called before calling this method, * - * \param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred - * \param guide_normal Vector normal to the guide line + * @param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred + * @param guide_normal Vector normal to the guide line */ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &/*guide_normal*/, SPGuideDragType drag_type) const { @@ -591,14 +580,13 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &/*guide_norma } /** - * \brief Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code) + * Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code). * * PS: SnapManager::setup() must have been called before calling this method, * - * \param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred - * \param guide_normal Vector normal to the guide line + * @param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred + * @param guide_normal Vector normal to the guide line */ - void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) const { if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() || !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE)) { @@ -620,7 +608,7 @@ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) } /** - * \brief Method for snapping sets of points while they are being transformed + * Method for snapping sets of points while they are being transformed. * * Method for snapping sets of points while they are being transformed, when using * for example the selector tool. This method is for internal use only, and should @@ -634,18 +622,17 @@ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) * If no snap has occurred and we're asked for a constrained snap then the constraint * will be applied nevertheless * - * \param points Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. - * \param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). - * \param constrained true if the snap is constrained, e.g. for stretching or for purely horizontal translation. - * \param constraint The direction or line along which snapping must occur, if 'constrained' is true; otherwise undefined. - * \param transformation_type Type of transformation to apply to points before trying to snap them. - * \param transformation Description of the transformation; details depend on the type. - * \param origin Origin of the transformation, if applicable. - * \param dim Dimension to which the transformation applies, if applicable. - * \param uniform true if the transformation should be uniform; only applicable for stretching and scaling. - * \return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. + * @param points Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. + * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). + * @param constrained true if the snap is constrained, e.g. for stretching or for purely horizontal translation. + * @param constraint The direction or line along which snapping must occur, if 'constrained' is true; otherwise undefined. + * @param transformation_type Type of transformation to apply to points before trying to snap them. + * @param transformation Description of the transformation; details depend on the type. + * @param origin Origin of the transformation, if applicable. + * @param dim Dimension to which the transformation applies, if applicable. + * @param uniform true if the transformation should be uniform; only applicable for stretching and scaling. + * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. */ - Inkscape::SnappedPoint SnapManager::_snapTransformed( std::vector const &points, Geom::Point const &pointer, @@ -937,14 +924,13 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( /** - * \brief Apply a translation to a set of points and try to snap freely in 2 degrees-of-freedom + * Apply a translation to a set of points and try to snap freely in 2 degrees-of-freedom. * - * \param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. - * \param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). - * \param tr Proposed translation; the final translation can only be calculated after snapping has occurred - * \return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. + * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. + * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). + * @param tr Proposed translation; the final translation can only be calculated after snapping has occurred + * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. */ - Inkscape::SnappedPoint SnapManager::freeSnapTranslate(std::vector const &p, Geom::Point const &pointer, Geom::Point const &tr) @@ -959,15 +945,14 @@ Inkscape::SnappedPoint SnapManager::freeSnapTranslate(std::vector const &p, Geom::Point const &pointer, Inkscape::Snapper::SnapConstraint const &constraint, @@ -984,15 +969,14 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapTranslate(std::vector const &p, Geom::Point const &pointer, Geom::Scale const &s, @@ -1009,15 +993,14 @@ Inkscape::SnappedPoint SnapManager::freeSnapScale(std::vector const &p, Geom::Point const &pointer, Geom::Scale const &s, @@ -1034,17 +1017,16 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapScale(std::vector const &p, Geom::Point const &pointer, Geom::Coord const &s, @@ -1062,17 +1044,16 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapStretch(std::vector const &p, Geom::Point const &pointer, Inkscape::Snapper::SnapConstraint const &constraint, @@ -1101,15 +1082,14 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapSkew(std::vector const &p, Geom::Point const &pointer, Geom::Coord const &angle, @@ -1132,16 +1112,15 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapRotate(std::vector &items_to_ignore, @@ -1355,17 +1333,16 @@ SPDocument *SnapManager::getDocument() const } /** - * \brief Takes an untransformed point, applies the given transformation, and returns the transformed point. Eliminates lots of duplicated code + * Takes an untransformed point, applies the given transformation, and returns the transformed point. Eliminates lots of duplicated code. * - * \param p The untransformed position of the point, paired with an identifier of the type of the snap source. - * \param transformation_type Type of transformation to apply. - * \param transformation Mathematical description of the transformation; details depend on the type. - * \param origin Origin of the transformation, if applicable. - * \param dim Dimension to which the transformation applies, if applicable. - * \param uniform true if the transformation should be uniform; only applicable for stretching and scaling. - * \return The position of the point after transformation + * @param p The untransformed position of the point, paired with an identifier of the type of the snap source. + * @param transformation_type Type of transformation to apply. + * @param transformation Mathematical description of the transformation; details depend on the type. + * @param origin Origin of the transformation, if applicable. + * @param dim Dimension to which the transformation applies, if applicable. + * @param uniform true if the transformation should be uniform; only applicable for stretching and scaling. + * @return The position of the point after transformation */ - Geom::Point SnapManager::_transformPoint(Inkscape::SnapCandidatePoint const &p, Transformation const transformation_type, Geom::Point const &transformation, @@ -1413,12 +1390,11 @@ Geom::Point SnapManager::_transformPoint(Inkscape::SnapCandidatePoint const &p, } /** - * \brief Mark the location of the snap source (not the snap target!) on the canvas by drawing a symbol + * Mark the location of the snap source (not the snap target!) on the canvas by drawing a symbol. * - * \param point_type Category of points to which the source point belongs: node, guide or bounding box - * \param p The transformed position of the source point, paired with an identifier of the type of the snap source. + * @param point_type Category of points to which the source point belongs: node, guide or bounding box + * @param p The transformed position of the source point, paired with an identifier of the type of the snap source. */ - void SnapManager::_displaySnapsource(Inkscape::SnapCandidatePoint const &p) const { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); -- cgit v1.2.3 From f4c59e50df9090a1a4801da06f9a0021b67ce7a2 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 8 Oct 2011 22:00:37 +0200 Subject: 1) make snapping to clip/mask paths optional (see document properties dialog -> snap tab) 2) for debugging purposes: code added for showing all snap candidates 3) groundwork for tangential/perpendicular snapping (bzr r10672) --- src/snap.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index fb6f120ec..56b48d507 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -180,6 +180,13 @@ void SnapManager::freeSnapReturnByRef(Geom::Point &p, s.getPointIfSnapped(p); } +void SnapManager::freeSnapReturnByRef(Geom::Point &p, + Inkscape::SnapSourceType const source_type, + boost::optional &starting_point) const +{ + Inkscape::SnappedPoint const s = freeSnap(Inkscape::SnapCandidatePoint(p, source_type, starting_point), Geom::OptRect()); + s.getPointIfSnapped(p); +} /** * Try to snap a point to grids, guides or objects. @@ -1136,6 +1143,23 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co std::cout << " Curves : " << isr.curves.size()<< std::endl; */ + /* + // Display all snap candidates on the canvas + _desktop->snapindicator->remove_debugging_points(); + for (std::list::const_iterator i = isr.points.begin(); i != isr.points.end(); i++) { + _desktop->snapindicator->set_new_debugging_point((*i).getPoint()); + } + for (std::list::const_iterator i = isr.curves.begin(); i != isr.curves.end(); i++) { + _desktop->snapindicator->set_new_debugging_point((*i).getPoint()); + } + for (std::list::const_iterator i = isr.grid_lines.begin(); i != isr.grid_lines.end(); i++) { + _desktop->snapindicator->set_new_debugging_point((*i).getPoint()); + } + for (std::list::const_iterator i = isr.guide_lines.begin(); i != isr.guide_lines.end(); i++) { + _desktop->snapindicator->set_new_debugging_point((*i).getPoint()); + } + */ + // Store all snappoints std::list sp_list; -- cgit v1.2.3 From 2633767789e4264b13ef91a684accf734fb4e94f Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 26 Oct 2011 21:55:51 -0700 Subject: Fixing more broken and split doc comments. (bzr r10697) --- src/snap.cpp | 312 +---------------------------------------------------------- 1 file changed, 1 insertion(+), 311 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 56b48d507..5f4872bba 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1,5 +1,4 @@ -/** - * \file snap.cpp +/* * SnapManager class. * * Authors: @@ -37,12 +36,6 @@ #include "util/mathfns.h" using std::vector; -/** - * Construct a SnapManager for a SPNamedView. - * - * \param v `Owning' SPNamedView. - */ - SnapManager::SnapManager(SPNamedView const *v) : guide(this, 0), object(this, 0), @@ -55,18 +48,6 @@ SnapManager::SnapManager(SPNamedView const *v) : { } -/** - * Return a list of snappers. - * - * Inkscape snaps to objects, grids, and guides. For each of these snap targets a - * separate class is used, which has been derived from the base Snapper class. The - * getSnappers() method returns a list of pointers to instances of this class. This - * list contains exactly one instance of the guide snapper and of the object snapper - * class, but any number of grid snappers (because each grid has its own snapper - * instance) - * - * @return List of snappers that we use. - */ SnapManager::SnapperList SnapManager::getSnappers() const { SnapManager::SnapperList s; @@ -79,16 +60,6 @@ SnapManager::SnapperList SnapManager::getSnappers() const return s; } -/** - * Return a list of gridsnappers. - * - * Each grid has its own instance of the snapper class. This way snapping can - * be enabled per grid individually. A list will be returned containing the - * pointers to these instances, but only for grids that are being displayed - * and for which snapping is enabled. - * - * @return List of gridsnappers that we use. - */ SnapManager::SnapperList SnapManager::getGridSnappers() const { SnapperList s; @@ -103,17 +74,6 @@ SnapManager::SnapperList SnapManager::getGridSnappers() const return s; } -/** - * Return true if any snapping might occur, whether its to grids, guides or objects. - * - * Each snapper instance handles its own snapping target, e.g. grids, guides or - * objects. This method iterates through all these snapper instances and returns - * true if any of the snappers might possible snap, considering only the relevant - * snapping preferences. - * - * @return true if one of the snappers will try to snap to something. - */ - bool SnapManager::someSnapperMightSnap() const { if ( !snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() ) { @@ -129,10 +89,6 @@ bool SnapManager::someSnapperMightSnap() const return (i != s.end()); } -/** - * \return true if one of the grids might be snapped to. - */ - bool SnapManager::gridSnapperMightSnap() const { if ( !snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() ) { @@ -148,30 +104,6 @@ bool SnapManager::gridSnapperMightSnap() const return (i != s.end()); } -/** - * Try to snap a point to grids, guides or objects. - * - * Try to snap a point to grids, guides or objects, in two degrees-of-freedom, - * i.e. snap in any direction on the two dimensional canvas to the nearest - * snap target. freeSnapReturnByRef() is equal in snapping behavior to - * freeSnap(), but the former returns the snapped point trough the referenced - * parameter p. This parameter p initially contains the position of the snap - * source and will we overwritten by the target position if snapping has occurred. - * This makes snapping transparent to the calling code. If this is not desired - * because either the calling code must know whether snapping has occurred, or - * because the original position should not be touched, then freeSnap() should be - * called instead. - * - * PS: - * 1) SnapManager::setup() must have been called before calling this method, - * but only once for a set of points - * 2) Only to be used when a single source point is to be snapped; it assumes - * that source_num = 0, which is inefficient when snapping sets our source points - * - * @param p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred - * @param source_type Detailed description of the source type, will be used by the snap indicator - * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation - */ void SnapManager::freeSnapReturnByRef(Geom::Point &p, Inkscape::SnapSourceType const source_type, Geom::OptRect const &bbox_to_snap) const @@ -188,21 +120,6 @@ void SnapManager::freeSnapReturnByRef(Geom::Point &p, s.getPointIfSnapped(p); } -/** - * Try to snap a point to grids, guides or objects. - * - * Try to snap a point to grids, guides or objects, in two degrees-of-freedom, - * i.e. snap in any direction on the two dimensional canvas to the nearest - * snap target. freeSnap() is equal in snapping behavior to - * freeSnapReturnByRef(). Please read the comments of the latter for more details - * - * PS: SnapManager::setup() must have been called before calling this method, - * but only once for a set of points - * - * @param p Source point to be snapped - * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation - * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics - */ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap) const { @@ -237,24 +154,6 @@ void SnapManager::preSnap(Inkscape::SnapCandidatePoint const &p) } } -/** - * Snap to the closest multiple of a grid pitch. - * - * When pasting, we would like to snap to the grid. Problem is that we don't know which - * nodes were aligned to the grid at the time of copying, so we don't know which nodes - * to snap. If we'd snap an unaligned node to the grid, previously aligned nodes would - * become unaligned. That's undesirable. Instead we will make sure that the offset - * between the source and its pasted copy is a multiple of the grid pitch. If the source - * was aligned, then the copy will therefore also be aligned. - * - * PS: Whether we really find a multiple also depends on the snapping range! Most users - * will have "always snap" enabled though, in which case a multiple will always be found. - * PS2: When multiple grids are present then the result will become ambiguous. There is no - * way to control to which grid this method will snap. - * - * @param t Vector that represents the offset of the pasted copy with respect to the original - * @return Offset vector after snapping to the closest multiple of a grid pitch - */ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point const &origin) { if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally()) @@ -310,35 +209,6 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c return t; } -/** - * Try to snap a point along a constraint line to grids, guides or objects. - * - * Try to snap a point to grids, guides or objects, in only one degree-of-freedom, - * i.e. snap in a specific direction on the two dimensional canvas to the nearest - * snap target. - * - * constrainedSnapReturnByRef() is equal in snapping behavior to - * constrainedSnap(), but the former returns the snapped point trough the referenced - * parameter p. This parameter p initially contains the position of the snap - * source and will be overwritten by the target position if snapping has occurred. - * This makes snapping transparent to the calling code. If this is not desired - * because either the calling code must know whether snapping has occurred, or - * because the original position should not be touched, then constrainedSnap() should - * be called instead. If there's nothing to snap to or if snapping has been disabled, - * then this method will still apply the constraint (but without snapping) - * - * PS: - * 1) SnapManager::setup() must have been called before calling this method, - * but only once for a set of points - * 2) Only to be used when a single source point is to be snapped; it assumes - * that source_num = 0, which is inefficient when snapping sets our source points - - * - * @param p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred - * @param source_type Detailed description of the source type, will be used by the snap indicator - * @param constraint The direction or line along which snapping must occur - * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation - */ void SnapManager::constrainedSnapReturnByRef(Geom::Point &p, Inkscape::SnapSourceType const source_type, Inkscape::Snapper::SnapConstraint const &constraint, @@ -348,23 +218,6 @@ void SnapManager::constrainedSnapReturnByRef(Geom::Point &p, p = s.getPoint(); // If we didn't snap, then we will return the point projected onto the constraint } -/** - * Try to snap a point along a constraint line to grids, guides or objects. - * - * Try to snap a point to grids, guides or objects, in only one degree-of-freedom, - * i.e. snap in a specific direction on the two dimensional canvas to the nearest - * snap target. constrainedSnap is equal in snapping behavior to - * constrainedSnapReturnByRef(). Please read the comments of the latter for more details. - * - * PS: SnapManager::setup() must have been called before calling this method, - * but only once for a set of points - * PS: If there's nothing to snap to or if snapping has been disabled, then this - * method will still apply the constraint (but without snapping) - * - * @param p Source point to be snapped - * @param constraint The direction or line along which snapping must occur - * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation - */ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint const &p, Inkscape::Snapper::SnapConstraint const &constraint, Geom::OptRect const &bbox_to_snap) const @@ -508,18 +361,6 @@ Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandi return no_snap; } -/** - * Try to snap a point to something at a specific angle. - * - * When drawing a straight line or modifying a gradient, it will snap to specific angle increments - * if CTRL is being pressed. This method will enforce this angular constraint (even if there is nothing - * to snap to) - * - * @param p Source point to be snapped - * @param p_ref Optional original point, relative to which the angle should be calculated. If empty then - * the angle will be calculated relative to the y-axis - * @param snaps Number of angular increments per PI radians; E.g. if snaps = 2 then we will snap every PI/2 = 90 degrees - */ Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandidatePoint const &p, boost::optional const &p_ref, Geom::Point const &o, @@ -556,14 +397,6 @@ Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandida return sp; } -/** - * Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code). - * - * PS: SnapManager::setup() must have been called before calling this method, - * - * @param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred - * @param guide_normal Vector normal to the guide line - */ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &/*guide_normal*/, SPGuideDragType drag_type) const { if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() || !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE)) { @@ -586,14 +419,6 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &/*guide_norma s.getPointIfSnapped(p); } -/** - * Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code). - * - * PS: SnapManager::setup() must have been called before calling this method, - * - * @param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred - * @param guide_normal Vector normal to the guide line - */ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) const { if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() || !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE)) { @@ -614,32 +439,6 @@ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) s.getPointIfSnapped(p); } -/** - * Method for snapping sets of points while they are being transformed. - * - * Method for snapping sets of points while they are being transformed, when using - * for example the selector tool. This method is for internal use only, and should - * not have to be called directly. Use freeSnapTransalation(), constrainedSnapScale(), - * etc. instead. - * - * This is what is being done in this method: transform each point, find out whether - * a free snap or constrained snap is more appropriate, do the snapping, calculate - * some metrics to quantify the snap "distance", and see if it's better than the - * previous snap. Finally, the best ("nearest") snap from all these points is returned. - * If no snap has occurred and we're asked for a constrained snap then the constraint - * will be applied nevertheless - * - * @param points Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. - * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). - * @param constrained true if the snap is constrained, e.g. for stretching or for purely horizontal translation. - * @param constraint The direction or line along which snapping must occur, if 'constrained' is true; otherwise undefined. - * @param transformation_type Type of transformation to apply to points before trying to snap them. - * @param transformation Description of the transformation; details depend on the type. - * @param origin Origin of the transformation, if applicable. - * @param dim Dimension to which the transformation applies, if applicable. - * @param uniform true if the transformation should be uniform; only applicable for stretching and scaling. - * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. - */ Inkscape::SnappedPoint SnapManager::_snapTransformed( std::vector const &points, Geom::Point const &pointer, @@ -930,14 +729,6 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( } -/** - * Apply a translation to a set of points and try to snap freely in 2 degrees-of-freedom. - * - * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. - * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). - * @param tr Proposed translation; the final translation can only be calculated after snapping has occurred - * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. - */ Inkscape::SnappedPoint SnapManager::freeSnapTranslate(std::vector const &p, Geom::Point const &pointer, Geom::Point const &tr) @@ -951,15 +742,6 @@ Inkscape::SnappedPoint SnapManager::freeSnapTranslate(std::vector const &p, Geom::Point const &pointer, Inkscape::Snapper::SnapConstraint const &constraint, @@ -975,15 +757,6 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapTranslate(std::vector const &p, Geom::Point const &pointer, Geom::Scale const &s, @@ -999,15 +772,6 @@ Inkscape::SnappedPoint SnapManager::freeSnapScale(std::vector const &p, Geom::Point const &pointer, Geom::Scale const &s, @@ -1023,17 +787,6 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapScale(std::vector const &p, Geom::Point const &pointer, Geom::Coord const &s, @@ -1050,17 +803,6 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapStretch(std::vector const &p, Geom::Point const &pointer, Inkscape::Snapper::SnapConstraint const &constraint, @@ -1088,15 +830,6 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapSkew(std::vector const &p, Geom::Point const &pointer, Geom::Coord const &angle, @@ -1118,16 +851,6 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapRotate(std::vector &items_to_ignore, @@ -1356,17 +1063,6 @@ SPDocument *SnapManager::getDocument() const return _named_view->document; } -/** - * Takes an untransformed point, applies the given transformation, and returns the transformed point. Eliminates lots of duplicated code. - * - * @param p The untransformed position of the point, paired with an identifier of the type of the snap source. - * @param transformation_type Type of transformation to apply. - * @param transformation Mathematical description of the transformation; details depend on the type. - * @param origin Origin of the transformation, if applicable. - * @param dim Dimension to which the transformation applies, if applicable. - * @param uniform true if the transformation should be uniform; only applicable for stretching and scaling. - * @return The position of the point after transformation - */ Geom::Point SnapManager::_transformPoint(Inkscape::SnapCandidatePoint const &p, Transformation const transformation_type, Geom::Point const &transformation, @@ -1413,12 +1109,6 @@ Geom::Point SnapManager::_transformPoint(Inkscape::SnapCandidatePoint const &p, return transformed; } -/** - * Mark the location of the snap source (not the snap target!) on the canvas by drawing a symbol. - * - * @param point_type Category of points to which the source point belongs: node, guide or bounding box - * @param p The transformed position of the source point, paired with an identifier of the type of the snap source. - */ void SnapManager::_displaySnapsource(Inkscape::SnapCandidatePoint const &p) const { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); -- cgit v1.2.3 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 From 8f1c271f1e1d226061e9fe63faa40cefdd1dcd81 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 18 Dec 2011 13:45:52 +0100 Subject: Refactor snap-preferences a bit more (bzr r10780) --- src/snap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 853268b4b..36d17102d 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1124,7 +1124,7 @@ void SnapManager::displaySnapsource(Inkscape::SnapCandidatePoint const &p) const 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()))) { + if (snapprefs.getSnapEnabledGlobally() && (p_is_other || (p_is_a_node && snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_NODE_CATEGORY)) || (p_is_a_bbox && snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_BBOX_CATEGORY)))) { _desktop->snapindicator->set_new_snapsource(p); } else { _desktop->snapindicator->remove_snapsource(); -- cgit v1.2.3