From 7b51b20d1cccdd85e7ad54100fbae1dc755185af Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 4 Sep 2007 18:53:01 +0000 Subject: LPE: add Paste LPE verb + menu item. add scale ratios to curve stitch and path-along-path. remove trailing space in verbs.cpp. Fix initialization of BoolParam (bzr r3675) --- src/live_effects/effect.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'src/live_effects/effect.cpp') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 30a90d834..29f9cb7ef 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -25,6 +25,8 @@ #include <2geom/sbasis-to-bezier.h> #include +#include + // include effects: #include "live_effects/lpe-skeletalstrokes.h" #include "live_effects/lpe-slant.h" @@ -114,7 +116,7 @@ Effect::doEffect (SPCurve * curve) { NArtBpath *new_bpath = doEffect(SP_CURVE_BPATH(curve)); - if (new_bpath) { // FIXME, add function to SPCurve to change bpath? or a copy function? + if (new_bpath && new_bpath != SP_CURVE_BPATH(curve)) { // FIXME, add function to SPCurve to change bpath? or a copy function? if (curve->_bpath) { g_free(curve->_bpath); //delete old bpath } @@ -125,13 +127,30 @@ Effect::doEffect (SPCurve * curve) NArtBpath * Effect::doEffect (NArtBpath * path_in) { - std::vector orig_pathv = BPath_to_2GeomPath(path_in); + try { + std::vector orig_pathv = BPath_to_2GeomPath(path_in); - std::vector result_pathv = doEffect(orig_pathv); + std::vector result_pathv = doEffect(orig_pathv); - NArtBpath *new_bpath = BPath_from_2GeomPath(result_pathv); + NArtBpath *new_bpath = BPath_from_2GeomPath(result_pathv); - return new_bpath; + return new_bpath; + } + catch (std::exception e) { + g_warning("An exception occurred during execution of an LPE - %s", e.what()); + // return here + NArtBpath *path_out; + + unsigned ret = 0; + while ( path_in[ret].code != NR_END ) { + ++ret; + } + unsigned len = ++ret; + + path_out = g_new(NArtBpath, len); + memcpy(path_out, path_in, len * sizeof(NArtBpath)); + return path_out; + } } std::vector -- cgit v1.2.3