summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4110fdb)
raw | patch | inline | side by side (parent: 4110fdb)
author | cilix42 <cilix42@users.sourceforge.net> | |
Tue, 29 Jul 2008 14:53:07 +0000 (14:53 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Tue, 29 Jul 2008 14:53:07 +0000 (14:53 +0000) |
index 467b1417d79fc4315503339dfc3dde4a5bc43b8a..0254c547c76cf884cf968a2d824cc53f011419dd 100644 (file)
#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
*/
// 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;
}
}
index 2798f88ce8cc4817995da27e21a3aa81ed750e54..37170eae0897d6b2a274f4b749ab5b3131f943c2 100644 (file)
// (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;
}
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;
index 8630c9cfa4898bac43994fde6fce481bf1cd5abf..74f032fd4e4c2e1e23e869351924a769592c5e4a 100644 (file)
grid_point15[Geom::Y] = 2.0/3*boundingbox_Y.max()+1.0/3*boundingbox_Y.min();
}
+/**
void
LPELattice::addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop)
{
c->unref();
}
+**/
/* ######################## */
index f22525b82bbd57514c50665fc111d0ac40533aa0..636b5e20b473b61dba4f936d61ec017c0ff03a9b 100644 (file)
virtual void resetDefaults(SPItem * item);
protected:
- virtual void addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop);
+ //virtual void addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop);
private:
index 02d520fe4c9d0c968ee1fc40b720cc1500986145..8c24c50de204de20a2c8bf13708cde93a170233e 100644 (file)
#include <glibmm/ustring.h>
#include <2geom/forward.h>
+#include <2geom/pathvector.h>
class KnotHolder;
+class SPLPEItem;
struct SPDesktop;
struct SPItem;
virtual Glib::ustring * param_getTooltip() { return ¶m_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*/) {};