summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-03-29 23:46:09 +0000
committerMarkus Engel <markus.engel@tum.de>2013-03-29 23:46:09 +0000
commit732214b111f2e830a8a0b654a88b087766be9067 (patch)
treeae0a9471ca69a2e580b350f0b13b64ce647d45b7 /src
parentAdded "virtual pads" to (diff)
downloadinkscape-732214b111f2e830a8a0b654a88b087766be9067.tar.gz
inkscape-732214b111f2e830a8a0b654a88b087766be9067.zip
Added "virtual pads" for
- ColorProfile - LivePathEffectObject - Persp3D (bzr r11608.1.51)
Diffstat (limited to 'src')
-rw-r--r--src/color-profile.cpp245
-rw-r--r--src/color-profile.h25
-rw-r--r--src/live_effects/lpeobject.cpp143
-rw-r--r--src/live_effects/lpeobject.h26
-rw-r--r--src/persp3d.cpp155
-rw-r--r--src/persp3d.h25
6 files changed, 586 insertions, 33 deletions
diff --git a/src/color-profile.cpp b/src/color-profile.cpp
index c9af64723..ac341dfe5 100644
--- a/src/color-profile.cpp
+++ b/src/color-profile.cpp
@@ -51,6 +51,8 @@ using Inkscape::ColorProfile;
using Inkscape::ColorProfileClass;
using Inkscape::ColorProfileImpl;
+using Inkscape::CColorProfile;
+
namespace
{
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
@@ -224,11 +226,21 @@ void ColorProfile::classInit( ColorProfileClass *klass )
sp_object_class->write = ColorProfile::write;
}
+CColorProfile::CColorProfile(ColorProfile* cp) : CObject(cp) {
+ this->colorprofile = cp;
+}
+
+CColorProfile::~CColorProfile() {
+}
+
/**
* Callback for ColorProfile object initialization.
*/
void ColorProfile::init( ColorProfile *cprof )
{
+ cprof->ccolorprofile = new CColorProfile(cprof);
+ cprof->cobject = cprof->ccolorprofile;
+
cprof->impl = new ColorProfileImpl();
cprof->href = 0;
@@ -243,6 +255,44 @@ void ColorProfile::init( ColorProfile *cprof )
*/
void ColorProfile::release( SPObject *object )
{
+// // Unregister ourselves
+// if ( object->document ) {
+// object->document->removeResource("iccprofile", object);
+// }
+//
+// ColorProfile *cprof = COLORPROFILE(object);
+// if ( cprof->href ) {
+// g_free( cprof->href );
+// cprof->href = 0;
+// }
+//
+// if ( cprof->local ) {
+// g_free( cprof->local );
+// cprof->local = 0;
+// }
+//
+// if ( cprof->name ) {
+// g_free( cprof->name );
+// cprof->name = 0;
+// }
+//
+// if ( cprof->intentStr ) {
+// g_free( cprof->intentStr );
+// cprof->intentStr = 0;
+// }
+//
+//#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
+// cprof->impl->_clearProfile();
+//#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
+//
+// delete cprof->impl;
+// cprof->impl = 0;
+ ((ColorProfile*)object)->ccolorprofile->onRelease();
+}
+
+void CColorProfile::onRelease() {
+ ColorProfile* object = this->colorprofile;
+
// Unregister ourselves
if ( object->document ) {
object->document->removeResource("iccprofile", object);
@@ -306,6 +356,31 @@ void ColorProfileImpl::_clearProfile()
*/
void ColorProfile::build( SPObject *object, SPDocument *document, Inkscape::XML::Node *repr )
{
+// ColorProfile *cprof = COLORPROFILE(object);
+// g_assert(cprof->href == 0);
+// g_assert(cprof->local == 0);
+// g_assert(cprof->name == 0);
+// g_assert(cprof->intentStr == 0);
+//
+//// if (cprof_parent_class->build) {
+//// (* cprof_parent_class->build)(object, document, repr);
+//// }
+//
+// object->readAttr( "xlink:href" );
+// object->readAttr( "local" );
+// object->readAttr( "name" );
+// object->readAttr( "rendering-intent" );
+//
+// // Register
+// if ( document ) {
+// document->addResource( "iccprofile", object );
+// }
+ ((ColorProfile*)object)->ccolorprofile->onBuild(document, repr);
+}
+
+void CColorProfile::onBuild(SPDocument *document, Inkscape::XML::Node *repr) {
+ ColorProfile* object = this->colorprofile;
+
ColorProfile *cprof = COLORPROFILE(object);
g_assert(cprof->href == 0);
g_assert(cprof->local == 0);
@@ -315,7 +390,7 @@ void ColorProfile::build( SPObject *object, SPDocument *document, Inkscape::XML:
// if (cprof_parent_class->build) {
// (* cprof_parent_class->build)(object, document, repr);
// }
- // CPPIFY: todo
+ CObject::onBuild(document, repr);
object->readAttr( "xlink:href" );
object->readAttr( "local" );
@@ -328,11 +403,131 @@ void ColorProfile::build( SPObject *object, SPDocument *document, Inkscape::XML:
}
}
+
/**
* Callback: set attribute.
*/
void ColorProfile::set( SPObject *object, unsigned key, gchar const *value )
{
+// ColorProfile *cprof = COLORPROFILE(object);
+//
+// switch (key) {
+// case SP_ATTR_XLINK_HREF:
+// if ( cprof->href ) {
+// g_free( cprof->href );
+// cprof->href = 0;
+// }
+// if ( value ) {
+// cprof->href = g_strdup( value );
+// if ( *cprof->href ) {
+//#if HAVE_LIBLCMS1
+// cmsErrorAction( LCMS_ERROR_SHOW );
+//#endif
+//#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
+//
+// // TODO open filename and URIs properly
+// //FILE* fp = fopen_utf8name( filename, "r" );
+// //LCMSAPI cmsHPROFILE LCMSEXPORT cmsOpenProfileFromMem(LPVOID MemPtr, cmsUInt32Number dwSize);
+//
+// // Try to open relative
+// SPDocument *doc = object->document;
+// if (!doc) {
+// doc = SP_ACTIVE_DOCUMENT;
+// g_warning("object has no document. using active");
+// }
+// //# 1. Get complete URI of document
+// gchar const *docbase = doc->getURI();
+// if (!docbase)
+// {
+// // Normal for files that have not yet been saved.
+// docbase = "";
+// }
+//
+// gchar* escaped = g_uri_escape_string(cprof->href, "!*'();:@=+$,/?#[]", TRUE);
+//
+// //g_message("docbase:%s\n", docbase);
+// org::w3c::dom::URI docUri(docbase);
+// //# 2. Get href of icc file. we don't care if it's rel or abs
+// org::w3c::dom::URI hrefUri(escaped);
+// //# 3. Resolve the href according the docBase. This follows
+// // the w3c specs. All absolute and relative issues are considered
+// org::w3c::dom::URI cprofUri = docUri.resolve(hrefUri);
+// gchar* fullname = g_uri_unescape_string(cprofUri.getNativePath().c_str(), "");
+// cprof->impl->_clearProfile();
+// cprof->impl->_profHandle = cmsOpenProfileFromFile( fullname, "r" );
+// if ( cprof->impl->_profHandle ) {
+// cprof->impl->_profileSpace = cmsGetColorSpace( cprof->impl->_profHandle );
+// cprof->impl->_profileClass = cmsGetDeviceClass( cprof->impl->_profHandle );
+// }
+// DEBUG_MESSAGE( lcmsOne, "cmsOpenProfileFromFile( '%s'...) = %p", fullname, (void*)cprof->impl->_profHandle );
+// g_free(escaped);
+// escaped = 0;
+// g_free(fullname);
+//#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
+// }
+// }
+// object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+// break;
+//
+// case SP_ATTR_LOCAL:
+// if ( cprof->local ) {
+// g_free( cprof->local );
+// cprof->local = 0;
+// }
+// cprof->local = g_strdup( value );
+// object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+// break;
+//
+// case SP_ATTR_NAME:
+// if ( cprof->name ) {
+// g_free( cprof->name );
+// cprof->name = 0;
+// }
+// cprof->name = g_strdup( value );
+// DEBUG_MESSAGE( lcmsTwo, "<color-profile> name set to '%s'", cprof->name );
+// object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+// break;
+//
+// case SP_ATTR_RENDERING_INTENT:
+// if ( cprof->intentStr ) {
+// g_free( cprof->intentStr );
+// cprof->intentStr = 0;
+// }
+// cprof->intentStr = g_strdup( value );
+//
+// if ( value ) {
+// if ( strcmp( value, "auto" ) == 0 ) {
+// cprof->rendering_intent = RENDERING_INTENT_AUTO;
+// } else if ( strcmp( value, "perceptual" ) == 0 ) {
+// cprof->rendering_intent = RENDERING_INTENT_PERCEPTUAL;
+// } else if ( strcmp( value, "relative-colorimetric" ) == 0 ) {
+// cprof->rendering_intent = RENDERING_INTENT_RELATIVE_COLORIMETRIC;
+// } else if ( strcmp( value, "saturation" ) == 0 ) {
+// cprof->rendering_intent = RENDERING_INTENT_SATURATION;
+// } else if ( strcmp( value, "absolute-colorimetric" ) == 0 ) {
+// cprof->rendering_intent = RENDERING_INTENT_ABSOLUTE_COLORIMETRIC;
+// } else {
+// cprof->rendering_intent = RENDERING_INTENT_UNKNOWN;
+// }
+// } else {
+// cprof->rendering_intent = RENDERING_INTENT_UNKNOWN;
+// }
+//
+// object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+// break;
+//
+// default:
+// if (cprof_parent_class->set) {
+// (* cprof_parent_class->set)(object, key, value);
+// }
+// break;
+// }
+ ((ColorProfile*)object)->ccolorprofile->onSet(key, value);
+}
+
+void CColorProfile::onSet(unsigned key, gchar const *value) {
+ ColorProfile* object = this->colorprofile;
+
ColorProfile *cprof = COLORPROFILE(object);
switch (key) {
@@ -441,12 +636,12 @@ void ColorProfile::set( SPObject *object, unsigned key, gchar const *value )
break;
default:
- if (cprof_parent_class->set) {
- (* cprof_parent_class->set)(object, key, value);
- }
+// if (cprof_parent_class->set) {
+// (* cprof_parent_class->set)(object, key, value);
+// }
+ CObject::onSet(key, value);
break;
}
-
}
/**
@@ -454,6 +649,39 @@ void ColorProfile::set( SPObject *object, unsigned key, gchar const *value )
*/
Inkscape::XML::Node* ColorProfile::write( SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags )
{
+// ColorProfile *cprof = COLORPROFILE(object);
+//
+// if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
+// repr = xml_doc->createElement("svg:color-profile");
+// }
+//
+// if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->href ) {
+// repr->setAttribute( "xlink:href", cprof->href );
+// }
+//
+// if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->local ) {
+// repr->setAttribute( "local", cprof->local );
+// }
+//
+// if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->name ) {
+// repr->setAttribute( "name", cprof->name );
+// }
+//
+// if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->intentStr ) {
+// repr->setAttribute( "rendering-intent", cprof->intentStr );
+// }
+//
+// if (cprof_parent_class->write) {
+// (* cprof_parent_class->write)(object, xml_doc, repr, flags);
+// }
+//
+// return repr;
+ return ((ColorProfile*)object)->ccolorprofile->onWrite(xml_doc, repr, flags);
+}
+
+Inkscape::XML::Node* CColorProfile::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
+ ColorProfile* object = this->colorprofile;
+
ColorProfile *cprof = COLORPROFILE(object);
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
@@ -476,9 +704,10 @@ Inkscape::XML::Node* ColorProfile::write( SPObject *object, Inkscape::XML::Docum
repr->setAttribute( "rendering-intent", cprof->intentStr );
}
- if (cprof_parent_class->write) {
- (* cprof_parent_class->write)(object, xml_doc, repr, flags);
- }
+// if (cprof_parent_class->write) {
+// (* cprof_parent_class->write)(object, xml_doc, repr, flags);
+// }
+ CObject::onWrite(xml_doc, repr, flags);
return repr;
}
diff --git a/src/color-profile.h b/src/color-profile.h
index 184481ce8..4ddf587cb 100644
--- a/src/color-profile.h
+++ b/src/color-profile.h
@@ -30,10 +30,15 @@ struct ColorProfileClass {
SPObjectClass parent_class;
};
+class CColorProfile;
+
/**
* Color Profile.
*/
-struct ColorProfile : public SPObject {
+class ColorProfile : public SPObject {
+public:
+ CColorProfile* ccolorprofile;
+
friend cmsHPROFILE colorprofile_get_handle( SPDocument*, guint*, gchar const* );
friend class CMSSystem;
@@ -69,9 +74,27 @@ private:
static void set( SPObject *object, unsigned key, gchar const *value );
static Inkscape::XML::Node *write( SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags );
+public:
ColorProfileImpl *impl;
};
+class CColorProfile : public CObject {
+public:
+ CColorProfile(ColorProfile* cp);
+ virtual ~CColorProfile();
+
+ virtual void onBuild(SPDocument* doc, Inkscape::XML::Node* repr);
+ virtual void onRelease();
+
+ virtual void onSet(unsigned int key, const gchar* value);
+
+ virtual Inkscape::XML::Node* onWrite(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags);
+
+private:
+ ColorProfile* colorprofile;
+};
+
+
GType colorprofile_get_type();
} // namespace Inkscape
diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp
index 052202e44..e9801fc11 100644
--- a/src/live_effects/lpeobject.cpp
+++ b/src/live_effects/lpeobject.cpp
@@ -73,6 +73,13 @@ LivePathEffectObject::livepatheffect_class_init(LivePathEffectObjectClass *klass
sp_object_class->write = livepatheffect_write;
}
+CLivePathEffectObject::CLivePathEffectObject(LivePathEffectObject* lpeo) : CObject(lpeo) {
+ this->livepatheffectobject = lpeo;
+}
+
+CLivePathEffectObject::~CLivePathEffectObject() {
+}
+
/**
* Callback to initialize livepatheffect object.
*/
@@ -82,6 +89,10 @@ LivePathEffectObject::livepatheffect_init(LivePathEffectObject *lpeobj)
#ifdef LIVEPATHEFFECT_VERBOSE
g_message("Init livepatheffectobject");
#endif
+
+ lpeobj->clivepatheffectobject = new CLivePathEffectObject(lpeobj);
+ lpeobj->cobject = lpeobj->clivepatheffectobject;
+
lpeobj->effecttype = Inkscape::LivePathEffect::INVALID_LPE;
lpeobj->lpe = NULL;
@@ -97,12 +108,30 @@ LivePathEffectObject::livepatheffect_build(SPObject *object, SPDocument *documen
#ifdef LIVEPATHEFFECT_VERBOSE
g_message("Build livepatheffect");
#endif
+// g_assert(object != NULL);
+// g_assert(SP_IS_OBJECT(object));
+//
+//// if (((SPObjectClass *) livepatheffect_parent_class)->build)
+//// (* ((SPObjectClass *) livepatheffect_parent_class)->build)(object, document, repr);
+//
+// object->readAttr( "effect" );
+//
+// if (repr) {
+// repr->addListener (&livepatheffect_repr_events, object);
+// }
+//
+// /* Register ourselves, is this necessary? */
+//// document->addResource("path-effect", object);
+ ((LivePathEffectObject*)object)->clivepatheffectobject->onBuild(document, repr);
+}
+
+void CLivePathEffectObject::onBuild(SPDocument *document, Inkscape::XML::Node *repr) {
+ LivePathEffectObject* object = this->livepatheffectobject;
+
g_assert(object != NULL);
g_assert(SP_IS_OBJECT(object));
-// if (((SPObjectClass *) livepatheffect_parent_class)->build)
-// (* ((SPObjectClass *) livepatheffect_parent_class)->build)(object, document, repr);
-// CPPIFY: todo
+ CObject::onBuild(document, repr);
object->readAttr( "effect" );
@@ -124,6 +153,42 @@ LivePathEffectObject::livepatheffect_release(SPObject *object)
g_print("Releasing livepatheffect");
#endif
+// LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object);
+//
+// object->getRepr()->removeListenerByData(object);
+//
+//
+///*
+// if (object->document) {
+// // Unregister ourselves
+// sp_document_removeResource(object->document, "livepatheffect", object);
+// }
+//
+// if (gradient->ref) {
+// gradient->modified_connection.disconnect();
+// gradient->ref->detach();
+// delete gradient->ref;
+// gradient->ref = NULL;
+// }
+//
+// gradient->modified_connection.~connection();
+//
+//*/
+//
+// if (lpeobj->lpe) {
+// delete lpeobj->lpe;
+// lpeobj->lpe = NULL;
+// }
+// lpeobj->effecttype = Inkscape::LivePathEffect::INVALID_LPE;
+//
+// if (((SPObjectClass *) livepatheffect_parent_class)->release)
+// ((SPObjectClass *) livepatheffect_parent_class)->release(object);
+ ((LivePathEffectObject*)object)->clivepatheffectobject->onRelease();
+}
+
+void CLivePathEffectObject::onRelease() {
+ LivePathEffectObject* object = this->livepatheffectobject;
+
LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object);
object->getRepr()->removeListenerByData(object);
@@ -152,8 +217,9 @@ LivePathEffectObject::livepatheffect_release(SPObject *object)
}
lpeobj->effecttype = Inkscape::LivePathEffect::INVALID_LPE;
- if (((SPObjectClass *) livepatheffect_parent_class)->release)
- ((SPObjectClass *) livepatheffect_parent_class)->release(object);
+// if (((SPObjectClass *) livepatheffect_parent_class)->release)
+// ((SPObjectClass *) livepatheffect_parent_class)->release(object);
+ CObject::onRelease();
}
/**
@@ -162,6 +228,38 @@ LivePathEffectObject::livepatheffect_release(SPObject *object)
void
LivePathEffectObject::livepatheffect_set(SPObject *object, unsigned key, gchar const *value)
{
+// LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object);
+//#ifdef LIVEPATHEFFECT_VERBOSE
+// g_print("Set livepatheffect");
+//#endif
+// switch (key) {
+// case SP_PROP_PATH_EFFECT:
+// if (lpeobj->lpe) {
+// delete lpeobj->lpe;
+// lpeobj->lpe = NULL;
+// }
+//
+// if ( value && Inkscape::LivePathEffect::LPETypeConverter.is_valid_key(value) ) {
+// lpeobj->effecttype = Inkscape::LivePathEffect::LPETypeConverter.get_id_from_key(value);
+// lpeobj->lpe = Inkscape::LivePathEffect::Effect::New(lpeobj->effecttype, lpeobj);
+// lpeobj->effecttype_set = true;
+// } else {
+// lpeobj->effecttype = Inkscape::LivePathEffect::INVALID_LPE;
+// lpeobj->effecttype_set = false;
+// }
+// object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+// break;
+// }
+//
+// if (((SPObjectClass *) livepatheffect_parent_class)->set) {
+// ((SPObjectClass *) livepatheffect_parent_class)->set(object, key, value);
+// }
+ ((LivePathEffectObject*)object)->clivepatheffectobject->onSet(key, value);
+}
+
+void CLivePathEffectObject::onSet(unsigned key, gchar const *value) {
+ LivePathEffectObject* object = this->livepatheffectobject;
+
LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object);
#ifdef LIVEPATHEFFECT_VERBOSE
g_print("Set livepatheffect");
@@ -185,9 +283,10 @@ LivePathEffectObject::livepatheffect_set(SPObject *object, unsigned key, gchar c
break;
}
- if (((SPObjectClass *) livepatheffect_parent_class)->set) {
- ((SPObjectClass *) livepatheffect_parent_class)->set(object, key, value);
- }
+// if (((SPObjectClass *) livepatheffect_parent_class)->set) {
+// ((SPObjectClass *) livepatheffect_parent_class)->set(object, key, value);
+// }
+ CObject::onSet(key, value);
}
/**
@@ -200,6 +299,28 @@ LivePathEffectObject::livepatheffect_write(SPObject *object, Inkscape::XML::Docu
g_print("Write livepatheffect");
#endif
+// LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object);
+//
+// if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
+// repr = xml_doc->createElement("inkscape:path-effect");
+// }
+//
+// if ((flags & SP_OBJECT_WRITE_ALL) || lpeobj->lpe) {
+// repr->setAttribute("effect", Inkscape::LivePathEffect::LPETypeConverter.get_key(lpeobj->effecttype).c_str());
+//
+// lpeobj->lpe->writeParamsToSVG();
+// }
+//
+// if (((SPObjectClass *) livepatheffect_parent_class)->write)
+// (* ((SPObjectClass *) livepatheffect_parent_class)->write)(object, xml_doc, repr, flags);
+//
+// return repr;
+ return ((LivePathEffectObject*)object)->clivepatheffectobject->onWrite(xml_doc, repr, flags);
+}
+
+Inkscape::XML::Node* CLivePathEffectObject::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
+ LivePathEffectObject* object = this->livepatheffectobject;
+
LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object);
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
@@ -212,8 +333,10 @@ LivePathEffectObject::livepatheffect_write(SPObject *object, Inkscape::XML::Docu
lpeobj->lpe->writeParamsToSVG();
}
- if (((SPObjectClass *) livepatheffect_parent_class)->write)
- (* ((SPObjectClass *) livepatheffect_parent_class)->write)(object, xml_doc, repr, flags);
+// if (((SPObjectClass *) livepatheffect_parent_class)->write)
+// (* ((SPObjectClass *) livepatheffect_parent_class)->write)(object, xml_doc, repr, flags);
+
+ CObject::onWrite(xml_doc, repr, flags);
return repr;
}
diff --git a/src/live_effects/lpeobject.h b/src/live_effects/lpeobject.h
index 3ea1ea9ad..d9349e0cc 100644
--- a/src/live_effects/lpeobject.h
+++ b/src/live_effects/lpeobject.h
@@ -31,8 +31,12 @@ struct LivePathEffectObjectClass {
SPObjectClass parent_class;
};
+class CLivePathEffectObject;
+
class LivePathEffectObject : public SPObject {
public:
+ CLivePathEffectObject* clivepatheffectobject;
+
Inkscape::LivePathEffect::EffectType effecttype;
bool effecttype_set;
@@ -43,13 +47,13 @@ public:
* So one should always check whether the returned value is NULL or not */
Inkscape::LivePathEffect::Effect * get_lpe() { return lpe; };
-private:
+//private:
Inkscape::LivePathEffect::Effect *lpe; // this can be NULL in a valid LivePathEffectObject
/* C-style class functions: */
-public:
+//public:
static GType livepatheffect_get_type();
-private:
+//private:
static void livepatheffect_class_init(LivePathEffectObjectClass *klass);
static void livepatheffect_init(LivePathEffectObject *stop);
static void livepatheffect_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
@@ -59,6 +63,22 @@ private:
};
+class CLivePathEffectObject : public CObject {
+public:
+ CLivePathEffectObject(LivePathEffectObject* lpeo);
+ virtual ~CLivePathEffectObject();
+
+ virtual void onBuild(SPDocument* doc, Inkscape::XML::Node* repr);
+ virtual void onRelease();
+
+ virtual void onSet(unsigned int key, const gchar* value);
+
+ virtual Inkscape::XML::Node* onWrite(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags);
+
+private:
+ LivePathEffectObject* livepatheffectobject;
+};
+
#endif
/*
diff --git a/src/persp3d.cpp b/src/persp3d.cpp
index 1e348bf35..549dc2445 100644
--- a/src/persp3d.cpp
+++ b/src/persp3d.cpp
@@ -101,26 +101,50 @@ static void persp3d_class_init(Persp3DClass *klass)
sp_object_class->write = persp3d_write;
}
+CPersp3D::CPersp3D(Persp3D* persp3d) : CObject(persp3d) {
+ this->persp3d = persp3d;
+}
+
+CPersp3D::~CPersp3D() {
+}
+
/**
* Callback to initialize Persp3D object.
*/
static void
persp3d_init(Persp3D *persp)
{
+ persp->cpersp3d = new CPersp3D(persp);
+ persp->cobject = persp->cpersp3d;
+
persp->perspective_impl = new Persp3DImpl();
}
/**
* Virtual build: set persp3d attributes from its associated XML node.
*/
-static void persp3d_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
-{
+//static void persp3d_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
+//{
// if (((SPObjectClass *) persp3d_parent_class)->build)
// (* ((SPObjectClass *) persp3d_parent_class)->build)(object, document, repr);
- // CPPIFY: todo
- /* calls sp_object_set for the respective attributes */
+ /* calls sp_object_set for the respective attributes */
// The transformation matrix is updated according to the values we read for the VPs
+// object->readAttr( "inkscape:vp_x" );
+// object->readAttr( "inkscape:vp_y" );
+// object->readAttr( "inkscape:vp_z" );
+// object->readAttr( "inkscape:persp3d-origin" );
+//
+// if (repr) {
+// repr->addListener (&persp3d_repr_events, object);
+// }
+//}
+
+void CPersp3D::onBuild(SPDocument *document, Inkscape::XML::Node *repr) {
+ CObject::onBuild(document, repr);
+
+ Persp3D* object = this->persp3d;
+
object->readAttr( "inkscape:vp_x" );
object->readAttr( "inkscape:vp_y" );
object->readAttr( "inkscape:vp_z" );
@@ -135,6 +159,15 @@ static void persp3d_build(SPObject *object, SPDocument *document, Inkscape::XML:
* Virtual release of Persp3D members before destruction.
*/
static void persp3d_release(SPObject *object) {
+// Persp3D *persp = SP_PERSP3D(object);
+// delete persp->perspective_impl;
+// object->getRepr()->removeListenerByData(object);
+ ((Persp3D*)object)->cpersp3d->onRelease();
+}
+
+void CPersp3D::onRelease() {
+ Persp3D* object = this->persp3d;
+
Persp3D *persp = SP_PERSP3D(object);
delete persp->perspective_impl;
object->getRepr()->removeListenerByData(object);
@@ -149,6 +182,59 @@ static void persp3d_release(SPObject *object) {
static void
persp3d_set(SPObject *object, unsigned key, gchar const *value)
{
+// Persp3DImpl *persp_impl = SP_PERSP3D(object)->perspective_impl;
+//
+// switch (key) {
+// case SP_ATTR_INKSCAPE_PERSP3D_VP_X: {
+// if (value) {
+// Proj::Pt2 new_image (value);
+// persp3d_update_with_point (persp_impl, Proj::X, new_image);
+// }
+// break;
+// }
+// case SP_ATTR_INKSCAPE_PERSP3D_VP_Y: {
+// if (value) {
+// Proj::Pt2 new_image (value);
+// persp3d_update_with_point (persp_impl, Proj::Y, new_image);
+// break;
+// }
+// }
+// case SP_ATTR_INKSCAPE_PERSP3D_VP_Z: {
+// if (value) {
+// Proj::Pt2 new_image (value);
+// persp3d_update_with_point (persp_impl, Proj::Z, new_image);
+// break;
+// }
+// }
+// case SP_ATTR_INKSCAPE_PERSP3D_ORIGIN: {
+// if (value) {
+// Proj::Pt2 new_image (value);
+// persp3d_update_with_point (persp_impl, Proj::W, new_image);
+// break;
+// }
+// }
+// default: {
+// if (((SPObjectClass *) persp3d_parent_class)->set)
+// (* ((SPObjectClass *) persp3d_parent_class)->set)(object, key, value);
+// break;
+// }
+// }
+//
+// // FIXME: Is this the right place for resetting the draggers?
+// SPEventContext *ec = inkscape_active_event_context();
+// if (SP_IS_BOX3D_CONTEXT(ec)) {
+// Box3DContext *bc = SP_BOX3D_CONTEXT(ec);
+// bc->_vpdrag->updateDraggers();
+// bc->_vpdrag->updateLines();
+// bc->_vpdrag->updateBoxHandles();
+// bc->_vpdrag->updateBoxReprs();
+// }
+ ((Persp3D*)object)->cpersp3d->onSet(key, value);
+}
+
+void CPersp3D::onSet(unsigned key, gchar const *value) {
+ Persp3D* object = this->persp3d;
+
Persp3DImpl *persp_impl = SP_PERSP3D(object)->perspective_impl;
switch (key) {
@@ -181,8 +267,9 @@ persp3d_set(SPObject *object, unsigned key, gchar const *value)
}
}
default: {
- if (((SPObjectClass *) persp3d_parent_class)->set)
- (* ((SPObjectClass *) persp3d_parent_class)->set)(object, key, value);
+// if (((SPObjectClass *) persp3d_parent_class)->set)
+// (* ((SPObjectClass *) persp3d_parent_class)->set)(object, key, value);
+ CObject::onSet(key, value);
break;
}
}
@@ -201,14 +288,27 @@ persp3d_set(SPObject *object, unsigned key, gchar const *value)
static void
persp3d_update(SPObject *object, SPCtx *ctx, guint flags)
{
+// if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
+//
+// /* TODO: Should we update anything here? */
+//
+// }
+//
+// if (((SPObjectClass *) persp3d_parent_class)->update)
+// ((SPObjectClass *) persp3d_parent_class)->update(object, ctx, flags);
+ ((Persp3D*)object)->cpersp3d->onUpdate(ctx, flags);
+}
+
+void CPersp3D::onUpdate(SPCtx *ctx, guint flags) {
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
/* TODO: Should we update anything here? */
}
- if (((SPObjectClass *) persp3d_parent_class)->update)
- ((SPObjectClass *) persp3d_parent_class)->update(object, ctx, flags);
+// if (((SPObjectClass *) persp3d_parent_class)->update)
+// ((SPObjectClass *) persp3d_parent_class)->update(object, ctx, flags);
+ CObject::onUpdate(ctx, flags);
}
Persp3D *persp3d_create_xml_element(SPDocument *document, Persp3DImpl *dup) {// if dup is given, copy the attributes over
@@ -270,6 +370,39 @@ Persp3D *persp3d_document_first_persp(SPDocument *document)
static Inkscape::XML::Node *
persp3d_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
{
+// Persp3DImpl *persp_impl = SP_PERSP3D(object)->perspective_impl;
+//
+// if ((flags & SP_OBJECT_WRITE_BUILD & SP_OBJECT_WRITE_EXT) && !repr) {
+// // this is where we end up when saving as plain SVG (also in other circumstances?);
+// // hence we don't set the sodipodi:type attribute
+// repr = xml_doc->createElement("inkscape:perspective");
+// }
+//
+// if (flags & SP_OBJECT_WRITE_EXT) {
+// gchar *str = NULL; // FIXME: Should this be freed each time we set an attribute or only in the end or at all?
+// str = persp3d_pt_to_str (persp_impl, Proj::X);
+// repr->setAttribute("inkscape:vp_x", str);
+//
+// str = persp3d_pt_to_str (persp_impl, Proj::Y);
+// repr->setAttribute("inkscape:vp_y", str);
+//
+// str = persp3d_pt_to_str (persp_impl, Proj::Z);
+// repr->setAttribute("inkscape:vp_z", str);
+//
+// str = persp3d_pt_to_str (persp_impl, Proj::W);
+// repr->setAttribute("inkscape:persp3d-origin", str);
+// }
+//
+// if (((SPObjectClass *) persp3d_parent_class)->write)
+// (* ((SPObjectClass *) persp3d_parent_class)->write)(object, xml_doc, repr, flags);
+//
+// return repr;
+ return ((Persp3D*)object)->cpersp3d->onWrite(xml_doc, repr, flags);
+}
+
+Inkscape::XML::Node* CPersp3D::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
+ Persp3D* object = this->persp3d;
+
Persp3DImpl *persp_impl = SP_PERSP3D(object)->perspective_impl;
if ((flags & SP_OBJECT_WRITE_BUILD & SP_OBJECT_WRITE_EXT) && !repr) {
@@ -293,8 +426,10 @@ persp3d_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML:
repr->setAttribute("inkscape:persp3d-origin", str);
}
- if (((SPObjectClass *) persp3d_parent_class)->write)
- (* ((SPObjectClass *) persp3d_parent_class)->write)(object, xml_doc, repr, flags);
+// if (((SPObjectClass *) persp3d_parent_class)->write)
+// (* ((SPObjectClass *) persp3d_parent_class)->write)(object, xml_doc, repr, flags);
+
+ CObject::onWrite(xml_doc, repr, flags);
return repr;
}
diff --git a/src/persp3d.h b/src/persp3d.h
index db4971635..9f1f72d7a 100644
--- a/src/persp3d.h
+++ b/src/persp3d.h
@@ -46,7 +46,12 @@ public:
// friend class Persp3D;
};
-struct Persp3D : public SPObject {
+class CPersp3D;
+
+class Persp3D : public SPObject {
+public:
+ CPersp3D* cpersp3d;
+
Persp3DImpl *perspective_impl;
};
@@ -54,6 +59,24 @@ struct Persp3DClass {
SPItemClass parent_class;
};
+class CPersp3D : public CObject {
+public:
+ CPersp3D(Persp3D* persp3d);
+ virtual ~CPersp3D();
+
+ virtual void onBuild(SPDocument* doc, Inkscape::XML::Node* repr);
+ virtual void onRelease();
+
+ virtual void onSet(unsigned int key, const gchar* value);
+
+ virtual void onUpdate(SPCtx* ctx, unsigned int flags);
+
+ virtual Inkscape::XML::Node* onWrite(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags);
+
+private:
+ Persp3D* persp3d;
+};
+
/* Standard GType function */
GType persp3d_get_type (void);