X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fnodepath.cpp;h=b712539ab767f78f872a3fb550c54095ae7f1f9f;hb=144c1b594591ba3d62513b126ca87a5f242b2f2b;hp=ee8e5e1237983194f3f11632312b944615a5e0ce;hpb=04c99c338ffdc6e10cb6f5c18f6f06b3f555e8eb;p=inkscape.git diff --git a/src/nodepath.cpp b/src/nodepath.cpp index ee8e5e123..b712539ab 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -152,6 +152,20 @@ 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(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(); + } +} + /** * \brief Creates new nodepath from item */ @@ -208,7 +222,13 @@ Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPObject *object, np->helperpath_rgba = prefs_get_int_attribute("tools.nodes", "highlight_color", 0xff0000ff); np->helperpath_width = 1.0; np->curve = curve->copy(); - np->show_helperpath = prefs_get_int_attribute ("tools.nodes", "show_helperpath", 0) == 1; + np->show_helperpath = (prefs_get_int_attribute ("tools.nodes", "show_helperpath", 0) == 1); + if (SP_IS_LPE_ITEM(object)) { + Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(object)); + if (lpe && lpe->isVisible() && lpe->showOrigPath()) { + np->show_helperpath = true; + } + } np->straight_path = false; if (IS_LIVEPATHEFFECT(object) && item) { np->item = item; @@ -264,17 +284,7 @@ Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPObject *object, // create the livarot representation from the same item sp_nodepath_ensure_livarot_path(np); - // Draw helper curve - if (np->show_helperpath) { - SPCurve *helper_curve = np->curve->copy(); - helper_curve->transform(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(); - } + sp_nodepath_draw_helper_curve(np, desktop); return np; } @@ -331,8 +341,8 @@ void sp_nodepath_ensure_livarot_path(Inkscape::NodePath::Path *np) { if (np && np->livarot_path == NULL) { SPCurve *curve = create_curve(np); - NArtBpath const *bpath = SP_CURVE_BPATH(curve); - np->livarot_path = bpath_to_Path(bpath); + np->livarot_path = new Path; + np->livarot_path->LoadPathVector(curve->get_pathvector()); if (np->livarot_path) np->livarot_path->ConvertWithBackData(0.01); @@ -4696,12 +4706,10 @@ SPCurve* sp_nodepath_object_get_curve(SPObject *object, const gchar *key) { } else if ( IS_LIVEPATHEFFECT(object) && key) { const gchar *svgd = object->repr->attribute(key); if (svgd) { - NArtBpath *bpath = sp_svg_read_path(svgd); - SPCurve *curve_new = SPCurve::new_from_bpath(bpath); + Geom::PathVector pv = sp_svg_read_pathv(svgd); + SPCurve *curve_new = new SPCurve(pv); if (curve_new) { curve = curve_new; // don't do curve_copy because curve_new is already only created for us! - } else { - g_free(bpath); } } } @@ -4731,15 +4739,13 @@ void sp_nodepath_set_curve (Inkscape::NodePath::Path *np, SPCurve *curve) { } SPCanvasItem * -sp_nodepath_generate_helperpath(SPDesktop *desktop, SPPath *path) { - // This should be put somewhere else under the name of "generate helperpath" or something. Because basically this is copied of code from nodepath... - SPCurve *curve_new = sp_path_get_curve_for_edit(path); - SPCurve *flash_curve = curve_new->copy(); - flash_curve->transform(sp_item_i2d_affine(SP_ITEM(path))); +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); @@ -4747,6 +4753,12 @@ sp_nodepath_generate_helperpath(SPDesktop *desktop, SPPath *path) { return canvasitem; } +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), + prefs_get_int_attribute("tools.nodes", "highlight_color", 0xff0000ff)); +} + void sp_nodepath_show_helperpath(Inkscape::NodePath::Path *np, bool show) { np->show_helperpath = show;