summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 33c3b68)
raw | patch | inline | side by side (parent: 33c3b68)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Fri, 25 Jul 2008 21:53:35 +0000 (21:53 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Fri, 25 Jul 2008 21:53:35 +0000 (21:53 +0000) |
src/nodepath.cpp | patch | blob | history |
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index f6b151837a65b7c92f8c39180673312b7fc9f9f3..f3d07a313b0ef918af69c844c70157fb2f887ef2 100644 (file)
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
@@ -1901,15 +1901,23 @@ sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, NR::Po
return;
}
- sp_nodepath_ensure_livarot_path(nodepath);
- NR::Maybe<Path::cut_position> maybe_position = get_nearest_position_on_Path(nodepath->livarot_path, p);
- if (!maybe_position) {
- return;
+ SPCurve *curve = create_curve(nodepath); // perhaps we can use nodepath->curve here instead?
+ Geom::PathVector const &pathv = curve->get_pathvector();
+ Geom::PathVectorPosition pvpos = Geom::nearestPoint(pathv, p);
+
+ // calculate index for nodepath's representation.
+ unsigned int segment_index = floor(pvpos.t) + 1;
+ for (unsigned int i = 0; i < pvpos.path_nr; ++i) {
+ segment_index += pathv[i].size() + 1;
+ if (pathv[i].closed()) {
+ segment_index += 1;
+ }
}
- Path::cut_position position = *maybe_position;
+
+ curve->unref();
//find segment to segment
- Inkscape::NodePath::Node *e = sp_nodepath_get_node_by_index(position.piece);
+ Inkscape::NodePath::Node *e = sp_nodepath_get_node_by_index(segment_index);
//fixme: this can return NULL, so check before proceeding.
g_return_if_fail(e != NULL);
@@ -1939,7 +1947,7 @@ sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p)
SPCurve *curve = create_curve(nodepath); // perhaps we can use nodepath->curve here instead?
Geom::PathVector const &pathv = curve->get_pathvector();
- Geom::PathVectorPosition pvpos = nearestPoint(pathv, p);
+ Geom::PathVectorPosition pvpos = Geom::nearestPoint(pathv, p);
// calculate index for nodepath's representation.
double int_part;