summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2008-01-02 18:10:43 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2008-01-02 18:10:43 +0000
commit4517038755f4211da3b5e9afb5567e9d608875da (patch)
tree6b8c8407c5e099d449cb206a7d9077221bd4cc2e /src/live_effects
parentadd libnr <=> 2geom conversion helper headerfile (diff)
downloadinkscape-4517038755f4211da3b5e9afb5567e9d608875da.tar.gz
inkscape-4517038755f4211da3b5e9afb5567e9d608875da.zip
+ Fix bug #179840, forking of LPEs
+ Groundwork for fixing transforming LPE bugs. TODO: implement the actual transformation of LPE parameters. (bzr r4367)
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/effect.cpp16
-rw-r--r--src/live_effects/effect.h12
-rw-r--r--src/live_effects/lpeobject.cpp31
-rw-r--r--src/live_effects/lpeobject.h14
4 files changed, 53 insertions, 20 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 117fbcdb7..21c1d6719 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -6,6 +6,8 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#include "live_effects/effect.h"
+
#include "display/display-forward.h"
#include "xml/node-event-vector.h"
#include "sp-object.h"
@@ -16,17 +18,19 @@
#include "document.h"
#include <glibmm/i18n.h>
-#include "live_effects/effect.h"
#include "live_effects/lpeobject.h"
#include "live_effects/parameter/parameter.h"
#include <glibmm/ustring.h>
#include "live_effects/n-art-bpath-2geom.h"
#include "display/curve.h"
-#include <2geom/sbasis-to-bezier.h>
#include <gtkmm.h>
#include <exception>
+#include <2geom/sbasis-to-bezier.h>
+#include <2geom/matrix.h>
+
+
// include effects:
#include "live_effects/lpe-skeletalstrokes.h"
#include "live_effects/lpe-pathalongpath.h"
@@ -351,6 +355,14 @@ Effect::setup_notepath(Inkscape::NodePath::Path *np)
np->helperpath_width = 1.0;
}
+void
+Effect::transform_multiply(Geom::Matrix const& postmul, bool set)
+{
+ // cycle through all parameters. Most parameters will not need transformation, but path and point params do.
+ for (std::vector<Parameter *>::iterator it = param_vector.begin(); it != param_vector.end(); it++) {
+ Parameter * param = *it;
+ }
+}
} /* namespace LivePathEffect */
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index 964bcd12b..4c1e4e0eb 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -4,7 +4,7 @@
/*
* Inkscape::LivePathEffect
*
-* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+* Copyright (C) Johan Engelen 2007-2008 <j.b.c.engelen@utwente.nl>
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -33,6 +33,10 @@ namespace Gtk {
class Tooltips;
}
+namespace Geom {
+ class Matrix;
+}
+
namespace Inkscape {
namespace XML {
@@ -74,6 +78,10 @@ public:
virtual void resetDefaults(SPItem * item);
+ virtual void setup_notepath(Inkscape::NodePath::Path *np);
+
+ virtual void transform_multiply(Geom::Matrix const& postmul, bool set);
+
Glib::ustring getName();
Inkscape::XML::Node * getRepr();
SPDocument * getSPDoc();
@@ -85,8 +93,6 @@ public:
void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
- virtual void setup_notepath(Inkscape::NodePath::Path *np);
-
protected:
Effect(LivePathEffectObject *lpeobject);
diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp
index 6066f11f3..bcb01463a 100644
--- a/src/live_effects/lpeobject.cpp
+++ b/src/live_effects/lpeobject.cpp
@@ -1,21 +1,23 @@
#define INKSCAPE_LIVEPATHEFFECT_OBJECT_CPP
/*
- * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ * Copyright (C) Johan Engelen 2007-2008 <j.b.c.engelen@utwente.nl>
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#include "live_effects/lpeobject.h"
+
+#include "live_effects/effect.h"
+
#include "xml/repr.h"
#include "xml/node-event-vector.h"
#include "sp-object.h"
#include "attributes.h"
-
#include "document.h"
-#include <glibmm/i18n.h>
+#include "document-private.h"
-#include "live_effects/lpeobject.h"
-#include "live_effects/effect.h"
+#include <glibmm/i18n.h>
//#define LIVEPATHEFFECT_VERBOSE
@@ -251,6 +253,25 @@ livepatheffect_on_repr_attr_changed ( Inkscape::XML::Node * /*repr*/,
lpeobj->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
+/**
+ * If this has other users, create a new private duplicate and return it
+ * returns 'this' when no forking was necessary (and therefore no duplicate was made)
+ */
+LivePathEffectObject *
+LivePathEffectObject::fork_private_if_necessary(int nr_of_allowed_users)
+{
+ if (SP_OBJECT_HREFCOUNT(this) > nr_of_allowed_users) {
+ SPDocument *doc = SP_OBJECT_DOCUMENT(this);
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR (this)->duplicate(xml_doc);
+ SP_OBJECT_REPR (SP_DOCUMENT_DEFS (doc))->addChild(repr, NULL);
+ LivePathEffectObject *lpeobj_new = (LivePathEffectObject *) doc->getObjectByRepr(repr);
+ Inkscape::GC::release(repr);
+ return lpeobj_new;
+ }
+ return this;
+}
/*
Local Variables:
diff --git a/src/live_effects/lpeobject.h b/src/live_effects/lpeobject.h
index c2e9fafa7..bc13e596a 100644
--- a/src/live_effects/lpeobject.h
+++ b/src/live_effects/lpeobject.h
@@ -4,7 +4,7 @@
/*
* Inkscape::LivePathEffect
*
-* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+* Copyright (C) Johan Engelen 2007-2008 <j.b.c.engelen@utwente.nl>
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -16,19 +16,13 @@
#define LIVEPATHEFFECT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), TYPE_LIVEPATHEFFECT, LivePathEffectObject))
#define IS_LIVEPATHEFFECT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), TYPE_LIVEPATHEFFECT))
-/*
-namespace Inkscape {
-namespace LivePathEffect {
- class Effect;
-};
-};
-*/
-
struct LivePathEffectObject : public SPObject {
- Inkscape::LivePathEffect::EffectType effecttype; // fixme: i think this is not needed
+ Inkscape::LivePathEffect::EffectType effecttype;
Inkscape::LivePathEffect::Effect *lpe;
bool effecttype_set;
+
+ LivePathEffectObject * fork_private_if_necessary(int nr_of_allowed_users = 1);
};
/// The LivePathEffect vtable.