From: dvlierop2 Date: Sat, 8 Mar 2008 11:32:18 +0000 (+0000) Subject: Node tool: snap to paths and their nodes, incl. to the path currently being edited X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5c681d52040046fc1284c71112618c2b09e36e86;p=inkscape.git Node tool: snap to paths and their nodes, incl. to the path currently being edited --- diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp index a84a80296..219bc7482 100644 --- a/src/line-snapper.cpp +++ b/src/line-snapper.cpp @@ -28,7 +28,8 @@ void Inkscape::LineSnapper::_doFreeSnap(SnappedConstraints &sc, NR::Point const &p, bool const &f, std::vector &points_to_snap, - std::list const &it) const + std::list const &it, + std::vector *unselected_nodes) const { /* Get the lines that we will try to snap to */ const LineList lines = _getSnapLines(p); diff --git a/src/line-snapper.h b/src/line-snapper.h index 6a1ff9016..c1c7da39a 100644 --- a/src/line-snapper.h +++ b/src/line-snapper.h @@ -32,7 +32,8 @@ private: NR::Point const &p, bool const &first_point, std::vector &points_to_snap, - std::list const &it) const; + std::list const &it, + std::vector *unselected_nodes) const; void _doConstrainedSnap(SnappedConstraints &sc, Inkscape::Snapper::PointType const &t, diff --git a/src/livarot/Path.h b/src/livarot/Path.h index b6e563d98..454fb4ca4 100644 --- a/src/livarot/Path.h +++ b/src/livarot/Path.h @@ -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); diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp index 7bc1114a3..ea8a86f3e 100644 --- a/src/livarot/PathCutting.cpp +++ b/src/livarot/PathCutting.cpp @@ -951,14 +951,17 @@ hence the Path-esque coding style" */ template 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; diff --git a/src/nodepath.cpp b/src/nodepath.cpp index 380a740fa..a563696cc 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -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 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()); } diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 0308efe2d..6c94679ec 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -6,7 +6,7 @@ * Carl Hetherington * Diederik van Lierop * - * 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 *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::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 *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::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 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 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 const *unselected_nodes) const +{ + if (unselected_nodes == NULL) { + return false; + } + + if (unselected_nodes->size() == 0) { + return false; + } + + for (std::vector::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 &points_to_snap, - std::list const &it) const + std::list const &it, + std::vector *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); + } } } diff --git a/src/object-snapper.h b/src/object-snapper.h index 73c622517..ef43af0e9 100644 --- a/src/object-snapper.h +++ b/src/object-snapper.h @@ -9,7 +9,7 @@ * Carl Hetherington * Diederik van Lierop * - * 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 &points_to_snap, - std::list const &it) const; + std::list const &it, + std::vector *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 *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 *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 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; diff --git a/src/snap.cpp b/src/snap.cpp index cb4ea3f58..093ae10e3 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -187,9 +187,34 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType t, std::vector 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 *unselected_nodes) const + +{ + std::list lit; + lit.push_back(it); + + std::vector 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 &points_to_snap, - std::list const &it) const + std::list const &it, + std::vector *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 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 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 sp_list; diff --git a/src/snap.h b/src/snap.h index 9702d011a..156703264 100644 --- a/src/snap.h +++ b/src/snap.h @@ -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 *unselected_nodes) const; + Inkscape::SnappedPoint freeSnap( Inkscape::Snapper::PointType t, NR::Point const &p, bool const &first_point, std::vector &points_to_snap, - std::list const &it) const; + std::list const &it, + std::vector *unselected_nodes) const; Inkscape::SnappedPoint constrainedSnap(Inkscape::Snapper::PointType t, NR::Point const &p, diff --git a/src/snapper.cpp b/src/snapper.cpp index 5f5261885..f8f7705f2 100644 --- a/src/snapper.cpp +++ b/src/snapper.cpp @@ -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 &points_to_snap, + std::vector &points_to_snap, SPItem const *it) const { std::list 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 &points_to_snap, - std::list const &it) const + std::vector &points_to_snap, + std::list const &it, + std::vector *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); } diff --git a/src/snapper.h b/src/snapper.h index 8aeea0a26..63f68173a 100644 --- a/src/snapper.h +++ b/src/snapper.h @@ -68,13 +68,14 @@ public: bool const &first_point, std::vector &points_to_snap, SPItem const *it) const; - + void freeSnap(SnappedConstraints &sc, PointType const &t, NR::Point const &p, bool const &first_point, std::vector &points_to_snap, - std::list const &it) const; + std::list const &it, + std::vector *unselected_nodes) const; class ConstraintLine { @@ -142,7 +143,8 @@ private: NR::Point const &p, bool const &first_point, std::vector &points_to_snap, - std::list const &it) const = 0; + std::list const &it, + std::vector *unselected_nodes) const = 0; /** * Try to snap a point to whatever this snapper is interested in, where diff --git a/src/sp-item-notify-moveto.cpp b/src/sp-item-notify-moveto.cpp index c7b852af5..391766fb6 100644 --- a/src/sp-item-notify-moveto.cpp +++ b/src/sp-item-notify-moveto.cpp @@ -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 snappoints; + std::vector snappoints; sp_item_snappoints(&item, true, SnapPointsIter(snappoints)); g_return_if_fail( snappoint_ix < int(snappoints.size()) ); diff --git a/src/sp-item-rm-unsatisfied-cns.cpp b/src/sp-item-rm-unsatisfied-cns.cpp index fe6d73a3a..bcd16e3aa 100644 --- a/src/sp-item-rm-unsatisfied-cns.cpp +++ b/src/sp-item-rm-unsatisfied-cns.cpp @@ -14,7 +14,7 @@ void sp_item_rm_unsatisfied_cns(SPItem &item) if (item.constraints.empty()) { return; } - vector snappoints; + std::vector snappoints; sp_item_snappoints(&item, true, SnapPointsIter(snappoints)); for (unsigned i = item.constraints.size(); i--;) { g_assert( i < item.constraints.size() ); diff --git a/src/sp-item-update-cns.cpp b/src/sp-item-update-cns.cpp index 44b26d45f..82ff0c458 100644 --- a/src/sp-item-update-cns.cpp +++ b/src/sp-item-update-cns.cpp @@ -9,7 +9,7 @@ using std::vector; void sp_item_update_cns(SPItem &item, SPDesktop const &desktop) { - vector snappoints; + std::vector snappoints; sp_item_snappoints(&item, true, SnapPointsIter(snappoints)); /* TODO: Implement the ordering. */ vector found_cns; diff --git a/src/splivarot.cpp b/src/splivarot.cpp index f176776a6..72f059bdc 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1839,10 +1839,10 @@ Path *bpath_to_Path(NArtBpath const *bpath) { return dest; } -NR::Maybe get_nearest_position_on_Path(Path *path, NR::Point p) +NR::Maybe 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; } diff --git a/src/splivarot.h b/src/splivarot.h index c0a7fb38b..61b5ee143 100644 --- a/src/splivarot.h +++ b/src/splivarot.h @@ -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 get_nearest_position_on_Path(Path *path, NR::Point p); +NR::Maybe 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);