summaryrefslogtreecommitdiffstats
path: root/src/snapped-point.cpp
diff options
context:
space:
mode:
authorDiederik van Lierop <mail@diedenrezi.nl>2007-11-03 14:48:50 +0000
committerdvlierop2 <dvlierop2@users.sourceforge.net>2007-11-03 14:48:50 +0000
commit84504bd815a6ef3c5b7b5958ce46429cbab56a66 (patch)
treed74ae924d96f98b07658dcb67d46b64c486d1beb /src/snapped-point.cpp
parentAdded an icons file with a cleaned up current icon set (prefix "ink_" in thei... (diff)
downloadinkscape-84504bd815a6ef3c5b7b5958ce46429cbab56a66.tar.gz
inkscape-84504bd815a6ef3c5b7b5958ce46429cbab56a66.zip
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)
Diffstat (limited to 'src/snapped-point.cpp')
-rw-r--r--src/snapped-point.cpp35
1 files changed, 20 insertions, 15 deletions
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 <libnr/nr-values.h>
-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<HighlightGroup*> *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::HighlightGroup*> Inkscape::SnappedPoint::getHighlightGroups() const
+// search for the closest snapped point
+bool getClosestSP(std::list<Inkscape::SnappedPoint> &list, Inkscape::SnappedPoint &result)
{
- return _hightlight_groups;
+ bool success = false;
+
+ for (std::list<Inkscape::SnappedPoint>::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++