summaryrefslogtreecommitdiffstats
path: root/src/snapped-curve.cpp
diff options
context:
space:
mode:
authorDiederik van Lierop <mailat-signdiedenrezidotnl>2010-01-19 20:16:06 +0000
committerDiederik van Lierop <mailat-signdiedenrezidotnl>2010-01-19 20:16:06 +0000
commitdb3380152e87e88c89691882ffb32bef78db07b0 (patch)
tree1434568dd36fb239fe900b327c5adb677fdff1c9 /src/snapped-curve.cpp
parentscour extension update (v0.23) (diff)
downloadinkscape-db3380152e87e88c89691882ffb32bef78db07b0.tar.gz
inkscape-db3380152e87e88c89691882ffb32bef78db07b0.zip
When snapping to a bounding box, flash that bounding box together with the snap indicator
(bzr r8999)
Diffstat (limited to 'src/snapped-curve.cpp')
-rw-r--r--src/snapped-curve.cpp41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/snapped-curve.cpp b/src/snapped-curve.cpp
index 334038638..d4ef0a83f 100644
--- a/src/snapped-curve.cpp
+++ b/src/snapped-curve.cpp
@@ -12,7 +12,7 @@
#include <2geom/crossing.h>
#include <2geom/path-intersection.h>
-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, SnapSourceType source, long source_num, SnapTargetType target)
+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, SnapSourceType source, long source_num, SnapTargetType target, Geom::OptRect target_bbox)
{
_distance = snapped_distance;
_tolerance = std::max(snapped_tolerance, 1.0);
@@ -27,6 +27,7 @@ Inkscape::SnappedCurve::SnappedCurve(Geom::Point const &snapped_point, Geom::Coo
_source = source;
_source_num = source_num;
_target = target;
+ _target_bbox = target_bbox;
}
Inkscape::SnappedCurve::SnappedCurve()
@@ -44,6 +45,7 @@ Inkscape::SnappedCurve::SnappedCurve()
_source = SNAPSOURCE_UNDEFINED;
_source_num = 0;
_target = SNAPTARGET_UNDEFINED;
+ _target_bbox = Geom::OptRect();
}
Inkscape::SnappedCurve::~SnappedCurve()
@@ -114,22 +116,27 @@ bool getClosestIntersectionCS(std::list<Inkscape::SnappedCurve> const &list, Geo
bool success = false;
for (std::list<Inkscape::SnappedCurve>::const_iterator i = list.begin(); i != list.end(); i++) {
- std::list<Inkscape::SnappedCurve>::const_iterator j = i;
- j++;
- for (; j != list.end(); j++) {
- Inkscape::SnappedPoint sp = (*i).intersect(*j, p, dt2doc);
- if (sp.getAtIntersection()) {
- // if it's the first point
- bool const c1 = !success;
- // or, if it's closer
- bool const c2 = sp.getSnapDistance() < result.getSnapDistance();
- // or, if it's just as close then look at the other distance
- // (only relevant for snapped points which are at an intersection)
- 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;
- success = true;
+ if ((*i).getTarget() != Inkscape::SNAPTARGET_BBOX_EDGE) { // We don't support snapping to intersections of bboxes,
+ // as this would require two bboxes two be flashed in the snap indicator
+ std::list<Inkscape::SnappedCurve>::const_iterator j = i;
+ j++;
+ for (; j != list.end(); j++) {
+ if ((*j).getTarget() != Inkscape::SNAPTARGET_BBOX_EDGE) { // We don't support snapping to intersections of bboxes
+ Inkscape::SnappedPoint sp = (*i).intersect(*j, p, dt2doc);
+ if (sp.getAtIntersection()) {
+ // if it's the first point
+ bool const c1 = !success;
+ // or, if it's closer
+ bool const c2 = sp.getSnapDistance() < result.getSnapDistance();
+ // or, if it's just as close then look at the other distance
+ // (only relevant for snapped points which are at an intersection)
+ 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;
+ success = true;
+ }
+ }
}
}
}