summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a0df1b8)
raw | patch | inline | side by side (parent: a0df1b8)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Wed, 29 Aug 2007 22:36:46 +0000 (22:36 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Wed, 29 Aug 2007 22:36:46 +0000 (22:36 +0000) |
- rename RealParam to ScalarParam, add range checking for ScalarParam, add integer only flag for it aswell.
- fix up todo.txt and create new one for parameters
- add Curve Stitch LPE
- fix up todo.txt and create new one for parameters
- add Curve Stitch LPE
14 files changed:
po/POTFILES.in | patch | blob | history | |
src/live_effects/Makefile_insert | patch | blob | history | |
src/live_effects/effect.cpp | patch | blob | history | |
src/live_effects/effect.h | patch | blob | history | |
src/live_effects/lpe-curvestitch.cpp | [new file with mode: 0644] | patch | blob |
src/live_effects/lpe-curvestitch.h | [new file with mode: 0644] | patch | blob |
src/live_effects/lpe-gears.h | patch | blob | history | |
src/live_effects/lpe-skeleton.h | patch | blob | history | |
src/live_effects/lpe-slant.h | patch | blob | history | |
src/live_effects/lpe-test-doEffect-stack.h | patch | blob | history | |
src/live_effects/parameter/parameter.cpp | patch | blob | history | |
src/live_effects/parameter/parameter.h | patch | blob | history | |
src/live_effects/parameter/todo.txt | [new file with mode: 0644] | patch | blob |
src/live_effects/todo.txt | patch | blob | history |
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 66779dc354cfc10211442315b6318f296eed77ac..cb6a924874938dee58fb56d6620a1ec46cfbb2cc 100644 (file)
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
src/live_effects/effect.cpp
src/live_effects/parameter/enum.h
src/live_effects/lpe-gears.cpp
+src/live_effects/lpe-curvestitch.cpp
src/live_effects/lpe-skeletalstrokes.cpp
src/live_effects/parameter/parameter.cpp
src/live_effects/parameter/path.cpp
index f285416e204a3002e114b7751588a4ff260e5d9b..fcce5721e11490f81fa2b978c1a9803ad71dadb7 100644 (file)
live_effects/n-art-bpath-2geom.h \\r
live_effects/lpe-skeletalstrokes.cpp \\r
live_effects/lpe-skeletalstrokes.h \\r
+ live_effects/lpe-curvestitch.cpp \\r
+ live_effects/lpe-curvestitch.h \\r
live_effects/lpe-gears.cpp \\r
live_effects/lpe-gears.h \\r
live_effects/lpe-test-doEffect-stack.cpp \\r
index a7f4d5781b7706650077eb7676dd635ca0368631..d13de7f9e9fea2d99c5a13ce0cdfd8b45b525c57 100644 (file)
#include "live_effects/lpe-slant.h"\r
#include "live_effects/lpe-test-doEffect-stack.h"\r
#include "live_effects/lpe-gears.h"\r
+#include "live_effects/lpe-curvestitch.h"\r
\r
namespace Inkscape {\r
\r
{SLANT, _("Slant"), "slant"},\r
{DOEFFECTSTACK_TEST, _("doEffect stack test"), "doeffectstacktest"},\r
#endif\r
- {GEARS, _("Gears"), "gears"}\r
+ {GEARS, _("Gears"), "gears"},\r
+ {CURVE_STITCH, _("Curve stitching"), "curvestitching"},\r
};\r
const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, INVALID_LPE);\r
\r
case GEARS:\r
neweffect = (Effect*) new LPEGears(lpeobj);\r
break;\r
+ case CURVE_STITCH:\r
+ neweffect = (Effect*) new LPECurveStitch(lpeobj);\r
+ break;\r
default:\r
g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr);\r
neweffect = NULL;\r
index 37e87a7a6bc6656908c1c0a4041d6a6069708928..f3c415269dc52890710372f57d83b6af2f903322 100644 (file)
DOEFFECTSTACK_TEST,\r
#endif\r
GEARS,\r
+ CURVE_STITCH,\r
INVALID_LPE // This must be last\r
};\r
\r
diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp
--- /dev/null
@@ -0,0 +1,106 @@
+#define INKSCAPE_LPE_EXPRESSION_CPP\r
+/** \file\r
+ * SVG <skeleton> implementation, used as an example for a base starting class\r
+ * when implementing new LivePathEffects.\r
+ *\r
+ */\r
+/*\r
+ * Authors:\r
+ * Johan Engelen\r
+*\r
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>\r
+ *\r
+ * Released under GNU GPL, read the file 'COPYING' for more information\r
+ */\r
+\r
+#include "live_effects/lpe-curvestitch.h"\r
+#include "display/curve.h"\r
+#include <libnr/n-art-bpath.h>\r
+\r
+#include <2geom/path.h>\r
+#include <2geom/piecewise.h>\r
+#include <2geom/sbasis.h>\r
+#include <2geom/sbasis-geometric.h>\r
+#include <2geom/bezier-to-sbasis.h>\r
+#include <2geom/sbasis-to-bezier.h>\r
+#include <2geom/d2.h>\r
+\r
+#include "ui/widget/scalar.h"\r
+#include "libnr/nr-values.h"\r
+\r
+namespace Inkscape {\r
+namespace LivePathEffect {\r
+\r
+using namespace Geom;\r
+\r
+LPECurveStitch::LPECurveStitch(LivePathEffectObject *lpeobject) :\r
+ Effect(lpeobject),\r
+ strokepath(_("Stroke path"), _("The path that will be stroked, whatever, think of good text here."), "strokepath", &wr, this, "M0,0 L1,1"),\r
+ nrofpaths(_("Nr of paths"), _("The number of paths that will be generated."), "count", &wr, this, 5),\r
+ startpoint_variation(_("Startpoint variation"), _("..."), "startpoint_variation", &wr, this, 0),\r
+ endpoint_variation(_("Endpoint variation"), _("..."), "endpoint_variation", &wr, this, 0)\r
+{\r
+ registerParameter( dynamic_cast<Parameter *>(&nrofpaths) );\r
+// registerParameter( dynamic_cast<Parameter *>(&startpoint_variation) );\r
+// registerParameter( dynamic_cast<Parameter *>(&endpoint_variation) );\r
+\r
+ nrofpaths.param_make_integer();\r
+ nrofpaths.param_set_range(2, NR_HUGE);\r
+\r
+// startpoint_variation.param_set_range(-NR_HUGE, 1);\r
+// endpoint_variation.param_set_range(-1, NR_HUGE);\r
+}\r
+\r
+LPECurveStitch::~LPECurveStitch()\r
+{\r
+\r
+}\r
+\r
+std::vector<Geom::Path>\r
+LPECurveStitch::doEffect (std::vector<Geom::Path> & path_in)\r
+{\r
+ if (path_in.size() >= 2) {\r
+ std::vector<Geom::Path> path_out (nrofpaths);\r
+\r
+ // do this for all permutations if there are more than 2 paths? realllly cool!\r
+ Piecewise<D2<SBasis> > A = arc_length_parametrization(Piecewise<D2<SBasis> >(path_in[0].toPwSb()),2,.1);\r
+ Piecewise<D2<SBasis> > B = arc_length_parametrization(Piecewise<D2<SBasis> >(path_in[1].toPwSb()),2,.1);\r
+ Interval bndsA = A.domain();\r
+ Interval bndsB = B.domain();\r
+ gdouble incrementA = (bndsA.max()-bndsA.min()) / (nrofpaths-1);\r
+ gdouble incrementB = (bndsB.max()-bndsB.min()) / (nrofpaths-1);\r
+ gdouble tA = bndsA.min();\r
+ gdouble tB = bndsB.min();\r
+ for (int i = 0; i < nrofpaths; i++) {\r
+ Point start = A(tA);\r
+ Point end = B(tB);\r
+ if (startpoint_variation != 0)\r
+ start = start + g_random_double_range(0, startpoint_variation) * (end - start);\r
+ if (endpoint_variation != 0)\r
+ end = end + g_random_double_range(0, endpoint_variation) * (end - start);\r
+\r
+ path_out[i].start( start );\r
+ path_out[i].appendNew<LineSegment>( end );\r
+ tA += incrementA;\r
+ tB += incrementB;\r
+ }\r
+\r
+ return path_out;\r
+ } else {\r
+ return path_in;\r
+ }\r
+}\r
+\r
+} //namespace LivePathEffect\r
+} /* namespace Inkscape */\r
+\r
+/*\r
+ Local Variables:\r
+ mode:c++\r
+ c-file-style:"stroustrup"\r
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))\r
+ indent-tabs-mode:nil\r
+ fill-column:99\r
+ End:\r
+*/\r
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :\r
diff --git a/src/live_effects/lpe-curvestitch.h b/src/live_effects/lpe-curvestitch.h
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef INKSCAPE_LPE_EXPRESSION_H\r
+#define INKSCAPE_LPE_EXPRESSION_H\r
+\r
+/** \file\r
+ * Implementation of an effect similar to Expression, see lpe-expression.cpp\r
+ */\r
+\r
+/*\r
+ * Authors:\r
+ * Johan Engelen\r
+*\r
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>\r
+ *\r
+ * Released under GNU GPL, read the file 'COPYING' for more information\r
+ */\r
+\r
+#include "live_effects/effect.h"\r
+#include "live_effects/parameter/path.h"\r
+#include "live_effects/parameter/parameter.h"\r
+\r
+namespace Inkscape {\r
+namespace LivePathEffect {\r
+\r
+class LPECurveStitch : public Effect {\r
+public:\r
+ LPECurveStitch(LivePathEffectObject *lpeobject);\r
+ ~LPECurveStitch();\r
+\r
+ std::vector<Geom::Path> doEffect (std::vector<Geom::Path> & path_in);\r
+\r
+private:\r
+ PathParam strokepath;\r
+ ScalarParam nrofpaths;\r
+ ScalarParam startpoint_variation;\r
+ ScalarParam endpoint_variation;\r
+\r
+ LPECurveStitch(const LPECurveStitch&);\r
+ LPECurveStitch& operator=(const LPECurveStitch&);\r
+};\r
+\r
+} //namespace LivePathEffect\r
+} //namespace Inkscape\r
+\r
+#endif\r
index 81a4ef0584aef33864c1483fe1e324103ccddbfe..b43fbd95eee8153f12ddb73ad386db5415e60c4d 100644 (file)
std::vector<Geom::Path> doEffect (std::vector<Geom::Path> & path_in);\r
\r
private:\r
- RealParam teeth;\r
- RealParam phi;\r
+ ScalarParam teeth;\r
+ ScalarParam phi;\r
\r
LPEGears(const LPEGears&);\r
LPEGears& operator=(const LPEGears&);\r
index cefbf0a0b35e9f9eb5ca6dd797d9183d8299996f..cce9bde3e708aca46d3b5da85f65b114d054287c 100644 (file)
\r
private:\r
// add the parameters for your effect here:\r
- RealParam number;\r
+ ScalarParam number;\r
// there are all kinds of parameters. Check the /live_effects/parameter directory which types exist!\r
\r
LPESkeleton(const LPESkeleton&);\r
index 95d4420faf6fa87f2a98c46288e9a0afd6445223..1f3ebcdb91c4736cad78d8ea3e486c0b69c6cb68 100644 (file)
void doEffect(SPCurve * curve);\r
\r
private:\r
- RealParam factor;\r
+ ScalarParam factor;\r
PointParam center;\r
\r
LPESlant(const LPESlant&);\r
diff --git a/src/live_effects/lpe-test-doEffect-stack.h b/src/live_effects/lpe-test-doEffect-stack.h
index 57748f5035e8a4d39fb5262de1263803716f75de..5e990868e35b108dcf4be248a30b9425f87fe54c 100644 (file)
Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in);\r
\r
private:\r
- RealParam step;\r
+ ScalarParam step;\r
\r
LPEdoEffectStackTest(const LPEdoEffectStackTest&);\r
LPEdoEffectStackTest& operator=(const LPEdoEffectStackTest&);\r
index 91df62e810e72a9ac94d90ede4d44c3ba86e6ded..42dd219957738a01ee0de553844ea453403475de 100644 (file)
#include "live_effects/parameter/parameter.h"\r
#include "live_effects/effect.h"\r
#include "svg/svg.h"\r
+#include "libnr/nr-values.h"\r
\r
#include <gtkmm.h>\r
#include "ui/widget/scalar.h"\r
/*###########################################\r
* REAL PARAM\r
*/\r
-RealParam::RealParam( const Glib::ustring& label, const Glib::ustring& tip,\r
+ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip,\r
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,\r
Effect* effect, gdouble default_value)\r
: Parameter(label, tip, key, wr, effect)\r
{\r
defvalue = default_value;\r
value = defvalue;\r
+ min = -NR_HUGE;\r
+ max = NR_HUGE;\r
+ integer = false;\r
rsu = NULL;\r
}\r
\r
-RealParam::~RealParam()\r
+ScalarParam::~ScalarParam()\r
{\r
if (rsu)\r
delete rsu;\r
}\r
\r
bool\r
-RealParam::param_readSVGValue(const gchar * strvalue)\r
+ScalarParam::param_readSVGValue(const gchar * strvalue)\r
{\r
double newval;\r
unsigned int success = sp_svg_number_read_d(strvalue, &newval);\r
}\r
\r
gchar *\r
-RealParam::param_writeSVGValue() const\r
+ScalarParam::param_writeSVGValue() const\r
{\r
Inkscape::SVGOStringStream os;\r
os << value;\r
}\r
\r
void\r
-RealParam::param_set_default() \r
+ScalarParam::param_set_default() \r
{\r
param_set_value(defvalue);\r
}\r
\r
void\r
-RealParam::param_set_value(gdouble val) \r
+ScalarParam::param_set_value(gdouble val) \r
{\r
value = val;\r
+ if (integer)\r
+ value = round(value);\r
+ if (value > max)\r
+ value = max;\r
+ if (value < min)\r
+ value = min;\r
+\r
if (rsu)\r
rsu->setValue(value);\r
}\r
\r
+void\r
+ScalarParam::param_set_range(gdouble min, gdouble max) \r
+{\r
+ this->min = min;\r
+ this->max = max;\r
+ if (rsu)\r
+ rsu->getS()->setRange(min, max);\r
+\r
+ param_set_value(value);\r
+}\r
+\r
+void\r
+ScalarParam::param_make_integer(bool yes)\r
+{\r
+ integer = yes;\r
+ if (rsu) {\r
+ rsu->getS()->setDigits(0);\r
+ rsu->getS()->setIncrements(1, 10);\r
+ }\r
+}\r
\r
Gtk::Widget *\r
-RealParam::param_getWidget()\r
+ScalarParam::param_getWidget()\r
{\r
if (!rsu) {\r
rsu = new Inkscape::UI::Widget::RegisteredScalar();\r
rsu->init(param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());\r
rsu->setValue(value);\r
+ if (integer)\r
+ param_make_integer();\r
+\r
rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter"));\r
}\r
return dynamic_cast<Gtk::Widget *> (rsu->getS());\r
\r
\r
} /* namespace LivePathEffect */\r
-\r
} /* namespace Inkscape */\r
\r
/*\r
index 942def5b86d8b4f1f24c9f5f42c279da3060ebc1..d8659600abeca866d814b7e42742e596f4f1ec64 100644 (file)
};\r
\r
\r
-class RealParam : public Parameter {\r
+class ScalarParam : public Parameter {\r
public:\r
- RealParam( const Glib::ustring& label,\r
+ ScalarParam( const Glib::ustring& label,\r
const Glib::ustring& tip,\r
const Glib::ustring& key, \r
Inkscape::UI::Widget::Registry* wr,\r
Effect* effect,\r
gdouble default_value = 1.0);\r
- ~RealParam();\r
+ ~ScalarParam();\r
\r
bool param_readSVGValue(const gchar * strvalue);\r
gchar * param_writeSVGValue() const;\r
\r
void param_set_default();\r
void param_set_value(gdouble val);\r
+ void param_make_integer(bool yes = true);\r
+ void param_set_range(gdouble min, gdouble max);\r
\r
Gtk::Widget * param_getWidget();\r
\r
{ return value; };\r
\r
private:\r
- RealParam(const RealParam&);\r
- RealParam& operator=(const RealParam&);\r
+ ScalarParam(const ScalarParam&);\r
+ ScalarParam& operator=(const ScalarParam&);\r
\r
gdouble value;\r
+ gdouble min;\r
+ gdouble max;\r
+ bool integer;\r
gdouble defvalue;\r
Inkscape::UI::Widget::RegisteredScalar * rsu;\r
};\r
\r
-\r
} //namespace LivePathEffect\r
\r
} //namespace Inkscape\r
diff --git a/src/live_effects/parameter/todo.txt b/src/live_effects/parameter/todo.txt
--- /dev/null
@@ -0,0 +1,9 @@
+reminder list\r
+\r
+- make robust\r
+For example, the spinbuttons for scalarparam can "hang" which is very very very annoying.\r
+\r
+- add more types! \r
+straightlinepaths: for example for the gears effect. (curves are not important there)\r
+random number: it must also store the random number generator seed!!!\r
+\r
index 87bafe4a1540fc244bd800f6736ffe109dd95a56..51a7a3c21ee15926d2ff763486dc815847237fc6 100644 (file)
\r
make sp_nodepath_is_over_stroke perhaps\r
\r
-Parameters:\r
-- make robust (?)\r
-- add range checking etc\r
-- add more types! (straightlinepath, enum, bool)\r
-- -->> add write to svg functionality (for lpeobject->write)\r
-\r
\r
find dir "fixme" and fix'em!
\ No newline at end of file