Code

patch by Diederik for jumping images, bug 168384
[inkscape.git] / src / live_effects / effect.h
index f1241c54b8a79ff305913a30138b2031af4e3de5..6f195b176f3c2aa9d07fda335519789b081c12c9 100644 (file)
 #include <map>
 #include <glibmm/ustring.h>
 #include <2geom/path.h>
+#include <2geom/forward.h>
 #include "ui/widget/registry.h"
-#include "util/enums.h"
 #include "sp-lpe-item.h"
 #include "knotholder.h"
 #include "parameter/bool.h"
+#include "effect-enum.h"
 
 #define  LPE_CONVERSION_TOLERANCE 0.01    // FIXME: find good solution for this.
 
-#define LPE_ENABLE_TEST_EFFECTS
-
 struct SPDocument;
 struct SPDesktop;
 struct SPItem;
-class NArtBpath;
+class SPNodeContext;
 struct LivePathEffectObject;
 
 namespace Gtk {
@@ -36,10 +35,6 @@ namespace Gtk {
     class Tooltips;
 }
 
-namespace Geom {
-    class Matrix;
-}
-
 namespace Inkscape {
 
 namespace XML {
@@ -52,35 +47,9 @@ namespace NodePath {
 
 namespace LivePathEffect {
 
-enum EffectType {
-    BEND_PATH = 0,
-    PATTERN_ALONG_PATH,
-    SKETCH,
-    VONKOCH,
-    KNOT,
-#ifdef LPE_ENABLE_TEST_EFFECTS
-    DOEFFECTSTACK_TEST,
-#endif
-    GEARS,
-    CURVE_STITCH,
-    CIRCLE_WITH_RADIUS,
-    PERSPECTIVE_PATH,
-    SPIRO,
-    LATTICE,
-    ENVELOPE,
-    CONSTRUCT_GRID,
-    PERP_BISECTOR,
-    TANGENT_TO_CURVE,
-    MIRROR_REFLECT,
-    INVALID_LPE // This must be last
-};
-
-extern const Util::EnumData<EffectType> LPETypeData[INVALID_LPE];
-extern const Util::EnumDataConverter<EffectType> LPETypeConverter;
-
 enum LPEPathFlashType {
     SUPPRESS_FLASH,
-    PERMANENT_FLASH,
+//    PERMANENT_FLASH,
     DEFAULT
 };
 
@@ -100,24 +69,45 @@ public:
     void writeParamsToSVG();
 
     virtual void acceptParamPath (SPPath *param_path);
-    virtual int acceptsNumParams() { return 0; }
+    static int acceptsNumClicks(EffectType type);
+    int acceptsNumClicks() { return acceptsNumClicks(effectType()); }
     void doAcceptPathPreparations(SPLPEItem *lpeitem);
 
-    inline bool pathParamAccepted() { return done_pathparam_set; }
+    /*
+     * isReady() indicates whether all preparations which are necessary to apply the LPE are done,
+     * e.g., waiting for a parameter path either before the effect is created or when it needs a
+     * path as argument. This is set in sp_lpe_item_add_path_effect().
+     */
+    inline bool isReady() { return is_ready; }
+    inline void setReady(bool ready = true) { is_ready = ready; }
 
     virtual void doEffect (SPCurve * curve);
 
     virtual Gtk::Widget * newWidget(Gtk::Tooltips * tooltips);
 
+    /**
+     * Sets all parameters to their default values and writes them to SVG.
+     */
     virtual void resetDefaults(SPItem * item);
 
     virtual void setup_nodepath(Inkscape::NodePath::Path *np);
 
+    /// /todo: is this method really necessary? it causes UI inconsistensies... (johan)
     virtual void transform_multiply(Geom::Matrix const& postmul, bool set);
 
-    bool providesKnotholder() { return (kh_entity_vector.size() > 0); }
+    // /TODO: providesKnotholder() is currently used as an indicator of whether a nodepath is
+    // created for an item or not. When we allow both at the same time, this needs rethinking!
+    bool providesKnotholder();
+    // /TODO: in view of providesOwnFlashPaths() below, this is somewhat redundant
+    //       (but spiro lpe still needs it!)
     virtual LPEPathFlashType pathFlashType() { return DEFAULT; }
     void addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
+    std::vector<Geom::PathVector> getHelperPaths(SPLPEItem *lpeitem);
+
+    inline bool providesOwnFlashPaths() {
+        return provides_own_flash_paths || show_orig_path;
+    }
+    inline bool showOrigPath() { return show_orig_path; }
 
     Glib::ustring          getName();
     Inkscape::XML::Node *  getRepr();
@@ -147,14 +137,21 @@ protected:
 
     void registerParameter(Parameter * param);
     void registerKnotHolderHandle(KnotHolderEntity* entity, const char* descr);
-    void addPointParamHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
     Parameter * getNextOncanvasEditableParam();
 
+    void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
+
+    //virtual std::vector<Geom::PathVector> getCanvasIndicators(SPLPEItem *lpeitem);
+    virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec);
+
+
     std::vector<Parameter *> param_vector;
     std::vector<std::pair<KnotHolderEntity*, const char*> > kh_entity_vector;
     int oncanvasedit_it;
     BoolParam is_visible;
-    bool done_pathparam_set;
+
+    bool show_orig_path; // set this to true in derived effects to automatically have the original
+                         // path displayed as helperpath
 
     Inkscape::UI::Widget::Registry wr;
 
@@ -165,11 +162,14 @@ protected:
     bool concatenate_before_pwd2;
 
 private:
+    bool provides_own_flash_paths; // if true, the standard flash path is suppressed
+
+    bool is_ready;
+
     Effect(const Effect&);
     Effect& operator=(const Effect&);
 };
 
-
 } //namespace LivePathEffect
 } //namespace Inkscape