Code

fix lpe-PathPAram when deleting the path that it links to
[inkscape.git] / src / live_effects / effect.cpp
index c664af049ef5ef60b1dfec77b101d2b690e83a1e..dc43af0d5073023a93f7fbfaeef94c7fee01e999 100644 (file)
 // include effects:
 #include "live_effects/lpe-skeletalstrokes.h"
 #include "live_effects/lpe-pathalongpath.h"
+//here!!
+#include "live_effects/lpe-sketch.h"
+#include "live_effects/lpe-vonkoch.h"
+#include "live_effects/lpe-knot.h"
 #include "live_effects/lpe-slant.h"
 #include "live_effects/lpe-test-doEffect-stack.h"
 #include "live_effects/lpe-gears.h"
@@ -48,13 +52,16 @@ namespace LivePathEffect {
 const Util::EnumData<EffectType> LPETypeData[INVALID_LPE] = {
     // {constant defined in effect.h, N_("name of your effect"), "name of your effect in SVG"}
     {PATH_ALONG_PATH,       N_("Bend Path"),             "bend_path"},
-    {SKELETAL_STROKES,      N_("Pattern along path"),    "skeletal"},
+    {SKELETAL_STROKES,      N_("Pattern Along Path"),    "skeletal"},
+    {SKETCH,                N_("Sketch"),                "sketch"},
+    {VONKOCH,               N_("VonKoch"),               "vonkoch"},
+    {KNOT,                  N_("Knot"),                  "knot"},
 #ifdef LPE_ENABLE_TEST_EFFECTS
     {SLANT,                 N_("Slant"),                 "slant"},
     {DOEFFECTSTACK_TEST,    N_("doEffect stack test"),   "doeffectstacktest"},
 #endif
     {GEARS,                 N_("Gears"),                 "gears"},
-    {CURVE_STITCH,          N_("Stitch subpaths"),       "curvestitching"},
+    {CURVE_STITCH,          N_("Stitch Sub-Paths"),       "curvestitching"},
 };
 const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, INVALID_LPE);
 
@@ -69,6 +76,16 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
         case PATH_ALONG_PATH:
             neweffect = (Effect*) new LPEPathAlongPath(lpeobj);
             break;
+//here!!
+        case SKETCH:
+            neweffect = (Effect*) new LPESketch(lpeobj);
+            break;
+        case VONKOCH:
+            neweffect = (Effect*) new LPEVonKoch(lpeobj);
+            break;
+        case KNOT:
+            neweffect = (Effect*) new LPEKnot(lpeobj);
+            break;
 #ifdef LPE_ENABLE_TEST_EFFECTS
             case SLANT:
             neweffect = (Effect*) new LPESlant(lpeobj);
@@ -98,17 +115,12 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
 
 Effect::Effect(LivePathEffectObject *lpeobject)
 {
-    vbox = NULL;
-    tooltips = NULL;
     lpeobj = lpeobject;
     oncanvasedit_it = 0;
 }
 
 Effect::~Effect()
 {
-    if (tooltips) {
-        delete tooltips;
-    }
 }
 
 Glib::ustring
@@ -120,6 +132,13 @@ Effect::getName()
         return Glib::ustring( _("No effect") );
 }
 
+void
+Effect::doBeforeEffect (SPLPEItem *lpeitem)
+{
+    //Do nothing for simple effects
+}
+
+
 /*
  *  Here be the doEffect function chain:
  */
@@ -236,30 +255,30 @@ Effect::registerParameter(Parameter * param)
     param_vector.push_back(param);
 }
 
+/**
+* This *creates* a new widget, management of deletion should be done by the caller
+*/
 Gtk::Widget *
-Effect::getWidget()
+Effect::newWidget(Gtk::Tooltips * tooltips)
 {
-    if (!vbox) {
-        vbox = Gtk::manage( new Gtk::VBox() ); // use manage here, because after deletion of Effect object, others might still be pointing to this widget.
-        //if (!tooltips)
-            tooltips = new Gtk::Tooltips();
-
-        vbox->set_border_width(5);
-
-        std::vector<Parameter *>::iterator it = param_vector.begin();
-        while (it != param_vector.end()) {
-            Parameter * param = *it;
-            Gtk::Widget * widg = param->param_getWidget();
-            Glib::ustring * tip = param->param_getTooltip();
-            if (widg) {
-               vbox->pack_start(*widg, true, true, 2);
-                if (tip != NULL) {
-                    tooltips->set_tip(*widg, *tip);
-                }
-            }
+    // use manage here, because after deletion of Effect object, others might still be pointing to this widget.
+    Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox() );
+
+    vbox->set_border_width(5);
 
-            it++;
+    std::vector<Parameter *>::iterator it = param_vector.begin();
+    while (it != param_vector.end()) {
+        Parameter * param = *it;
+        Gtk::Widget * widg = param->param_newWidget(tooltips);
+        Glib::ustring * tip = param->param_getTooltip();
+        if (widg) {
+           vbox->pack_start(*widg, true, true, 2);
+            if (tip != NULL) {
+                tooltips->set_tip(*widg, *tip);
+            }
         }
+
+        it++;
     }
 
     return dynamic_cast<Gtk::Widget *>(vbox);