From: cilix42 Date: Tue, 10 Jun 2008 12:35:36 +0000 (+0000) Subject: Write all effect parameters to SVG when a LPE knotholder handle is ungrabbed X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=97a20864afec63a0b7bb757b628ee2ae596cf648;p=inkscape.git Write all effect parameters to SVG when a LPE knotholder handle is ungrabbed --- diff --git a/src/knot-holder-entity.h b/src/knot-holder-entity.h index f0862c874..ea90c4254 100644 --- a/src/knot-holder-entity.h +++ b/src/knot-holder-entity.h @@ -52,8 +52,7 @@ public: virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state) = 0; virtual NR::Point knot_get() = 0; virtual void knot_click(guint /*state*/) {} - virtual void onKnotUngrabbed() {} // this is called 'manually' from KnotHolder; would it be - // more efficient to establish another signal connection? + virtual void onKnotUngrabbed() {} void update_knot(); diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 1ca280d48..f78198275 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -29,6 +29,7 @@ #include "box3d.h" #include "sp-pattern.h" #include "style.h" +#include "live_effects/lpeobject.h" #include "xml/repr.h" // for debugging only @@ -165,6 +166,17 @@ KnotHolder::knot_ungrabbed_handler(SPKnot *knot) /* do cleanup tasks (e.g., for LPE items write the parameter values * that were changed by dragging the handle to SVG) */ + if (SP_IS_LPE_ITEM(item)) { + // This writes all parameters to SVG. Is this sufficiently efficient or should we only write + // the ones that were changed (e.g., via the individual handles' onKnotUngrabbed() method? + Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); + if (lpe) { + LivePathEffectObject *lpeobj = lpe->getLPEObj(); + SP_OBJECT(lpeobj)->updateRepr(); + } + } + // this was once used to write individual parameter values to SVG but this is now done globally above; + // we leave the calls to onKnotUngrabbed, anyway, in case any other cleanup tasks need to be done for(std::list::iterator i = this->entity.begin(); i != this->entity.end(); ++i) { KnotHolderEntity *e = *i; if (e->knot == knot) { diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index b08077e79..de41d6a59 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -215,6 +215,16 @@ Effect::doBeforeEffect (SPLPEItem */*lpeitem*/) } +void +Effect::writeParamsToSVG() { + g_print ("Parameters get written to SVG\n"); + std::vector::iterator p; + for (p = param_vector.begin(); p != param_vector.end(); ++p) { + g_print ("writing parameter %s to SVG\n", (*p)->param_key.c_str()); + (*p)->write_to_SVG(); + } +} + /* * Here be the doEffect function chain: */ diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index f0d0ffdd5..b78e931f9 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -96,6 +96,7 @@ public: virtual void doOnApply (SPLPEItem *lpeitem); virtual void doBeforeEffect (SPLPEItem *lpeitem); + void writeParamsToSVG(); virtual void doEffect (SPCurve * curve); diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp index 9c7ed0a7e..a7963ce7b 100644 --- a/src/live_effects/lpe-perp_bisector.cpp +++ b/src/live_effects/lpe-perp_bisector.cpp @@ -32,7 +32,6 @@ public: virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state); virtual NR::Point knot_get(); - virtual void onKnotUngrabbed(); }; class KnotHolderEntityRightEnd : public KnotHolderEntity @@ -42,7 +41,6 @@ public: virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state); virtual NR::Point knot_get(); - virtual void onKnotUngrabbed(); }; // TODO: Make this more generic @@ -100,20 +98,6 @@ KnotHolderEntityRightEnd::knot_set(NR::Point const &p, NR::Point const &/*origin bisector_end_set(item, p, false); } -void -KnotHolderEntityLeftEnd::onKnotUngrabbed() -{ - LPEPerpBisector *lpe = get_effect(item); - lpe->length_left.write_to_SVG(); -} - -void -KnotHolderEntityRightEnd::onKnotUngrabbed() -{ - LPEPerpBisector *lpe = get_effect(item); - lpe->length_right.write_to_SVG(); -} - /** NR::Point path_start_get(SPItem *item) { Inkscape::LivePathEffect::LPEPerpBisector *lpe = diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp index 6fc7161ed..2115e9d7e 100644 --- a/src/live_effects/lpe-tangent_to_curve.cpp +++ b/src/live_effects/lpe-tangent_to_curve.cpp @@ -36,7 +36,6 @@ public: virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state); virtual NR::Point knot_get(); - virtual void onKnotUngrabbed(); }; class KnotHolderEntityLeftEnd : public KnotHolderEntity @@ -46,7 +45,6 @@ public: virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state); virtual NR::Point knot_get(); - virtual void onKnotUngrabbed(); }; class KnotHolderEntityRightEnd : public KnotHolderEntity @@ -56,7 +54,6 @@ public: virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state); virtual NR::Point knot_get(); - virtual void onKnotUngrabbed(); }; } // namespace TtC @@ -183,27 +180,6 @@ KnotHolderEntityRightEnd::knot_get() return lpe->D; } -void -KnotHolderEntityAttachPt::onKnotUngrabbed() -{ - LPETangentToCurve *lpe = get_effect(item); - lpe->t_attach.write_to_SVG(); -} - -void -KnotHolderEntityLeftEnd::onKnotUngrabbed() -{ - LPETangentToCurve *lpe = get_effect(item); - lpe->length_left.write_to_SVG(); -} - -void -KnotHolderEntityRightEnd::onKnotUngrabbed() -{ - LPETangentToCurve *lpe = get_effect(item); - lpe->length_right.write_to_SVG(); -} - } // namespace TtC } //namespace LivePathEffect diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp index 0a7fb5eb0..432a484ee 100644 --- a/src/live_effects/lpeobject.cpp +++ b/src/live_effects/lpeobject.cpp @@ -221,6 +221,8 @@ livepatheffect_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) // lpeobj->lpe->write(repr); something like this. + lpeobj->lpe->writeParamsToSVG(); + if (((SPObjectClass *) livepatheffect_parent_class)->write) (* ((SPObjectClass *) livepatheffect_parent_class)->write)(object, repr, flags);