summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bbb1b1e)
raw | patch | inline | side by side (parent: bbb1b1e)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Fri, 25 Jul 2008 22:06:29 +0000 (22:06 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Fri, 25 Jul 2008 22:06:29 +0000 (22:06 +0000) |
src/shape-editor.cpp | patch | blob | history |
diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp
index 5bda2d2989a9b030065cc330afdf711094bd8b59..4c182788f3cb78c727e7ae9cfb1ec6e65da50cfd 100644 (file)
--- a/src/shape-editor.cpp
+++ b/src/shape-editor.cpp
#include "xml/node-event-vector.h"
#include "prefs-utils.h"
#include "object-edit.h"
-#include "splivarot.h"
#include "style.h"
+#include "display/curve.h"
+#include <2geom/pathvector.h>
#include "shape-editor.h"
this->curvepoint_doc = desktop->w2d(event_p);
this->curvepoint_doc *= from_2geom(sp_item_dt2i_affine(item));
- sp_nodepath_ensure_livarot_path(this->nodepath);
+ SPCurve *curve = this->nodepath->curve; // not sure if np->curve is always up to date...
+ Geom::PathVector const &pathv = curve->get_pathvector();
+ Geom::PathVectorPosition pvpos = Geom::nearestPoint(pathv, this->curvepoint_doc);
- NR::Maybe<Path::cut_position> position = get_nearest_position_on_Path(this->nodepath->livarot_path, this->curvepoint_doc);
- if (!position) {
- return false;
- }
-
- NR::Point nearest = get_point_on_Path(this->nodepath->livarot_path, position->piece, position->t);
+ NR::Point nearest = pathv[pvpos.path_nr].pointAt(pvpos.t);
NR::Point delta = nearest - this->curvepoint_doc;
delta = desktop->d2w(delta);
bool close = (NR::L2 (delta) < stroke_tolerance);
if (remember && close) {
+ // calculate index for nodepath's representation.
+ double int_part;
+ double t = std::modf(pvpos.t, &int_part);
+ unsigned int segment_index = (unsigned int)int_part + 1;
+ for (unsigned int i = 0; i < pvpos.path_nr; ++i) {
+ segment_index += pathv[i].size() + 1;
+ if (pathv[i].closed())
+ segment_index += 1;
+ }
+
this->curvepoint_event[NR::X] = (gint) event_p [NR::X];
this->curvepoint_event[NR::Y] = (gint) event_p [NR::Y];
this->hit = true;
- this->grab_t = position->t;
- this->grab_node = position->piece;
+ this->grab_t = t;
+ this->grab_node = segment_index;
}
return close;