summaryrefslogtreecommitdiffstats
path: root/src/nodepath.cpp
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2008-07-29 14:53:25 +0000
committercilix42 <cilix42@users.sourceforge.net>2008-07-29 14:53:25 +0000
commitf9af09ff9c01ff075f5da07d83c399f1d6f0ca50 (patch)
tree4ded25ebdd4e75a8d26d98a34dadadd7f8073547 /src/nodepath.cpp
parentRemove addHelperPaths() from Effect; now getHelperPaths() returns a list of c... (diff)
downloadinkscape-f9af09ff9c01ff075f5da07d83c399f1d6f0ca50.tar.gz
inkscape-f9af09ff9c01ff075f5da07d83c399f1d6f0ca50.zip
Refactor some code in nodepath.cpp (eliminate duplicates in generate_helperpath(), draw_helper_curve(), etc.).
(bzr r6451)
Diffstat (limited to 'src/nodepath.cpp')
-rw-r--r--src/nodepath.cpp38
1 files changed, 26 insertions, 12 deletions
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index bd1f8d785..3f3443550 100644
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
@@ -157,18 +157,19 @@ static void sp_nodepath_set_curve (Inkscape::NodePath::Path *np, SPCurve *curve)
// active_node indicates mouseover node
Inkscape::NodePath::Node * Inkscape::NodePath::Path::active_node = NULL;
-static void sp_nodepath_draw_helper_curve(Inkscape::NodePath::Path *np, SPDesktop *desktop) {
- // Draw helper curve
- if (np->show_helperpath) {
- SPCurve *helper_curve = np->curve->copy();
- helper_curve->transform(to_2geom(np->i2d));
- np->helper_path = sp_canvas_bpath_new(sp_desktop_controls(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);
- sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(np->helper_path), 0, SP_WIND_RULE_NONZERO);
- sp_canvas_item_move_to_z(np->helper_path, 0);
- sp_canvas_item_show(np->helper_path);
- helper_curve->unref();
+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_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;
}
/**
@@ -289,7 +290,10 @@ Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPObject *object,
delete[] typestr;
curve->unref();
- sp_nodepath_draw_helper_curve(np, desktop);
+ // Draw helper curve
+ if (np->show_helperpath) {
+ np->helper_path = sp_nodepath_make_helper_curve(np, desktop, np->curve, true);
+ }
return np;
}
@@ -4770,6 +4774,12 @@ void sp_nodepath_set_curve (Inkscape::NodePath::Path *np, SPCurve *curve) {
}
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));
+}
+
+/**
+SPCanvasItem *
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();
@@ -4789,7 +4799,9 @@ sp_nodepath_generate_helperpath(SPDesktop *desktop, SPPath *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));
}
+**/
+// TODO: Merge this with sp_nodepath_make_helper_curve()!
void sp_nodepath_show_helperpath(Inkscape::NodePath::Path *np, bool show) {
np->show_helperpath = show;
@@ -4797,6 +4809,8 @@ void sp_nodepath_show_helperpath(Inkscape::NodePath::Path *np, bool 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_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);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(np->helper_path), 0, SP_WIND_RULE_NONZERO);