From a69e3ca5fcc8acacf862c577620d75f472d58cec Mon Sep 17 00:00:00 2001 From: johanengelen Date: Sun, 15 Mar 2009 22:10:43 +0000 Subject: [PATCH] correctly implement 'resetDefaults()' for LPEs. Now when applying an LPE, all default values are written to SVG. This greatly improves future compatibility. --- src/live_effects/effect.cpp | 6 +++++- src/live_effects/effect.h | 3 +++ src/live_effects/lpe-bendpath.cpp | 2 ++ src/live_effects/lpe-curvestitch.cpp | 2 ++ src/live_effects/lpe-envelope.cpp | 2 ++ src/live_effects/lpe-interpolate.cpp | 2 ++ src/live_effects/lpe-lattice.cpp | 2 ++ src/live_effects/lpe-rough-hatches.cpp | 2 ++ src/live_effects/lpe-vonkoch.cpp | 2 ++ 9 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index f67ee28a7..3cdb21d6a 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -647,7 +647,11 @@ Effect::editNextParamOncanvas(SPItem * item, SPDesktop * desktop) void Effect::resetDefaults(SPItem * /*item*/) { - // do nothing for simple effects + std::vector::iterator p; + for (p = param_vector.begin(); p != param_vector.end(); ++p) { + (*p)->param_set_default(); + (*p)->write_to_SVG(); + } } void diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index ae42e358c..702036f14 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -85,6 +85,9 @@ public: virtual Gtk::Widget * newWidget(Gtk::Tooltips * tooltips); + /** + * Sets all parameters to their default values and writes them to SVG. + */ virtual void resetDefaults(SPItem * item); virtual void setup_nodepath(Inkscape::NodePath::Path *np); diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index c3be57981..a820fe478 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -124,6 +124,8 @@ LPEBendPath::doEffect_pwd2 (Geom::Piecewise > const & pwd void LPEBendPath::resetDefaults(SPItem * item) { + Effect::resetDefaults(item); + original_bbox(SP_LPE_ITEM(item)); Geom::Point start(boundingbox_X.min(), (boundingbox_Y.max()+boundingbox_Y.min())/2); diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp index 2716e45d7..89fdef2f0 100644 --- a/src/live_effects/lpe-curvestitch.cpp +++ b/src/live_effects/lpe-curvestitch.cpp @@ -153,6 +153,8 @@ LPECurveStitch::doEffect_path (std::vector const & path_in) void LPECurveStitch::resetDefaults(SPItem * item) { + Effect::resetDefaults(item); + if (!SP_IS_PATH(item)) return; using namespace Geom; diff --git a/src/live_effects/lpe-envelope.cpp b/src/live_effects/lpe-envelope.cpp index 553390585..a730f14ff 100755 --- a/src/live_effects/lpe-envelope.cpp +++ b/src/live_effects/lpe-envelope.cpp @@ -220,6 +220,8 @@ LPEEnvelope::doEffect_pwd2 (Geom::Piecewise > const & pwd void LPEEnvelope::resetDefaults(SPItem * item) { + Effect::resetDefaults(item); + original_bbox(SP_LPE_ITEM(item)); Geom::Point Up_Left(boundingbox_X.min(), boundingbox_Y.min()); diff --git a/src/live_effects/lpe-interpolate.cpp b/src/live_effects/lpe-interpolate.cpp index b2f1547a9..e19d2e6e7 100644 --- a/src/live_effects/lpe-interpolate.cpp +++ b/src/live_effects/lpe-interpolate.cpp @@ -95,6 +95,8 @@ LPEInterpolate::doEffect_path (Geom::PathVector const & path_in) void LPEInterpolate::resetDefaults(SPItem * item) { + Effect::resetDefaults(item); + if (!SP_IS_PATH(item)) return; diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp index f77434f92..0beedb537 100644 --- a/src/live_effects/lpe-lattice.cpp +++ b/src/live_effects/lpe-lattice.cpp @@ -183,6 +183,8 @@ LPELattice::doBeforeEffect (SPLPEItem *lpeitem) void LPELattice::resetDefaults(SPItem * item) { + Effect::resetDefaults(item); + original_bbox(SP_LPE_ITEM(item), false); // place the 16 control points diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index 1bac02ec4..7fa865c01 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -565,6 +565,8 @@ LPERoughHatches::doBeforeEffect (SPLPEItem */*lpeitem*/) void LPERoughHatches::resetDefaults(SPItem * item) { + Effect::resetDefaults(item); + Geom::OptRect bbox = item->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX); Geom::Point origin(0.,0.); Geom::Point vector(50.,0.); diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index 0f105ad60..f18c4011b 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -271,6 +271,8 @@ LPEVonKoch::doBeforeEffect (SPLPEItem *lpeitem) void LPEVonKoch::resetDefaults(SPItem * item) { + Effect::resetDefaults(item); + using namespace Geom; original_bbox(SP_LPE_ITEM(item)); -- 2.30.2