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 | |
| 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')
| -rw-r--r-- | src/live_effects/lpe-curvestitch.cpp | 7 | ||||
| -rw-r--r-- | src/live_effects/lpe-pathalongpath.cpp | 3 | ||||
| -rw-r--r-- | src/live_effects/lpe-skeletalstrokes.cpp | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-vonkoch.cpp | 2 | ||||
| -rw-r--r-- | src/live_effects/parameter/path.cpp | 27 | ||||
| -rw-r--r-- | src/live_effects/parameter/path.h | 16 | ||||
| -rw-r--r-- | src/selection-chemistry.cpp | 2 |
7 files changed, 41 insertions, 18 deletions
diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp index 85d6e5e8f..dc9cfe635 100644 --- a/src/live_effects/lpe-curvestitch.cpp +++ b/src/live_effects/lpe-curvestitch.cpp @@ -80,7 +80,7 @@ LPECurveStitch::doEffect_path (std::vector<Geom::Path> & path_in) startpoint_spacing_variation.resetRandomizer(); endpoint_spacing_variation.resetRandomizer(); - D2<Piecewise<SBasis> > stroke = make_cuts_independant(strokepath); + D2<Piecewise<SBasis> > stroke = make_cuts_independant(strokepath.get_pwd2()); Interval bndsStroke = bounds_exact(stroke[0]); gdouble scaling = bndsStroke.max() - bndsStroke.min(); Interval bndsStrokeY = bounds_exact(stroke[1]); @@ -123,7 +123,7 @@ LPECurveStitch::doEffect_path (std::vector<Geom::Path> & path_in) transform.setXAxis( (end-start) / scaling ); transform.setYAxis( rot90(unit_vector(end-start)) * scaling_y); transform.setTranslation( start ); - Piecewise<D2<SBasis> > pwd2_out = (strokepath-stroke_origin) * transform; + Piecewise<D2<SBasis> > pwd2_out = (strokepath.get_pwd2()-stroke_origin) * transform; // add stuff to one big pw<d2<sbasis> > and then outside the loop convert to path? // No: this way, the separate result paths are kept separate which might come in handy some time! @@ -157,12 +157,13 @@ LPECurveStitch::resetDefaults(SPItem * item) using namespace Geom; // set the stroke path to run horizontally in the middle of the bounding box of the original path + + // calculate bounding box: (isn't there a simpler way?) Piecewise<D2<SBasis> > pwd2; std::vector<Geom::Path> temppath = SVGD_to_2GeomPath( SP_OBJECT_REPR(item)->attribute("inkscape:original-d")); for (unsigned int i=0; i < temppath.size(); i++) { pwd2.concat( temppath[i].toPwSb() ); } - D2<Piecewise<SBasis> > d2pw = make_cuts_independant(pwd2); Interval bndsX = bounds_exact(d2pw[0]); Interval bndsY = bounds_exact(d2pw[1]); diff --git a/src/live_effects/lpe-pathalongpath.cpp b/src/live_effects/lpe-pathalongpath.cpp index 750d78346..0475f4603 100644 --- a/src/live_effects/lpe-pathalongpath.cpp +++ b/src/live_effects/lpe-pathalongpath.cpp @@ -81,7 +81,7 @@ LPEPathAlongPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2 /* Much credit should go to jfb and mgsloan of lib2geom development for the code below! */ - Piecewise<D2<SBasis> > uskeleton = arc_length_parametrization(Piecewise<D2<SBasis> >(bend_path),2,.1); + Piecewise<D2<SBasis> > uskeleton = arc_length_parametrization(Piecewise<D2<SBasis> >(bend_path.get_pwd2()),2,.1); uskeleton = remove_short_cuts(uskeleton,.01); Piecewise<D2<SBasis> > n = rot90(derivative(uskeleton)); n = force_continuity(remove_short_cuts(n,.1)); @@ -123,7 +123,6 @@ LPEPathAlongPath::resetDefaults(SPItem * item) for (unsigned int i=0; i < temppath.size(); i++) { pwd2.concat( temppath[i].toPwSb() ); } - D2<Piecewise<SBasis> > d2pw = make_cuts_independant(pwd2); Interval bndsX = bounds_exact(d2pw[0]); Interval bndsY = bounds_exact(d2pw[1]); diff --git a/src/live_effects/lpe-skeletalstrokes.cpp b/src/live_effects/lpe-skeletalstrokes.cpp index 0f8e013b8..77c5a75c8 100644 --- a/src/live_effects/lpe-skeletalstrokes.cpp +++ b/src/live_effects/lpe-skeletalstrokes.cpp @@ -103,7 +103,7 @@ LPESkeletalStrokes::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pw Piecewise<D2<SBasis> > n = rot90(derivative(uskeleton)); n = force_continuity(remove_short_cuts(n,.1)); - D2<Piecewise<SBasis> > patternd2 = make_cuts_independant(pattern); + D2<Piecewise<SBasis> > patternd2 = make_cuts_independant(pattern.get_pwd2()); Piecewise<SBasis> x = vertical_pattern.get_value() ? Piecewise<SBasis>(patternd2[1]) : Piecewise<SBasis>(patternd2[0]); Piecewise<SBasis> y = vertical_pattern.get_value() ? Piecewise<SBasis>(patternd2[0]) : Piecewise<SBasis>(patternd2[1]); Interval pattBndsX = bounds_exact(x); diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index cb5ea126c..760295ed7 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -79,7 +79,7 @@ std::vector<Geom::Path> LPEVonKoch::doEffect_path (std::vector<Geom::Path> & path_in) { using namespace Geom; - std::vector<Geom::Path> generating_path = path_from_piecewise(generator,.01);//TODO what should that tolerance be? + std::vector<Geom::Path> generating_path = path_from_piecewise(generator.get_pwd2(),.01);//TODO what should that tolerance be? //Collect transform matrices. //FIXME: fusing/cutting nodes mix up component order in the path. This is why the last segment is used. 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&); }; diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 81af6512a..e40746061 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1178,7 +1178,7 @@ void sp_selection_copy_lpe_pathparam(Inkscape::LivePathEffect::PathParam * pathp clipboard = g_slist_prepend(clipboard, newnode); - Geom::Rect bnds = Geom::bounds_exact(*pathparam); + Geom::Rect bnds = Geom::bounds_exact(pathparam->get_pwd2()); size_clipboard = from_2geom(bnds); } |
