summaryrefslogtreecommitdiffstats
path: root/src/live_effects/effect.cpp
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2008-07-29 14:53:07 +0000
committercilix42 <cilix42@users.sourceforge.net>2008-07-29 14:53:07 +0000
commit342dd01630733af71538f8c8040937d732675fc1 (patch)
tree15997706096950624127f5b213e24cf9fca3ee16 /src/live_effects/effect.cpp
parentRemove obsolete function param_editOncanvas for PointParams (diff)
downloadinkscape-342dd01630733af71538f8c8040937d732675fc1.tar.gz
inkscape-342dd01630733af71538f8c8040937d732675fc1.zip
Remove addHelperPaths() from Effect; now getHelperPaths() returns a list of canvas indicators provided by the effect itself or its parameters (overload addCanvasIndicators to provide them in derived effects)
(bzr r6450)
Diffstat (limited to 'src/live_effects/effect.cpp')
-rw-r--r--src/live_effects/effect.cpp60
1 files changed, 34 insertions, 26 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 467b1417d..0254c547c 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -36,7 +36,7 @@
#include <2geom/sbasis-to-bezier.h>
#include <2geom/matrix.h>
-
+#include <2geom/pathvector.h>
// include effects:
#include "live_effects/lpe-patternalongpath.h"
@@ -450,42 +450,49 @@ Effect::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem
}
}
-void
-Effect::addHelperPaths(SPLPEItem *lpeitem, SPDesktop *desktop)
+/**
+ * Return a vector of PathVectors which contain all helperpaths that should be drawn by the effect.
+ * This is the function called by external code like SPLPEItem.
+ */
+std::vector<Geom::PathVector>
+Effect::getHelperPaths(SPLPEItem *lpeitem)
{
- g_return_if_fail(desktop);
- g_return_if_fail(SP_IS_PATH(lpeitem));
-
- if (providesKnotholder() && showOrigPath()) {
- // TODO: we assume that if the LPE provides its own knotholder, there is no nodepath so we
- // must create the helper curve for the original path manually; once we allow nodepaths and
- // knotholders alongside each other, this needs to be rethought!
- SPCanvasItem *canvasitem = sp_nodepath_generate_helperpath(desktop, SP_PATH(lpeitem));
- Inkscape::Display::TemporaryItem* tmpitem = desktop->add_temporary_canvasitem (canvasitem, 0);
- lpeitem->lpe_helperpaths.push_back(tmpitem);
+ std::vector<Geom::PathVector> hp_vec;
+
+ if (!SP_IS_SHAPE(lpeitem)) {
+ g_print ("How to handle helperpaths for non-shapes?\n");
+ return hp_vec;
}
- for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) {
- if ( Inkscape::LivePathEffect::PathParam *pathparam = dynamic_cast<Inkscape::LivePathEffect::PathParam*>(*p) ) {
- SPCurve *c = new SPCurve(pathparam->get_pathvector());
+ // TODO: we can probably optimize this by using a lot more references
+ // rather than copying PathVectors all over the place
+ if (show_orig_path) {
+ // add original path to helperpaths
+ SPCurve* curve = sp_shape_get_curve (SP_SHAPE(lpeitem));
+ hp_vec.push_back(curve->get_pathvector());
+ }
- // TODO: factor this out (also the copied code above); see also lpe-lattice.cpp
- SPCanvasItem *canvasitem = sp_nodepath_generate_helperpath(desktop, c, SP_ITEM(lpeitem), 0x009000ff);
- Inkscape::Display::TemporaryItem* tmpitem = desktop->add_temporary_canvasitem (canvasitem, 0);
- lpeitem->lpe_helperpaths.push_back(tmpitem);
- }
+ // add other helperpaths provided by the effect itself
+ addCanvasIndicators(lpeitem, hp_vec);
+
+ // add helperpaths provided by the effect's parameters
+ for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) {
+ (*p)->addCanvasIndicators(lpeitem, hp_vec);
}
- addHelperPathsImpl(lpeitem, desktop);
+ return hp_vec;
}
+/**
+ * Add possible canvas indicators (i.e., helperpaths other than the original path) to \a hp_vec
+ * This function should be overwritten by derived effects if they want to provide their own helperpaths.
+ */
void
-Effect::addHelperPathsImpl(SPLPEItem */*lpeitem*/, SPDesktop */*desktop*/)
+Effect::addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec)
{
- // if this method is overloaded in derived classes, provides_own_flash_paths will be true
- provides_own_flash_paths = false;
}
+
/**
* This *creates* a new widget, management of deletion should be done by the caller
*/
@@ -627,7 +634,8 @@ Effect::providesKnotholder()
// otherwise: are there any PointParams?
for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) {
- if ( Inkscape::LivePathEffect::PointParam *pointparam = dynamic_cast<Inkscape::LivePathEffect::PointParam*>(*p) ) {
+// if ( Inkscape::LivePathEffect::PointParam *pointparam = dynamic_cast<Inkscape::LivePathEffect::PointParam*>(*p) ) {
+ if (dynamic_cast<Inkscape::LivePathEffect::PointParam*>(*p)) {
return true;
}
}