Code

Use a better snap metric for constrained snapping (i.e. calculate the distance to...
authorDiederik van Lierop <mailat-signdiedenrezidotnl>
Tue, 19 Oct 2010 20:50:03 +0000 (22:50 +0200)
committerDiederik van Lierop <mailat-signdiedenrezidotnl>
Tue, 19 Oct 2010 20:50:03 +0000 (22:50 +0200)
src/line-snapper.cpp
src/object-snapper.cpp

index be64438ed503d5b6282b77fed33348822f4b79b6..22a964d43487e2b1e7c20851b0e43b458c532917 100644 (file)
@@ -99,8 +99,8 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
                 Geom::Coord d = Geom::L2(gridguide_line.versor()); // length of versor, needed to normalize the versor
                 if (d > 0) {
                     Geom::Point v = l*gridguide_line.versor()/d;
-                    _addSnappedPoint(sc, p_proj + v, Geom::L2(pp - (p_proj + v)), p.getSourceType(), p.getSourceNum(), true);
-                    _addSnappedPoint(sc, p_proj - v, Geom::L2(pp - (p_proj - v)), p.getSourceType(), p.getSourceNum(), true);
+                    _addSnappedPoint(sc, p_proj + v, Geom::L2(p.getPoint() - (p_proj + v)), p.getSourceType(), p.getSourceNum(), true);
+                    _addSnappedPoint(sc, p_proj - v, Geom::L2(p.getPoint() - (p_proj - v)), p.getSourceType(), p.getSourceNum(), true);
                 }
             }
         } else {
@@ -119,7 +119,7 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
 
             if (inters) {
                 Geom::Point t = constraint_line.pointAt((*inters).ta);
-                const Geom::Coord dist = Geom::L2(t - pp);
+                const Geom::Coord dist = Geom::L2(t - p.getPoint());
                 if (dist < getSnapperTolerance()) {
                     // When doing a constrained snap, we're already at an intersection.
                     // This snappoint is therefore fully constrained, so there's no need
index b11e857dcd067a7c6e17ceba4328ce704129fa4b..7e7e2592194627c298b790c2280530b7eb127b71 100644 (file)
@@ -633,7 +633,7 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc,
                 // Convert to desktop coordinates
                 (*p_inters) = _snapmanager->getDesktop()->doc2dt(*p_inters);
                 // Construct a snapped point
-                Geom::Coord dist = Geom::L2(p_proj_on_constraint - *p_inters);
+                Geom::Coord dist = Geom::L2(p.getPoint() - *p_inters);
                 SnappedPoint s = SnappedPoint(*p_inters, p.getSourceType(), p.getSourceNum(), k->target_type, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), true, k->target_bbox);;
                 // Store the snapped point
                 if (dist <= tolerance) { // If the intersection is within snapping range, then we might snap to it