6b5295071724a32f4bf97435104911ae66758b2a
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 SKETCH,
56 VONKOCH,
57 KNOT,
58 #ifdef LPE_ENABLE_TEST_EFFECTS
59 SLANT,
60 DOEFFECTSTACK_TEST,
61 #endif
62 GEARS,
63 CURVE_STITCH,
64 INVALID_LPE // This must be last
65 };
67 extern const Util::EnumData<EffectType> LPETypeData[INVALID_LPE];
68 extern const Util::EnumDataConverter<EffectType> LPETypeConverter;
70 class Parameter;
72 class Effect {
73 public:
74 static Effect* New(EffectType lpenr, LivePathEffectObject *lpeobj);
76 virtual ~Effect();
78 virtual void doEffect (SPCurve * curve);
80 virtual Gtk::Widget * newWidget(Gtk::Tooltips * tooltips);
82 virtual void resetDefaults(SPItem * item);
84 virtual void setup_nodepath(Inkscape::NodePath::Path *np);
86 virtual void transform_multiply(Geom::Matrix const& postmul, bool set);
88 Glib::ustring getName();
89 Inkscape::XML::Node * getRepr();
90 SPDocument * getSPDoc();
91 LivePathEffectObject * getLPEObj() {return lpeobj;};
92 Parameter * getParameter(const char * key);
94 void readallParameters(Inkscape::XML::Node * repr);
95 void setParameter(const gchar * key, const gchar * new_value);
97 void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
99 protected:
100 Effect(LivePathEffectObject *lpeobject);
102 // provide a set of doEffect functions so the developer has a choice
103 // of what kind of input/output parameters he desires.
104 // the order in which they appear is the order in which they are
105 // called by this base class. (i.e. doEffect(SPCurve * curve) defaults to calling
106 // doEffect(std::vector<Geom::Path> )
107 virtual NArtBpath *
108 doEffect_nartbpath (NArtBpath * path_in);
109 virtual std::vector<Geom::Path>
110 doEffect_path (std::vector<Geom::Path> & path_in);
111 virtual Geom::Piecewise<Geom::D2<Geom::SBasis> >
112 doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in);
114 void registerParameter(Parameter * param);
115 Parameter * getNextOncanvasEditableParam();
117 std::vector<Parameter *> param_vector;
118 int oncanvasedit_it;
120 Inkscape::UI::Widget::Registry wr;
122 LivePathEffectObject *lpeobj;
124 private:
125 Effect(const Effect&);
126 Effect& operator=(const Effect&);
127 };
130 } //namespace LivePathEffect
131 } //namespace Inkscape
133 #endif