From: johanengelen Date: Thu, 19 Mar 2009 23:26:11 +0000 (+0000) Subject: tidy up SPObjects that must always be LivePathEffectObjects X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=30291effadd982ef29531e075db0059bd1d91a1e;p=inkscape.git tidy up SPObjects that must always be LivePathEffectObjects --- diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 1214a1766..5b6af68d2 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -202,7 +202,7 @@ PathParam::param_editOncanvas(SPItem * item, SPDesktop * dt) ShapeEditor * shape_editor = dt->event_context->shape_editor; if (!href) { - shape_editor->set_item_lpe_path_parameter(item, SP_OBJECT(param_effect->getLPEObj()), param_key.c_str()); + shape_editor->set_item_lpe_path_parameter(item, param_effect->getLPEObj(), param_key.c_str()); } else { // set referred item for editing shape_editor->set_item(ref.getObject(), SH_NODEPATH); diff --git a/src/nodepath.cpp b/src/nodepath.cpp index 1899f7978..b59a2d865 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -248,10 +248,16 @@ sp_nodepath_destroy_helperpaths(Inkscape::NodePath::Path *np) { /** * \brief Creates new nodepath from item * + * If repr_key_in is not NULL, object *has* to be a LivePathEffectObject ! + * * \todo create proper constructor for nodepath::path, this method returns null a constructor cannot so this cannot be simply converted to constructor. */ Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPObject *object, bool show_handles, const char * repr_key_in, SPItem *item) { + if (repr_key_in) { + g_assert(IS_LIVEPATHEFFECT(object)); + } + Inkscape::XML::Node *repr = object->repr; /** \todo @@ -328,7 +334,7 @@ Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPObject *object, np->d2i = np->i2d.inverse(); np->repr = repr; - if (repr_key_in) { // apparently the object is an LPEObject (this is a dirty check, hopefully nobody tries feeding non-lpeobjects into this method with non-null repr_key_in) + if (repr_key_in) { // apparently the object is an LPEObject np->repr_key = g_strdup(repr_key_in); np->repr_nodetypes_key = g_strconcat(np->repr_key, "-nodetypes", NULL); Inkscape::LivePathEffect::Effect * lpe = LIVEPATHEFFECT(object)->get_lpe(); diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp index bfe407957..dc1ec1c7e 100644 --- a/src/shape-editor.cpp +++ b/src/shape-editor.cpp @@ -287,7 +287,7 @@ void ShapeEditor::set_item(SPItem *item, SubType type, bool keep_knotholder) { /** Please note that this function only works for path parameters. * All other parameters probably will crash Inkscape! */ -void ShapeEditor::set_item_lpe_path_parameter(SPItem *item, SPObject *lpeobject, const char * key) +void ShapeEditor::set_item_lpe_path_parameter(SPItem *item, LivePathEffectObject *lpeobject, const char * key) { unset_item(SH_NODEPATH); @@ -324,7 +324,7 @@ void ShapeEditor::reset_item (SubType type, bool keep_knotholder) case SH_NODEPATH: if ( (nodepath) && (IS_LIVEPATHEFFECT(nodepath->object)) ) { char * key = g_strdup(nodepath->repr_key); - set_item_lpe_path_parameter(nodepath->item, nodepath->object, key); // the above checks for nodepath, so it is indeed a path that we are editing + set_item_lpe_path_parameter(nodepath->item, LIVEPATHEFFECT(nodepath->object), key); // the above checks for nodepath, so it is indeed a path that we are editing g_free(key); } else { set_item(SP_ITEM(obj), SH_NODEPATH); diff --git a/src/shape-editor.h b/src/shape-editor.h index f30f1aa12..ef81540ae 100644 --- a/src/shape-editor.h +++ b/src/shape-editor.h @@ -13,20 +13,21 @@ */ #include -#include +#include <2geom/forward.h> namespace Inkscape { namespace NodePath { class Path; } } namespace Inkscape { namespace XML { class Node; } } -#include "libnr/nr-path-code.h" -#include "libnr/nr-point.h" -#include -#include - class KnotHolder; class SPDesktop; class SPNodeContext; class ShapeEditorsCollective; +class LivePathEffectObject; + +#include "libnr/nr-path-code.h" +#include <2geom/point.h> +#include +#include enum SubType{ SH_NODEPATH, @@ -40,7 +41,7 @@ public: ~ShapeEditor(); void set_item (SPItem *item, SubType type, bool keep_knotholder = false); - void set_item_lpe_path_parameter(SPItem *item, SPObject *lpeobject, const char * key); + void set_item_lpe_path_parameter(SPItem *item, LivePathEffectObject *lpeobject, const char * key); void unset_item (SubType type, bool keep_knotholder = false); bool has_nodepath (); //((deprecated))