Code

Applied patch and updated to address non-BMP Unicode charcters. Fixes bug #369861.
[inkscape.git] / src / line-snapper.cpp
index 19e6c0fe67b56108957c937ccee6b24bb4179783..be64438ed503d5b6282b77fed33348822f4b79b6 100644 (file)
@@ -64,18 +64,22 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
                                                Inkscape::SnapCandidatePoint const &p,
                                                Geom::OptRect const &/*bbox_to_snap*/,
                                                SnapConstraint const &c,
-                                               std::vector<SPItem const *> const */*it*/) const
+                                               std::vector<SPItem const *> const */*it*/,
+                                               std::vector<SnapCandidatePoint> */*unselected_nodes*/) const
 
 {
     if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false) {
         return;
     }
 
+    // project the mouse pointer onto the constraint. Only the projected point will be considered for snapping
+    Geom::Point pp = c.projection(p.getPoint());
+
     /* Get the lines that we will try to snap to */
-    const LineList lines = _getSnapLines(p.getPoint());
+    const LineList lines = _getSnapLines(pp);
 
     for (LineList::const_iterator i = lines.begin(); i != lines.end(); i++) {
-        Geom::Point const point_on_line = c.hasPoint() ? c.getPoint() : p.getPoint();
+        Geom::Point const point_on_line = c.hasPoint() ? c.getPoint() : pp;
         Geom::Line gridguide_line(i->second, i->second + Geom::rot90(i->first));
 
         if (c.isCircular()) {
@@ -87,7 +91,7 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
             Geom::Coord radius = c.getRadius();
             if (dist == radius) {
                 // Only one point of intersection;
-                _addSnappedPoint(sc, p_proj, Geom::L2(p.getPoint() - p_proj), p.getSourceType(), p.getSourceNum(), true);
+                _addSnappedPoint(sc, p_proj, Geom::L2(pp - p_proj), p.getSourceType(), p.getSourceNum(), true);
             } else if (dist < radius) {
                 // Two points of intersection, symmetrical with respect to the projected point
                 // Calculate half the length of the linesegment between the two points of intersection
@@ -95,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(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);
+                    _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);
                 }
             }
         } else {
@@ -115,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 - p.getPoint());
+                const Geom::Coord dist = Geom::L2(t - pp);
                 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