summaryrefslogtreecommitdiffstats
path: root/src/line-snapper.cpp
diff options
context:
space:
mode:
authorDiederik van Lierop <mailat-signdiedenrezidotnl>2010-08-20 20:20:02 +0000
committerDiederik van Lierop <mailat-signdiedenrezidotnl>2010-08-20 20:20:02 +0000
commit4254ddc1b51813c1cd7c8eec31fcbcf16802b1cf (patch)
tree6b1b2ceeeea996da24fb6be4e3dbc94bba8ff562 /src/line-snapper.cpp
parentTranslations. Korean translation update by yongdoria. (diff)
downloadinkscape-4254ddc1b51813c1cd7c8eec31fcbcf16802b1cf.tar.gz
inkscape-4254ddc1b51813c1cd7c8eec31fcbcf16802b1cf.zip
When doing a constrained snap, then don't try snapping the mouse pointer itself but try snapping its projection (onto the constraint) instead
(bzr r9719)
Diffstat (limited to 'src/line-snapper.cpp')
-rw-r--r--src/line-snapper.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp
index 0a1567a47..be64438ed 100644
--- a/src/line-snapper.cpp
+++ b/src/line-snapper.cpp
@@ -72,11 +72,14 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
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()) {
@@ -88,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
@@ -96,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 {
@@ -116,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