summaryrefslogtreecommitdiffstats
path: root/src/snapped-line.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/snapped-line.cpp')
-rw-r--r--src/snapped-line.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/snapped-line.cpp b/src/snapped-line.cpp
index 5f7d5407b..706893673 100644
--- a/src/snapped-line.cpp
+++ b/src/snapped-line.cpp
@@ -12,10 +12,12 @@
#include <2geom/geom.h>
#include "libnr/nr-values.h"
-Inkscape::SnappedLineSegment::SnappedLineSegment(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, Geom::Coord const &snapped_tolerance, bool const &always_snap, Geom::Point const &start_point_of_line, Geom::Point const &end_point_of_line)
+Inkscape::SnappedLineSegment::SnappedLineSegment(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, SnapTargetType const &target, Geom::Coord const &snapped_tolerance, bool const &always_snap, Geom::Point const &start_point_of_line, Geom::Point const &end_point_of_line)
: _start_point_of_line(start_point_of_line), _end_point_of_line(end_point_of_line)
{
_point = snapped_point;
+ _source = source;
+ _target = target;
_distance = snapped_distance;
_tolerance = std::max(snapped_tolerance, 1.0);
_always_snap = always_snap;
@@ -30,6 +32,8 @@ Inkscape::SnappedLineSegment::SnappedLineSegment()
_start_point_of_line = Geom::Point(0,0);
_end_point_of_line = Geom::Point(0,0);
_point = Geom::Point(0,0);
+ _source = SNAPSOURCE_UNDEFINED;
+ _target = SNAPTARGET_UNDEFINED;
_distance = NR_HUGE;
_tolerance = 1;
_always_snap = false;
@@ -69,20 +73,22 @@ Inkscape::SnappedPoint Inkscape::SnappedLineSegment::intersect(SnappedLineSegmen
Inkscape::SnappedLineSegment const *secondarySLS = use_this_as_primary ? &line : this;
Geom::Coord primaryDist = use_this_as_primary ? Geom::L2(intersection_2geom - this->getPoint()) : Geom::L2(intersection_2geom - line.getPoint());
Geom::Coord secondaryDist = use_this_as_primary ? Geom::L2(intersection_2geom - line.getPoint()) : Geom::L2(intersection_2geom - this->getPoint());
- return SnappedPoint(intersection, SNAPTARGET_PATH_INTERSECTION, primaryDist, primarySLS->getTolerance(), primarySLS->getAlwaysSnap(), true, true,
+ return SnappedPoint(intersection, SNAPSOURCE_UNDEFINED, SNAPTARGET_PATH_INTERSECTION, primaryDist, primarySLS->getTolerance(), primarySLS->getAlwaysSnap(), true, true,
secondaryDist, secondarySLS->getTolerance(), secondarySLS->getAlwaysSnap());
}
// No intersection
- return SnappedPoint(intersection, SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false, NR_HUGE, 0, false);
+ return SnappedPoint(intersection, SNAPSOURCE_UNDEFINED, SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false, NR_HUGE, 0, false);
};
-Inkscape::SnappedLine::SnappedLine(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, Geom::Coord const &snapped_tolerance, bool const &always_snap, Geom::Point const &normal_to_line, Geom::Point const &point_on_line)
+Inkscape::SnappedLine::SnappedLine(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, SnapTargetType const &target, Geom::Coord const &snapped_tolerance, bool const &always_snap, Geom::Point const &normal_to_line, Geom::Point const &point_on_line)
: _normal_to_line(normal_to_line), _point_on_line(point_on_line)
{
- _distance = snapped_distance;
+ _source = source;
+ _target = target;
+ _distance = snapped_distance;
_tolerance = std::max(snapped_tolerance, 1.0);
_always_snap = always_snap;
_second_distance = NR_HUGE;
@@ -96,6 +102,8 @@ Inkscape::SnappedLine::SnappedLine()
{
_normal_to_line = Geom::Point(0,0);
_point_on_line = Geom::Point(0,0);
+ _source = SNAPSOURCE_UNDEFINED;
+ _target = SNAPTARGET_UNDEFINED;
_distance = NR_HUGE;
_tolerance = 1;
_always_snap = false;
@@ -137,14 +145,14 @@ Inkscape::SnappedPoint Inkscape::SnappedLine::intersect(SnappedLine const &line)
Inkscape::SnappedLine const *secondarySL = use_this_as_primary ? &line : this;
Geom::Coord primaryDist = use_this_as_primary ? Geom::L2(intersection_2geom - this->getPoint()) : Geom::L2(intersection_2geom - line.getPoint());
Geom::Coord secondaryDist = use_this_as_primary ? Geom::L2(intersection_2geom - line.getPoint()) : Geom::L2(intersection_2geom - this->getPoint());
- return SnappedPoint(intersection, Inkscape::SNAPTARGET_UNDEFINED, primaryDist, primarySL->getTolerance(), primarySL->getAlwaysSnap(), true, true,
+ return SnappedPoint(intersection, Inkscape::SNAPSOURCE_UNDEFINED, Inkscape::SNAPTARGET_UNDEFINED, primaryDist, primarySL->getTolerance(), primarySL->getAlwaysSnap(), true, true,
secondaryDist, secondarySL->getTolerance(), secondarySL->getAlwaysSnap());
// The type of the snap target is yet undefined, as we cannot tell whether
// we're snapping to grid or the guide lines; must be set by on a higher level
}
// No intersection
- return SnappedPoint(intersection, SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false, NR_HUGE, 0, false);
+ return SnappedPoint(intersection, SNAPSOURCE_UNDEFINED, SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false, NR_HUGE, 0, false);
}
// search for the closest snapped line segment