Code

remember and use geom::point normal when dragging new guides
[inkscape.git] / src / snapper.cpp
index 7a82fe1d462f384e3be8c9ff85146c1d3f768fff..1daa1d15183574d90839e1f668ec014b11155d3c 100644 (file)
 
 Inkscape::Snapper::PointType const Inkscape::Snapper::SNAPPOINT_BBOX = 0x1;
 Inkscape::Snapper::PointType const Inkscape::Snapper::SNAPPOINT_NODE = 0x2;
+Inkscape::Snapper::PointType const Inkscape::Snapper::SNAPPOINT_GUIDE = 0x4;
 
 /**
  *  Construct new Snapper for named view.
  *  \param nv Named view.
  *  \param d Snap distance.
  */
-Inkscape::Snapper::Snapper(SPNamedView const *nv, NR::Coord const d) : _named_view(nv), _enabled(true), _distance(d)
+Inkscape::Snapper::Snapper(SPNamedView const *nv, NR::Coord const d) : _named_view(nv), _snap_enabled(true), _distance(d)
 {
     g_assert(_named_view != NULL);
     g_assert(SP_IS_NAMEDVIEW(_named_view));
@@ -75,7 +76,7 @@ bool Inkscape::Snapper::getSnapFrom(PointType t) const
 
 void Inkscape::Snapper::setEnabled(bool s)
 {
-    _enabled = s;
+    _snap_enabled = s;
 }
 
 
@@ -90,13 +91,17 @@ void Inkscape::Snapper::setEnabled(bool s)
  *  \return Snapped point.
  */
 
-Inkscape::SnappedPoint Inkscape::Snapper::freeSnap(PointType const &t,
+void Inkscape::Snapper::freeSnap(SnappedConstraints &sc,
+                                                   
+                                                   PointType const &t,
                                                    NR::Point const &p,
+                                                   bool const &first_point,
+                                                    std::vector<NR::Point> &points_to_snap,                         
                                                    SPItem const *it) const
 {
     std::list<SPItem const *> lit;
     lit.push_back(it);
-    return freeSnap(t, p, lit);
+    freeSnap(sc, t, p, first_point, points_to_snap, lit);
 }
 
 
@@ -111,15 +116,19 @@ Inkscape::SnappedPoint Inkscape::Snapper::freeSnap(PointType const &t,
  *  \return Snapped point.
  */
 
-Inkscape::SnappedPoint Inkscape::Snapper::freeSnap(PointType const &t,
+void Inkscape::Snapper::freeSnap(SnappedConstraints &sc, 
+                                                   
+                                                   PointType const &t,
                                                    NR::Point const &p,
+                                                   bool const &first_point,
+                                                    std::vector<NR::Point> &points_to_snap,                     
                                                    std::list<SPItem const *> const &it) const
 {
-    if (_enabled == false || getSnapFrom(t) == false) {
-        return SnappedPoint(p, NR_HUGE);
+    if (_snap_enabled == false || getSnapFrom(t) == false) {
+        return;
     }
 
-    return _doFreeSnap(t, p, it);
+    _doFreeSnap(sc, t, p, first_point, points_to_snap, it);
 }
 
 
@@ -136,14 +145,18 @@ Inkscape::SnappedPoint Inkscape::Snapper::freeSnap(PointType const &t,
  *  \return Snapped point.
  */
 
-Inkscape::SnappedPoint Inkscape::Snapper::constrainedSnap(PointType const &t,
+void Inkscape::Snapper::constrainedSnap(SnappedConstraints &sc, 
+                                                          
+                                                          PointType const &t,
                                                           NR::Point const &p,
+                                                          bool const &first_point,
+                                                           std::vector<NR::Point> &points_to_snap,
                                                           ConstraintLine const &c,
                                                           SPItem const *it) const
 {
     std::list<SPItem const *> lit;
     lit.push_back(it);
-    return constrainedSnap(t, p, c, lit);
+    constrainedSnap(sc, t, p, first_point, points_to_snap, c, lit);
 }
 
 
@@ -158,16 +171,19 @@ Inkscape::SnappedPoint Inkscape::Snapper::constrainedSnap(PointType const &t,
  *  \return Snapped point.
  */
 
-Inkscape::SnappedPoint Inkscape::Snapper::constrainedSnap(PointType const &t,
+void Inkscape::Snapper::constrainedSnap(SnappedConstraints &sc, 
+                                                          PointType const &t,
                                                           NR::Point const &p,
+                                                          bool const &first_point,
+                                                          std::vector<NR::Point> &points_to_snap,                         
                                                           ConstraintLine const &c,
                                                           std::list<SPItem const *> const &it) const
 {
-    if (_enabled == false || getSnapFrom(t) == false) {
-        return SnappedPoint(p, NR_HUGE);
+    if (_snap_enabled == false || getSnapFrom(t) == false) {
+        return;
     }
 
-    return _doConstrainedSnap(t, p, c, it);
+    _doConstrainedSnap(sc, t, p, first_point, points_to_snap, c, it);
 }
 
 /*