summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f5b0c2b)
raw | patch | inline | side by side (parent: f5b0c2b)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Tue, 6 Nov 2007 18:57:10 +0000 (18:57 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Tue, 6 Nov 2007 18:57:10 +0000 (18:57 +0000) |
* add better default strokepath for stitch subcurves
src/live_effects/effect.cpp | patch | blob | history | |
src/live_effects/lpe-curvestitch.cpp | patch | blob | history | |
src/live_effects/lpe-curvestitch.h | patch | blob | history |
index a1cb355a41b3361227892e8963e901c02febba66..77e89ddf4a4e91968e5623676bac7a1afe76897a 100644 (file)
{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);
index c39277727fc2c4b339ce30b007d4462513458545..0268cec33c6192c01c16b117791ee5d5915d02f9 100644 (file)
-#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.
#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>
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),
}
}
+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 */
index ce7ad583ce4f80bbeb5d16bd27e51a6621227b0f..db09a34ee53f5909fa181c69abb7afd18f7a2016 100644 (file)
-#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
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;