From 442e92e07cfe50f73dda0d06638025a65e23a956 Mon Sep 17 00:00:00 2001 From: johanengelen Date: Sun, 23 Mar 2008 20:29:06 +0000 Subject: [PATCH] prepare PathParam for linking to other object --- src/live_effects/parameter/path.cpp | 48 +++++++++++++++++------------ src/live_effects/parameter/path.h | 2 +- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index c87cff613..12e67693a 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -44,7 +44,7 @@ PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip, _pathvector(), must_recalculate_pwd2(false), _pwd2(), - referring(false) + href(NULL) { defvalue = g_strdup(default_value); param_readSVGValue(defvalue); @@ -59,26 +59,14 @@ PathParam::~PathParam() std::vector const & PathParam::get_pathvector() { - if (!referring) { - return _pathvector; - } else { - update_from_referred(); - must_recalculate_pwd2 = true; - return _pathvector; - } + return _pathvector; } Geom::Piecewise > const & PathParam::get_pwd2() { - if (!referring) { - ensure_pwd2(); - return _pwd2; - } else { - update_from_referred(); - ensure_pwd2(); - return _pwd2; - } + ensure_pwd2(); + return _pwd2; } void @@ -98,9 +86,20 @@ PathParam::param_readSVGValue(const gchar * strvalue) { if (strvalue) { _pathvector.clear(); - _pathvector = SVGD_to_2GeomPath(strvalue); + if (href) { + g_free(href); + href = NULL; + } must_recalculate_pwd2 = true; + if (false /*if strvalue is xlink*/) { + href = g_strdup(strvalue); + update_from_referred(); + // TODO: add listener, because we must update when referred updates. we must always be up-to-date with referred path data + } else { + _pathvector = SVGD_to_2GeomPath(strvalue); + } + signal_path_changed.emit(); return true; } @@ -168,7 +167,11 @@ PathParam::param_editOncanvas(SPItem * item, SPDesktop * dt) } ShapeEditor * shape_editor = SP_NODE_CONTEXT( dt->event_context )->shape_editor; - shape_editor->set_item_lpe_path_parameter(item, SP_OBJECT(param_effect->getLPEObj()), param_key.c_str()); + if (!href) { + shape_editor->set_item_lpe_path_parameter(item, SP_OBJECT(param_effect->getLPEObj()), param_key.c_str()); + } else { + // set referred item for editing + } } void @@ -183,7 +186,7 @@ void PathParam::param_transform_multiply(Geom::Matrix const& postmul, bool /*set*/) { // TODO: recode this to apply transform to _pathvector instead? - if (!referring) { + if (!href) { // only apply transform when not referring to other path ensure_pwd2(); param_set_and_write_new_value( _pwd2 * postmul ); @@ -218,7 +221,12 @@ PathParam::ensure_pwd2() void PathParam::update_from_referred() { - // TODO + if (!href) { + g_warning("PathParam::update_from_referred - logical error, this should not possible"); + return; + } + + // TODO: implement! // optimize, only update from referred when referred changed. } diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h index 6f2a0d1fd..b294c0d2e 100644 --- a/src/live_effects/parameter/path.h +++ b/src/live_effects/parameter/path.h @@ -59,7 +59,7 @@ protected: bool must_recalculate_pwd2; // set when _pathvector was updated, but _pwd2 not void ensure_pwd2(); // ensures _pwd2 is up to date - bool referring; // set when referring to another path, i.e. does not have its own pwd2, but should get it from another path + gchar * href; // contains link to other object, e.g. "#path2428", NULL if PathParam contains pathdata itself void update_from_referred(); // updates path data by looking up refered path void on_edit_button_click(); -- 2.30.2