summaryrefslogtreecommitdiffstats
path: root/src/snapped-point.cpp
diff options
context:
space:
mode:
authorDiederik van Lierop <mailat-signdiedenrezidotnl>2010-05-09 11:49:41 +0000
committerDiederik van Lierop <mailat-signdiedenrezidotnl>2010-05-09 11:49:41 +0000
commit72e9ba8d26a4c68d451a56bb6fad99e33414d49b (patch)
treebe9267bccf3ed3820f4f084650fdf64416700576 /src/snapped-point.cpp
parentFix tooltip error in the preferences (Bug #446723). (diff)
downloadinkscape-72e9ba8d26a4c68d451a56bb6fad99e33414d49b.tar.gz
inkscape-72e9ba8d26a4c68d451a56bb6fad99e33414d49b.zip
Small improvement of my previous fix in rev. #9402 (bounding box snapping)
(bzr r9404)
Diffstat (limited to 'src/snapped-point.cpp')
-rw-r--r--src/snapped-point.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/snapped-point.cpp b/src/snapped-point.cpp
index 352f2dd1e..f598cc624 100644
--- a/src/snapped-point.cpp
+++ b/src/snapped-point.cpp
@@ -138,7 +138,6 @@ bool Inkscape::SnappedPoint::isOtherSnapBetter(Inkscape::SnappedPoint const &oth
// there's more than one). It is not useful when trying to find the best snapped target point.
// (both the snap distance and the pointer distance are measured in document pixels, not in screen pixels)
if (weighted) {
-
Geom::Coord const dist_pointer_other = other_one.getPointerDistance();
Geom::Coord const dist_pointer_this = getPointerDistance();
// Weight factor: controls which node should be preferred for snapping, which is either
@@ -194,13 +193,21 @@ bool Inkscape::SnappedPoint::isOtherSnapBetter(Inkscape::SnappedPoint const &oth
// But don't fall back...
bool c4n = d && other_one.getAtIntersection() && !getAtIntersection();
- // or, if it's just as close then consider the second distance
+ // or, if it's just as close then consider the second distance ...
bool c5a = (dist_other == dist_this);
bool c5b = (other_one.getSecondSnapDistance() < getSecondSnapDistance()) && (getSecondSnapDistance() < NR_HUGE);
+ // ... or prefer free snaps over constrained snaps
+ bool c5c = !other_one.getConstrainedSnap() && getConstrainedSnap();
+
+ bool other_is_better = (c1 || c2 || c3 || c4 || (c5a && (c5b || c5c))) && !c2n && (!c3n || c2) && !c4n;
+
+ /*
+ std::cout << other_one.getPoint() << " (Other one, dist = " << dist_other << ") vs. " << getPoint() << " (this one, dist = " << dist_this << ") ---> ";
+ std::cout << "c1 = " << c1 << " | c2 = " << c2 << " | c2n = " << c2n << " | c3 = " << c3 << " | c3n = " << c3n << " | c4 = " << c4 << " | c4n = " << c4n << " | c5a = " << c5a << " | c5b = " << c5b << " | c5c = " << c5c << std::endl;
+ std::cout << "Other one provides a better snap: " << other_is_better << std::endl;
+ */
- // std::cout << other_one.getPoint() << " (Other one, dist = " << dist_other << ") vs. " << getPoint() << " (this one, dist = " << dist_this << ") ---> ";
- // std::cout << "c1 = " << c1 << " | c2 = " << c2 << " | c2n = " << c2n << " | c3 = " << c3 << " | c3n = " << c3n << " | c4 = " << c4 << " | c4n = " << c4n << " | c5a = " << c5a << " | c5b = " << c5b << std::endl;
- return (c1 || c2 || c3 || c4 || (c5a && c5b)) && !c2n && (!c3n || c2) && !c4n;
+ return other_is_better;
}
/*