Code

535cec0b6c12ea92830e723b3a7ae05b88de31bc
[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-2008 <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 Geom {
37     class Matrix;
38 }
40 namespace Inkscape {
42 namespace XML {
43     class Node;
44 }
46 namespace NodePath {
47     class Path ;
48 }
50 namespace LivePathEffect {
52 enum EffectType {
53     PATH_ALONG_PATH = 0,
54     SKELETAL_STROKES,
55 #ifdef LPE_ENABLE_TEST_EFFECTS
56     SLANT,
57     DOEFFECTSTACK_TEST,
58 #endif
59     GEARS,
60     CURVE_STITCH,
61     INVALID_LPE // This must be last
62 };
64 extern const Util::EnumData<EffectType> LPETypeData[INVALID_LPE];
65 extern const Util::EnumDataConverter<EffectType> LPETypeConverter;
67 class Parameter;
69 class Effect {
70 public:
71     static Effect* New(EffectType lpenr, LivePathEffectObject *lpeobj);
73     virtual ~Effect();
75     virtual void doEffect (SPCurve * curve);
77     virtual Gtk::Widget * getWidget();
79     virtual void resetDefaults(SPItem * item);
81     virtual void setup_nodepath(Inkscape::NodePath::Path *np);
83     virtual void transform_multiply(Geom::Matrix const& postmul, bool set);
85     Glib::ustring          getName();
86     Inkscape::XML::Node *  getRepr();
87     SPDocument *           getSPDoc();
88     LivePathEffectObject * getLPEObj() {return lpeobj;};
89     Parameter *            getParameter(const char * key);
91     void readallParameters(Inkscape::XML::Node * repr);
92     void setParameter(const gchar * key, const gchar * new_value);
94     void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
96 protected:
97     Effect(LivePathEffectObject *lpeobject);
99     // provide a set of doEffect functions so the developer has a choice
100     // of what kind of input/output parameters he desires.
101     // the order in which they appear is the order in which they are
102     // called by this base class. (i.e. doEffect(SPCurve * curve) defaults to calling
103     // doEffect(std::vector<Geom::Path> )
104     virtual NArtBpath *
105             doEffect_nartbpath (NArtBpath * path_in);
106     virtual std::vector<Geom::Path>
107             doEffect_path (std::vector<Geom::Path> & path_in);
108     virtual Geom::Piecewise<Geom::D2<Geom::SBasis> >
109             doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in);
111     void registerParameter(Parameter * param);
112     Parameter * getNextOncanvasEditableParam();
114     std::vector<Parameter *> param_vector;
115     int oncanvasedit_it;
118     Inkscape::UI::Widget::Registry wr;
119     Gtk::VBox * vbox;
120     Gtk::Tooltips * tooltips;
122     LivePathEffectObject *lpeobj;
124 private:
125     Effect(const Effect&);
126     Effect& operator=(const Effect&);
127 };
130 } //namespace LivePathEffect
131 } //namespace Inkscape
133 #endif