diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2008-03-23 19:23:08 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2008-03-23 19:23:08 +0000 |
| commit | d788700346e4aa68855180315d5120728f2e4bdd (patch) | |
| tree | 3f7ea2876d9486dbd5f7cd8dca9b8d6eabeafae8 /src/live_effects/parameter | |
| parent | expand visual bbox for item with a filter (diff) | |
| download | inkscape-d788700346e4aa68855180315d5120728f2e4bdd.tar.gz inkscape-d788700346e4aa68855180315d5120728f2e4bdd.zip | |
remove multiple inheritance from lpe PathParam. since it is often desired to get the path not as pw< d2<> >, but also as geom::path or maybe as dw< pw<> >. Plus this enabled linking to an object, instead of keeping its own path data. (i.e. linking to other objects)
(bzr r5176)
Diffstat (limited to 'src/live_effects/parameter')
| -rw-r--r-- | src/live_effects/parameter/path.cpp | 27 | ||||
| -rw-r--r-- | src/live_effects/parameter/path.h | 16 |
2 files changed, 33 insertions, 10 deletions
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index ded004eee..944fe3da7 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -40,7 +40,9 @@ namespace LivePathEffect { PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, const gchar * default_value) - : Parameter(label, tip, key, wr, effect) + : Parameter(label, tip, key, wr, effect), + _pwd2(), + referring(false) { defvalue = g_strdup(default_value); param_readSVGValue(defvalue); @@ -52,6 +54,19 @@ PathParam::~PathParam() g_free(defvalue); } +Geom::Piecewise<Geom::D2<Geom::SBasis> > & +PathParam::get_pwd2() +{ + if (!referring) { + return _pwd2; + } else { + /* update own pwd2 with data from path referred to + when this works, optimize to only update own pwd2 when referred path changed. */ + //_pwd2 = ...; + return _pwd2; + } +} + void PathParam::param_set_default() { @@ -73,7 +88,7 @@ PathParam::param_readSVGValue(const gchar * strvalue) for (unsigned int i=0; i < temppath.size(); i++) { newpath.concat( temppath[i].toPwSb() ); } - *( dynamic_cast<Geom::Piecewise<Geom::D2<Geom::SBasis> > *> (this) ) = newpath; + _pwd2 = newpath; signal_path_changed.emit(); return true; } @@ -85,7 +100,7 @@ gchar * PathParam::param_writeSVGValue() const { const std::vector<Geom::Path> temppath = - Geom::path_from_piecewise(* dynamic_cast<const Geom::Piecewise<Geom::D2<Geom::SBasis> > *> (this), LPE_CONVERSION_TOLERANCE); + Geom::path_from_piecewise(_pwd2, LPE_CONVERSION_TOLERANCE); gchar * svgd = SVGD_from_2GeomPath( temppath ); return svgd; } @@ -157,11 +172,13 @@ PathParam::param_setup_nodepath(Inkscape::NodePath::Path *np) void PathParam::param_transform_multiply(Geom::Matrix const& postmul, bool /*set*/) { - param_set_and_write_new_value( (*this) * postmul ); + // only apply transform when not referring to other path + if (!referring) + param_set_and_write_new_value( _pwd2 * postmul ); } void -PathParam::param_set_and_write_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > newpath) +PathParam::param_set_and_write_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & newpath) { const std::vector<Geom::Path> temppath = Geom::path_from_piecewise(newpath, LPE_CONVERSION_TOLERANCE); gchar * svgd = SVGD_from_2GeomPath( temppath ); diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h index 0bb65b77c..838543cd9 100644 --- a/src/live_effects/parameter/path.h +++ b/src/live_effects/parameter/path.h @@ -22,7 +22,7 @@ namespace Inkscape { namespace LivePathEffect { -class PathParam : public Geom::Piecewise<Geom::D2<Geom::SBasis> >, public Parameter { +class PathParam : public Parameter { public: PathParam ( const Glib::ustring& label, const Glib::ustring& tip, @@ -32,6 +32,8 @@ public: const gchar * default_value = "M0,0 L1,1"); virtual ~PathParam(); + Geom::Piecewise<Geom::D2<Geom::SBasis> > & get_pwd2(); + virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * tooltips); bool param_readSVGValue(const gchar * strvalue); @@ -39,7 +41,7 @@ public: void param_set_default(); void param_set_and_write_default(); - void param_set_and_write_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > newpath); + void param_set_and_write_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & newpath); virtual void param_editOncanvas(SPItem * item, SPDesktop * dt); virtual void param_setup_nodepath(Inkscape::NodePath::Path *np); @@ -49,15 +51,19 @@ public: sigc::signal <void> signal_path_pasted; sigc::signal <void> signal_path_changed; -private: - PathParam(const PathParam&); - PathParam& operator=(const PathParam&); +protected: + Geom::Piecewise<Geom::D2<Geom::SBasis> > _pwd2; + bool referring; // set when referring to another path, i.e. does not have its own pwd2, but should get it from another path void on_edit_button_click(); void on_paste_button_click(); void on_copy_button_click(); gchar * defvalue; + +private: + PathParam(const PathParam&); + PathParam& operator=(const PathParam&); }; |
