diff options
| author | Diederik van Lierop <mailat-signdiedenrezidotnl> | 2010-01-09 21:14:38 +0000 |
|---|---|---|
| committer | Diederik van Lierop <mailat-signdiedenrezidotnl> | 2010-01-09 21:14:38 +0000 |
| commit | e8f4c644181a8a68e2c33e1783f77a400dc1a29f (patch) | |
| tree | 38083930039a3507ff467c62cf2e588a229a061f /src/snapped-point.cpp | |
| parent | Patch by Alex Leone to fix crash with recursive masks from 190130, I also add... (diff) | |
| download | inkscape-e8f4c644181a8a68e2c33e1783f77a400dc1a29f.tar.gz inkscape-e8f4c644181a8a68e2c33e1783f77a400dc1a29f.zip | |
Refactoring the snapping API (making it easier to maintain and understand for the devs)
(bzr r8960)
Diffstat (limited to 'src/snapped-point.cpp')
| -rw-r--r-- | src/snapped-point.cpp | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/src/snapped-point.cpp b/src/snapped-point.cpp index 102e761b9..e3559d655 100644 --- a/src/snapped-point.cpp +++ b/src/snapped-point.cpp @@ -25,6 +25,24 @@ Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p, SnapSourceType const _second_always_snap = false; _transformation = Geom::Point(1,1); _pointer_distance = NR_HUGE; + _target_bbox = Geom::Rect(); +} + +Inkscape::SnappedPoint::SnappedPoint(Inkscape::SnapCandidatePoint const &p, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &fully_constrained) + : _target(target), _distance(d), _tolerance(std::max(t,1.0)), _always_snap(a) +{ + _point = p.getPoint(); + _source = p.getSourceType(); + _source_num = p.getSourceNum(); + _at_intersection = false; + _fully_constrained = fully_constrained; + _second_distance = NR_HUGE; + _second_tolerance = 1; + _second_always_snap = false; + _transformation = Geom::Point(1,1); + _pointer_distance = NR_HUGE; + _target_bbox = Geom::Rect(); + } Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &at_intersection, bool const &fully_constrained, Geom::Coord const &d2, Geom::Coord const &t2, bool const &a2) @@ -35,6 +53,7 @@ Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p, SnapSourceType const // isOtherSnapBetter. We don't want a division by zero. _transformation = Geom::Point(1,1); _pointer_distance = NR_HUGE; + _target_bbox = Geom::Rect(); } Inkscape::SnappedPoint::SnappedPoint() @@ -53,6 +72,26 @@ Inkscape::SnappedPoint::SnappedPoint() _second_always_snap = false; _transformation = Geom::Point(1,1); _pointer_distance = NR_HUGE; + _target_bbox = Geom::Rect(); +} + +Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p) +{ + _point = p; + _source = SNAPSOURCE_UNDEFINED, + _source_num = 0, + _target = SNAPTARGET_UNDEFINED, + _at_intersection = false; + _fully_constrained = false; + _distance = NR_HUGE; + _tolerance = 1; + _always_snap = false; + _second_distance = NR_HUGE; + _second_tolerance = 1; + _second_always_snap = false; + _transformation = Geom::Point(1,1); + _pointer_distance = NR_HUGE; + _target_bbox = Geom::Rect(); } Inkscape::SnappedPoint::~SnappedPoint() @@ -69,7 +108,7 @@ void Inkscape::SnappedPoint::getPoint(Geom::Point &p) const } // search for the closest snapped point -bool getClosestSP(std::list<Inkscape::SnappedPoint> &list, Inkscape::SnappedPoint &result) +bool getClosestSP(std::list<Inkscape::SnappedPoint> const &list, Inkscape::SnappedPoint &result) { bool success = false; @@ -86,6 +125,10 @@ bool getClosestSP(std::list<Inkscape::SnappedPoint> &list, Inkscape::SnappedPoin bool Inkscape::SnappedPoint::isOtherSnapBetter(Inkscape::SnappedPoint const &other_one, bool weighted) const { + if (!other_one.getSnapped()) { + return false; + } + double dist_other = other_one.getSnapDistance(); double dist_this = getSnapDistance(); |
