diff --git a/src/snapped-point.cpp b/src/snapped-point.cpp
index 9df76b7047f362945101e5bed31ffa93a57f0c48..02f7ed165b0cf25b83c71e0f5651bb6565e4dd6b 100644 (file)
--- a/src/snapped-point.cpp
+++ b/src/snapped-point.cpp
*
* Authors:
* Mathieu Dimanche <mdimanche@free.fr>
+ * Diederik van Lierop <mail@diedenrezi.nl>
*
* Released under GNU GPL, read the file 'COPYING' for more information.
*/
#include "snapped-point.h"
-#include <libnr/nr-values.h>
-Inkscape::SnappedPoint::SnappedPoint(NR::Point p, NR::Coord d, bool at_intersection)
- : _distance(d), _point(p), _at_intersection(at_intersection)
+// overloaded constructor
+Inkscape::SnappedPoint::SnappedPoint(NR::Point const &p, SnapTargetType const &target, NR::Coord const &d, NR::Coord const &t, bool const &a)
+ : _point(p), _target(target), _distance(d), _tolerance(t), _always_snap(a)
{
+ _at_intersection = false;
+ _second_distance = NR_HUGE;
+ _second_tolerance = 0;
+ _second_always_snap = false;
+ _transformation = NR::Point(1,1);
+}
+
+Inkscape::SnappedPoint::SnappedPoint(NR::Point const &p, SnapTargetType const &target, NR::Coord const &d, NR::Coord const &t, bool const &a, bool const &at_intersection, NR::Coord const &d2, NR::Coord const &t2, bool const &a2)
+ : _point(p), _target(target), _at_intersection(at_intersection), _distance(d), _tolerance(t), _always_snap(a),
+ _second_distance(d2), _second_tolerance(t2), _second_always_snap(a2)
+{
+ _transformation = NR::Point(1,1);
}
Inkscape::SnappedPoint::SnappedPoint()
{
- _distance = NR_HUGE;
- _point = NR::Point(0,0);
- _at_intersection = false;
+ _point = NR::Point(0,0);
+ _target = SNAPTARGET_UNDEFINED,
+ _distance = NR_HUGE;
+ _tolerance = 0;
+ _always_snap = false;
+ _at_intersection = false;
+ _second_distance = NR_HUGE;
+ _second_tolerance = 0;
+ _second_always_snap = false;
+ _transformation = NR::Point(1,1);
}
return _distance;
}
-NR::Point Inkscape::SnappedPoint::getPoint() const
+NR::Coord Inkscape::SnappedPoint::getTolerance() const
+{
+ return _tolerance;
+}
+
+bool Inkscape::SnappedPoint::getAlwaysSnap() const
{
- return _point;
+ return _always_snap;
+}
+
+NR::Coord Inkscape::SnappedPoint::getSecondDistance() const
+{
+ return _second_distance;
+}
+
+NR::Coord Inkscape::SnappedPoint::getSecondTolerance() const
+{
+ return _second_tolerance;
+}
+
+bool Inkscape::SnappedPoint::getSecondAlwaysSnap() const
+{
+ return _second_always_snap;
+}
+
+
+void Inkscape::SnappedPoint::getPoint(NR::Point &p) const
+{
+ // When we have snapped
+ if (getSnapped()) {
+ // then return the snapped point by overwriting p
+ p = _point;
+ } //otherwise p will be left untouched; this way the caller doesn't have to check wether we've snapped
}
// search for the closest snapped point
-bool getClosestSP(std::list<Inkscape::SnappedPoint> &list, Inkscape::SnappedPoint &result)
+bool getClosestSP(std::list<Inkscape::SnappedPoint> &list, Inkscape::SnappedPoint &result)
{
- 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;
+ 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;
}
/*