diff options
| author | Maximilian Albert <maximilian.albert@gmail.com> | 2008-06-18 22:30:36 +0000 |
|---|---|---|
| committer | cilix42 <cilix42@users.sourceforge.net> | 2008-06-18 22:30:36 +0000 |
| commit | 4e8bfe1693fe11e16c7f6aa94348895d94eff3c1 (patch) | |
| tree | e7c3c0b5ce4368cf02ad8ecf825bdb6a60194837 /src/live_effects | |
| parent | Update LPE helper paths "live" on changes (diff) | |
| download | inkscape-4e8bfe1693fe11e16c7f6aa94348895d94eff3c1.tar.gz inkscape-4e8bfe1693fe11e16c7f6aa94348895d94eff3c1.zip | |
Display helper grid for LPELattice; automatically add helper paths for LPE PathParams
(bzr r5996)
Diffstat (limited to 'src/live_effects')
| -rw-r--r-- | src/live_effects/effect.cpp | 12 | ||||
| -rw-r--r-- | src/live_effects/lpe-lattice.cpp | 55 | ||||
| -rw-r--r-- | src/live_effects/lpe-lattice.h | 2 |
3 files changed, 67 insertions, 2 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 4e500a498..9326f54b9 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -434,11 +434,21 @@ Effect::addHelperPaths(SPLPEItem *lpeitem, SPDesktop *desktop) // 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)); - // TODO: Make sure the tempitem doesn't get destroyed when the mouse leaves the item Inkscape::Display::TemporaryItem* tmpitem = desktop->add_temporary_canvasitem (canvasitem, 0); lpeitem->lpe_helperpaths.push_back(tmpitem); } + for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) { + if ((*p)->paramType() == Inkscape::LivePathEffect::PATH_PARAM) { + SPCurve *c = new SPCurve(static_cast<Inkscape::LivePathEffect::PathParam*>(*p)->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); + } + } + addHelperPathsImpl(lpeitem, desktop); } diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp index d70920279..6f929a9e5 100644 --- a/src/live_effects/lpe-lattice.cpp +++ b/src/live_effects/lpe-lattice.cpp @@ -23,6 +23,7 @@ #include "display/curve.h" #include "libnr/n-art-bpath-2geom.h" #include "svg/svg.h" +#include "nodepath.h" #include <2geom/sbasis.h> #include <2geom/sbasis-2d.h> @@ -33,6 +34,8 @@ #include <2geom/piecewise.h> #include <2geom/transforms.h> +#include "desktop.h" // TODO: should be factored out (see below) + using namespace Geom; namespace Inkscape { @@ -231,9 +234,59 @@ LPELattice::resetDefaults(SPItem * item) grid_point15[Geom::X] = 2.0/3*boundingbox_X.max()+1.0/3*boundingbox_X.min(); grid_point15[Geom::Y] = 2.0/3*boundingbox_Y.max()+1.0/3*boundingbox_Y.min(); +} +void +LPELattice::addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop) +{ + SPCurve *c = new SPCurve (); + c->moveto(grid_point0); + c->lineto(grid_point4); + c->lineto(grid_point5); + c->lineto(grid_point1); - + c->moveto(grid_point8); + c->lineto(grid_point12); + c->lineto(grid_point13); + c->lineto(grid_point9); + + c->moveto(grid_point10); + c->lineto(grid_point14); + c->lineto(grid_point15); + c->lineto(grid_point11); + + c->moveto(grid_point2); + c->lineto(grid_point6); + c->lineto(grid_point7); + c->lineto(grid_point3); + + + c->moveto(grid_point0); + c->lineto(grid_point8); + c->lineto(grid_point10); + c->lineto(grid_point2); + + c->moveto(grid_point4); + c->lineto(grid_point12); + c->lineto(grid_point14); + c->lineto(grid_point6); + + c->moveto(grid_point5); + c->lineto(grid_point13); + c->lineto(grid_point15); + c->lineto(grid_point7); + + c->moveto(grid_point1); + c->lineto(grid_point9); + c->lineto(grid_point11); + c->lineto(grid_point3); + + // TODO: factor this out (and remove the #include of desktop.h above) + 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); + + c->unref(); } /* ######################## */ diff --git a/src/live_effects/lpe-lattice.h b/src/live_effects/lpe-lattice.h index 16c15083a..f22525b82 100644 --- a/src/live_effects/lpe-lattice.h +++ b/src/live_effects/lpe-lattice.h @@ -39,6 +39,8 @@ public: virtual void resetDefaults(SPItem * item); +protected: + virtual void addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop); private: |
