Code

Connector tool: make connectors avoid the convex hull of shapes.
[inkscape.git] / src / snapped-curve.cpp
index 20d7aea33ccd680bb6e4ff8562c6e29aacd5ce5a..4da2d4c7d5601aaf8699bcb23249f8b5a58501ca 100644 (file)
@@ -9,12 +9,10 @@
  */
 
 #include "snapped-curve.h"
-#include "libnr/nr-values.h"
 #include <2geom/crossing.h>
 #include <2geom/path-intersection.h>
-#include <libnr/nr-convert2geom.h>
 
-Inkscape::SnappedCurve::SnappedCurve(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, Geom::Coord const &snapped_tolerance, bool const &always_snap, bool const &fully_constrained, Geom::Curve const *curve)
+Inkscape::SnappedCurve::SnappedCurve(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, Geom::Coord const &snapped_tolerance, bool const &always_snap, bool const &fully_constrained, Geom::Curve const *curve, SnapSourceType source, SnapTargetType target)
 {
     _distance = snapped_distance;
     _tolerance = std::max(snapped_tolerance, 1.0);
@@ -26,6 +24,8 @@ Inkscape::SnappedCurve::SnappedCurve(Geom::Point const &snapped_point, Geom::Coo
     _point = snapped_point;
     _at_intersection = false;
     _fully_constrained = fully_constrained;
+    _source = source;
+    _target = target;
 }
 
 Inkscape::SnappedCurve::SnappedCurve()
@@ -40,6 +40,8 @@ Inkscape::SnappedCurve::SnappedCurve()
     _point = Geom::Point(0,0);
     _at_intersection = false;
     _fully_constrained = false;
+    _source = SNAPSOURCE_UNDEFINED;
+    _target = SNAPTARGET_UNDEFINED;
 }
 
 Inkscape::SnappedCurve::~SnappedCurve()
@@ -81,12 +83,12 @@ Inkscape::SnappedPoint Inkscape::SnappedCurve::intersect(SnappedCurve const &cur
         // TODO: Investigate whether it is possible to use document coordinates everywhere
         // in the snapper code. Only the mouse position should be in desktop coordinates, I guess.
         // All paths are already in document coords and we are certainly not going to change THAT.
-        return SnappedPoint(best_p, Inkscape::SNAPTARGET_PATH_INTERSECTION, primaryDist, primaryC->getTolerance(), primaryC->getAlwaysSnap(), true, true,
+        return SnappedPoint(best_p, Inkscape::SNAPSOURCE_UNDEFINED, Inkscape::SNAPTARGET_PATH_INTERSECTION, primaryDist, primaryC->getTolerance(), primaryC->getAlwaysSnap(), true, true,
                 secondaryDist, secondaryC->getTolerance(), secondaryC->getAlwaysSnap());
     }
 
     // No intersection
-    return SnappedPoint(Geom::Point(NR_HUGE, NR_HUGE), SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false, NR_HUGE, 0, false);
+    return SnappedPoint(Geom::Point(NR_HUGE, NR_HUGE), SNAPSOURCE_UNDEFINED, SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false, NR_HUGE, 0, false);
 }
 
 // search for the closest snapped line