summaryrefslogtreecommitdiffstats
path: root/src/persp3d.cpp
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-03-29 23:52:42 +0000
committerMarkus Engel <markus.engel@tum.de>2013-03-29 23:52:42 +0000
commita168040d5a452544328a1e6ad35aaac351f94d44 (patch)
treefae1ba829f543a473da281bd5fa6e4deabbf6912 /src/persp3d.cpp
parentRemoved function pointers from SPObject and subclasses. (diff)
parentDutch translation update (diff)
downloadinkscape-a168040d5a452544328a1e6ad35aaac351f94d44.tar.gz
inkscape-a168040d5a452544328a1e6ad35aaac351f94d44.zip
merged from trunk
(bzr r11608.1.56)
Diffstat (limited to 'src/persp3d.cpp')
-rw-r--r--src/persp3d.cpp174
1 files changed, 3 insertions, 171 deletions
diff --git a/src/persp3d.cpp b/src/persp3d.cpp
index 9c7f7b46c..0fc18a717 100644
--- a/src/persp3d.cpp
+++ b/src/persp3d.cpp
@@ -27,22 +27,11 @@
using Inkscape::DocumentUndo;
-static void persp3d_class_init(Persp3DClass *klass);
-static void persp3d_init(Persp3D *persp);
-
-static void persp3d_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
-static void persp3d_release(SPObject *object);
-static void persp3d_set(SPObject *object, unsigned key, gchar const *value);
-static void persp3d_update(SPObject *object, SPCtx *ctx, guint flags);
-static Inkscape::XML::Node *persp3d_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
-
static void persp3d_on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data);
static void persp3d_update_with_point (Persp3DImpl *persp_impl, Proj::Axis const axis, Proj::Pt2 const &new_image);
static gchar * persp3d_pt_to_str (Persp3DImpl *persp_impl, Proj::Axis const axis);
-static SPObjectClass *persp3d_parent_class;
-
static int global_counter = 0;
/* Constructor/destructor for the internal class */
@@ -54,28 +43,7 @@ Persp3DImpl::Persp3DImpl() {
my_counter = global_counter++;
}
-/**
- * Registers Persp3d class and returns its type.
- */
-GType
-persp3d_get_type()
-{
- static GType type = 0;
- if (!type) {
- GTypeInfo info = {
- sizeof(Persp3DClass),
- NULL, NULL,
- (GClassInitFunc) persp3d_class_init,
- NULL, NULL,
- sizeof(Persp3D),
- 16,
- (GInstanceInitFunc) persp3d_init,
- NULL, /* value_table */
- };
- type = g_type_register_static(SP_TYPE_OBJECT, "Persp3D", &info, (GTypeFlags)0);
- }
- return type;
-}
+G_DEFINE_TYPE(Persp3D, persp3d, SP_TYPE_OBJECT);
static Inkscape::XML::NodeEventVector const persp3d_repr_events = {
NULL, /* child_added */
@@ -92,13 +60,6 @@ static void persp3d_class_init(Persp3DClass *klass)
{
SPObjectClass *sp_object_class = (SPObjectClass *) klass;
- persp3d_parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT);
-
- //sp_object_class->build = persp3d_build;
-// sp_object_class->release = persp3d_release;
-// sp_object_class->set = persp3d_set;
-// sp_object_class->update = persp3d_update;
-// sp_object_class->write = persp3d_write;
}
CPersp3D::CPersp3D(Persp3D* persp3d) : CObject(persp3d) {
@@ -115,6 +76,8 @@ static void
persp3d_init(Persp3D *persp)
{
persp->cpersp3d = new CPersp3D(persp);
+
+ delete persp->cobject;
persp->cobject = persp->cpersp3d;
persp->perspective_impl = new Persp3DImpl();
@@ -123,23 +86,6 @@ persp3d_init(Persp3D *persp)
/**
* Virtual build: set persp3d attributes from its associated XML node.
*/
-//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);
-
- /* 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);
@@ -158,13 +104,6 @@ void CPersp3D::onBuild(SPDocument *document, Inkscape::XML::Node *repr) {
/**
* 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;
@@ -179,59 +118,6 @@ void CPersp3D::onRelease() {
*/
// FIXME: Currently we only read the finite positions of vanishing points;
// should we move VPs into their own repr (as it's done for SPStop, e.g.)?
-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;
@@ -267,8 +153,6 @@ void CPersp3D::onSet(unsigned key, gchar const *value) {
}
}
default: {
-// if (((SPObjectClass *) persp3d_parent_class)->set)
-// (* ((SPObjectClass *) persp3d_parent_class)->set)(object, key, value);
CObject::onSet(key, value);
break;
}
@@ -285,20 +169,6 @@ void CPersp3D::onSet(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)) {
@@ -306,8 +176,6 @@ void CPersp3D::onUpdate(SPCtx *ctx, guint flags) {
}
-// if (((SPObjectClass *) persp3d_parent_class)->update)
-// ((SPObjectClass *) persp3d_parent_class)->update(object, ctx, flags);
CObject::onUpdate(ctx, flags);
}
@@ -367,39 +235,6 @@ Persp3D *persp3d_document_first_persp(SPDocument *document)
/**
* Virtual write: write object attributes to repr.
*/
-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;
@@ -426,9 +261,6 @@ Inkscape::XML::Node* CPersp3D::onWrite(Inkscape::XML::Document *xml_doc, Inkscap
repr->setAttribute("inkscape:persp3d-origin", str);
}
-// if (((SPObjectClass *) persp3d_parent_class)->write)
-// (* ((SPObjectClass *) persp3d_parent_class)->write)(object, xml_doc, repr, flags);
-
CObject::onWrite(xml_doc, repr, flags);
return repr;