Code

5169ff22f5d6345239138627e044244fecb1917c
[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 SPShape;
25 struct SPDocument;
26 class NArtBpath;
27 struct LivePathEffectObject;
29 namespace Gtk {
30     class Widget;
31     class VBox;
32     class Tooltips;
33 }
35 namespace Inkscape {
37 namespace XML {
38     class Node;
39 }
41 namespace LivePathEffect {
43 enum EffectType {
44     SKELETAL_STROKES = 0,
45 #ifdef LPE_ENABLE_TEST_EFFECTS
46     SLANT,
47     DOEFFECTSTACK_TEST,
48 #endif
49     GEARS,
50     CURVE_STITCH,
51     INVALID_LPE // This must be last
52 };
54 extern const Util::EnumData<EffectType> LPETypeData[INVALID_LPE];
55 extern const Util::EnumDataConverter<EffectType> LPETypeConverter;
57 class Parameter;
59 class Effect {
60 public:
61     virtual ~Effect();
63     Glib::ustring getName();
65     virtual void doEffect (SPCurve * curve);
67     static Effect* New(EffectType lpenr, LivePathEffectObject *lpeobj);
69     virtual Gtk::Widget * getWidget();
71     Inkscape::XML::Node * getRepr();
72     SPDocument * getSPDoc();
74     void readallParameters(Inkscape::XML::Node * repr);
75     void setParameter(Inkscape::XML::Node * repr, const gchar * key, const gchar * old_value, const gchar * new_value);
77 protected:
78     Effect(LivePathEffectObject *lpeobject);
80     // provide a set of doEffect functions so the developer has a choice 
81     // of what kind of input/output parameters he desires.
82     // the order in which they appear is the order in which they are 
83     // called by this base class. (i.e. doEffect(SPCurve * curve) defaults to calling
84     // doEffect(std::vector<Geom::Path> )
85     virtual NArtBpath *
86             doEffect (NArtBpath * path_in);
87     virtual std::vector<Geom::Path> 
88             doEffect (std::vector<Geom::Path> & path_in);
89     virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > 
90             doEffect (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in);
92     void registerParameter(Parameter * param);
94     typedef std::map<Glib::ustring, Parameter *> param_map_type;
95     param_map_type param_map;
97     Inkscape::UI::Widget::Registry wr; 
98     Gtk::VBox * vbox;
99     Gtk::Tooltips * tooltips;
101     LivePathEffectObject *lpeobj;
103 private:
104     Effect(const Effect&);
105     Effect& operator=(const Effect&);
106 };
109 } //namespace LivePathEffect
110 } //namespace Inkscape
112 #endif