From 49354077a17c09dcfb4ff3b9f77a4d74d0563399 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 18 Aug 2012 21:30:20 +0200 Subject: Added "virtual pad" to Box3DSide. (bzr r11608.1.10) --- src/box3d-side.cpp | 86 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 22 deletions(-) (limited to 'src/box3d-side.cpp') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 031b16a7c..3b30e31ab 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -76,27 +76,45 @@ static void box3d_side_class_init(Box3DSideClass *klass) shape_class->set_shape = box3d_side_set_shape; } +CBox3DSide::CBox3DSide(Box3DSide* box3dside) : CPolygon(box3dside) { + this->spbox3dside = box3dside; +} + +CBox3DSide::~CBox3DSide() { +} + static void box3d_side_init (Box3DSide * side) { + side->cbox3dside = new CBox3DSide(side); + side->cpolygon = side->cbox3dside; + side->cshape = side->cbox3dside; + side->clpeitem = side->cbox3dside; + side->citem = side->cbox3dside; + side->cobject = side->cbox3dside; + side->dir1 = Box3D::NONE; side->dir2 = Box3D::NONE; side->front_or_rear = Box3D::FRONT; } -static void box3d_side_build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) -{ - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build(object, document, repr); - } +void CBox3DSide::onBuild(SPDocument * document, Inkscape::XML::Node * repr) { + Box3DSide* object = this->spbox3dside; + + CPolygon::onBuild(document, repr); object->readAttr( "inkscape:box3dsidetype" ); } -static Inkscape::XML::Node * -box3d_side_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +// CPPIFY: remove +static void box3d_side_build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) { - Box3DSide *side = SP_BOX3D_SIDE (object); + ((Box3DSide*)object)->cbox3dside->onBuild(document, repr); +} + +Inkscape::XML::Node* CBox3DSide::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + Box3DSide* object = this->spbox3dside; + Box3DSide *side = object; if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { // this is where we end up when saving as plain SVG (also in other circumstances?) @@ -120,16 +138,21 @@ box3d_side_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape:: repr->setAttribute("d", d); g_free (d); - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); + CPolygon::onWrite(xml_doc, repr, flags); return repr; } -static void -box3d_side_set (SPObject *object, unsigned int key, const gchar *value) +// CPPIFY: remove +static Inkscape::XML::Node * +box3d_side_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - Box3DSide *side = SP_BOX3D_SIDE (object); + return ((Box3DSide*)object)->cbox3dside->onWrite(xml_doc, repr, flags); +} + +void CBox3DSide::onSet(unsigned int key, const gchar* value) { + Box3DSide* object = this->spbox3dside; + Box3DSide *side = object; // TODO: In case the box was recreated (by undo, e.g.) we need to recreate the path // (along with other info?) from the parent box. @@ -154,15 +177,21 @@ box3d_side_set (SPObject *object, unsigned int key, const gchar *value) } break; default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + CPolygon::onSet(key, value); break; } } +// CPPIFY: remove static void -box3d_side_update (SPObject *object, SPCtx *ctx, guint flags) +box3d_side_set (SPObject *object, unsigned int key, const gchar *value) { + ((Box3DSide*)object)->cbox3dside->onSet(key, value); +} + +void CBox3DSide::onUpdate(SPCtx* ctx, guint flags) { + Box3DSide* object = this->spbox3dside; + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { flags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; // since we change the description, it's not a "just translation" anymore } @@ -173,8 +202,14 @@ box3d_side_update (SPObject *object, SPCtx *ctx, guint flags) static_cast(object)->setShape (); } - if (((SPObjectClass *) parent_class)->update) - ((SPObjectClass *) parent_class)->update (object, ctx, flags); + CPolygon::onUpdate(ctx, flags); +} + +// CPPIFY: remove +static void +box3d_side_update (SPObject *object, SPCtx *ctx, guint flags) +{ + ((Box3DSide*)object)->cbox3dside->onUpdate(ctx, flags); } /* Create a new Box3DSide and append it to the parent box */ @@ -205,10 +240,10 @@ box3d_side_position_set (Box3DSide *side) { side->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } -void -box3d_side_set_shape (SPShape *shape) -{ - Box3DSide *side = SP_BOX3D_SIDE (shape); +void CBox3DSide::onSetShape() { + Box3DSide* shape = this->spbox3dside; + Box3DSide *side = shape; + if (!side->document->getRoot()) { // avoid a warning caused by sp_document_height() (which is called from sp_item_i2d_affine() below) // when reading a file containing 3D boxes @@ -266,6 +301,13 @@ box3d_side_set_shape (SPShape *shape) c->unref(); } +// CPPIFY: remove +void +box3d_side_set_shape (SPShape *shape) +{ + ((Box3DSide*)shape)->cbox3dside->onSetShape(); +} + gchar *box3d_side_axes_string(Box3DSide *side) { GString *pstring = g_string_new(""); -- cgit v1.2.3 From 260c7156ca920232cca2e829782373a805d59cae Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 29 Sep 2012 17:43:15 +0200 Subject: Removed old calls to set_shape and update_patheffect. (bzr r11608.1.45) --- src/box3d-side.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/box3d-side.cpp') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 3b30e31ab..39982c49c 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -73,7 +73,7 @@ static void box3d_side_class_init(Box3DSideClass *klass) sp_object_class->set = box3d_side_set; sp_object_class->update = box3d_side_update; - shape_class->set_shape = box3d_side_set_shape; + //shape_class->set_shape = box3d_side_set_shape; } CBox3DSide::CBox3DSide(Box3DSide* box3dside) : CPolygon(box3dside) { -- cgit v1.2.3 From 8849fb5e5edbeb212a3f5fa61dd2a55acfc561a6 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 7 Oct 2012 01:01:59 +0200 Subject: Added some virtual pad calls to SPObject. (bzr r11608.1.47) --- src/box3d-side.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/box3d-side.cpp') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 39982c49c..b42bd6811 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -33,8 +33,8 @@ static void box3d_side_build (SPObject *object, SPDocument *document, Inkscape:: static Inkscape::XML::Node *box3d_side_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void box3d_side_set (SPObject *object, unsigned int key, const gchar *value); static void box3d_side_update (SPObject *object, SPCtx *ctx, guint flags); - -static void box3d_side_set_shape (SPShape *shape); +// +//static void box3d_side_set_shape (SPShape *shape); static void box3d_side_compute_corner_ids(Box3DSide *side, unsigned int corners[4]); @@ -64,7 +64,7 @@ box3d_side_get_type (void) static void box3d_side_class_init(Box3DSideClass *klass) { SPObjectClass *sp_object_class = reinterpret_cast(klass); - SPShapeClass *shape_class = reinterpret_cast(klass); +// SPShapeClass *shape_class = reinterpret_cast(klass); parent_class = (SPShapeClass *)g_type_class_ref (SP_TYPE_SHAPE); @@ -234,7 +234,8 @@ int Box3DSide::getFaceId() void box3d_side_position_set (Box3DSide *side) { - box3d_side_set_shape (SP_SHAPE (side)); + //box3d_side_set_shape (SP_SHAPE (side)); + side->cbox3dside->onSetShape(); // This call is responsible for live update of the sides during the initial drag side->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); @@ -302,11 +303,11 @@ void CBox3DSide::onSetShape() { } // CPPIFY: remove -void -box3d_side_set_shape (SPShape *shape) -{ - ((Box3DSide*)shape)->cbox3dside->onSetShape(); -} +//void +//box3d_side_set_shape (SPShape *shape) +//{ +// ((Box3DSide*)shape)->cbox3dside->onSetShape(); +//} gchar *box3d_side_axes_string(Box3DSide *side) { -- cgit v1.2.3 From a0a8d020201e0e38a63d9aa3dce228d7d9e6fb35 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Thu, 14 Mar 2013 12:42:39 +0100 Subject: Various changes. (bzr r11608.1.48) --- src/box3d-side.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/box3d-side.cpp') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index b42bd6811..c82344d46 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -68,7 +68,7 @@ static void box3d_side_class_init(Box3DSideClass *klass) parent_class = (SPShapeClass *)g_type_class_ref (SP_TYPE_SHAPE); - sp_object_class->build = box3d_side_build; + //sp_object_class->build = box3d_side_build; sp_object_class->write = box3d_side_write; sp_object_class->set = box3d_side_set; sp_object_class->update = box3d_side_update; -- cgit v1.2.3 From 957c3e4b7909d42c5a13f1b1dd583f877fc32259 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 00:46:57 +0100 Subject: Removed function pointers from SPObject and subclasses. Added some missing virtual pads for classes that were hidden by preprocessor macros. (bzr r11608.1.55) --- src/box3d-side.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/box3d-side.cpp') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index c82344d46..e79d2f3e2 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -69,9 +69,9 @@ static void box3d_side_class_init(Box3DSideClass *klass) parent_class = (SPShapeClass *)g_type_class_ref (SP_TYPE_SHAPE); //sp_object_class->build = box3d_side_build; - sp_object_class->write = box3d_side_write; - sp_object_class->set = box3d_side_set; - sp_object_class->update = box3d_side_update; +// sp_object_class->write = box3d_side_write; +// sp_object_class->set = box3d_side_set; +// sp_object_class->update = box3d_side_update; //shape_class->set_shape = box3d_side_set_shape; } -- cgit v1.2.3 From 7df6616da5ea2debb86838366ddf746841549cdb Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 00:56:13 +0100 Subject: Renamed virtual function names. (bzr r11608.1.57) --- src/box3d-side.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/box3d-side.cpp') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index ec09b60f3..c2672d89a 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -58,16 +58,16 @@ box3d_side_init (Box3DSide * side) side->front_or_rear = Box3D::FRONT; } -void CBox3DSide::onBuild(SPDocument * document, Inkscape::XML::Node * repr) { +void CBox3DSide::build(SPDocument * document, Inkscape::XML::Node * repr) { Box3DSide* object = this->spbox3dside; - CPolygon::onBuild(document, repr); + CPolygon::build(document, repr); object->readAttr( "inkscape:box3dsidetype" ); } -Inkscape::XML::Node* CBox3DSide::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +Inkscape::XML::Node* CBox3DSide::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { Box3DSide* object = this->spbox3dside; Box3DSide *side = object; @@ -93,12 +93,12 @@ Inkscape::XML::Node* CBox3DSide::onWrite(Inkscape::XML::Document *xml_doc, Inksc repr->setAttribute("d", d); g_free (d); - CPolygon::onWrite(xml_doc, repr, flags); + CPolygon::write(xml_doc, repr, flags); return repr; } -void CBox3DSide::onSet(unsigned int key, const gchar* value) { +void CBox3DSide::set(unsigned int key, const gchar* value) { Box3DSide* object = this->spbox3dside; Box3DSide *side = object; @@ -125,12 +125,12 @@ void CBox3DSide::onSet(unsigned int key, const gchar* value) { } break; default: - CPolygon::onSet(key, value); + CPolygon::set(key, value); break; } } -void CBox3DSide::onUpdate(SPCtx* ctx, guint flags) { +void CBox3DSide::update(SPCtx* ctx, guint flags) { Box3DSide* object = this->spbox3dside; if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { @@ -143,7 +143,7 @@ void CBox3DSide::onUpdate(SPCtx* ctx, guint flags) { static_cast(object)->setShape (); } - CPolygon::onUpdate(ctx, flags); + CPolygon::update(ctx, flags); } @@ -169,13 +169,13 @@ int Box3DSide::getFaceId() void box3d_side_position_set (Box3DSide *side) { - side->cbox3dside->onSetShape(); + side->cbox3dside->set_shape(); // This call is responsible for live update of the sides during the initial drag side->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } -void CBox3DSide::onSetShape() { +void CBox3DSide::set_shape() { Box3DSide* shape = this->spbox3dside; Box3DSide *side = shape; -- cgit v1.2.3 From a5d6e692d661f0bf7648e64e8fcb04588bb8f3ab Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 1 Apr 2013 00:07:00 +0200 Subject: Prepared exchange of casting macros. (bzr r11608.1.63) --- src/box3d-side.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/box3d-side.cpp') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index c2672d89a..a04fffa86 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -45,6 +45,7 @@ static void box3d_side_init (Box3DSide * side) { side->cbox3dside = new CBox3DSide(side); + side->typeHierarchy.insert(typeid(Box3DSide)); delete side->cpolygon; side->cpolygon = side->cbox3dside; -- cgit v1.2.3 From 69f3b6f1abb2bb422935d43262e1e99aab359954 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 2 Apr 2013 01:41:30 +0200 Subject: Added constructors to SP classes. (bzr r11608.1.67) --- src/box3d-side.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/box3d-side.cpp') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index a04fffa86..3b46b203a 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -28,7 +28,7 @@ struct SPPathClass; static void box3d_side_compute_corner_ids(Box3DSide *side, unsigned int corners[4]); -G_DEFINE_TYPE(Box3DSide, box3d_side, SP_TYPE_SHAPE); +G_DEFINE_TYPE(Box3DSide, box3d_side, G_TYPE_OBJECT); static void box3d_side_class_init(Box3DSideClass *klass) { @@ -41,9 +41,9 @@ CBox3DSide::CBox3DSide(Box3DSide* box3dside) : CPolygon(box3dside) { CBox3DSide::~CBox3DSide() { } -static void -box3d_side_init (Box3DSide * side) -{ +Box3DSide::Box3DSide() : SPPolygon() { + Box3DSide* side = this; + side->cbox3dside = new CBox3DSide(side); side->typeHierarchy.insert(typeid(Box3DSide)); @@ -59,6 +59,12 @@ box3d_side_init (Box3DSide * side) side->front_or_rear = Box3D::FRONT; } +static void +box3d_side_init (Box3DSide * side) +{ + new (side) Box3DSide(); +} + void CBox3DSide::build(SPDocument * document, Inkscape::XML::Node * repr) { Box3DSide* object = this->spbox3dside; -- cgit v1.2.3 From d1af3566872dfff2aeec84859c87f1f8d13f79df Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 2 Apr 2013 19:14:36 +0200 Subject: Registered classes with new factory. Hkern, Vkern and FeFuncX have to be rewritten, as they aren't real classes. (bzr r11608.1.69) --- src/box3d-side.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/box3d-side.cpp') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 3b46b203a..23bc269d5 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -28,6 +28,16 @@ struct SPPathClass; static void box3d_side_compute_corner_ids(Box3DSide *side, unsigned int corners[4]); +#include "sp-factory.h" + +namespace { + SPObject* createBox3DSide() { + return new Box3DSide(); + } + + bool box3DSideRegistered = SPFactory::instance().registerObject("inkscape:box3dside", createBox3DSide); +} + G_DEFINE_TYPE(Box3DSide, box3d_side, G_TYPE_OBJECT); static void box3d_side_class_init(Box3DSideClass *klass) -- cgit v1.2.3 From 8443720ce6429b9beec839e60b8a808595f4ba72 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 2 Apr 2013 23:01:45 +0200 Subject: Cleaned up a bit. Uses some C++11 features. (bzr r11608.1.72) --- src/box3d-side.cpp | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src/box3d-side.cpp') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 23bc269d5..c2940254f 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -24,8 +24,6 @@ #include "desktop-style.h" #include "box3d.h" -struct SPPathClass; - static void box3d_side_compute_corner_ids(Box3DSide *side, unsigned int corners[4]); #include "sp-factory.h" @@ -38,12 +36,6 @@ namespace { bool box3DSideRegistered = SPFactory::instance().registerObject("inkscape:box3dside", createBox3DSide); } -G_DEFINE_TYPE(Box3DSide, box3d_side, G_TYPE_OBJECT); - -static void box3d_side_class_init(Box3DSideClass *klass) -{ -} - CBox3DSide::CBox3DSide(Box3DSide* box3dside) : CPolygon(box3dside) { this->spbox3dside = box3dside; } @@ -69,12 +61,6 @@ Box3DSide::Box3DSide() : SPPolygon() { side->front_or_rear = Box3D::FRONT; } -static void -box3d_side_init (Box3DSide * side) -{ - new (side) Box3DSide(); -} - void CBox3DSide::build(SPDocument * document, Inkscape::XML::Node * repr) { Box3DSide* object = this->spbox3dside; -- cgit v1.2.3 From 748ffce08bb6250c87adabb64f45bff02509e9e7 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Fri, 5 Apr 2013 00:27:58 +0200 Subject: Combined some classes. (bzr r11608.1.75) --- src/box3d-side.cpp | 120 +++++++++++++++++++++++++---------------------------- 1 file changed, 56 insertions(+), 64 deletions(-) (limited to 'src/box3d-side.cpp') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index c2940254f..ca80f91df 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -36,44 +36,28 @@ namespace { bool box3DSideRegistered = SPFactory::instance().registerObject("inkscape:box3dside", createBox3DSide); } -CBox3DSide::CBox3DSide(Box3DSide* box3dside) : CPolygon(box3dside) { - this->spbox3dside = box3dside; -} - -CBox3DSide::~CBox3DSide() { -} - Box3DSide::Box3DSide() : SPPolygon() { - Box3DSide* side = this; - - side->cbox3dside = new CBox3DSide(side); - side->typeHierarchy.insert(typeid(Box3DSide)); - - delete side->cpolygon; - side->cpolygon = side->cbox3dside; - side->cshape = side->cbox3dside; - side->clpeitem = side->cbox3dside; - side->citem = side->cbox3dside; - side->cobject = side->cbox3dside; - - side->dir1 = Box3D::NONE; - side->dir2 = Box3D::NONE; - side->front_or_rear = Box3D::FRONT; + this->cshape = this; + this->clpeitem = this; + this->citem = this; + this->cobject = this; + + this->dir1 = Box3D::NONE; + this->dir2 = Box3D::NONE; + this->front_or_rear = Box3D::FRONT; } -void CBox3DSide::build(SPDocument * document, Inkscape::XML::Node * repr) { - Box3DSide* object = this->spbox3dside; +Box3DSide::~Box3DSide() { +} - CPolygon::build(document, repr); +void Box3DSide::build(SPDocument * document, Inkscape::XML::Node * repr) { + SPPolygon::build(document, repr); - object->readAttr( "inkscape:box3dsidetype" ); + this->readAttr( "inkscape:box3dsidetype" ); } -Inkscape::XML::Node* CBox3DSide::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - Box3DSide* object = this->spbox3dside; - Box3DSide *side = object; - +Inkscape::XML::Node* Box3DSide::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { // this is where we end up when saving as plain SVG (also in other circumstances?) // thus we don' set "sodipodi:type" so that the box is only saved as an ordinary svg:path @@ -81,30 +65,29 @@ Inkscape::XML::Node* CBox3DSide::write(Inkscape::XML::Document *xml_doc, Inkscap } if (flags & SP_OBJECT_WRITE_EXT) { - sp_repr_set_int(repr, "inkscape:box3dsidetype", side->dir1 ^ side->dir2 ^ side->front_or_rear); + sp_repr_set_int(repr, "inkscape:box3dsidetype", this->dir1 ^ this->dir2 ^ this->front_or_rear); } - static_cast(object)->setShape(); + this->setShape(); /* Duplicate the path */ - SPCurve const *curve = (SP_SHAPE(object))->_curve; + SPCurve const *curve = this->_curve; + //Nulls might be possible if this called iteratively if ( !curve ) { return NULL; } + char *d = sp_svg_write_path ( curve->get_pathvector() ); repr->setAttribute("d", d); g_free (d); - CPolygon::write(xml_doc, repr, flags); + SPPolygon::write(xml_doc, repr, flags); return repr; } -void CBox3DSide::set(unsigned int key, const gchar* value) { - Box3DSide* object = this->spbox3dside; - Box3DSide *side = object; - +void Box3DSide::set(unsigned int key, const gchar* value) { // TODO: In case the box was recreated (by undo, e.g.) we need to recreate the path // (along with other info?) from the parent box. @@ -117,25 +100,25 @@ void CBox3DSide::set(unsigned int key, const gchar* value) { if (!Box3D::is_face_id(desc)) { g_print ("desc is not a face id: =%s=\n", value); } + g_return_if_fail (Box3D::is_face_id (desc)); + Box3D::Axis plane = (Box3D::Axis) (desc & 0x7); plane = (Box3D::is_plane(plane) ? plane : Box3D::orth_plane_or_axis(plane)); - side->dir1 = Box3D::extract_first_axis_direction(plane); - side->dir2 = Box3D::extract_second_axis_direction(plane); - side->front_or_rear = (Box3D::FrontOrRear) (desc & 0x8); + this->dir1 = Box3D::extract_first_axis_direction(plane); + this->dir2 = Box3D::extract_second_axis_direction(plane); + this->front_or_rear = (Box3D::FrontOrRear) (desc & 0x8); - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } break; default: - CPolygon::set(key, value); + SPPolygon::set(key, value); break; } } -void CBox3DSide::update(SPCtx* ctx, guint flags) { - Box3DSide* object = this->spbox3dside; - +void Box3DSide::update(SPCtx* ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { flags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; // since we change the description, it's not a "just translation" anymore } @@ -143,11 +126,11 @@ void CBox3DSide::update(SPCtx* ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { - static_cast(object)->setShape (); - } - CPolygon::update(ctx, flags); + this->setShape(); + } + SPPolygon::update(ctx, flags); } /* Create a new Box3DSide and append it to the parent box */ @@ -172,30 +155,30 @@ int Box3DSide::getFaceId() void box3d_side_position_set (Box3DSide *side) { - side->cbox3dside->set_shape(); + side->set_shape(); // This call is responsible for live update of the sides during the initial drag side->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } -void CBox3DSide::set_shape() { - Box3DSide* shape = this->spbox3dside; - Box3DSide *side = shape; - - if (!side->document->getRoot()) { +void Box3DSide::set_shape() { + if (!this->document->getRoot()) { // avoid a warning caused by sp_document_height() (which is called from sp_item_i2d_affine() below) // when reading a file containing 3D boxes return; } - SPObject *parent = side->parent; + SPObject *parent = this->parent; + if (!SP_IS_BOX3D(parent)) { - g_warning ("Parent of 3D box side is not a 3D box.\n"); + g_warning("Parent of 3D box side is not a 3D box.\n"); return; } + SPBox3D *box = SP_BOX3D(parent); - Persp3D *persp = box3d_side_perspective(side); + Persp3D *persp = box3d_side_perspective(this); + if (!persp) { return; } @@ -206,7 +189,7 @@ void CBox3DSide::set_shape() { // resulting path. unsigned int corners[4]; - box3d_side_compute_corner_ids(side, corners); + box3d_side_compute_corner_ids(this, corners); SPCurve *c = new SPCurve(); @@ -225,17 +208,21 @@ void CBox3DSide::set_shape() { c->lineto(box3d_get_corner_screen(box, corners[3])); c->closepath(); - /* Reset the shape'scurve to the "original_curve" + /* Reset the this'scurve to the "original_curve" * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ - shape->setCurveInsync( c, TRUE); - if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(shape)) && sp_lpe_item_path_effects_enabled(SP_LPE_ITEM(shape))) { + this->setCurveInsync( c, TRUE); + + if (sp_lpe_item_has_path_effect(this) && sp_lpe_item_path_effects_enabled(this)) { SPCurve *c_lpe = c->copy(); - bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM (shape), c_lpe); + bool success = sp_lpe_item_perform_path_effect(this, c_lpe); + if (success) { - shape->setCurveInsync( c_lpe, TRUE); + this->setCurveInsync(c_lpe, TRUE); } + c_lpe->unref(); } + c->unref(); } @@ -243,19 +230,24 @@ gchar *box3d_side_axes_string(Box3DSide *side) { GString *pstring = g_string_new(""); g_string_printf (pstring, "%s", Box3D::string_from_axes ((Box3D::Axis) (side->dir1 ^ side->dir2))); + switch ((Box3D::Axis) (side->dir1 ^ side->dir2)) { case Box3D::XY: g_string_append_printf (pstring, (side->front_or_rear == Box3D::FRONT) ? "front" : "rear"); break; + case Box3D::XZ: g_string_append_printf (pstring, (side->front_or_rear == Box3D::FRONT) ? "top" : "bottom"); break; + case Box3D::YZ: g_string_append_printf (pstring, (side->front_or_rear == Box3D::FRONT) ? "right" : "left"); break; + default: break; } + return pstring->str; } -- cgit v1.2.3 From cfe48de7f071e2e07a1f2f2ace3456f7b410e93b Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Fri, 5 Apr 2013 15:37:33 +0200 Subject: Merged Shape and subclasses. Cleaned up a bit. (bzr r11608.1.76) --- src/box3d-side.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/box3d-side.cpp') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index ca80f91df..240a2ee98 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -37,7 +37,6 @@ namespace { } Box3DSide::Box3DSide() : SPPolygon() { - this->cshape = this; this->clpeitem = this; this->citem = this; this->cobject = this; @@ -68,7 +67,7 @@ Inkscape::XML::Node* Box3DSide::write(Inkscape::XML::Document *xml_doc, Inkscape sp_repr_set_int(repr, "inkscape:box3dsidetype", this->dir1 ^ this->dir2 ^ this->front_or_rear); } - this->setShape(); + this->set_shape(); /* Duplicate the path */ SPCurve const *curve = this->_curve; @@ -127,7 +126,7 @@ void Box3DSide::update(SPCtx* ctx, guint flags) { SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { - this->setShape(); + this->set_shape(); } SPPolygon::update(ctx, flags); -- cgit v1.2.3 From 19d00efa85cfc42ccae9bd17ef575602f0d22c50 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Fri, 5 Apr 2013 19:42:32 +0200 Subject: Merged more classes. (bzr r11608.1.78) --- src/box3d-side.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/box3d-side.cpp') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 240a2ee98..2761bde61 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -37,7 +37,6 @@ namespace { } Box3DSide::Box3DSide() : SPPolygon() { - this->clpeitem = this; this->citem = this; this->cobject = this; -- cgit v1.2.3 From 8073924aacdda310fb7492750f78d5389b3186af Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Fri, 5 Apr 2013 22:45:01 +0200 Subject: Merged Item. (bzr r11608.1.81) --- src/box3d-side.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/box3d-side.cpp') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 2761bde61..fc261ae85 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -37,7 +37,6 @@ namespace { } Box3DSide::Box3DSide() : SPPolygon() { - this->citem = this; this->cobject = this; this->dir1 = Box3D::NONE; -- cgit v1.2.3 From 27e2102f96a5554bcd5310ec11435d155773b279 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 7 Apr 2013 18:28:22 +0200 Subject: Merge Object and subclasses. Merging of SP- and C-classes complete. (bzr r11608.1.86) --- src/box3d-side.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/box3d-side.cpp') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index fc261ae85..d3d3b82a2 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -37,8 +37,6 @@ namespace { } Box3DSide::Box3DSide() : SPPolygon() { - this->cobject = this; - this->dir1 = Box3D::NONE; this->dir2 = Box3D::NONE; this->front_or_rear = Box3D::FRONT; -- cgit v1.2.3