From 8a38c52bce619b07117cdd87a183eb05fb51e28e Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 6 Jun 2008 01:43:35 +0000 Subject: merge gsoc2008_johan_path2geom into trunk (bzr r5823) --- src/live_effects/effect.cpp | 30 ++++++---------------------- src/live_effects/effect.h | 2 -- src/live_effects/lpe-curvestitch.cpp | 4 ++-- src/live_effects/lpe-knot.h | 1 - src/live_effects/lpe-test-doEffect-stack.cpp | 23 +-------------------- src/live_effects/lpe-test-doEffect-stack.h | 1 - src/live_effects/lpe-vonkoch.cpp | 2 +- src/live_effects/parameter/parameter.h | 3 +-- src/live_effects/parameter/path.cpp | 12 +++++------ 9 files changed, 17 insertions(+), 61 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 765d0a59b..0749e4e93 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -221,40 +221,22 @@ Effect::doBeforeEffect (SPLPEItem */*lpeitem*/) void Effect::doEffect (SPCurve * curve) { - NArtBpath *new_bpath = doEffect_nartbpath(curve->get_bpath()); + NArtBpath const *bpath_in = curve->get_bpath(); - curve->set_bpath(new_bpath); -} + std::vector result_pathv; -NArtBpath * -Effect::doEffect_nartbpath (NArtBpath const * path_in) -{ try { - std::vector orig_pathv = BPath_to_2GeomPath(path_in); - - std::vector result_pathv = doEffect_path(orig_pathv); + std::vector orig_pathv = BPath_to_2GeomPath(bpath_in); - NArtBpath *new_bpath = BPath_from_2GeomPath(result_pathv); - - return new_bpath; + result_pathv = doEffect_path(orig_pathv); } catch (std::exception & e) { g_warning("Exception during LPE %s execution. \n %s", getName().c_str(), e.what()); SP_ACTIVE_DESKTOP->messageStack()->flash( Inkscape::WARNING_MESSAGE, _("An exception occurred during execution of the Path Effect.") ); - - 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; } + + curve->set_pathv(result_pathv); } std::vector diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index c04f248e3..a8cb525b8 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -125,8 +125,6 @@ protected: // the order in which they appear is the order in which they are // called by this base class. (i.e. doEffect(SPCurve * curve) defaults to calling // doEffect(std::vector ) - virtual NArtBpath * - doEffect_nartbpath (NArtBpath const * path_in) __attribute__ ((deprecated)); virtual std::vector doEffect_path (std::vector const & path_in); virtual Geom::Piecewise > diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp index 9cf9f2f26..814a381af 100644 --- a/src/live_effects/lpe-curvestitch.cpp +++ b/src/live_effects/lpe-curvestitch.cpp @@ -17,7 +17,7 @@ #include "sp-item.h" #include "sp-path.h" -#include "libnr/n-art-bpath-2geom.h" +#include "svg/svg.h" #include "xml/repr.h" #include <2geom/path.h> @@ -158,7 +158,7 @@ LPECurveStitch::resetDefaults(SPItem * item) // calculate bounding box: (isn't there a simpler way?) Piecewise > pwd2; - std::vector temppath = SVGD_to_2GeomPath( SP_OBJECT_REPR(item)->attribute("inkscape:original-d")); + std::vector temppath = sp_svg_read_pathv( SP_OBJECT_REPR(item)->attribute("inkscape:original-d")); for (unsigned int i=0; i < temppath.size(); i++) { pwd2.concat( temppath[i].toPwSb() ); } diff --git a/src/live_effects/lpe-knot.h b/src/live_effects/lpe-knot.h index 521c2d7c9..a68888105 100644 --- a/src/live_effects/lpe-knot.h +++ b/src/live_effects/lpe-knot.h @@ -27,7 +27,6 @@ public: // Choose to implement one of the doEffect functions. You can delete or comment out the others. // virtual void doEffect (SPCurve * curve); -// virtual NArtBpath * doEffect_nartbpath (NArtBpath * path_in); virtual std::vector doEffect_path (std::vector const & input_path); // virtual Geom::Piecewise > doEffect_pwd2 (Geom::Piecewise > & pwd2_in); diff --git a/src/live_effects/lpe-test-doEffect-stack.cpp b/src/live_effects/lpe-test-doEffect-stack.cpp index f3fb346fe..3b578b2c6 100644 --- a/src/live_effects/lpe-test-doEffect-stack.cpp +++ b/src/live_effects/lpe-test-doEffect-stack.cpp @@ -45,31 +45,10 @@ LPEdoEffectStackTest::doEffect (SPCurve * curve) } } -NArtBpath * -LPEdoEffectStackTest::doEffect_nartbpath (NArtBpath const * path_in) -{ - if (step >= 2) { - return Effect::doEffect_nartbpath(path_in); - } else { - // 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 LPEdoEffectStackTest::doEffect_path (std::vector const & path_in) { - if (step >= 3) { + if (step >= 2) { return Effect::doEffect_path(path_in); } else { // return here diff --git a/src/live_effects/lpe-test-doEffect-stack.h b/src/live_effects/lpe-test-doEffect-stack.h index cf2d480b1..7c22a3b37 100644 --- a/src/live_effects/lpe-test-doEffect-stack.h +++ b/src/live_effects/lpe-test-doEffect-stack.h @@ -26,7 +26,6 @@ public: virtual ~LPEdoEffectStackTest(); virtual void doEffect (SPCurve * curve); - virtual NArtBpath * doEffect_nartbpath (NArtBpath const * path_in); virtual std::vector doEffect_path (std::vector const & path_in); virtual Geom::Piecewise > doEffect_pwd2 (Geom::Piecewise > const & pwd2_in); diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index ee09221ed..114dd7263 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -159,7 +159,7 @@ LPEVonKoch::resetDefaults(SPItem * item) // set the bend path to run horizontally in the middle of the bounding box of the original path Piecewise > pwd2; - std::vector temppath = SVGD_to_2GeomPath( SP_OBJECT_REPR(item)->attribute("inkscape:original-d")); + std::vector temppath = sp_svg_read_pathv( SP_OBJECT_REPR(item)->attribute("inkscape:original-d")); for (unsigned int i=0; i < temppath.size(); i++) { pwd2.concat( temppath[i].toPwSb() ); } diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index d3afec3af..511ce46a2 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -10,8 +10,7 @@ */ #include -#include <2geom/point.h> -#include <2geom/path.h> +#include <2geom/forward.h> struct SPDesktop; struct SPItem; diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 376e61bee..759e9f788 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -113,10 +113,10 @@ PathParam::param_readSVGValue(const gchar * strvalue) } catch (Inkscape::BadURIException &e) { g_warning("%s", e.what()); ref.detach(); - _pathvector = SVGD_to_2GeomPath(defvalue); + _pathvector = sp_svg_read_pathv(defvalue); } } else { - _pathvector = SVGD_to_2GeomPath(strvalue); + _pathvector = sp_svg_read_pathv(strvalue); } signal_path_changed.emit(); @@ -132,7 +132,7 @@ PathParam::param_getSVGValue() const if (href) { return href; } else { - gchar * svgd = SVGD_from_2GeomPath( _pathvector ); + gchar * svgd = sp_svg_write_path( _pathvector ); return svgd; } } @@ -233,7 +233,7 @@ PathParam::param_set_and_write_new_value (Geom::Piecewise { remove_link(); _pathvector = Geom::path_from_piecewise(newpath, LPE_CONVERSION_TOLERANCE); - gchar * svgd = SVGD_from_2GeomPath( _pathvector ); + gchar * svgd = sp_svg_write_path( _pathvector ); param_write_to_repr(svgd); g_free(svgd); // force value upon pwd2 and don't recalculate. @@ -248,7 +248,7 @@ PathParam::param_set_and_write_new_value (std::vector const & newpat _pathvector = newpath; must_recalculate_pwd2 = true; - gchar * svgd = SVGD_from_2GeomPath( _pathvector ); + gchar * svgd = sp_svg_write_path( _pathvector ); param_write_to_repr(svgd); g_free(svgd); } @@ -324,7 +324,7 @@ PathParam::linked_modified(SPObject *linked_obj, guint /*flags*/) if (curve == NULL) { // curve invalid, set default value - _pathvector = SVGD_to_2GeomPath(defvalue); + _pathvector = sp_svg_read_pathv(defvalue); } else { _pathvector = BPath_to_2GeomPath(SP_CURVE_BPATH(curve)); curve->unref(); -- cgit v1.2.3