Code

Node tool: snap to paths and their nodes, incl. to the path currently being edited
authordvlierop2 <dvlierop2@users.sourceforge.net>
Sat, 8 Mar 2008 11:32:18 +0000 (11:32 +0000)
committerdvlierop2 <dvlierop2@users.sourceforge.net>
Sat, 8 Mar 2008 11:32:18 +0000 (11:32 +0000)
16 files changed:
src/line-snapper.cpp
src/line-snapper.h
src/livarot/Path.h
src/livarot/PathCutting.cpp
src/nodepath.cpp
src/object-snapper.cpp
src/object-snapper.h
src/snap.cpp
src/snap.h
src/snapper.cpp
src/snapper.h
src/sp-item-notify-moveto.cpp
src/sp-item-rm-unsatisfied-cns.cpp
src/sp-item-update-cns.cpp
src/splivarot.cpp
src/splivarot.h

index a84a802961fe04ed40a6bd9411bcb9e51bb637d5..219bc7482d7501c54d6259087a488acce0d64d0f 100644 (file)
@@ -28,7 +28,8 @@ void Inkscape::LineSnapper::_doFreeSnap(SnappedConstraints &sc,
                                                     NR::Point const &p,
                                                     bool const &f,
                                                     std::vector<NR::Point> &points_to_snap,
-                                                    std::list<SPItem const *> const &it) const
+                                                    std::list<SPItem const *> const &it,
+                                                    std::vector<NR::Point> *unselected_nodes) const
 {
     /* Get the lines that we will try to snap to */
     const LineList lines = _getSnapLines(p);
index 6a1ff9016b105d140cb9d62af7213bc5d29fcb27..c1c7da39a7dbc2bba44eddec414345efcec287a7 100644 (file)
@@ -32,7 +32,8 @@ private:
                    NR::Point const &p,
                    bool const &first_point,
                    std::vector<NR::Point> &points_to_snap,
-                   std::list<SPItem const *> const &it) const;
+                   std::list<SPItem const *> const &it,
+                   std::vector<NR::Point> *unselected_nodes) const;
   
   void _doConstrainedSnap(SnappedConstraints &sc,
                           Inkscape::Snapper::PointType const &t,
index b6e563d983021b5d974380e62609b07cfaf2747a..454fb4ca4da44d25ad9258027bdb7da0d93623b6 100644 (file)
@@ -203,7 +203,7 @@ public:
     double        t;
   };
   cut_position*    CurvilignToPosition(int nbCv,double* cvAbs,int &nbCut);
-  cut_position    PointToCurvilignPosition(NR::Point const &pos) const;
+  cut_position    PointToCurvilignPosition(NR::Point const &pos, unsigned seg = 0) const;
   //Should this take a cut_position as a param?
   double           PositionToLength(int piece, double t);
   
index 7bc1114a38fa76ecb63e2f1ce94ef1141098a762..ea8a86f3e26ba851fdea42af044ce12b4ccaa53a 100644 (file)
@@ -951,14 +951,17 @@ hence the Path-esque coding style"
 
 */
 template<typename T> inline static T square(T x) {return x*x;}
-Path::cut_position Path::PointToCurvilignPosition(NR::Point const &pos) const
+Path::cut_position Path::PointToCurvilignPosition(NR::Point const &pos, unsigned seg) const
 {
+    // if the parameter "seg" == 0, then all segments will be considered
+    // In however e.g. "seg" == 6 , then only the 6th segment will be considered 
     unsigned bestSeg = 0;
     double bestRangeSquared = DBL_MAX;
     double bestT = 0.0; // you need a sentinel, or make sure that you prime with correct values.
 
     for (unsigned i = 1 ; i < pts.size() ; i++) {
-        if (pts[i].isMoveTo == polyline_moveto) continue;
+        if (pts[i].isMoveTo == polyline_moveto || (seg > 0 && i != seg)) continue;
         NR::Point p1, p2, localPos;
         double thisRangeSquared;
         double t;
index 380a740fa0c1c85024ae3a693de9e7367d614693..a563696cccbb4efbf1cbb395676974197cd81423 100644 (file)
@@ -1102,18 +1102,36 @@ static void sp_nodepath_selected_nodes_move(Inkscape::NodePath::Path *nodepath,
     NR::Point best_pt = delta;
     NR::Point best_abs(NR_HUGE, NR_HUGE);
 
-    if (snap) {
-        SnapManager const &m = nodepath->desktop->namedview->snap_manager;
-
+    
+    if (snap) {    
+        /* When dragging a (selected) node, it should only snap to other nodes (i.e. unselected nodes), and
+         * not to itself. The snapper however can not tell which nodes are selected and which are not, so we 
+         * must provide that information. */
+          
+        // Build a list of the unselected nodes to which the snapper should snap 
+        std::vector<NR::Point> unselected_nodes;
+        for (GList *spl = nodepath->subpaths; spl != NULL; spl = spl->next) {
+            Inkscape::NodePath::SubPath *subpath = (Inkscape::NodePath::SubPath *) spl->data;
+            for (GList *nl = subpath->nodes; nl != NULL; nl = nl->next) {
+                Inkscape::NodePath::Node *node = (Inkscape::NodePath::Node *) nl->data;
+                if (!node->selected) {
+                    unselected_nodes.push_back(node->pos);
+                }    
+            }
+        }        
+        
+        SnapManager &m = nodepath->desktop->namedview->snap_manager;
+        
         for (GList *l = nodepath->selected; l != NULL; l = l->next) {
             Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data;
-            Inkscape::SnappedPoint const s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, n->pos + delta, SP_PATH(n->subpath->nodepath->item));
+            Inkscape::SnappedPoint s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, n->pos + delta, SP_PATH(n->subpath->nodepath->item), &unselected_nodes);            
             if (s.getDistance() < best) {
                 best = s.getDistance();
                 best_abs = s.getPoint();
                 best_pt = best_abs - n->pos;
             }
         }
+                        
         if (best_abs[NR::X] < NR_HUGE) {
             nodepath->desktop->snapindicator->set_new_snappoint(best_abs.to_2geom());
         }
index 0308efe2d5e65e2b40907e8fedacf8cb5e632293..6c94679ecb0b33245273194c100f59e765cb1c12 100644 (file)
@@ -6,7 +6,7 @@
  *   Carl Hetherington <inkscape@carlh.net>
  *   Diederik van Lierop <mail@diedenrezi.nl>
  *
- * Copyright (C) 2005 - 2007 Authors
+ * Copyright (C) 2005 - 2008 Authors
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
@@ -193,12 +193,17 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::Snapper::PointType const &
 void Inkscape::ObjectSnapper::_snapNodes(SnappedConstraints &sc,
                                          Inkscape::Snapper::PointType const &t,
                                          NR::Point const &p,
-                                         bool const &first_point) const
+                                         bool const &first_point,
+                                         std::vector<NR::Point> *unselected_nodes) const
 {
     // Iterate through all nodes, find out which one is the closest to p, and snap to it!
     
     _collectNodes(t, first_point);
     
+    if (unselected_nodes != NULL) {
+        _points_to_snap_to->insert(_points_to_snap_to->end(), unselected_nodes->begin(), unselected_nodes->end());
+    }   
+    
     SnappedPoint s;
     bool success = false;
     
@@ -245,7 +250,8 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuideToNodes(SnappedConstraints &s
 }
 
 void Inkscape::ObjectSnapper::_collectPaths(Inkscape::Snapper::PointType const &t,
-                                         bool const &first_point) const
+                                         bool const &first_point,
+                                         SPPath const *selected_path) const
 {
     // Now, let's first collect all paths to snap to. If we have a whole bunch of points to snap,
     // e.g. when translating an item using the selector tool, then we will only do this for the
@@ -262,6 +268,17 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::Snapper::PointType const &
             gchar const *prefs_bbox = prefs_get_string_attribute("tools", "bounding_box");
             bbox_type = (prefs_bbox != NULL && strcmp(prefs_bbox, "geometric")==0)? SPItem::GEOMETRIC_BBOX : SPItem::APPROXIMATE_BBOX;
         }
+        
+        /* While editing a path in the node tool, findCandidates must ignore that path because 
+         * of the node snapping requirements (i.e. only unselected nodes must be snapable).
+         * This path must not be ignored however when snapping to the paths, so we add it here
+         * manually when applicable. 
+         * 
+         * It must be the last one in the list, as this is assumption is being used in _snapPaths() 
+         */ 
+        if (_snap_to_itempath && selected_path != NULL) {
+            _candidates->push_back(SP_ITEM(selected_path));            
+        }
             
         for (std::vector<SPItem*>::const_iterator i = _candidates->begin(); i != _candidates->end(); i++) {
 
@@ -307,7 +324,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::Snapper::PointType const &
                         if (curve) {
                             NArtBpath *bpath = bpath_for_curve(root_item, curve, true, true);
                             _bpaths_to_snap_to->push_back(bpath);
-                            // Because in bpath_for_curve we set doTransformation to true, we
+                            // Because we set doTransformation to true in bpath_for_curve, we
                             // will get a dupe of the path, which must be freed at some point
                             sp_curve_unref(curve);
                         }
@@ -331,9 +348,11 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::Snapper::PointType const &
 void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc,
                                      Inkscape::Snapper::PointType const &t,
                                      NR::Point const &p,
-                                     bool const &first_point) const
+                                     bool const &first_point,
+                                     std::vector<NR::Point> *unselected_nodes,
+                                     SPPath const *selected_path) const
 {
-    _collectPaths(t, first_point);
+    _collectPaths(t, first_point, selected_path);
     
     // Now we can finally do the real snapping, using the paths collected above
     SnappedPoint s;
@@ -359,34 +378,72 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc,
     
     for (std::vector<Path*>::const_iterator k = _paths_to_snap_to->begin(); k != _paths_to_snap_to->end(); k++) {
         if (*k) {
-            /* Look for the nearest position on this SPItem to our snap point */
-            NR::Maybe<Path::cut_position> const o = get_nearest_position_on_Path(*k, p_doc);
-            if (o && o->t >= 0 && o->t <= 1) {
-
-                /* Convert the nearest point back to desktop coordinates */
-                NR::Point const o_it = get_point_on_Path(*k, o->piece, o->t);
-                NR::Point const o_dt = desktop->doc2dt(o_it);                
-                NR::Coord const dist = NR::L2(o_dt - p);
-
-                if (dist < getSnapperTolerance()) {
-                       // if we snap to a straight line segment (within a path), then return this line segment
-                       if ((*k)->IsLineSegment(o->piece)) {
-                           NR::Point start_point;
-                           NR::Point end_point;
-                           (*k)->PointAt(o->piece, 0, start_point);
-                           (*k)->PointAt(o->piece, 1, end_point);
-                           start_point = desktop->doc2dt(start_point);
-                           end_point = desktop->doc2dt(end_point);
-                           sc.lines.push_back(Inkscape::SnappedLineSegment(o_dt, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), start_point, end_point));    
-                       } else {                
-                           // for segments other than straight lines of a path, we'll return just the closest snapped point
-                           if (dist < s.getDistance()) {
-                               s = SnappedPoint(o_dt, dist, getSnapperTolerance(), getSnapperAlwaysSnap());
-                               success = true;
-                           }
-                       }
+            bool being_edited = false; // True if the current path is being edited in the node tool            
+            if (unselected_nodes != NULL) {
+                if (unselected_nodes->size() > 0 && selected_path != NULL) { // If the node tool is active ...
+                    if (*k == _paths_to_snap_to->back()) { // and we arrived at the last path in the vector ...
+                        being_edited = true;  // then this path is currently being edited
+                    }        
                 }
             }
+            
+            for (unsigned i = 1 ; i < (*k)->pts.size() ; i++) {
+                NR::Point start_point;
+                NR::Point end_point;   
+                NR::Maybe<Path::cut_position> o = NR::Nothing();                 
+                if (being_edited) { 
+                    /* If the path is being edited, then we will try to snap to each piece of the 
+                     * path individually. We should only snap though to stationary pieces of the paths
+                     * and not to the pieces that are being dragged around. This way we avoid 
+                     * self-snapping. For this we check whether the nodes at both ends of the current
+                     * piece are unselected; if they are then this piece must be stationary 
+                     */
+                    (*k)->PointAt(i, 0, start_point);
+                    (*k)->PointAt(i, 1, end_point);
+                    start_point = desktop->doc2dt(start_point);
+                    end_point = desktop->doc2dt(end_point);
+                    g_assert(unselected_nodes != NULL);
+                    bool c1 = isUnselectedNode(start_point, unselected_nodes);
+                    bool c2 = isUnselectedNode(end_point, unselected_nodes);     
+                    if (c1 && c2) {
+                        o = get_nearest_position_on_Path(*k, p_doc, i);
+                    }
+                } else {
+                    /* If the path is NOT being edited, then we will try to snap to the path as a
+                     * whole, so we need to do this only once and we will break out at the end of
+                     * this for-loop iteration */                    
+                    /* Look for the nearest position on this SPItem to our snap point */
+                    o = get_nearest_position_on_Path(*k, p_doc);
+                    (*k)->PointAt(o->piece, 0, start_point);
+                    (*k)->PointAt(o->piece, 1, end_point);
+                    start_point = desktop->doc2dt(start_point);
+                    end_point = desktop->doc2dt(end_point);                        
+                }
+                
+                if (o && o->t >= 0 && o->t <= 1) {    
+                    /* Convert the nearest point back to desktop coordinates */
+                    NR::Point const o_it = get_point_on_Path(*k, o->piece, o->t);
+                    NR::Point const o_dt = desktop->doc2dt(o_it);                
+                    NR::Coord const dist = NR::L2(o_dt - p);
+    
+                    if (dist < getSnapperTolerance()) {
+                        // if we snap to a straight line segment (within a path), then return this line segment
+                        if ((*k)->IsLineSegment(o->piece)) {
+                            sc.lines.push_back(Inkscape::SnappedLineSegment(o_dt, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), start_point, end_point));    
+                        } else {                
+                            // for segments other than straight lines of a path, we'll return just the closest snapped point
+                            if (dist < s.getDistance()) {
+                                s = SnappedPoint(o_dt, dist, getSnapperTolerance(), getSnapperAlwaysSnap());
+                                success = true;
+                            }
+                        }
+                    }
+                }        
+                
+                // If the path is NOT being edited, then we will try to snap to the path as a whole
+                // so we need to do this only once
+                if (!being_edited) break;
+            }
         }
     }
 
@@ -395,6 +452,26 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc,
     }
 }
 
+/* Returns true if point is coincident with one of the unselected nodes */ 
+bool Inkscape::ObjectSnapper::isUnselectedNode(NR::Point const &point, std::vector<NR::Point> const *unselected_nodes) const
+{
+    if (unselected_nodes == NULL) {
+        return false;
+    }
+    
+    if (unselected_nodes->size() == 0) {
+        return false;
+    }
+    
+    for (std::vector<NR::Point>::const_iterator i = unselected_nodes->begin(); i != unselected_nodes->end(); i++) {
+        if (NR::L2(point - *i) < 1e-4) {
+            return true;
+        }   
+    }  
+    
+    return false;    
+}
+
 void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc,
                                      Inkscape::Snapper::PointType const &t,
                                      NR::Point const &p,
@@ -461,7 +538,8 @@ void Inkscape::ObjectSnapper::_doFreeSnap(SnappedConstraints &sc,
                                             NR::Point const &p,
                                             bool const &first_point,
                                             std::vector<NR::Point> &points_to_snap,
-                                            std::list<SPItem const *> const &it) const
+                                            std::list<SPItem const *> const &it,
+                                            std::vector<NR::Point> *unselected_nodes) const
 {
     if ( NULL == _named_view ) {
         return;
@@ -471,12 +549,25 @@ void Inkscape::ObjectSnapper::_doFreeSnap(SnappedConstraints &sc,
     if (first_point) {
         _findCandidates(sp_document_root(_named_view->document), it, first_point, points_to_snap, TRANSL_SNAP_XY);
     }
-
+    
     if (_snap_to_itemnode || _snap_to_bboxnode) {
-        _snapNodes(sc, t, p, first_point);
+        _snapNodes(sc, t, p, first_point, unselected_nodes);
     }
+    
     if (_snap_to_itempath || _snap_to_bboxpath) {
-        _snapPaths(sc, t, p, first_point);
+        unsigned n = (unselected_nodes == NULL) ? 0 : unselected_nodes->size();
+        if (n > 0) {
+            /* While editing a path in the node tool, findCandidates must ignore that path because 
+             * of the node snapping requirements (i.e. only unselected nodes must be snapable).
+             * That path must not be ignored however when snapping to the paths, so we add it here
+             * manually when applicable
+             */
+            g_assert(it.size() == 1);
+            g_assert(SP_IS_PATH(*it.begin()));
+            _snapPaths(sc, t, p, first_point, unselected_nodes, SP_PATH(*it.begin()));    
+        } else {
+            _snapPaths(sc, t, p, first_point, NULL, NULL);   
+        }        
     }
 }
 
index 73c62251713c688c9ae7816d0cc53b6c201c273a..ef43af0e97790442e482d7a2481a614246b59b97 100644 (file)
@@ -9,7 +9,7 @@
  *   Carl Hetherington <inkscape@carlh.net>
  *   Diederik van Lierop <mail@diedenrezi.nl>
  *
- * Copyright (C) 2005 - 2007 Authors 
+ * Copyright (C) 2005 - 2008 Authors 
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
@@ -101,7 +101,8 @@ private:
                       NR::Point const &p,
                       bool const &first_point,
                       std::vector<NR::Point> &points_to_snap,
-                      std::list<SPItem const *> const &it) const;
+                      std::list<SPItem const *> const &it,
+                      std::vector<NR::Point> *unselected_nodes) const;
 
   void _doConstrainedSnap(SnappedConstraints &sc,
                       Inkscape::Snapper::PointType const &t,
@@ -120,7 +121,8 @@ private:
   void _snapNodes(SnappedConstraints &sc,
                       Inkscape::Snapper::PointType const &t,
                       NR::Point const &p, 
-                      bool const &first_point) const;
+                      bool const &first_point,
+                      std::vector<NR::Point> *unselected_nodes) const;
                       
   void _snapTranslatingGuideToNodes(SnappedConstraints &sc,
                      Inkscape::Snapper::PointType const &t,
@@ -133,16 +135,20 @@ private:
   void _snapPaths(SnappedConstraints &sc,
                       Inkscape::Snapper::PointType const &t, 
                       NR::Point const &p,
-                      bool const &first_point) const;
+                      bool const &first_point,
+                      std::vector<NR::Point> *unselected_nodes,
+                      SPPath const *selected_path) const;
                       
   void _snapPathsConstrained(SnappedConstraints &sc,
                  Inkscape::Snapper::PointType const &t,
                  NR::Point const &p,
                  bool const &first_point,
                  ConstraintLine const &c) const;
+  bool isUnselectedNode(NR::Point const &point, std::vector<NR::Point> const *unselected_nodes) const;
   
   void _collectPaths(Inkscape::Snapper::PointType const &t, 
-                  bool const &first_point) const;
+                  bool const &first_point,
+                  SPPath const *selected_path = NULL) const;
   void _clear_paths() const;
   
   bool _snap_to_itemnode;
index cb4ea3f5882af10ed7bad80830513ccbb4935728..093ae10e3d497e00272bfd4bfb818b42d3565f5b 100644 (file)
@@ -187,9 +187,34 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType t,
     std::vector<NR::Point> points_to_snap;
     points_to_snap.push_back(p);
     
-    return freeSnap(t, p, true, points_to_snap, lit);
+    return freeSnap(t, p, true, points_to_snap, lit, NULL);
 }
 
+/**
+ *  Try to snap a point to any interested snappers.
+ *
+ *  \param t Type of point.
+ *  \param p Point.
+ *  \param it Item to ignore when snapping.
+ *  \return Snapped point.
+ */
+
+Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType t,
+                                             NR::Point const &p,
+                                             SPItem const *it,
+                                             std::vector<NR::Point> *unselected_nodes) const
+
+{
+    std::list<SPItem const *> lit;
+    lit.push_back(it);
+    
+    std::vector<NR::Point> points_to_snap;
+    points_to_snap.push_back(p);
+    
+    return freeSnap(t, p, true, points_to_snap, lit, unselected_nodes);
+}
+
+
 /**
  *  Try to snap a point to any of the specified snappers.
  *
@@ -206,7 +231,8 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType t,
                                              NR::Point const &p,
                                              bool const &first_point,
                                              std::vector<NR::Point> &points_to_snap,
-                                             std::list<SPItem const *> const &it) const
+                                             std::list<SPItem const *> const &it,
+                                             std::vector<NR::Point> *unselected_nodes) const
 {
     if (!SomeSnapperMightSnap()) {
         return Inkscape::SnappedPoint(p, NR_HUGE, 0, false);
@@ -217,7 +243,7 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType t,
     SnapperList const snappers = getSnappers();
 
     for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) {
-        (*i)->freeSnap(sc, t, p, first_point, points_to_snap, it);
+        (*i)->freeSnap(sc, t, p, first_point, points_to_snap, it, unselected_nodes);
     }
 
     return findBestSnap(p, sc, false);
@@ -414,7 +440,7 @@ std::pair<NR::Point, bool> SnapManager::_snapTransformed(
             }
             snapped = constrainedSnap(type, *j, i == points.begin(), transformed_points, dedicated_constraint, ignore);
         } else {
-            snapped = freeSnap(type, *j, i == points.begin(), transformed_points, ignore);
+            snapped = freeSnap(type, *j, i == points.begin(), transformed_points, ignore, NULL);
         }
 
         NR::Point result;
@@ -704,6 +730,14 @@ std::pair<NR::Coord, bool> SnapManager::freeSnapSkew(Inkscape::Snapper::PointTyp
 
 Inkscape::SnappedPoint SnapManager::findBestSnap(NR::Point const &p, SnappedConstraints &sc, bool constrained) const
 {
+    /*
+    std::cout << "Type and number of snapped constraints: " << std::endl;
+    std::cout << "  Points      : " << sc.points.size() << std::endl;
+    std::cout << "  Lines       : " << sc.lines.size() << std::endl;
+    std::cout << "  Grid lines  : " << sc.grid_lines.size()<< std::endl;
+    std::cout << "  Guide lines : " << sc.guide_lines.size()<< std::endl;
+    */
+        
     // Store all snappoints
     std::list<Inkscape::SnappedPoint> sp_list;
     
index 9702d011aa5d42f04866ab36d4a21d1f2583d79a..156703264a413fb2b535e2dad6987673d6ef3ce7 100644 (file)
@@ -49,12 +49,18 @@ public:
     Inkscape::SnappedPoint freeSnap(Inkscape::Snapper::PointType t,
                                     NR::Point const &p,
                                     SPItem const *it) const;
-
+                                    
+    Inkscape::SnappedPoint freeSnap(Inkscape::Snapper::PointType t,
+                                    NR::Point const &p,
+                                    SPItem const *it,
+                                    std::vector<NR::Point> *unselected_nodes) const;
+    
     Inkscape::SnappedPoint freeSnap( Inkscape::Snapper::PointType t,
                                       NR::Point const &p,
                                       bool const &first_point,
                                       std::vector<NR::Point> &points_to_snap,
-                                      std::list<SPItem const *> const &it) const;
+                                      std::list<SPItem const *> const &it,
+                                      std::vector<NR::Point> *unselected_nodes) const;
 
     Inkscape::SnappedPoint constrainedSnap(Inkscape::Snapper::PointType t,
                                            NR::Point const &p,
index 5f5261885fa75a6fb190e833617c31bb6aecb261..f8f7705f23d5e3963e72f6a2e51426d0255ad4a9 100644 (file)
@@ -97,20 +97,21 @@ void Inkscape::Snapper::setEnabled(bool s)
  *  \return Snapped point.
  */
 
-void Inkscape::Snapper::freeSnap(SnappedConstraints &sc,
-                                                   
+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::vector<NR::Point> &points_to_snap,                         
                                                    SPItem const *it) const
 {
     std::list<SPItem const *> lit;
-    lit.push_back(it);
-    freeSnap(sc, t, p, first_point, points_to_snap, lit);
+    if (it) {
+        lit.push_back(it);
+    }
+    
+    freeSnap(sc, t, p, first_point, points_to_snap, lit, NULL);
 }
 
-
 /**
  *  Try to snap a point to whatever this snapper is interested in.  Any
  *  snap that occurs will be to the nearest "interesting" thing (e.g. a
@@ -127,14 +128,15 @@ 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
+                                                   std::vector<NR::Point> &points_to_snap,                     
+                                                   std::list<SPItem const *> const &it,
+                                                   std::vector<NR::Point> *unselected_nodes) const
 {
     if (_snap_enabled == false || getSnapFrom(t) == false) {
         return;
     }
 
-    _doFreeSnap(sc, t, p, first_point, points_to_snap, it);
+    _doFreeSnap(sc, t, p, first_point, points_to_snap, it, unselected_nodes);
 }
 
 
index 8aeea0a26c60bf15eacc170604df0ecf46f1c6c1..63f68173a14c73e170c67fc360b00bd1d793fcd3 100644 (file)
@@ -68,13 +68,14 @@ public:
                           bool const &first_point,                                             
                           std::vector<NR::Point> &points_to_snap,                         
                           SPItem const *it) const;
-
+                          
     void 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;
+                          std::list<SPItem const *> const &it,
+                          std::vector<NR::Point> *unselected_nodes) const;
 
     class ConstraintLine
     {
@@ -142,7 +143,8 @@ private:
                                      NR::Point const &p,
                                      bool const &first_point,                                             
                                      std::vector<NR::Point> &points_to_snap,
-                                     std::list<SPItem const *> const &it) const = 0;
+                                     std::list<SPItem const *> const &it,
+                                     std::vector<NR::Point> *unselected_nodes) const = 0;
 
     /**
      *  Try to snap a point to whatever this snapper is interested in, where
index c7b852af5ccc599d94fba19b4b7d813dc305d0ed..391766fb6ff679c2db1829e71f949234a7fcd7db 100644 (file)
@@ -24,7 +24,7 @@ void sp_item_notify_moveto(SPItem &item, SPGuide const &mv_g, int const snappoin
     double const dir_lensq(dot(dir, dir));
     g_return_if_fail( dir_lensq != 0 );
 
-    vector<NR::Point> snappoints;
+    std::vector<NR::Point> snappoints;
     sp_item_snappoints(&item, true, SnapPointsIter(snappoints));
     g_return_if_fail( snappoint_ix < int(snappoints.size()) );
 
index fe6d73a3a844d750d7272fea83d33ff790e7934a..bcd16e3aa77167d75fe3977810ce35e005a236c5 100644 (file)
@@ -14,7 +14,7 @@ void sp_item_rm_unsatisfied_cns(SPItem &item)
     if (item.constraints.empty()) {
         return;
     }
-    vector<NR::Point> snappoints;
+    std::vector<NR::Point> snappoints;
     sp_item_snappoints(&item, true, SnapPointsIter(snappoints));
     for (unsigned i = item.constraints.size(); i--;) {
         g_assert( i < item.constraints.size() );
index 44b26d45f6e2998689f774781216d08b142dbb9c..82ff0c458675d5e55790cb05e18645d1c03cb191 100644 (file)
@@ -9,7 +9,7 @@ using std::vector;
 
 void sp_item_update_cns(SPItem &item, SPDesktop const &desktop)
 {
-    vector<NR::Point> snappoints;
+    std::vector<NR::Point> snappoints;
     sp_item_snappoints(&item, true, SnapPointsIter(snappoints));
     /* TODO: Implement the ordering. */
     vector<SPGuideConstraint> found_cns;
index f176776a68f1c0b62d969b1167afdb02eca28b28..72f059bdcdbb314b4e90ec2e03e9f5e732bc5ba9 100644 (file)
@@ -1839,10 +1839,10 @@ Path *bpath_to_Path(NArtBpath const *bpath) {
     return dest;
 }
 
-NR::Maybe<Path::cut_position> get_nearest_position_on_Path(Path *path, NR::Point p)
+NR::Maybe<Path::cut_position> get_nearest_position_on_Path(Path *path, NR::Point p, unsigned seg)
 {
     //get nearest position on path
-    Path::cut_position pos = path->PointToCurvilignPosition(p);
+    Path::cut_position pos = path->PointToCurvilignPosition(p, seg);
     return pos;
 }
 
index c0a7fb38b76a7eaaf0a02e949c74a516f7cd8847..61b5ee14380eecd170db947dd0d7747164d5a322 100644 (file)
@@ -45,7 +45,7 @@ void sp_selected_path_simplify ();
 Path *Path_for_item(SPItem *item, bool doTransformation, bool transformFull = true);
 NArtBpath *bpath_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transformFull);
 SPCurve *curve_for_item(SPItem *item);
-NR::Maybe<Path::cut_position> get_nearest_position_on_Path(Path *path, NR::Point p);
+NR::Maybe<Path::cut_position> get_nearest_position_on_Path(Path *path, NR::Point p, unsigned seg = 0);
 NR::Point get_point_on_Path(Path *path, int piece, double t);
 Path *bpath_to_Path(NArtBpath const *bpath);