summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2008-06-18 22:30:36 +0000
committercilix42 <cilix42@users.sourceforge.net>2008-06-18 22:30:36 +0000
commit4e8bfe1693fe11e16c7f6aa94348895d94eff3c1 (patch)
treee7c3c0b5ce4368cf02ad8ecf825bdb6a60194837 /src
parentUpdate LPE helper paths "live" on changes (diff)
downloadinkscape-4e8bfe1693fe11e16c7f6aa94348895d94eff3c1.tar.gz
inkscape-4e8bfe1693fe11e16c7f6aa94348895d94eff3c1.zip
Display helper grid for LPELattice; automatically add helper paths for LPE PathParams
(bzr r5996)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/effect.cpp12
-rw-r--r--src/live_effects/lpe-lattice.cpp55
-rw-r--r--src/live_effects/lpe-lattice.h2
-rw-r--r--src/nodepath.cpp6
-rw-r--r--src/nodepath.h2
5 files changed, 71 insertions, 6 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:
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index 0a5993823..efa356fab 100644
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
@@ -4741,14 +4741,13 @@ void sp_nodepath_set_curve (Inkscape::NodePath::Path *np, SPCurve *curve) {
}
SPCanvasItem *
-sp_nodepath_generate_helperpath(SPDesktop *desktop, SPCurve *curve, const SPItem *item) {
+sp_nodepath_generate_helperpath(SPDesktop *desktop, SPCurve *curve, const SPItem *item, guint32 color = 0xff0000ff) {
SPCurve *flash_curve = curve->copy();
Geom::Matrix i2d = item ? sp_item_i2d_affine(item) : Geom::identity();
flash_curve->transform(i2d);
SPCanvasItem * canvasitem = sp_canvas_bpath_new(sp_desktop_tempgroup(desktop), flash_curve);
// would be nice if its color could be XORed or something, now it is invisible for red stroked objects...
// unless we also flash the nodes...
- guint32 color = prefs_get_int_attribute("tools.nodes", "highlight_color", 0xff0000ff);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvasitem), color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvasitem), 0, SP_WIND_RULE_NONZERO);
sp_canvas_item_show(canvasitem);
@@ -4758,7 +4757,8 @@ sp_nodepath_generate_helperpath(SPDesktop *desktop, SPCurve *curve, const SPItem
SPCanvasItem *
sp_nodepath_generate_helperpath(SPDesktop *desktop, SPPath *path) {
- return sp_nodepath_generate_helperpath(desktop, sp_path_get_curve_for_edit(path), SP_ITEM(path));
+ return sp_nodepath_generate_helperpath(desktop, sp_path_get_curve_for_edit(path), SP_ITEM(path),
+ prefs_get_int_attribute("tools.nodes", "highlight_color", 0xff0000ff));
}
void sp_nodepath_show_helperpath(Inkscape::NodePath::Path *np, bool show) {
diff --git a/src/nodepath.h b/src/nodepath.h
index 77cf5a518..fbcfe69da 100644
--- a/src/nodepath.h
+++ b/src/nodepath.h
@@ -307,7 +307,7 @@ NR::Rect sp_node_selected_bbox (Inkscape::NodePath::Path *nodepath);
NR::Maybe<NR::Coord> sp_node_selected_common_coord (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis);
void sp_nodepath_show_handles(Inkscape::NodePath::Path *nodepath, bool show);
-SPCanvasItem *sp_nodepath_generate_helperpath(SPDesktop *desktop, SPCurve *curve, const SPItem *item);
+SPCanvasItem *sp_nodepath_generate_helperpath(SPDesktop *desktop, SPCurve *curve, const SPItem *item, guint32 color);
SPCanvasItem *sp_nodepath_generate_helperpath(SPDesktop *desktop, SPPath *path);
void sp_nodepath_show_helperpath(Inkscape::NodePath::Path *nodepath, bool show);
void sp_nodepath_make_straight_path(Inkscape::NodePath::Path *np);