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"
19 #include "sp-lpe-item.h"
21 #define LPE_CONVERSION_TOLERANCE 0.01 // FIXME: find good solution for this.
23 #define LPE_ENABLE_TEST_EFFECTS
25 struct SPDocument;
26 struct SPDesktop;
27 struct SPItem;
28 class NArtBpath;
29 struct LivePathEffectObject;
31 namespace Gtk {
32 class Widget;
33 class VBox;
34 class Tooltips;
35 }
37 namespace Geom {
38 class Matrix;
39 }
41 namespace Inkscape {
43 namespace XML {
44 class Node;
45 }
47 namespace NodePath {
48 class Path ;
49 }
51 namespace LivePathEffect {
53 enum EffectType {
54 PATH_ALONG_PATH = 0,
55 SKELETAL_STROKES,
56 SKETCH,
57 VONKOCH,
58 KNOT,
59 #ifdef LPE_ENABLE_TEST_EFFECTS
60 SLANT,
61 DOEFFECTSTACK_TEST,
62 #endif
63 GEARS,
64 CURVE_STITCH,
65 INVALID_LPE // This must be last
66 };
68 extern const Util::EnumData<EffectType> LPETypeData[INVALID_LPE];
69 extern const Util::EnumDataConverter<EffectType> LPETypeConverter;
71 class Parameter;
73 class Effect {
74 public:
75 static Effect* New(EffectType lpenr, LivePathEffectObject *lpeobj);
77 virtual ~Effect();
79 virtual void doBeforeEffect (SPLPEItem *lpeitem);
81 virtual void doEffect (SPCurve * curve);
83 virtual Gtk::Widget * newWidget(Gtk::Tooltips * tooltips);
85 virtual void resetDefaults(SPItem * item);
87 virtual void setup_nodepath(Inkscape::NodePath::Path *np);
89 virtual void transform_multiply(Geom::Matrix const& postmul, bool set);
91 Glib::ustring getName();
92 Inkscape::XML::Node * getRepr();
93 SPDocument * getSPDoc();
94 LivePathEffectObject * getLPEObj() {return lpeobj;};
95 Parameter * getParameter(const char * key);
97 void readallParameters(Inkscape::XML::Node * repr);
98 void setParameter(const gchar * key, const gchar * new_value);
100 void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
102 protected:
103 Effect(LivePathEffectObject *lpeobject);
105 // provide a set of doEffect functions so the developer has a choice
106 // of what kind of input/output parameters he desires.
107 // the order in which they appear is the order in which they are
108 // called by this base class. (i.e. doEffect(SPCurve * curve) defaults to calling
109 // doEffect(std::vector<Geom::Path> )
110 virtual NArtBpath *
111 doEffect_nartbpath (NArtBpath * path_in);
112 virtual std::vector<Geom::Path>
113 doEffect_path (std::vector<Geom::Path> & path_in);
114 virtual Geom::Piecewise<Geom::D2<Geom::SBasis> >
115 doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in);
117 void registerParameter(Parameter * param);
118 Parameter * getNextOncanvasEditableParam();
120 std::vector<Parameter *> param_vector;
121 int oncanvasedit_it;
123 Inkscape::UI::Widget::Registry wr;
125 LivePathEffectObject *lpeobj;
127 private:
128 Effect(const Effect&);
129 Effect& operator=(const Effect&);
130 };
133 } //namespace LivePathEffect
134 } //namespace Inkscape
136 #endif