summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2007-11-06 18:57:10 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2007-11-06 18:57:10 +0000
commit4735d6ac9303ea6aa5488101e5d60de63d3193fe (patch)
tree7b448b4e55918f34d260069af43a77c9648b9957 /src
parent2geom update to 2Geom-SVN-rev. 1161 (diff)
downloadinkscape-4735d6ac9303ea6aa5488101e5d60de63d3193fe.tar.gz
inkscape-4735d6ac9303ea6aa5488101e5d60de63d3193fe.zip
* UI text change "Curve stitching" to "Stitch subcurves"
* add better default strokepath for stitch subcurves (bzr r4035)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/effect.cpp2
-rw-r--r--src/live_effects/lpe-curvestitch.cpp33
-rw-r--r--src/live_effects/lpe-curvestitch.h8
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<EffectType> 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<EffectType> 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 <skeleton> 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 <libnr/n-art-bpath.h>
+#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<Geom::Path> & 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<D2<SBasis> > pwd2;
+ std::vector<Path> 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<Piecewise<SBasis> > 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<Geom::LineSegment>( 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<Geom::Path> doEffect (std::vector<Geom::Path> & path_in);
+ virtual std::vector<Geom::Path> doEffect (std::vector<Geom::Path> & path_in);
+
+ virtual void resetDefaults(SPItem * item);
private:
PathParam strokepath;