Code

Rename LPE: mirror reflect --> mirror symmetry
[inkscape.git] / src / live_effects / effect.h
index 98cb746c5f1d41327429195d316583e2dbdc0f34..dc5d6ec4a1fb6fcdfa18be85b71fcb5123daa13b 100644 (file)
@@ -4,7 +4,7 @@
 /*
  * Inkscape::LivePathEffect
  *
-* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+* Copyright (C) Johan Engelen 2007-2008 <j.b.c.engelen@utwente.nl>
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
 #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"
 
 #define  LPE_CONVERSION_TOLERANCE 0.01    // FIXME: find good solution for this.
 
-//#define LPE_ENABLE_TEST_EFFECTS
+#define LPE_ENABLE_TEST_EFFECTS
 
 struct SPDocument;
 struct SPDesktop;
 struct SPItem;
+class SPNodeContext;
 class NArtBpath;
 struct LivePathEffectObject;
 
@@ -46,34 +51,88 @@ namespace NodePath {
 namespace LivePathEffect {
 
 enum EffectType {
-    PATH_ALONG_PATH = 0,
-    SKELETAL_STROKES,
+    BEND_PATH = 0,
+    PATTERN_ALONG_PATH,
+    SKETCH,
+    VONKOCH,
+    KNOT,
 #ifdef LPE_ENABLE_TEST_EFFECTS
-    SLANT,
     DOEFFECTSTACK_TEST,
 #endif
     GEARS,
     CURVE_STITCH,
+    CIRCLE_WITH_RADIUS,
+    PERSPECTIVE_PATH,
+    SPIRO,
+    LATTICE,
+    ENVELOPE,
+    CONSTRUCT_GRID,
+    PERP_BISECTOR,
+    TANGENT_TO_CURVE,
+    MIRROR_SYMMETRY,
+    CIRCLE_3PTS,
+    ANGLE_BISECTOR,
+    PARALLEL,
+    COPY_ROTATE,
+    OFFSET,
     INVALID_LPE // This must be last
 };
 
 extern const Util::EnumData<EffectType> LPETypeData[INVALID_LPE];
 extern const Util::EnumDataConverter<EffectType> LPETypeConverter;
 
-class Parameter;
+enum LPEPathFlashType {
+    SUPPRESS_FLASH,
+//    PERMANENT_FLASH,
+    DEFAULT
+};
 
 class Effect {
 public:
     static Effect* New(EffectType lpenr, LivePathEffectObject *lpeobj);
+    static void createAndApply(const char* name, SPDocument *doc, SPItem *item);
+    static void createAndApply(EffectType type, SPDocument *doc, SPItem *item);
 
     virtual ~Effect();
 
+    EffectType effectType ();
+
+    virtual void doOnApply (SPLPEItem *lpeitem);
+    virtual void doBeforeEffect (SPLPEItem *lpeitem);
+
+    void writeParamsToSVG();
+
+    virtual void acceptParamPath (SPPath *param_path);
+    virtual int acceptsNumParams() { return 0; }
+    void doAcceptPathPreparations(SPLPEItem *lpeitem);
+
+    inline bool pathParamAccepted() { return done_pathparam_set; }
+
     virtual void doEffect (SPCurve * curve);
 
-    virtual Gtk::Widget * getWidget();
+    virtual Gtk::Widget * newWidget(Gtk::Tooltips * tooltips);
 
     virtual void resetDefaults(SPItem * item);
 
+    virtual void setup_nodepath(Inkscape::NodePath::Path *np);
+
+    virtual void transform_multiply(Geom::Matrix const& postmul, bool set);
+
+    // 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);
+    void addPointParamHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
+
+    void addHelperPaths(SPLPEItem *lpeitem, SPDesktop *desktop);
+    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();
     SPDocument *           getSPDoc();
@@ -83,39 +142,49 @@ public:
     void readallParameters(Inkscape::XML::Node * repr);
     void setParameter(const gchar * key, const gchar * new_value);
 
-    void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
+    inline bool isVisible() { return is_visible; }
 
-    virtual void setup_notepath(Inkscape::NodePath::Path *np);
+    void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
 
 protected:
     Effect(LivePathEffectObject *lpeobject);
 
-    // provide a set of doEffect functions so the developer has a choice 
+    // provide a set of doEffect functions so the developer has a choice
     // of what kind of input/output parameters he desires.
-    // the order in which they appear is the order in which they are 
+    // the order in which they appear is the order in which they are
     // called by this base class. (i.e. doEffect(SPCurve * curve) defaults to calling
     // doEffect(std::vector<Geom::Path> )
-    virtual NArtBpath *
-            doEffect_nartbpath (NArtBpath * path_in);
-    virtual std::vector<Geom::Path> 
-            doEffect_path (std::vector<Geom::Path> & path_in);
-    virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > 
-            doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in);
+    virtual std::vector<Geom::Path>
+            doEffect_path (std::vector<Geom::Path> const & path_in);
+    virtual Geom::Piecewise<Geom::D2<Geom::SBasis> >
+            doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
 
     void registerParameter(Parameter * param);
+    void registerKnotHolderHandle(KnotHolderEntity* entity, const char* descr);
     Parameter * getNextOncanvasEditableParam();
 
+    virtual void addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop);
+
     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; 
-    Gtk::VBox * vbox;
-    Gtk::Tooltips * tooltips;
+    Inkscape::UI::Widget::Registry wr;
 
     LivePathEffectObject *lpeobj;
 
+    // this boolean defaults to false, it concatenates the input path to one pwd2,
+    // instead of normally 'splitting' the path into continuous pwd2 paths.
+    bool concatenate_before_pwd2;
+
 private:
+    bool provides_own_flash_paths; // if true, the standard flash path is suppressed
+
     Effect(const Effect&);
     Effect& operator=(const Effect&);
 };
@@ -125,3 +194,14 @@ private:
 } //namespace Inkscape
 
 #endif
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+  indent-tabs-mode:nil
+  fill-column:99
+  End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :