From 8bb95fe13ab4a36335f43c5633243b777d4ddbad Mon Sep 17 00:00:00 2001 From: johanengelen Date: Tue, 6 Nov 2007 18:57:10 +0000 Subject: [PATCH] * UI text change "Curve stitching" to "Stitch subcurves" * add better default strokepath for stitch subcurves --- src/live_effects/effect.cpp | 2 +- src/live_effects/lpe-curvestitch.cpp | 33 ++++++++++++++++++++++++++-- src/live_effects/lpe-curvestitch.h | 8 ++++--- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index a1cb355a4..77e89ddf4 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -50,7 +50,7 @@ const Util::EnumData LPETypeData[INVALID_LPE] = { {DOEFFECTSTACK_TEST, N_("doEffect stack test"), "doeffectstacktest"}, #endif {GEARS, N_("Gears"), "gears"}, - {CURVE_STITCH, N_("Curve stitching"), "curvestitching"}, + {CURVE_STITCH, N_("Stitch subcurves"), "curvestitching"}, }; const Util::EnumDataConverter LPETypeConverter(LPETypeData, INVALID_LPE); diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp index c39277727..0268cec33 100644 --- a/src/live_effects/lpe-curvestitch.cpp +++ b/src/live_effects/lpe-curvestitch.cpp @@ -1,4 +1,4 @@ -#define INKSCAPE_LPE_EXPRESSION_CPP +#define INKSCAPE_LPE_CURVESTITCH_CPP /** \file * SVG implementation, used as an example for a base starting class * when implementing new LivePathEffects. @@ -16,6 +16,9 @@ #include "live_effects/lpe-curvestitch.h" #include "display/curve.h" #include +#include "sp-item.h" +#include "sp-path.h" +#include "live_effects/n-art-bpath-2geom.h" #include <2geom/path.h> #include <2geom/piecewise.h> @@ -37,7 +40,7 @@ using namespace Geom; LPECurveStitch::LPECurveStitch(LivePathEffectObject *lpeobject) : Effect(lpeobject), - strokepath(_("Stroke path"), _("The path that will be stroked, whatever, think of good text here."), "strokepath", &wr, this, "M0,0 L1,0"), + strokepath(_("Stroke path"), _("The path that will be used as stitch."), "strokepath", &wr, this, "M0,0 L1,0"), nrofpaths(_("Nr of paths"), _("The number of paths that will be generated."), "count", &wr, this, 5), startpoint_variation(_("Startpoint variation"), _("..."), "startpoint_variation", &wr, this, 0), endpoint_variation(_("Endpoint variation"), _("..."), "endpoint_variation", &wr, this, 0), @@ -120,6 +123,32 @@ LPECurveStitch::doEffect (std::vector & path_in) } } +void +LPECurveStitch::resetDefaults(SPItem * item) +{ + if (!SP_IS_PATH(item)) return; + + using namespace Geom; + + // set the stroke 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")); + for (unsigned int i=0; i < temppath.size(); i++) { + pwd2.concat( temppath[i].toPwSb() ); + } + + D2 > d2pw = make_cuts_independant(pwd2); + Interval bndsX = bounds_exact(d2pw[0]); + Interval bndsY = bounds_exact(d2pw[1]); + Point start(bndsX.min(), (bndsY.max()+bndsY.min())/2); + Point end(bndsX.max(), (bndsY.max()+bndsY.min())/2); + + Geom::Path path; + path.start( start ); + path.appendNew( end ); + strokepath.param_set_and_write_new_value( path.toPwSb() ); +} + } //namespace LivePathEffect } /* namespace Inkscape */ diff --git a/src/live_effects/lpe-curvestitch.h b/src/live_effects/lpe-curvestitch.h index ce7ad583c..db09a34ee 100644 --- a/src/live_effects/lpe-curvestitch.h +++ b/src/live_effects/lpe-curvestitch.h @@ -1,5 +1,5 @@ -#ifndef INKSCAPE_LPE_EXPRESSION_H -#define INKSCAPE_LPE_EXPRESSION_H +#ifndef INKSCAPE_LPE_CURVESTITCH_H +#define INKSCAPE_LPE_CURVESTITCH_H /** \file * Implementation of an effect similar to Expression, see lpe-expression.cpp @@ -28,7 +28,9 @@ public: LPECurveStitch(LivePathEffectObject *lpeobject); virtual ~LPECurveStitch(); - std::vector doEffect (std::vector & path_in); + virtual std::vector doEffect (std::vector & path_in); + + virtual void resetDefaults(SPItem * item); private: PathParam strokepath; -- 2.30.2