summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4c83e07)
raw | patch | inline | side by side (parent: 4c83e07)
author | cilix42 <cilix42@users.sourceforge.net> | |
Tue, 29 Jul 2008 14:53:51 +0000 (14:53 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Tue, 29 Jul 2008 14:53:51 +0000 (14:53 +0000) |
src/node-context.cpp | patch | blob | history | |
src/nodepath.cpp | patch | blob | history | |
src/nodepath.h | patch | blob | history |
diff --git a/src/node-context.cpp b/src/node-context.cpp
index a72501af71e92115592fc5cee1674f985a6530a0..66e535ac3100c795144d8b8e2e192f5d179a3d3a 100644 (file)
--- a/src/node-context.cpp
+++ b/src/node-context.cpp
static void
sp_node_context_flash_path(SPEventContext *event_context, SPItem *item, guint timeout) {
+ g_print ("-----> sp_node_context_flash_path(): TODO: generate the helper path!!\n");
SPNodeContext *nc = SP_NODE_CONTEXT(event_context);
nc->remove_flash_counter = 3; // for some reason root_handler is called twice after each item_handler...
@@ -196,7 +197,7 @@ sp_node_context_flash_path(SPEventContext *event_context, SPItem *item, guint ti
}
if (SP_IS_PATH(item)) {
- SPCanvasItem *canvasitem = sp_nodepath_generate_helperpath(desktop, SP_PATH(item));
+ SPCanvasItem *canvasitem = sp_nodepath_helperpath_from_path(desktop, SP_PATH(item));
nc->flash_tempitem = desktop->add_temporary_canvasitem (canvasitem, timeout);
}
}
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index 3f3443550c56ca7f52a4f2673ae2d838eaf170a2..7a6674d2f4c28349addf6794e34ddf38209843fa 100644 (file)
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
#include <cmath>
#include <string>
#include "live_effects/lpeobject.h"
+#include "live_effects/lpeobject-reference.h"
#include "live_effects/effect.h"
#include "live_effects/parameter/parameter.h"
#include "live_effects/parameter/path.h"
@@ -158,20 +159,76 @@ static void sp_nodepath_set_curve (Inkscape::NodePath::Path *np, SPCurve *curve)
Inkscape::NodePath::Node * Inkscape::NodePath::Path::active_node = NULL;
static SPCanvasItem *
-sp_nodepath_make_helper_curve(Inkscape::NodePath::Path *np, SPDesktop *desktop, const SPCurve *curve, bool show = false) {
- SPCurve *canvasitem = curve->copy();
- canvasitem->transform(to_2geom(np->i2d));
- SPCanvasItem *helper_path = sp_canvas_bpath_new(sp_desktop_controls(desktop), canvasitem);
+sp_nodepath_make_helper_item(Inkscape::NodePath::Path *np, /*SPDesktop *desktop, */const SPCurve *curve, bool show = false) {
+ g_print ("sp_nodepath_make_helper_item()\n");
+ SPCurve *helper_curve = curve->copy();
+ helper_curve->transform(to_2geom(np->i2d));
+ SPCanvasItem *helper_path = sp_canvas_bpath_new(sp_desktop_controls(np->desktop), helper_curve);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(helper_path), np->helperpath_rgba, np->helperpath_width, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(helper_path), 0, SP_WIND_RULE_NONZERO);
sp_canvas_item_move_to_z(helper_path, 0);
if (show) {
sp_canvas_item_show(helper_path);
}
- canvasitem->unref();
- return canvasitem;
+ helper_curve->unref();
+ return helper_path;
+}
+
+static SPCanvasItem *
+canvasitem_from_pathvec(Inkscape::NodePath::Path *np, Geom::PathVector const &pathv, bool show) {
+ g_print ("canvasitem_from_pathvec()\n");
+ SPCurve *helper_curve = new SPCurve(pathv);
+ return sp_nodepath_make_helper_item(np, helper_curve, show);
+}
+
+static void
+sp_nodepath_create_helperpaths(Inkscape::NodePath::Path *np) {
+ g_print ("sp_nodepath_create_helperpaths()\n");
+ //std::map<Inkscape::LivePathEffect::Effect *, std::vector<SPCanvasItem *> >* helper_path_vec;
+ if (np->item) {
+ g_print ("np->item: %s\n", SP_OBJECT_REPR(np->item)->attribute("id"));
+ } else {
+ g_print ("np->item == NULL!\n");
+ }
+
+ if (!SP_IS_LPE_ITEM(np->item)) {
+ g_print ("Only LPEItems can have helperpaths!\n");
+ return;
+ }
+
+ SPLPEItem *lpeitem = SP_LPE_ITEM(np->item);
+ PathEffectList lpelist = sp_lpe_item_get_effect_list(lpeitem);
+ for (PathEffectList::iterator i = lpelist.begin(); i != lpelist.end(); ++i) {
+ Inkscape::LivePathEffect::Effect *lpe = (*i)->lpeobject->lpe;
+ g_print ("Processing LPE %s\n", SP_OBJECT_REPR((*i)->lpeobject)->attribute("id"));
+ // create new canvas items from the effect's helper paths
+ std::vector<Geom::PathVector> hpaths = lpe->getHelperPaths(lpeitem);
+ for (std::vector<Geom::PathVector>::iterator j = hpaths.begin(); j != hpaths.end(); ++j) {
+ g_print (" ... creating helper path\n");
+ (*np->helper_path_vec)[lpe].push_back(canvasitem_from_pathvec(np, *j, true));
+ }
+ }
+ g_print ("\n");
}
+//typedef std::map<Inkscape::LivePathEffect::Effect *, std::vector<SPCanvasItem *> > HelperPathList;
+
+static void
+sp_nodepath_destroy_helperpaths(Inkscape::NodePath::Path *np) {
+ g_print ("sp_nodepath_destroy_helperpaths()\n");
+ for (HelperPathList::iterator i = np->helper_path_vec->begin(); i != np->helper_path_vec->end(); ++i) {
+ g_print ("processing helper paths for LPE %s\n", SP_OBJECT_REPR((*i).first->getLPEObj())->attribute("id"));
+ for (std::vector<SPCanvasItem *>::iterator j = (*i).second.begin(); j != (*i).second.end(); ++j) {
+ g_print (" ... destroying helper path\n");
+ GtkObject *temp = *j;
+ *j = NULL;
+ gtk_object_destroy(temp);
+ }
+ }
+ g_print ("\n");
+}
+
+
/**
* \brief Creates new nodepath from item
*/
np->local_change = 0;
np->show_handles = show_handles;
np->helper_path = NULL;
+ np->helper_path_vec = new HelperPathList;
np->helperpath_rgba = prefs_get_int_attribute("tools.nodes", "highlight_color", 0xff0000ff);
np->helperpath_width = 1.0;
np->curve = curve->copy();
@@ -292,9 +350,11 @@ Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPObject *object,
// Draw helper curve
if (np->show_helperpath) {
- np->helper_path = sp_nodepath_make_helper_curve(np, desktop, np->curve, true);
+ np->helper_path = sp_nodepath_make_helper_item(np, /*desktop, */np->curve, true);
}
+ sp_nodepath_create_helperpaths(np);
+
return np;
}
np->repr_nodetypes_key = NULL;
}
+ sp_nodepath_destroy_helperpaths(np);
+ delete np->helper_path_vec;
+ np->helper_path_vec = NULL;
+
np->desktop = NULL;
g_free(np);
}
}
+/**
SPCanvasItem *
-sp_nodepath_to_canvasitem(Inkscape::NodePath::Path *np, SPDesktop *desktop, SPPath *path) {
- return sp_nodepath_make_helper_curve(np, desktop, sp_path_get_curve_for_edit(path));
+sp_nodepath_path_to_canvasitem(Inkscape::NodePath::Path *np, SPPath *path) {
+ return sp_nodepath_make_helper_item(np, sp_path_get_curve_for_edit(path));
}
+**/
/**
SPCanvasItem *
}
**/
-// TODO: Merge this with sp_nodepath_make_helper_curve()!
+SPCanvasItem *
+sp_nodepath_helperpath_from_path(SPDesktop *desktop, SPPath *path) {
+ SPCurve *flash_curve = sp_path_get_curve_for_edit(path)->copy();
+ Geom::Matrix i2d = sp_item_i2d_affine(SP_ITEM(path));
+ 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);
+ flash_curve->unref();
+ return canvasitem;
+}
+
+// TODO: Merge this with sp_nodepath_make_helper_item()!
void sp_nodepath_show_helperpath(Inkscape::NodePath::Path *np, bool show) {
np->show_helperpath = show;
SPCurve *helper_curve = np->curve->copy();
helper_curve->transform(to_2geom(np->i2d));
if (!np->helper_path) {
- //np->helper_path = sp_nodepath_make_helper_curve(np, desktop, helper_curve, true); // Caution: this applies the transform np->i2d twice!!
+ //np->helper_path = sp_nodepath_make_helper_item(np, desktop, helper_curve, true); // Caution: this applies the transform np->i2d twice!!
np->helper_path = sp_canvas_bpath_new(sp_desktop_controls(np->desktop), helper_curve);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(np->helper_path), np->helperpath_rgba, np->helperpath_width, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
diff --git a/src/nodepath.h b/src/nodepath.h
index 22cf316a4dc735e760eeaa87589d084cdc91046d..f11d309cc03122b84e1cd532d29c1f1d5728daf3 100644 (file)
--- a/src/nodepath.h
+++ b/src/nodepath.h
class LivePathEffectObject;
namespace Inkscape {
-namespace XML {
-class Node;
-}
+ namespace XML {
+ class Node;
+ }
+
+ namespace LivePathEffect {
+ class Effect;
+ }
}
+typedef std::map<Inkscape::LivePathEffect::Effect *, std::vector<SPCanvasItem *> > HelperPathList;
/**
* Radial objects are represented by an angle and a distance from
guint32 helperpath_rgba;
gdouble helperpath_width;
+ // the helperpaths provided by all LPEs (and their paramaters) of the current item
+ HelperPathList* helper_path_vec;
+
/// true if we changed repr, to tell this change from an external one such as from undo, simplify, or another desktop
unsigned int local_change;
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, guint32 color);
-SPCanvasItem *sp_nodepath_generate_helperpath(SPDesktop *desktop, SPPath *path);
+//SPCanvasItem *sp_nodepath_generate_helperpath(SPDesktop *desktop, SPCurve *curve, const SPItem *item, guint32 color);
+//SPCanvasItem *sp_nodepath_generate_helperpath(SPDesktop *desktop, SPPath *path);
+SPCanvasItem *sp_nodepath_helperpath_from_path(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);