b5c1d6aeb2dd6bb80992aede8105ce3479dfca28
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 BEND_PATH = 0,
55 PATTERN_ALONG_PATH,
56 SKETCH,
57 VONKOCH,
58 KNOT,
59 #ifdef LPE_ENABLE_TEST_EFFECTS
60 DOEFFECTSTACK_TEST,
61 #endif
62 GEARS,
63 CURVE_STITCH,
64 CIRCLE_WITH_RADIUS,
65 PERSPECTIVE_PATH,
66 SPIRO,
67 CONSTRUCT_GRID,
68 ENVELOPE,
69 PERP_BISECTOR,
70 INVALID_LPE // This must be last
71 };
73 extern const Util::EnumData<EffectType> LPETypeData[INVALID_LPE];
74 extern const Util::EnumDataConverter<EffectType> LPETypeConverter;
76 class Parameter;
78 class Effect {
79 public:
80 static Effect* New(EffectType lpenr, LivePathEffectObject *lpeobj);
82 virtual ~Effect();
84 EffectType effectType ();
86 virtual void doOnApply (SPLPEItem *lpeitem);
88 virtual void doBeforeEffect (SPLPEItem *lpeitem);
90 virtual void doEffect (SPCurve * curve);
92 virtual Gtk::Widget * newWidget(Gtk::Tooltips * tooltips);
94 virtual void resetDefaults(SPItem * item);
96 virtual void setup_nodepath(Inkscape::NodePath::Path *np);
98 virtual void transform_multiply(Geom::Matrix const& postmul, bool set);
100 Glib::ustring getName();
101 Inkscape::XML::Node * getRepr();
102 SPDocument * getSPDoc();
103 LivePathEffectObject * getLPEObj() {return lpeobj;};
104 Parameter * getParameter(const char * key);
106 void readallParameters(Inkscape::XML::Node * repr);
107 void setParameter(const gchar * key, const gchar * new_value);
109 void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
111 protected:
112 Effect(LivePathEffectObject *lpeobject);
114 // provide a set of doEffect functions so the developer has a choice
115 // of what kind of input/output parameters he desires.
116 // the order in which they appear is the order in which they are
117 // called by this base class. (i.e. doEffect(SPCurve * curve) defaults to calling
118 // doEffect(std::vector<Geom::Path> )
119 virtual NArtBpath *
120 doEffect_nartbpath (NArtBpath const * path_in) __attribute__ ((deprecated));
121 virtual std::vector<Geom::Path>
122 doEffect_path (std::vector<Geom::Path> const & path_in);
123 virtual Geom::Piecewise<Geom::D2<Geom::SBasis> >
124 doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
126 void registerParameter(Parameter * param);
127 Parameter * getNextOncanvasEditableParam();
129 std::vector<Parameter *> param_vector;
130 int oncanvasedit_it;
131 Inkscape::UI::Widget::Registry wr;
133 LivePathEffectObject *lpeobj;
135 // this boolean defaults to false, it concatenates the input path to one pwd2,
136 // instead of normally 'splitting' the path into continuous pwd2 paths.
137 bool concatenate_before_pwd2;
139 private:
140 Effect(const Effect&);
141 Effect& operator=(const Effect&);
142 };
145 } //namespace LivePathEffect
146 } //namespace Inkscape
148 #endif