summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2008-06-10 12:35:36 +0000
committercilix42 <cilix42@users.sourceforge.net>2008-06-10 12:35:36 +0000
commit9df0d95cbecfc05c9c4fbe7bd51a6b744c5c56a5 (patch)
tree7f79bec201fa7fac6dab847dcf497091ad174404 /src
parentfix compile (diff)
downloadinkscape-9df0d95cbecfc05c9c4fbe7bd51a6b744c5c56a5.tar.gz
inkscape-9df0d95cbecfc05c9c4fbe7bd51a6b744c5c56a5.zip
Write all effect parameters to SVG when a LPE knotholder handle is ungrabbed
(bzr r5870)
Diffstat (limited to 'src')
-rw-r--r--src/knot-holder-entity.h3
-rw-r--r--src/knotholder.cpp12
-rw-r--r--src/live_effects/effect.cpp10
-rw-r--r--src/live_effects/effect.h1
-rw-r--r--src/live_effects/lpe-perp_bisector.cpp16
-rw-r--r--src/live_effects/lpe-tangent_to_curve.cpp24
-rw-r--r--src/live_effects/lpeobject.cpp2
7 files changed, 26 insertions, 42 deletions
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<KnotHolderEntity *>::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<Inkscape::LivePathEffect::Parameter *>::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);