summaryrefslogtreecommitdiffstats
path: root/src/nodepath.cpp
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2008-07-29 14:54:06 +0000
committercilix42 <cilix42@users.sourceforge.net>2008-07-29 14:54:06 +0000
commited7808ecd3d67f4cabaa4547096e31e3a1018087 (patch)
tree1b4b4d95a2f374b7396dd99666f09689a611fe72 /src/nodepath.cpp
parentAlong with nodepath also create/destroy the helperpaths of any LPEs associate... (diff)
downloadinkscape-ed7808ecd3d67f4cabaa4547096e31e3a1018087.tar.gz
inkscape-ed7808ecd3d67f4cabaa4547096e31e3a1018087.zip
Update helperpaths when a nodepath's item is updated. TODO: They also need to be updated when the associated LPEs change.
(bzr r6453)
Diffstat (limited to 'src/nodepath.cpp')
-rw-r--r--src/nodepath.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index 7a6674d2f..598cc4116 100644
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
@@ -211,6 +211,36 @@ sp_nodepath_create_helperpaths(Inkscape::NodePath::Path *np) {
g_print ("\n");
}
+static void
+sp_nodepath_update_helperpaths(Inkscape::NodePath::Path *np) {
+ g_print ("sp_nodepath_update_helperpaths()\n");
+ //std::map<Inkscape::LivePathEffect::Effect *, std::vector<SPCanvasItem *> >* helper_path_vec;
+ if (!SP_IS_LPE_ITEM(np->item)) {
+ g_print ("Only LPEItems can have helperpaths!\n");
+ return;
+ }
+
+ SPLPEItem *lpeitem = SP_LPE_ITEM(np->item);
+ PathEffectList lpelist = sp_lpe_item_get_effect_list(lpeitem);
+ for (PathEffectList::iterator i = lpelist.begin(); i != lpelist.end(); ++i) {
+ Inkscape::LivePathEffect::Effect *lpe = (*i)->lpeobject->lpe;
+ g_print ("Processing LPE %s\n", SP_OBJECT_REPR((*i)->lpeobject)->attribute("id"));
+ /* update canvas items from the effect's helper paths; note that this code relies on the
+ * fact that getHelperPaths() will always return the same number of helperpaths in the same
+ * order as during their creation in sp_nodepath_create_helperpaths
+ */
+ std::vector<Geom::PathVector> hpaths = lpe->getHelperPaths(lpeitem);
+ for (unsigned int j = 0; j < hpaths.size(); ++j) {
+ g_print (" ... updating helper path\n");
+ SPCurve *curve = new SPCurve(hpaths[j]);
+ curve->transform(to_2geom(np->i2d));
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(((*np->helper_path_vec)[lpe])[j]), curve);
+ curve = curve->unref();
+ }
+ }
+ g_print ("\n");
+}
+
//typedef std::map<Inkscape::LivePathEffect::Effect *, std::vector<SPCanvasItem *> > HelperPathList;
static void
@@ -624,6 +654,8 @@ static void update_object(Inkscape::NodePath::Path *np)
helper_curve->unref();
}
+ sp_nodepath_update_helperpaths(np);
+
// now that nodepath and knotholder can be enabled simultaneously, we must update the knotholder, too
// TODO: this should be done from ShapeEditor!! nodepath should be oblivious of knotholder!
np->shape_editor->update_knotholder();
@@ -664,7 +696,10 @@ static void update_repr_internal(Inkscape::NodePath::Path *np)
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(np->helper_path), helper_curve);
helper_curve->unref();
}
- }
+
+ // TODO: do we need this call here? after all, update_object() should have been called just before
+ //sp_nodepath_update_helperpaths(np);
+}
/**
* Update XML path node with data from path object, commit changes forever.