index a0a8f3db9569c39f266efc03face9e64c5e035f7..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
namespace LivePathEffect {\r
\r
-const Util::EnumData<EffectType> LPETypeData[ENDTYPE_LPE] = {\r
- {INVALID_LPE, _("Invalid effect"), "invalid"},\r
- {SKELETAL_STROKES, _("Skeletal Strokes"), "skeletal"},\r
+const Util::EnumData<EffectType> LPETypeData[INVALID_LPE] = {\r
+ // {constant defined in effect.h, _("name of your effect"), "name of your effect in SVG"}\r
+ {SKELETAL_STROKES, _("Path along path"), "skeletal"},\r
+#ifdef LPE_ENABLE_TEST_EFFECTS\r
{SLANT, _("Slant"), "slant"},\r
{DOEFFECTSTACK_TEST, _("doEffect stack test"), "doeffectstacktest"},\r
- {GEARS, _("Gears"), "gears"}\r
+#endif\r
+ {GEARS, _("Gears"), "gears"},\r
+ {CURVE_STITCH, _("Curve stitching"), "curvestitching"},\r
};\r
-const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, ENDTYPE_LPE);\r
+const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, INVALID_LPE);\r
\r
Effect*\r
Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)\r
{\r
+ Effect* neweffect = NULL;\r
switch (lpenr) {\r
- case INVALID_LPE:\r
- g_warning("LivePathEffect::Effect::New called with invalid patheffect type");\r
- return NULL;\r
case SKELETAL_STROKES:\r
- return (Effect*) new LPESkeletalStrokes(lpeobj);\r
- case SLANT:\r
- return (Effect*) new LPESlant(lpeobj);\r
+ neweffect = (Effect*) new LPESkeletalStrokes(lpeobj);\r
+ break;\r
+#ifdef LPE_ENABLE_TEST_EFFECTS\r
+ case SLANT:\r
+ neweffect = (Effect*) new LPESlant(lpeobj);\r
+ break;\r
case DOEFFECTSTACK_TEST:\r
- return (Effect*) new LPEdoEffectStackTest(lpeobj);\r
+ neweffect = (Effect*) new LPEdoEffectStackTest(lpeobj);\r
+ break;\r
+#endif\r
case GEARS:\r
- return (Effect*) new LPEGears(lpeobj);\r
- case ENDTYPE_LPE:\r
- return NULL;\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
+ break;\r
}\r
\r
- return NULL;\r
+ if (neweffect) {\r
+ neweffect->readallParameters(SP_OBJECT_REPR(lpeobj));\r
+ }\r
+\r
+ return neweffect;\r
}\r
\r
Effect::Effect(LivePathEffectObject *lpeobject)\r
Glib::ustring \r
Effect::getName()\r
{\r
- return Glib::ustring( LPETypeConverter.get_label(lpeobj->effecttype) );\r
+ if (lpeobj->effecttype_set && lpeobj->effecttype < INVALID_LPE)\r
+ return Glib::ustring( LPETypeConverter.get_label(lpeobj->effecttype) );\r
+ else\r
+ return Glib::ustring( _("No effect") );\r
}\r
\r
/*\r
Effect::doEffect (std::vector<Geom::Path> & path_in)\r
{\r
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_in;\r
- // FIXME: find standard function to convert std::vector<Geom::Path> ==> Piecewise< D2<SBasis> >\r
+\r
for (unsigned int i=0; i < path_in.size(); i++) {\r
pwd2_in.concat( path_in[i].toPwSb() );\r
}\r
@@ -158,11 +178,18 @@ Effect::setParameter(Inkscape::XML::Node * repr, const gchar * key, const gchar
\r
param_map_type::iterator it = param_map.find(stringkey);\r
if (it != param_map.end()) {\r
- bool accepted = it->second->param_readSVGValue(new_value);\r
- /* think: can this backfire and create infinite loop when started with unacceptable old_value?\r
- if (!accepted) { // change was not accepted, so change it back.\r
- repr->setAttribute(key, old_value);\r
- } */\r
+ if (new_value) {\r
+ bool accepted = it->second->param_readSVGValue(new_value);\r
+ if (!accepted) { \r
+ g_warning("Effect::setParameter - '%s' not accepted for %s", new_value, key);\r
+ // change was not accepted, so change it back.\r
+ // think: can this backfire and create infinite loop when started with unacceptable old_value?\r
+ // repr->setAttribute(key, old_value);\r
+ }\r
+ } else {\r
+ // set default value\r
+ it->second->param_set_default();\r
+ }\r
}\r
}\r
\r
SPDocument * \r
Effect::getSPDoc()\r
{\r
- if (SP_OBJECT_DOCUMENT(lpeobj) == NULL) g_message("oh crap");\r
+ if (SP_OBJECT_DOCUMENT(lpeobj) == NULL) g_message("Effect::getSPDoc() returns NULL");\r
return SP_OBJECT_DOCUMENT(lpeobj);\r
}\r
\r
\r
-}; /* namespace LivePathEffect */\r
+} /* namespace LivePathEffect */\r
\r
-}; /* namespace Inkscape */\r
+} /* namespace Inkscape */\r
\r
/*\r
Local Variables:\r