summaryrefslogtreecommitdiffstats
path: root/src/snapped-curve.cpp
diff options
context:
space:
mode:
authorDiederik van Lierop <mail@diedenrezi.nl>2008-11-23 13:55:26 +0000
committerdvlierop2 <dvlierop2@users.sourceforge.net>2008-11-23 13:55:26 +0000
commit6b8572be4bdae9ee79fc42c9d18fd9882dec21aa (patch)
treeccfc4f2203495ee82127b0cb596f23a9d9f48803 /src/snapped-curve.cpp
parentUpdating the includes on these files because they need to include simple-node... (diff)
downloadinkscape-6b8572be4bdae9ee79fc42c9d18fd9882dec21aa.tar.gz
inkscape-6b8572be4bdae9ee79fc42c9d18fd9882dec21aa.zip
1) Improve the way the distance to the pointer is taken into account when finding the best snap
2) Use this distance also when snapping nodes in the path editor 3) Add a slider in the preferences dialog to control the weighing of this distance (bzr r6895)
Diffstat (limited to 'src/snapped-curve.cpp')
-rw-r--r--src/snapped-curve.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/snapped-curve.cpp b/src/snapped-curve.cpp
index 3a6512e5e..327de90bd 100644
--- a/src/snapped-curve.cpp
+++ b/src/snapped-curve.cpp
@@ -21,11 +21,11 @@
Inkscape::SnappedCurve::SnappedCurve(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, Geom::Coord const &snapped_tolerance, bool const &always_snap, bool const &fully_constrained, Geom::Curve const *curve)
{
_distance = snapped_distance;
- _tolerance = snapped_tolerance;
+ _tolerance = std::max(snapped_tolerance, 1.0);
_always_snap = always_snap;
_curve = curve;
_second_distance = NR_HUGE;
- _second_tolerance = 0;
+ _second_tolerance = 1;
_second_always_snap = false;
_point = snapped_point;
_at_intersection = false;
@@ -35,11 +35,11 @@ Inkscape::SnappedCurve::SnappedCurve(Geom::Point const &snapped_point, Geom::Coo
Inkscape::SnappedCurve::SnappedCurve()
{
_distance = NR_HUGE;
- _tolerance = 0;
+ _tolerance = 1;
_always_snap = false;
_curve = NULL;
_second_distance = NR_HUGE;
- _second_tolerance = 0;
+ _second_tolerance = 1;
_second_always_snap = false;
_point = Geom::Point(0,0);
_at_intersection = false;
@@ -73,7 +73,7 @@ Inkscape::SnappedPoint Inkscape::SnappedCurve::intersect(SnappedCurve const &cur
}
// Now we've found the closests intersection, return it as a SnappedPoint
- bool const use_this_as_primary = _distance < curve.getDistance();
+ bool const use_this_as_primary = _distance < curve.getSnapDistance();
Inkscape::SnappedCurve const *primaryC = use_this_as_primary ? this : &curve;
Inkscape::SnappedCurve const *secondaryC = use_this_as_primary ? &curve : this;
// The intersection should in fact be returned in desktop coordinates, but for this
@@ -83,8 +83,8 @@ Inkscape::SnappedPoint Inkscape::SnappedCurve::intersect(SnappedCurve const &cur
// TODO: Investigate whether it is possible to use document coordinates everywhere
// in the snapper code. Only the mouse position should be in desktop coordinates, I guess.
// All paths are already in document coords and we are certainly not going to change THAT.
- return SnappedPoint(from_2geom(best_p), Inkscape::SNAPTARGET_PATH_INTERSECTION, primaryC->getDistance(), primaryC->getTolerance(), primaryC->getAlwaysSnap(), true, true,
- secondaryC->getDistance(), secondaryC->getTolerance(), secondaryC->getAlwaysSnap());
+ return SnappedPoint(from_2geom(best_p), Inkscape::SNAPTARGET_PATH_INTERSECTION, primaryC->getSnapDistance(), primaryC->getTolerance(), primaryC->getAlwaysSnap(), true, true,
+ secondaryC->getSnapDistance(), secondaryC->getTolerance(), secondaryC->getAlwaysSnap());
}
// No intersection
@@ -97,7 +97,7 @@ bool getClosestCurve(std::list<Inkscape::SnappedCurve> const &list, Inkscape::Sn
bool success = false;
for (std::list<Inkscape::SnappedCurve>::const_iterator i = list.begin(); i != list.end(); i++) {
- if ((i == list.begin()) || (*i).getDistance() < result.getDistance()) {
+ if ((i == list.begin()) || (*i).getSnapDistance() < result.getSnapDistance()) {
result = *i;
success = true;
}
@@ -120,10 +120,10 @@ bool getClosestIntersectionCS(std::list<Inkscape::SnappedCurve> const &list, Geo
// if it's the first point
bool const c1 = !success;
// or, if it's closer
- bool const c2 = sp.getDistance() < result.getDistance();
+ bool const c2 = sp.getSnapDistance() < result.getSnapDistance();
// or, if it's just then look at the other distance
// (only relevant for snapped points which are at an intersection
- bool const c3 = (sp.getDistance() == result.getDistance()) && (sp.getSecondDistance() < result.getSecondDistance());
+ bool const c3 = (sp.getSnapDistance() == result.getSnapDistance()) && (sp.getSecondSnapDistance() < result.getSecondSnapDistance());
// then prefer this point over the previous one
if (c1 || c2 || c3) {
result = sp;