From 84504bd815a6ef3c5b7b5958ce46429cbab56a66 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 3 Nov 2007 14:48:50 +0000 Subject: Groundwork to snap to intersections, e.g. intersections of gridlines with guidelines, and of objects with other objects. The snappers used to return only SnappedPoints, but now also SnappedLines and SnappedInfiniteLines can be returned. SnappedPaths will be implemented later. (bzr r4016) --- src/snapped-point.cpp | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'src/snapped-point.cpp') diff --git a/src/snapped-point.cpp b/src/snapped-point.cpp index 5d0d242dd..9df76b704 100644 --- a/src/snapped-point.cpp +++ b/src/snapped-point.cpp @@ -9,28 +9,24 @@ */ #include "snapped-point.h" +#include -Inkscape::SnappedPoint::SnappedPoint(NR::Point p, NR::Coord d) - : _distance(d), _point(p) +Inkscape::SnappedPoint::SnappedPoint(NR::Point p, NR::Coord d, bool at_intersection) + : _distance(d), _point(p), _at_intersection(at_intersection) { - } -Inkscape::SnappedPoint::~SnappedPoint() +Inkscape::SnappedPoint::SnappedPoint() { - /// TODO : empty the _hightlight_groups vector and destroy the - /// HighlightGroup items it holds + _distance = NR_HUGE; + _point = NR::Point(0,0); + _at_intersection = false; } -void Inkscape::SnappedPoint::addHighlightGroup(HighlightGroup *group) -{ - /// TODO -} -void Inkscape::SnappedPoint::addHighlightGroups(std::vector *groups) +Inkscape::SnappedPoint::~SnappedPoint() { - /// TODO } NR::Coord Inkscape::SnappedPoint::getDistance() const @@ -43,12 +39,21 @@ NR::Point Inkscape::SnappedPoint::getPoint() const return _point; } -std::vector Inkscape::SnappedPoint::getHighlightGroups() const +// search for the closest snapped point +bool getClosestSP(std::list &list, Inkscape::SnappedPoint &result) { - return _hightlight_groups; + bool success = false; + + for (std::list::const_iterator i = list.begin(); i != list.end(); i++) { + if ((i == list.begin()) || (*i).getDistance() < result.getDistance()) { + result = *i; + success = true; + } + } + + return success; } - /* Local Variables: mode:c++ -- cgit v1.2.3