Code

german translation update
[inkscape.git] / src / line-snapper.cpp
index 5ceece66bc4d6832e6737f70ab0f5f239ff39b5b..22a964d43487e2b1e7c20851b0e43b458c532917 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()) {
@@ -83,16 +87,11 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
             // First, project the origin of the circle onto the line
             Geom::Point const origin = c.getPoint();
             Geom::Point const p_proj = Geom::projection(origin, gridguide_line);
-            Geom::Point v_orig = c.getDirection(); // vector from the origin to the original (untransformed) point
-            Geom::Point v_proj = p_proj - origin;
-            Geom::Coord dist = Geom::L2(v_proj); // distance from circle origin to constraint line
+            Geom::Coord dist = Geom::L2(p_proj - origin); // distance from circle origin to constraint line
             Geom::Coord radius = c.getRadius();
-            Geom::Coord radians = NR_HUGE;
             if (dist == radius) {
                 // Only one point of intersection;
-                // Calculate the rotation in radians...
-                radians = atan2(Geom::dot(Geom::rot90(v_orig), v_proj), Geom::dot(v_orig, v_proj));
-                _addSnappedPoint(sc, p_proj, Geom::L2(p.getPoint() - p_proj), p.getSourceType(), p.getSourceNum(), true, radians);
+                _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
@@ -100,12 +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;
-                    v_proj = p_proj + v - origin;
-                    radians = atan2(Geom::dot(Geom::rot90(v_orig), v_proj), Geom::dot(v_orig, v_proj));
-                    _addSnappedPoint(sc, p_proj + v, Geom::L2(p.getPoint() - (p_proj + v)), p.getSourceType(), p.getSourceNum(), true, radians);
-                    v_proj = p_proj - v - origin;
-                    radians = atan2(Geom::dot(Geom::rot90(v_orig), v_proj), Geom::dot(v_orig, v_proj));
-                    _addSnappedPoint(sc, p_proj - v, Geom::L2(p.getPoint() - (p_proj - v)), p.getSourceType(), p.getSourceNum(), true, radians);
+                    _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 {
@@ -130,7 +125,7 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
                     // This snappoint is therefore fully constrained, so there's no need
                     // to look for additional intersections; just return the snapped point
                     // and forget about the line
-                    _addSnappedPoint(sc, t, dist, p.getSourceType(), p.getSourceNum(), true, 1);
+                    _addSnappedPoint(sc, t, dist, p.getSourceType(), p.getSourceNum(), true);
                 }
             }
         }