844a158b59ca9e59ccf1f2aa1b62b2c7386d9e69
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 SKELETAL_STROKES = 0,
46 #ifdef LPE_ENABLE_TEST_EFFECTS
47 SLANT,
48 DOEFFECTSTACK_TEST,
49 #endif
50 GEARS,
51 CURVE_STITCH,
52 INVALID_LPE // This must be last
53 };
55 extern const Util::EnumData<EffectType> LPETypeData[INVALID_LPE];
56 extern const Util::EnumDataConverter<EffectType> LPETypeConverter;
58 class Parameter;
60 class Effect {
61 public:
62 virtual ~Effect();
64 Glib::ustring getName();
66 virtual void doEffect (SPCurve * curve);
68 static Effect* New(EffectType lpenr, LivePathEffectObject *lpeobj);
70 virtual Gtk::Widget * getWidget();
72 Inkscape::XML::Node * getRepr();
73 SPDocument * getSPDoc();
74 LivePathEffectObject * getLPEObj() {return lpeobj;};
76 void readallParameters(Inkscape::XML::Node * repr);
77 void setParameter(const gchar * key, const gchar * new_value);
79 void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
81 protected:
82 Effect(LivePathEffectObject *lpeobject);
84 // provide a set of doEffect functions so the developer has a choice
85 // of what kind of input/output parameters he desires.
86 // the order in which they appear is the order in which they are
87 // called by this base class. (i.e. doEffect(SPCurve * curve) defaults to calling
88 // doEffect(std::vector<Geom::Path> )
89 virtual NArtBpath *
90 doEffect (NArtBpath * path_in);
91 virtual std::vector<Geom::Path>
92 doEffect (std::vector<Geom::Path> & path_in);
93 virtual Geom::Piecewise<Geom::D2<Geom::SBasis> >
94 doEffect (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in);
96 void registerParameter(Parameter * param);
97 Parameter * getNextOncanvasEditableParam();
99 typedef std::map<Glib::ustring, Parameter *> param_map_type;
100 param_map_type param_map;
102 Inkscape::UI::Widget::Registry wr;
103 Gtk::VBox * vbox;
104 Gtk::Tooltips * tooltips;
106 LivePathEffectObject *lpeobj;
108 param_map_type::iterator oncanvasedit_it;
110 private:
111 Effect(const Effect&);
112 Effect& operator=(const Effect&);
113 };
116 } //namespace LivePathEffect
117 } //namespace Inkscape
119 #endif