Code

LPE: implement NEW path-along-path effect, i think that old one has become obsolete...
[inkscape.git] / src / live_effects / effect.h
1 #ifndef INKSCAPE_LIVEPATHEFFECT_H
2 #define INKSCAPE_LIVEPATHEFFECT_H
4 /*
5  * Inkscape::LivePathEffect
6  *
7 * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  */
13 #include "display/display-forward.h"
14 #include <map>
15 #include <glibmm/ustring.h>
16 #include <2geom/path.h>
17 #include "ui/widget/registry.h"
18 #include "util/enums.h"
20 #define  LPE_CONVERSION_TOLERANCE 0.01    // FIXME: find good solution for this.
22 //#define LPE_ENABLE_TEST_EFFECTS
24 struct SPDocument;
25 struct SPDesktop;
26 struct SPItem;
27 class NArtBpath;
28 struct LivePathEffectObject;
30 namespace Gtk {
31     class Widget;
32     class VBox;
33     class Tooltips;
34 }
36 namespace Inkscape {
38 namespace XML {
39     class Node;
40 }
42 namespace LivePathEffect {
44 enum EffectType {
45     PATH_ALONG_PATH = 0,
46     SKELETAL_STROKES,
47 #ifdef LPE_ENABLE_TEST_EFFECTS
48     SLANT,
49     DOEFFECTSTACK_TEST,
50 #endif
51     GEARS,
52     CURVE_STITCH,
53     INVALID_LPE // This must be last
54 };
56 extern const Util::EnumData<EffectType> LPETypeData[INVALID_LPE];
57 extern const Util::EnumDataConverter<EffectType> LPETypeConverter;
59 class Parameter;
61 class Effect {
62 public:
63     static Effect* New(EffectType lpenr, LivePathEffectObject *lpeobj);
65     virtual ~Effect();
67     virtual void doEffect (SPCurve * curve);
69     virtual Gtk::Widget * getWidget();
71     virtual void resetDefaults(SPItem * item);
73     Glib::ustring          getName();
74     Inkscape::XML::Node *  getRepr();
75     SPDocument *           getSPDoc();
76     LivePathEffectObject * getLPEObj() {return lpeobj;};
78     void readallParameters(Inkscape::XML::Node * repr);
79     void setParameter(const gchar * key, const gchar * new_value);
81     void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
83     bool straight_original_path;
85 protected:
86     Effect(LivePathEffectObject *lpeobject);
88     // provide a set of doEffect functions so the developer has a choice 
89     // of what kind of input/output parameters he desires.
90     // the order in which they appear is the order in which they are 
91     // called by this base class. (i.e. doEffect(SPCurve * curve) defaults to calling
92     // doEffect(std::vector<Geom::Path> )
93     virtual NArtBpath *
94             doEffect (NArtBpath * path_in);
95     virtual std::vector<Geom::Path> 
96             doEffect (std::vector<Geom::Path> & path_in);
97     virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > 
98             doEffect (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in);
100     void registerParameter(Parameter * param);
101     Parameter * getNextOncanvasEditableParam();
103     typedef std::map<Glib::ustring, Parameter *> param_map_type;
104     param_map_type param_map;
106     Inkscape::UI::Widget::Registry wr; 
107     Gtk::VBox * vbox;
108     Gtk::Tooltips * tooltips;
110     LivePathEffectObject *lpeobj;
112     param_map_type::iterator oncanvasedit_it;
114 private:
115     Effect(const Effect&);
116     Effect& operator=(const Effect&);
117 };
120 } //namespace LivePathEffect
121 } //namespace Inkscape
123 #endif