summaryrefslogtreecommitdiffstats
path: root/src/sp-shape.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sp-shape.cpp')
-rw-r--r--src/sp-shape.cpp191
1 files changed, 7 insertions, 184 deletions
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index 12929e89c..1556226f1 100644
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
@@ -18,7 +18,6 @@
# include "config.h"
#endif
-
#include <libnr/n-art-bpath.h>
#include <libnr/nr-matrix-fns.h>
#include <libnr/nr-matrix-ops.h>
@@ -38,9 +37,7 @@
#include "prefs-utils.h"
#include "attributes.h"
-#include "live_effects/effect.h"
#include "live_effects/lpeobject.h"
-#include "live_effects/lpeobject-reference.h"
#include "uri.h"
#include "extract-uri.h"
#include "uri-references.h"
@@ -71,10 +68,7 @@ static void sp_shape_snappoints (SPItem const *item, SnapPointsIter p);
static void sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai);
-static void lpeobject_ref_changed(SPObject *old_ref, SPObject *ref, SPShape *shape);
-static void lpeobject_ref_modified(SPObject *href, guint flags, SPShape *shape);
-
-static SPItemClass *parent_class;
+static SPLPEItemClass *parent_class;
/**
* Registers the SPShape class with Gdk and returns its type number.
@@ -94,7 +88,7 @@ sp_shape_get_type (void)
(GInstanceInitFunc) sp_shape_init,
NULL, /* value_table */
};
- type = g_type_register_static (SP_TYPE_ITEM, "SPShape", &info, (GTypeFlags)0);
+ type = g_type_register_static (SP_TYPE_LPE_ITEM, "SPShape", &info, (GTypeFlags)0);
}
return type;
}
@@ -109,14 +103,13 @@ sp_shape_class_init (SPShapeClass *klass)
GObjectClass *gobject_class;
SPObjectClass *sp_object_class;
SPItemClass * item_class;
- SPPathClass * path_class;
+ SPLPEItemClass * lpe_item_class;
gobject_class = (GObjectClass *) klass;
sp_object_class = (SPObjectClass *) klass;
item_class = (SPItemClass *) klass;
- path_class = (SPPathClass *) klass;
- parent_class = (SPItemClass *)g_type_class_peek_parent (klass);
+ parent_class = (SPLPEItemClass *)g_type_class_peek_parent (klass);
gobject_class->finalize = sp_shape_finalize;
@@ -132,9 +125,9 @@ sp_shape_class_init (SPShapeClass *klass)
item_class->show = sp_shape_show;
item_class->hide = sp_shape_hide;
item_class->snappoints = sp_shape_snappoints;
+ lpe_item_class->update_patheffect = NULL;
klass->set_shape = NULL;
- klass->update_patheffect = NULL;
}
/**
@@ -143,10 +136,6 @@ sp_shape_class_init (SPShapeClass *klass)
static void
sp_shape_init (SPShape *shape)
{
- shape->path_effect_href = NULL;
- shape->path_effect_ref = new Inkscape::LivePathEffect::LPEObjectReference(SP_OBJECT(shape));
- new (&shape->lpe_modified_connection) sigc::connection();
-
for ( int i = 0 ; i < SP_MARKER_LOC_QTY ; i++ ) {
new (&shape->release_connect[i]) sigc::connection();
new (&shape->modified_connect[i]) sigc::connection();
@@ -180,10 +169,6 @@ sp_shape_finalize (GObject *object)
static void
sp_shape_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
{
- SP_SHAPE(object)->path_effect_ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(lpeobject_ref_changed), SP_SHAPE(object)));
-
- sp_object_read_attr(object, "inkscape:path-effect");
-
if (((SPObjectClass *) (parent_class))->build) {
(*((SPObjectClass *) (parent_class))->build) (object, document, repr);
}
@@ -222,14 +207,6 @@ sp_shape_release (SPObject *object)
if (shape->curve) {
shape->curve = sp_curve_unref (shape->curve);
}
-
- if (shape->path_effect_href) {
- g_free(shape->path_effect_href);
- }
- shape->path_effect_ref->detach();
-
- shape->lpe_modified_connection.disconnect();
- shape->lpe_modified_connection.~connection();
if (((SPObjectClass *) parent_class)->release) {
((SPObjectClass *) parent_class)->release (object);
@@ -241,52 +218,14 @@ sp_shape_release (SPObject *object)
static void
sp_shape_set(SPObject *object, unsigned int key, gchar const *value)
{
- SPShape *shape = (SPShape *) object;
-
- switch (key) {
- case SP_ATTR_INKSCAPE_PATH_EFFECT:
- if ( value && shape->path_effect_href && ( strcmp(value, shape->path_effect_href) == 0 ) ) {
- /* No change, do nothing. */
- } else {
- if (shape->path_effect_href) {
- g_free(shape->path_effect_href);
- shape->path_effect_href = NULL;
- }
- if (value) {
- shape->path_effect_href = g_strdup(value);
-
- // Now do the attaching, which emits the changed signal.
- try {
- shape->path_effect_ref->attach(Inkscape::URI(value));
- } catch (Inkscape::BadURIException &e) {
- g_warning("%s", e.what());
- shape->path_effect_ref->detach();
- }
- } else {
- // Detach, which emits the changed signal.
- shape->path_effect_ref->detach();
- }
- }
- break;
- default:
- if (((SPObjectClass *) parent_class)->set) {
- ((SPObjectClass *) parent_class)->set(object, key, value);
- }
- break;
+ if (((SPObjectClass *) parent_class)->set) {
+ ((SPObjectClass *) parent_class)->set(object, key, value);
}
}
static Inkscape::XML::Node *
sp_shape_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
{
- SPShape *shape = (SPShape *) object;
-
- if ( shape->path_effect_href ) {
- repr->setAttribute("inkscape:path-effect", shape->path_effect_href);
- } else {
- repr->setAttribute("inkscape:path-effect", NULL);
- }
-
if (((SPObjectClass *)(parent_class))->write) {
((SPObjectClass *)(parent_class))->write(object, repr, flags);
}
@@ -1146,122 +1085,6 @@ static void sp_shape_snappoints(SPItem const *item, SnapPointsIter p)
}
}
-
-LivePathEffectObject *
-sp_shape_get_livepatheffectobject(SPShape *shape) {
- if (!shape) return NULL;
-
- if (sp_shape_has_path_effect(shape)) {
- return shape->path_effect_ref->lpeobject;
- } else {
- return NULL;
- }
-}
-
-Inkscape::LivePathEffect::Effect *
-sp_shape_get_livepatheffect(SPShape *shape) {
- if (!shape) return NULL;
-
- LivePathEffectObject * lpeobj = sp_shape_get_livepatheffectobject(shape);
- if (lpeobj)
- return lpeobj->lpe;
- else
- return NULL;
-}
-
-/**
- * Calls any registered handlers for the update_patheffect action
- */
-void
-sp_shape_update_patheffect (SPShape *shape, bool write)
-{
-#ifdef SHAPE_VERBOSE
- g_message("sp_shape_update_patheffect: %p\n", shape);
-#endif
- g_return_if_fail (shape != NULL);
- g_return_if_fail (SP_IS_SHAPE (shape));
-
- if (SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (shape))->update_patheffect) {
- SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (shape))->update_patheffect (shape, write);
- }
-}
-
-void sp_shape_perform_path_effect(SPCurve *curve, SPShape *shape) {
- if (!shape) return;
- if (!curve) return;
-
- LivePathEffectObject *lpeobj = sp_shape_get_livepatheffectobject(shape);
- if (lpeobj && lpeobj->lpe) {
- lpeobj->lpe->doEffect(curve);
- }
-}
-
-/**
- * Gets called when (re)attached to another lpeobject.
- */
-static void
-lpeobject_ref_changed(SPObject *old_ref, SPObject *ref, SPShape *shape)
-{
- if (old_ref) {
- sp_signal_disconnect_by_data(old_ref, shape);
- }
- if ( IS_LIVEPATHEFFECT(ref) && ref != shape )
- {
- shape->lpe_modified_connection.disconnect();
- shape->lpe_modified_connection = ref->connectModified(sigc::bind(sigc::ptr_fun(&lpeobject_ref_modified), shape));
- lpeobject_ref_modified(ref, 0, shape);
- }
-}
-
-/**
- * Gets called when lpeobject repr contents change: i.e. parameter change.
- */
-static void
-lpeobject_ref_modified(SPObject */*href*/, guint /*flags*/, SPShape *shape)
-{
- sp_shape_update_patheffect (shape, true);
-}
-
-void sp_shape_set_path_effect(SPShape *shape, gchar *value)
-{
- if (!value) {
- sp_shape_remove_path_effect(shape);
- } else {
- SP_OBJECT_REPR(shape)->setAttribute("inkscape:path-effect", value);
- }
-}
-
-void sp_shape_set_path_effect(SPShape *shape, LivePathEffectObject * new_lpeobj)
-{
- const gchar * repr_id = SP_OBJECT_REPR(new_lpeobj)->attribute("id");
- gchar *hrefstr = g_strdup_printf("#%s", repr_id);
- sp_shape_set_path_effect(shape, hrefstr);
- g_free(hrefstr);
-}
-
-void sp_shape_remove_path_effect(SPShape *shape)
-{
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(shape);
- repr->setAttribute("inkscape:path-effect", NULL);
- if (SP_IS_PATH(shape)) {
- repr->setAttribute("d", repr->attribute("inkscape:original-d"));
- repr->setAttribute("inkscape:original-d", NULL);
- }
-}
-
-bool sp_shape_has_path_effect(SPShape *shape)
-{
- return (shape->path_effect_href != NULL);
-}
-
-void sp_shape_edit_next_param_oncanvas(SPShape *shape, SPDesktop *dt)
-{
- LivePathEffectObject *lpeobj = sp_shape_get_livepatheffectobject(shape);
- if (lpeobj && lpeobj->lpe) {
- lpeobj->lpe->editNextParamOncanvas(SP_ITEM(shape), dt);
- }
-}
-
/*
Local Variables:
mode:c++