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/sp-shape.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index beec860be..7f24dd089 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -1188,18 +1188,13 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { - return; - } - Geom::PathVector const &pathv = shape->curve->get_pathvector(); if (pathv.empty()) return; Geom::Affine const i2dt (item->i2dt_affine ()); - if (snapprefs->getSnapObjectMidpoints()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)) { Geom::OptRect bbox = item->getBounds(i2dt); if (bbox) { p.push_back(Inkscape::SnapCandidatePoint(bbox->midpoint(), Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); @@ -1207,7 +1202,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapToItemNode()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP)) { // Add the first point of the path p.push_back(Inkscape::SnapCandidatePoint(path_it->initialPoint() * i2dt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); } @@ -1217,14 +1212,14 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorend_default()) { // For each path: consider midpoints of line segments for snapping - if (snapprefs->getSnapLineMidpoints()) { // only do this when we're snapping nodes (enforces strict snapping) + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_LINE_MIDPOINT)) { if (Geom::LineSegment const* line_segment = dynamic_cast(&(*curve_it1))) { p.push_back(Inkscape::SnapCandidatePoint(Geom::middle_point(*line_segment) * i2dt, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT)); } } if (curve_it2 == path_it->end_default()) { // Test will only pass for the last iteration of the while loop - if (snapprefs->getSnapToItemNode() && !path_it->closed()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && !path_it->closed()) { // Add the last point of the path, but only for open paths // (for closed paths the first and last point will coincide) p.push_back(Inkscape::SnapCandidatePoint((*curve_it1).finalPoint() * i2dt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); @@ -1235,8 +1230,8 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapToItemNode() && (nodetype == Geom::NODE_CUSP || nodetype == Geom::NODE_NONE); - bool c2 = snapprefs->getSnapSmoothNodes() && (nodetype == Geom::NODE_SMOOTH || nodetype == Geom::NODE_SYMM); + bool c1 = snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && (nodetype == Geom::NODE_CUSP || nodetype == Geom::NODE_NONE); + bool c2 = snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH) && (nodetype == Geom::NODE_SMOOTH || nodetype == Geom::NODE_SYMM); if (c1 || c2) { Inkscape::SnapSourceType sst; @@ -1266,7 +1261,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapIntersectionCS()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION)) { Geom::Crossings cs; try { cs = self_crossings(*path_it); -- cgit v1.2.3