summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/live_effects/effect.cpp60
-rw-r--r--src/live_effects/effect.h7
-rw-r--r--src/live_effects/lpe-lattice.cpp2
-rw-r--r--src/live_effects/lpe-lattice.h2
-rw-r--r--src/live_effects/parameter/parameter.h4
5 files changed, 46 insertions, 29 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;
}
}
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index 2798f88ce..37170eae0 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -129,8 +129,8 @@ public:
// (but spiro lpe still needs it!)
virtual LPEPathFlashType pathFlashType() { return DEFAULT; }
void addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
+ std::vector<Geom::PathVector> getHelperPaths(SPLPEItem *lpeitem);
- void addHelperPaths(SPLPEItem *lpeitem, SPDesktop *desktop);
inline bool providesOwnFlashPaths() {
return provides_own_flash_paths || show_orig_path;
}
@@ -167,7 +167,10 @@ protected:
Parameter * getNextOncanvasEditableParam();
void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
- virtual void addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop);
+
+ //virtual std::vector<Geom::PathVector> getCanvasIndicators(SPLPEItem *lpeitem);
+ virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec);
+
std::vector<Parameter *> param_vector;
std::vector<std::pair<KnotHolderEntity*, const char*> > kh_entity_vector;
diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp
index 8630c9cfa..74f032fd4 100644
--- a/src/live_effects/lpe-lattice.cpp
+++ b/src/live_effects/lpe-lattice.cpp
@@ -236,6 +236,7 @@ LPELattice::resetDefaults(SPItem * item)
grid_point15[Geom::Y] = 2.0/3*boundingbox_Y.max()+1.0/3*boundingbox_Y.min();
}
+/**
void
LPELattice::addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop)
{
@@ -288,6 +289,7 @@ LPELattice::addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop)
c->unref();
}
+**/
/* ######################## */
diff --git a/src/live_effects/lpe-lattice.h b/src/live_effects/lpe-lattice.h
index f22525b82..636b5e20b 100644
--- a/src/live_effects/lpe-lattice.h
+++ b/src/live_effects/lpe-lattice.h
@@ -40,7 +40,7 @@ public:
virtual void resetDefaults(SPItem * item);
protected:
- virtual void addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop);
+ //virtual void addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop);
private:
diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h
index 02d520fe4..8c24c50de 100644
--- a/src/live_effects/parameter/parameter.h
+++ b/src/live_effects/parameter/parameter.h
@@ -11,8 +11,10 @@
#include <glibmm/ustring.h>
#include <2geom/forward.h>
+#include <2geom/pathvector.h>
class KnotHolder;
+class SPLPEItem;
struct SPDesktop;
struct SPItem;
@@ -57,7 +59,9 @@ public:
virtual Glib::ustring * param_getTooltip() { return &param_tooltip; };
+ // overload these for your particular parameter to make it provide knotholder handles or canvas helperpaths
virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) {}
+ virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec) {};
virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
virtual void param_setup_nodepath(Inkscape::NodePath::Path */*np*/) {};