From 07eac1237fe242e6680bd0d76552771ff852fef7 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 18 Aug 2012 01:36:49 +0200 Subject: Added "virtual pad" to SPItem. (bzr r11608.1.2) --- src/sp-item.cpp | 161 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 123 insertions(+), 38 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index b1eb5a24a..20b6b3ef3 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -120,11 +120,22 @@ SPItemClass::sp_item_class_init(SPItemClass *klass) klass->snappoints = SPItem::sp_item_private_snappoints; } +// CPPIFY: remove +CItem::CItem(SPItem* item) : CObject(item) { + this->spitem = item; +} + +CItem::~CItem() { +} + /** * Callback for SPItem object initialization. */ void SPItem::sp_item_init(SPItem *item) { + item->citem = new CItem(item); + item->cobject = item->citem; + item->init(); } @@ -413,9 +424,9 @@ void SPItem::moveTo(SPItem *target, gboolean intoafter) { } } +void CItem::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { + SPItem* object = this->spitem; -void SPItem::sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -{ object->readAttr( "style" ); object->readAttr( "transform" ); object->readAttr( "clip-path" ); @@ -427,14 +438,17 @@ void SPItem::sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML object->readAttr( "inkscape:connector-avoid" ); object->readAttr( "inkscape:connection-points" ); - if (((SPObjectClass *) (SPItemClass::static_parent_class))->build) { - (* ((SPObjectClass *) (SPItemClass::static_parent_class))->build)(object, document, repr); - } + CObject::onBuild(document, repr); } -void SPItem::sp_item_release(SPObject *object) +// CPPIFY: remove +void SPItem::sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - SPItem *item = (SPItem *) object; + ((SPItem*)object)->citem->onBuild(document, repr); +} + +void CItem::onRelease() { + SPItem* item = this->spitem; // Note: do this here before the clip_ref is deleted, since calling // ensureUpToDate() for triggered routing may reference @@ -447,20 +461,25 @@ void SPItem::sp_item_release(SPObject *object) delete item->clip_ref; delete item->mask_ref; - if (((SPObjectClass *) (SPItemClass::static_parent_class))->release) { - ((SPObjectClass *) SPItemClass::static_parent_class)->release(object); - } + CObject::onRelease(); while (item->display) { - item->display = sp_item_view_list_remove(item->display, item->display); + item->display = SPItem::sp_item_view_list_remove(item->display, item->display); } item->_transformed_signal.~signal(); + } -void SPItem::sp_item_set(SPObject *object, unsigned key, gchar const *value) +// CPPIFY: remove +void SPItem::sp_item_release(SPObject *object) { - SPItem *item = (SPItem *) object; + ((SPItem*)object)->citem->onRelease(); +} + +void CItem::onSet(unsigned int key, gchar const* value) { + SPItem *item = this->spitem; + SPItem* object = item; switch (key) { case SP_ATTR_TRANSFORM: { @@ -544,14 +563,18 @@ void SPItem::sp_item_set(SPObject *object, unsigned key, gchar const *value) sp_style_read_from_object(object->style, object); object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); } else { - if (((SPObjectClass *) (SPItemClass::static_parent_class))->set) { - (* ((SPObjectClass *) (SPItemClass::static_parent_class))->set)(object, key, value); - } + CObject::onSet(key, value); } break; } } +// CPPIFY: remove +void SPItem::sp_item_set(SPObject *object, unsigned key, gchar const *value) +{ + ((SPItem*)object)->citem->onSet(key, value); +} + void SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) { if (old_clip) { @@ -601,13 +624,16 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) } } -void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) -{ - SPItem *item = SP_ITEM(object); +void CItem::onUpdate(SPCtx *ctx, guint flags) { + SPItem *item = this->spitem; + SPItem* object = item; - if (((SPObjectClass *) (SPItemClass::static_parent_class))->update) { - (* ((SPObjectClass *) (SPItemClass::static_parent_class))->update)(object, ctx, flags); - } + // CPPIFY: As CItem is derived directly from CObject, this doesn't make no sense. + // CObject::onUpdate is pure. What was the idea behind these lines? +// if (((SPObjectClass *) (SPItemClass::static_parent_class))->update) { +// (* ((SPObjectClass *) (SPItemClass::static_parent_class))->update)(object, ctx, flags); +// } +// CObject::onUpdate(ctx, flags); // any of the modifications defined in sp-object.h might change bbox, // so we invalidate it unconditionally @@ -661,9 +687,15 @@ void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) item->avoidRef->handleSettingChange(); } -Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +// CPPIFY: remove +void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) { - SPItem *item = SP_ITEM(object); + ((SPItem*)object)->citem->onUpdate(ctx, flags); +} + +Inkscape::XML::Node* CItem::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPItem *item = this->spitem; + SPItem* object = item; // in the case of SP_OBJECT_WRITE_BUILD, the item should always be newly created, // so we need to add any children from the underlying object to the new repr @@ -721,13 +753,22 @@ Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML } } - if (((SPObjectClass *) (SPItemClass::static_parent_class))->write) { - ((SPObjectClass *) (SPItemClass::static_parent_class))->write(object, xml_doc, repr, flags); - } + CObject::onWrite(xml_doc, repr, flags); return repr; } +// CPPIFY: remove +Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +{ + return ((SPItem*)object)->citem->onWrite(xml_doc, repr, flags); +} + +// CPPIFY: make pure virtual +Geom::OptRect CItem::onBbox(Geom::Affine const &transform, SPItem::BBoxType type) { + throw; +} + /** * Get item's geometric bounding box in this item's coordinate system. * @@ -813,6 +854,7 @@ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const return bbox; } + Geom::OptRect SPItem::bounds(BBoxType type, Geom::Affine const &transform) const { if (type == GEOMETRIC_BBOX) { @@ -902,6 +944,12 @@ unsigned SPItem::pos_in_parent() return 0; } +// CPPIFY: make pure virtual, see below! +void CItem::onSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { + throw; +} + +// CPPIFY: remove void SPItem::sp_item_private_snappoints(SPItem const * /*item*/, std::vector &/*p*/, Inkscape::SnapPreferences const * /*snapprefs*/) { /* This will only be called if the derived class doesn't override this. @@ -911,7 +959,6 @@ void SPItem::sp_item_private_snappoints(SPItem const * /*item*/, std::vector &p, Inkscape::SnapPreferences const *snapprefs) const { // Get the snappoints of the item @@ -953,6 +1000,11 @@ void SPItem::getSnappoints(std::vector &p, Inkscap } } +// CPPIFY: make pure virtual +void CItem::onPrint(SPPrintContext* ctx) { + throw; +} + void SPItem::invoke_print(SPPrintContext *ctx) { if ( !isHidden() ) { @@ -970,9 +1022,15 @@ void SPItem::invoke_print(SPPrintContext *ctx) } } -gchar *SPItem::sp_item_private_description(SPItem */*item*/) +// CPPIFY: is it possible to combine this method with "SPItem::description()"? +gchar* CItem::onDescription() { + return g_strdup(_("Object")); +} + +// CPPIFY: remove +gchar *SPItem::sp_item_private_description(SPItem *item) { - return g_strdup(_("Object")); + return item->citem->onDescription(); } /** @@ -1040,6 +1098,11 @@ unsigned SPItem::display_key_new(unsigned numkeys) return dkey - numkeys; } +// CPPIFY: make pure virtual +Inkscape::DrawingItem* CItem::onShow(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { + throw; +} + Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned key, unsigned flags) { Inkscape::DrawingItem *ai = NULL; @@ -1094,6 +1157,11 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned return ai; } +// CPPIFY: make pure virtual +void CItem::onHide(unsigned int key) { + throw; +} + void SPItem::invoke_hide(unsigned key) { if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->hide) { @@ -1323,6 +1391,11 @@ void SPItem::adjust_livepatheffect (Geom::Affine const &postmul, bool set) } } +// CPPIFY:: make pure virtual +Geom::Affine CItem::onSetTransform(Geom::Affine const &transform) { + throw; +} + /** * Set a new transform on an object. * @@ -1425,6 +1498,11 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra _transformed_signal.emit(&advertized_transform, this); } +// CPPIFY: see below, do not make pure? +gint CItem::onEvent(SPEvent* event) { + return FALSE; +} + gint SPItem::emitEvent(SPEvent &event) { if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->event) { @@ -1449,15 +1527,22 @@ void SPItem::set_item_transform(Geom::Affine const &transform_matrix) } } -void SPItem::convert_item_to_guides() { - // Use derived method if present ... - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->convert_to_guides) { - (*((SPItemClass *) G_OBJECT_GET_CLASS(this))->convert_to_guides)(this); - } else { - // .. otherwise simply place the guides around the item's bounding box +void CItem::onConvertToGuides() { + // CPPIFY: If not overridden, call SPItem::convert_to_guides(), see below! + this->spitem->convert_to_guides(); +} - convert_to_guides(); - } +// CPPIFY: remove +void SPItem::convert_item_to_guides() { +// // Use derived method if present ... +// if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->convert_to_guides) { +// (*((SPItemClass *) G_OBJECT_GET_CLASS(this))->convert_to_guides)(this); +// } else { +// // .. otherwise simply place the guides around the item's bounding box +// +// convert_to_guides(); +// } + this->citem->onConvertToGuides(); } -- cgit v1.2.3 From 3e79e62687153095acc0c2e7dc6865905d33a827 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 20 Aug 2012 08:29:15 +0200 Subject: As all subclasses of SPItem now have "virtual pads" with correct inheritance, all virtual function calls in SPItem were converted to C++ style. (bzr r11608.1.30) --- src/sp-item.cpp | 120 +++++++++++++++++++++++--------------------------------- 1 file changed, 50 insertions(+), 70 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 20b6b3ef3..e6cc563f6 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -777,10 +777,10 @@ Geom::OptRect CItem::onBbox(Geom::Affine const &transform, SPItem::BBoxType type Geom::OptRect SPItem::geometricBounds(Geom::Affine const &transform) const { Geom::OptRect bbox; + // call the subclass method - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) { - bbox = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, transform, SPItem::GEOMETRIC_BBOX); - } + bbox = this->citem->onBbox(transform, SPItem::GEOMETRIC_BBOX); + return bbox; } @@ -797,10 +797,8 @@ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const Geom::OptRect bbox; if ( style && style->filter.href && style->getFilter() && SP_IS_FILTER(style->getFilter())) { - // call the subclass method - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) { - bbox = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, Geom::identity(), SPItem::VISUAL_BBOX); - } + // call the subclass method + bbox = this->citem->onBbox(Geom::identity(), SPItem::VISUAL_BBOX); SPFilter *filter = SP_FILTER(style->getFilter()); // default filer area per the SVG spec: @@ -843,10 +841,8 @@ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const bbox = Geom::OptRect(minp, maxp); *bbox *= transform; } else { - // call the subclass method - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) { - bbox = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, transform, SPItem::VISUAL_BBOX); - } + // call the subclass method + bbox = this->citem->onBbox(transform, SPItem::VISUAL_BBOX); } if (clip_ref->getObject()) { bbox.intersectWith(SP_CLIPPATH(clip_ref->getObject())->geometricBounds(transform)); @@ -962,10 +958,7 @@ void SPItem::sp_item_private_snappoints(SPItem const * /*item*/, std::vector &p, Inkscape::SnapPreferences const *snapprefs) const { // Get the snappoints of the item - SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(this); - if (item_class.snappoints) { - item_class.snappoints(this, p, snapprefs); - } + this->citem->onSnappoints(p, snapprefs); // Get the snappoints at the item's center if (snapprefs != NULL && snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER)) { @@ -1008,17 +1001,13 @@ void CItem::onPrint(SPPrintContext* ctx) { void SPItem::invoke_print(SPPrintContext *ctx) { if ( !isHidden() ) { - if ( reinterpret_cast(G_OBJECT_GET_CLASS(this))->print ) { - if (!transform.isIdentity() - || style->opacity.value != SP_SCALE24_MAX) - { - sp_print_bind(ctx, transform, SP_SCALE24_TO_FLOAT(style->opacity.value)); - reinterpret_cast(G_OBJECT_GET_CLASS(this))->print(this, ctx); - sp_print_release(ctx); - } else { - reinterpret_cast(G_OBJECT_GET_CLASS(this))->print(this, ctx); - } - } + if (!transform.isIdentity() || style->opacity.value != SP_SCALE24_MAX) { + sp_print_bind(ctx, transform, SP_SCALE24_TO_FLOAT(style->opacity.value)); + this->citem->onPrint(ctx); + sp_print_release(ctx); + } else { + this->citem->onPrint(ctx); + } } } @@ -1040,34 +1029,29 @@ gchar *SPItem::sp_item_private_description(SPItem *item) */ gchar *SPItem::description() { - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->description) { - gchar *s = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->description(this); - if (s && clip_ref->getObject()) { - gchar *snew = g_strdup_printf (_("%s; clipped"), s); - g_free (s); - s = snew; - } - if (s && mask_ref->getObject()) { - gchar *snew = g_strdup_printf (_("%s; masked"), s); - g_free (s); - s = snew; - } - if ( style && style->filter.href && style->filter.href->getObject() ) { - const gchar *label = style->filter.href->getObject()->label(); - gchar *snew = 0; - if (label) { - snew = g_strdup_printf (_("%s; filtered (%s)"), s, _(label)); - } else { - snew = g_strdup_printf (_("%s; filtered"), s); - } - g_free (s); - s = snew; - } - return s; - } - - g_assert_not_reached(); - return NULL; + gchar* s = this->citem->onDescription(); + if (s && clip_ref->getObject()) { + gchar *snew = g_strdup_printf (_("%s; clipped"), s); + g_free (s); + s = snew; + } + if (s && mask_ref->getObject()) { + gchar *snew = g_strdup_printf (_("%s; masked"), s); + g_free (s); + s = snew; + } + if ( style && style->filter.href && style->filter.href->getObject() ) { + const gchar *label = style->filter.href->getObject()->label(); + gchar *snew = 0; + if (label) { + snew = g_strdup_printf (_("%s; filtered (%s)"), s, _(label)); + } else { + snew = g_strdup_printf (_("%s; filtered"), s); + } + g_free (s); + s = snew; + } + return s; } /** @@ -1077,9 +1061,11 @@ gchar *SPItem::description() int SPItem::ifilt() { int retval=0; - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->description) { - if ( style && style->filter.href && style->filter.href->getObject() ) { retval=1; } - } + + if ( style && style->filter.href && style->filter.href->getObject() ) { + retval=1; + } + return retval; } @@ -1106,9 +1092,8 @@ Inkscape::DrawingItem* CItem::onShow(Inkscape::Drawing &drawing, unsigned int ke Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned key, unsigned flags) { Inkscape::DrawingItem *ai = NULL; - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->show) { - ai = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->show(this, drawing, key, flags); - } + + ai = this->citem->onShow(drawing, key, flags); if (ai != NULL) { Geom::OptRect item_bbox = geometricBounds(); @@ -1164,9 +1149,7 @@ void CItem::onHide(unsigned int key) { void SPItem::invoke_hide(unsigned key) { - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->hide) { - ((SPItemClass *) G_OBJECT_GET_CLASS(this))->hide(this, key); - } + this->citem->onHide(key); SPItemView *ref = NULL; SPItemView *v = display; @@ -1461,13 +1444,14 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra gint preserve = prefs->getBool("/options/preservetransform/value", 0); Geom::Affine transform_attr (transform); if ( // run the object's set_transform (i.e. embed transform) only if: - ((SPItemClass *) G_OBJECT_GET_CLASS(this))->set_transform && // it does have a set_transform method !preserve && // user did not chose to preserve all transforms !clip_ref->getObject() && // the object does not have a clippath !mask_ref->getObject() && // the object does not have a mask !(!transform.isTranslation() && style && style->getFilter()) // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) ) { - transform_attr = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->set_transform(this, transform); + + transform_attr = this->citem->onSetTransform(transform); + if (freeze_stroke_width) { freeze_stroke_width_recursive(false); } @@ -1505,11 +1489,7 @@ gint CItem::onEvent(SPEvent* event) { gint SPItem::emitEvent(SPEvent &event) { - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->event) { - return ((SPItemClass *) G_OBJECT_GET_CLASS(this))->event(this, &event); - } - - return FALSE; + return this->citem->onEvent(&event); } /** -- cgit v1.2.3 From a6ee236472ac07f5719e41bc396163d485757dc6 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 21 Aug 2012 14:41:57 +0200 Subject: Fixed some virtual function calls in SPItem and SPUse that led to crashes as they were not implemented in the base class. (bzr r11608.1.36) --- src/sp-item.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index e6cc563f6..ea78e2e99 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1374,9 +1374,11 @@ void SPItem::adjust_livepatheffect (Geom::Affine const &postmul, bool set) } } -// CPPIFY:: make pure virtual +// CPPIFY:: make pure virtual? +// Not all SPItems must necessarily have a set transform method! Geom::Affine CItem::onSetTransform(Geom::Affine const &transform) { - throw; +// throw; + return transform; } /** @@ -1443,6 +1445,11 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra gint preserve = prefs->getBool("/options/preservetransform/value", 0); Geom::Affine transform_attr (transform); + + // CPPIFY: check this code. + // If onSetTransform is not overridden, CItem::onSetTransform will return the transform it was given as a parameter. + // onSetTransform cannot be pure due to the fact that not all visible Items are transformable. + if ( // run the object's set_transform (i.e. embed transform) only if: !preserve && // user did not chose to preserve all transforms !clip_ref->getObject() && // the object does not have a clippath -- cgit v1.2.3 From 99cb30e28d4ee193f39e23464abbd7630cac8a2d Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 6 Oct 2012 23:56:27 +0200 Subject: Added virtual pad to SPFlowtext; removed old calls to virtual SPItem methods. (bzr r11608.1.46) --- src/sp-item.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index ea78e2e99..3058d8974 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -116,8 +116,8 @@ SPItemClass::sp_item_class_init(SPItemClass *klass) sp_object_class->update = SPItem::sp_item_update; sp_object_class->write = SPItem::sp_item_write; - klass->description = SPItem::sp_item_private_description; - klass->snappoints = SPItem::sp_item_private_snappoints; +// klass->description = SPItem::sp_item_private_description; +// klass->snappoints = SPItem::sp_item_private_snappoints; } // CPPIFY: remove @@ -946,14 +946,14 @@ void CItem::onSnappoints(std::vector &p, Inkscape: } // CPPIFY: remove -void SPItem::sp_item_private_snappoints(SPItem const * /*item*/, std::vector &/*p*/, Inkscape::SnapPreferences const * /*snapprefs*/) -{ +//void SPItem::sp_item_private_snappoints(SPItem const * /*item*/, std::vector &/*p*/, Inkscape::SnapPreferences const * /*snapprefs*/) +//{ /* This will only be called if the derived class doesn't override this. * see for example sp_genericellipse_snappoints in sp-ellipse.cpp * We don't know what shape we could be dealing with here, so we'll just * do nothing */ -} +//} void SPItem::getSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const { @@ -1017,10 +1017,10 @@ gchar* CItem::onDescription() { } // CPPIFY: remove -gchar *SPItem::sp_item_private_description(SPItem *item) -{ - return item->citem->onDescription(); -} +//gchar *SPItem::sp_item_private_description(SPItem *item) +//{ +// return item->citem->onDescription(); +//} /** * Returns a string suitable for status bar, formatted in pango markup language. -- 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/sp-item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 3058d8974..ebbe04f03 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -110,7 +110,7 @@ SPItemClass::sp_item_class_init(SPItemClass *klass) static_parent_class = (SPObjectClass *)g_type_class_ref(SP_TYPE_OBJECT); - sp_object_class->build = SPItem::sp_item_build; + //sp_object_class->build = SPItem::sp_item_build; sp_object_class->release = SPItem::sp_item_release; sp_object_class->set = SPItem::sp_item_set; sp_object_class->update = SPItem::sp_item_update; -- cgit v1.2.3 From 3d7b1356600880a43e44e864cab08fff29cd23af Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 00:45:33 +0100 Subject: Added "virtual pads" to - SPFeFuncNode - SPFeDistantLight - SPFeMergeNode - SPFePointLight - SPFeSpotLight - SPFilter - SPFont - SPGuide Changes in SPItem and SPNamedView. (bzr r11608.1.49) --- src/sp-item.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index ebbe04f03..1ba1aa7ea 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -442,10 +442,10 @@ void CItem::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { } // CPPIFY: remove -void SPItem::sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -{ - ((SPItem*)object)->citem->onBuild(document, repr); -} +//void SPItem::sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +//{ +// ((SPItem*)object)->citem->onBuild(document, repr); +//} void CItem::onRelease() { SPItem* item = this->spitem; @@ -766,7 +766,8 @@ Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML // CPPIFY: make pure virtual Geom::OptRect CItem::onBbox(Geom::Affine const &transform, SPItem::BBoxType type) { - throw; + //throw; + return Geom::OptRect(); } /** @@ -942,7 +943,7 @@ unsigned SPItem::pos_in_parent() // CPPIFY: make pure virtual, see below! void CItem::onSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { - throw; + //throw; } // CPPIFY: remove @@ -995,7 +996,7 @@ void SPItem::getSnappoints(std::vector &p, Inkscap // CPPIFY: make pure virtual void CItem::onPrint(SPPrintContext* ctx) { - throw; + //throw; } void SPItem::invoke_print(SPPrintContext *ctx) @@ -1086,7 +1087,8 @@ unsigned SPItem::display_key_new(unsigned numkeys) // CPPIFY: make pure virtual Inkscape::DrawingItem* CItem::onShow(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { - throw; + //throw; + return 0; } Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned key, unsigned flags) @@ -1144,7 +1146,7 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned // CPPIFY: make pure virtual void CItem::onHide(unsigned int key) { - throw; + //throw; } void SPItem::invoke_hide(unsigned key) -- 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/sp-item.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 1ba1aa7ea..33e6bf342 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -111,10 +111,10 @@ SPItemClass::sp_item_class_init(SPItemClass *klass) static_parent_class = (SPObjectClass *)g_type_class_ref(SP_TYPE_OBJECT); //sp_object_class->build = SPItem::sp_item_build; - sp_object_class->release = SPItem::sp_item_release; - sp_object_class->set = SPItem::sp_item_set; - sp_object_class->update = SPItem::sp_item_update; - sp_object_class->write = SPItem::sp_item_write; +// sp_object_class->release = SPItem::sp_item_release; +// sp_object_class->set = SPItem::sp_item_set; +// sp_object_class->update = SPItem::sp_item_update; +// sp_object_class->write = SPItem::sp_item_write; // klass->description = SPItem::sp_item_private_description; // klass->snappoints = SPItem::sp_item_private_snappoints; -- 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/sp-item.cpp | 58 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 9dfb22139..4e157666a 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -395,7 +395,7 @@ void SPItem::moveTo(SPItem *target, gboolean intoafter) { } } -void CItem::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { +void CItem::build(SPDocument *document, Inkscape::XML::Node *repr) { SPItem* object = this->spitem; object->readAttr( "style" ); @@ -409,10 +409,10 @@ void CItem::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { object->readAttr( "inkscape:connector-avoid" ); object->readAttr( "inkscape:connection-points" ); - CObject::onBuild(document, repr); + CObject::build(document, repr); } -void CItem::onRelease() { +void CItem::release() { SPItem* item = this->spitem; // Note: do this here before the clip_ref is deleted, since calling @@ -426,7 +426,7 @@ void CItem::onRelease() { delete item->clip_ref; delete item->mask_ref; - CObject::onRelease(); + CObject::release(); while (item->display) { item->display = sp_item_view_list_remove(item->display, item->display); @@ -435,7 +435,7 @@ void CItem::onRelease() { item->_transformed_signal.~signal(); } -void CItem::onSet(unsigned int key, gchar const* value) { +void CItem::set(unsigned int key, gchar const* value) { SPItem *item = this->spitem; SPItem* object = item; @@ -518,7 +518,7 @@ void CItem::onSet(unsigned int key, gchar const* value) { sp_style_read_from_object(object->style, object); object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); } else { - CObject::onSet(key, value); + CObject::set(key, value); } break; } @@ -574,7 +574,7 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) } } -void CItem::onUpdate(SPCtx *ctx, guint flags) { +void CItem::update(SPCtx *ctx, guint flags) { SPItem *item = this->spitem; SPItem* object = item; @@ -632,7 +632,7 @@ void CItem::onUpdate(SPCtx *ctx, guint flags) { item->avoidRef->handleSettingChange(); } -Inkscape::XML::Node* CItem::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +Inkscape::XML::Node* CItem::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPItem *item = this->spitem; SPItem* object = item; @@ -692,13 +692,13 @@ Inkscape::XML::Node* CItem::onWrite(Inkscape::XML::Document *xml_doc, Inkscape:: } } - CObject::onWrite(xml_doc, repr, flags); + CObject::write(xml_doc, repr, flags); return repr; } // CPPIFY: make pure virtual -Geom::OptRect CItem::onBbox(Geom::Affine const &transform, SPItem::BBoxType type) { +Geom::OptRect CItem::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { //throw; return Geom::OptRect(); } @@ -712,7 +712,7 @@ Geom::OptRect SPItem::geometricBounds(Geom::Affine const &transform) const Geom::OptRect bbox; // call the subclass method - bbox = this->citem->onBbox(transform, SPItem::GEOMETRIC_BBOX); + bbox = this->citem->bbox(transform, SPItem::GEOMETRIC_BBOX); return bbox; } @@ -731,7 +731,7 @@ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const if ( style && style->filter.href && style->getFilter() && SP_IS_FILTER(style->getFilter())) { // call the subclass method - bbox = this->citem->onBbox(Geom::identity(), SPItem::VISUAL_BBOX); + bbox = this->citem->bbox(Geom::identity(), SPItem::VISUAL_BBOX); SPFilter *filter = SP_FILTER(style->getFilter()); // default filer area per the SVG spec: @@ -775,7 +775,7 @@ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const *bbox *= transform; } else { // call the subclass method - bbox = this->citem->onBbox(transform, SPItem::VISUAL_BBOX); + bbox = this->citem->bbox(transform, SPItem::VISUAL_BBOX); } if (clip_ref->getObject()) { bbox.intersectWith(SP_CLIPPATH(clip_ref->getObject())->geometricBounds(transform)); @@ -874,7 +874,7 @@ unsigned SPItem::pos_in_parent() } // CPPIFY: make pure virtual, see below! -void CItem::onSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { +void CItem::snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { //throw; } /* This will only be called if the derived class doesn't override this. @@ -886,7 +886,7 @@ void CItem::onSnappoints(std::vector &p, Inkscape: void SPItem::getSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const { // Get the snappoints of the item - this->citem->onSnappoints(p, snapprefs); + this->citem->snappoints(p, snapprefs); // Get the snappoints at the item's center if (snapprefs != NULL && snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER)) { @@ -922,7 +922,7 @@ void SPItem::getSnappoints(std::vector &p, Inkscap } // CPPIFY: make pure virtual -void CItem::onPrint(SPPrintContext* ctx) { +void CItem::print(SPPrintContext* ctx) { //throw; } @@ -931,16 +931,16 @@ void SPItem::invoke_print(SPPrintContext *ctx) if ( !isHidden() ) { if (!transform.isIdentity() || style->opacity.value != SP_SCALE24_MAX) { sp_print_bind(ctx, transform, SP_SCALE24_TO_FLOAT(style->opacity.value)); - this->citem->onPrint(ctx); + this->citem->print(ctx); sp_print_release(ctx); } else { - this->citem->onPrint(ctx); + this->citem->print(ctx); } } } // CPPIFY: is it possible to combine this method with "SPItem::description()"? -gchar* CItem::onDescription() { +gchar* CItem::description() { return g_strdup(_("Object")); } @@ -951,7 +951,7 @@ gchar* CItem::onDescription() { */ gchar *SPItem::description() { - gchar* s = this->citem->onDescription(); + gchar* s = this->citem->description(); if (s && clip_ref->getObject()) { gchar *snew = g_strdup_printf (_("%s; clipped"), s); g_free (s); @@ -1006,7 +1006,7 @@ unsigned SPItem::display_key_new(unsigned numkeys) } // CPPIFY: make pure virtual -Inkscape::DrawingItem* CItem::onShow(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { +Inkscape::DrawingItem* CItem::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { //throw; return 0; } @@ -1015,7 +1015,7 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned { Inkscape::DrawingItem *ai = NULL; - ai = this->citem->onShow(drawing, key, flags); + ai = this->citem->show(drawing, key, flags); if (ai != NULL) { Geom::OptRect item_bbox = geometricBounds(); @@ -1065,13 +1065,13 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned } // CPPIFY: make pure virtual -void CItem::onHide(unsigned int key) { +void CItem::hide(unsigned int key) { //throw; } void SPItem::invoke_hide(unsigned key) { - this->citem->onHide(key); + this->citem->hide(key); SPItemView *ref = NULL; SPItemView *v = display; @@ -1298,7 +1298,7 @@ void SPItem::adjust_livepatheffect (Geom::Affine const &postmul, bool set) // CPPIFY:: make pure virtual? // Not all SPItems must necessarily have a set transform method! -Geom::Affine CItem::onSetTransform(Geom::Affine const &transform) { +Geom::Affine CItem::set_transform(Geom::Affine const &transform) { // throw; return transform; } @@ -1378,7 +1378,7 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra !mask_ref->getObject() && // the object does not have a mask !(!transform.isTranslation() && style && style->getFilter()) // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) ) { - transform_attr = this->citem->onSetTransform(transform); + transform_attr = this->citem->set_transform(transform); if (freeze_stroke_width) { freeze_stroke_width_recursive(false); @@ -1411,13 +1411,13 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra } // CPPIFY: see below, do not make pure? -gint CItem::onEvent(SPEvent* event) { +gint CItem::event(SPEvent* event) { return FALSE; } gint SPItem::emitEvent(SPEvent &event) { - return this->citem->onEvent(&event); + return this->citem->event(&event); } /** @@ -1435,7 +1435,7 @@ void SPItem::set_item_transform(Geom::Affine const &transform_matrix) } } -void CItem::onConvertToGuides() { +void CItem::convert_to_guides() { // CPPIFY: If not overridden, call SPItem::convert_to_guides(), see below! this->spitem->convert_to_guides(); } -- cgit v1.2.3 From f51227a487f3d80e096c04470a969f5efa911a98 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 21:49:36 +0100 Subject: Turned all functions concerning SPRect into member functions. (bzr r11608.1.60) --- src/sp-item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 4e157666a..ccc3e2313 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1230,7 +1230,7 @@ static void sp_item_adjust_rects_recursive(SPItem *item, Geom::Affine advertized_transform) { if (SP_IS_RECT (item)) { - sp_rect_compensate_rxry (SP_RECT(item), advertized_transform); + SP_RECT(item)->compensateRxRy(advertized_transform); } for (SPObject *o = item->children; o != NULL; o = o->next) { -- 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/sp-item.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index ccc3e2313..5075bdcd3 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -103,6 +103,7 @@ static void sp_item_init(SPItem *item) { item->citem = new CItem(item); + item->typeHierarchy.insert(typeid(SPItem)); delete item->cobject; item->cobject = item->citem; -- cgit v1.2.3 From 7504b21ce73f7f2d3787ab5f363b5e5acc721a23 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 1 Apr 2013 23:50:52 +0200 Subject: Added experimental constructor to SPRect. Memory leaks because of non-virtual destructor. (bzr r11608.1.66) --- src/sp-item.cpp | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 5075bdcd3..63fd25bcc 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -78,7 +78,7 @@ static SPItemView* sp_item_view_list_remove(SPItemView *list, SPItemView *view); -G_DEFINE_TYPE(SPItem, sp_item, SP_TYPE_OBJECT); +G_DEFINE_TYPE(SPItem, sp_item, G_TYPE_OBJECT); /** * SPItem vtable initialization. @@ -96,21 +96,40 @@ CItem::CItem(SPItem* item) : CObject(item) { CItem::~CItem() { } -/** - * Callback for SPItem object initialization. - */ -static void -sp_item_init(SPItem *item) -{ +SPItem::SPItem() : SPObject() { + SPItem* item = this; + item->citem = new CItem(item); item->typeHierarchy.insert(typeid(SPItem)); delete item->cobject; item->cobject = item->citem; + item->sensitive = 0; + item->clip_ref = NULL; + item->avoidRef = NULL; + item->_is_evaluated = false; + item->stop_paint = 0; + item->_evaluated_status = 0; + item->bbox_valid = 0; + item->freeze_stroke_width = false; + item->transform_center_x = 0; + item->transform_center_y = 0; + item->display = NULL; + item->mask_ref = NULL; + item->init(); } +/** + * Callback for SPItem object initialization. + */ +static void +sp_item_init(SPItem *item) +{ + new (item) SPItem(); +} + void SPItem::init() { sensitive = TRUE; bbox_valid = FALSE; -- 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/sp-item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 63fd25bcc..b6298e3a6 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -110,7 +110,7 @@ SPItem::SPItem() : SPObject() { item->avoidRef = NULL; item->_is_evaluated = false; item->stop_paint = 0; - item->_evaluated_status = 0; + item->_evaluated_status = StatusUnknown; item->bbox_valid = 0; item->freeze_stroke_width = false; item->transform_center_x = 0; -- 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/sp-item.cpp | 149 +++++++++++++++++++++++++------------------------------- 1 file changed, 66 insertions(+), 83 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index b6298e3a6..57c00d12d 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -78,59 +78,25 @@ static SPItemView* sp_item_view_list_remove(SPItemView *list, SPItemView *view); -G_DEFINE_TYPE(SPItem, sp_item, G_TYPE_OBJECT); -/** - * SPItem vtable initialization. - */ -static void -sp_item_class_init(SPItemClass *klass) -{ -} - -// CPPIFY: remove -CItem::CItem(SPItem* item) : CObject(item) { - this->spitem = item; -} -CItem::~CItem() { -} - -SPItem::SPItem() : SPObject() { - SPItem* item = this; - - item->citem = new CItem(item); - item->typeHierarchy.insert(typeid(SPItem)); - - delete item->cobject; - item->cobject = item->citem; - - item->sensitive = 0; - item->clip_ref = NULL; - item->avoidRef = NULL; - item->_is_evaluated = false; - item->stop_paint = 0; - item->_evaluated_status = StatusUnknown; - item->bbox_valid = 0; - item->freeze_stroke_width = false; - item->transform_center_x = 0; - item->transform_center_y = 0; - item->display = NULL; - item->mask_ref = NULL; - - item->init(); -} +SPItem::SPItem() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; -/** - * Callback for SPItem object initialization. - */ -static void -sp_item_init(SPItem *item) -{ - new (item) SPItem(); -} + this->sensitive = 0; + this->clip_ref = NULL; + this->avoidRef = NULL; + this->_is_evaluated = false; + this->stop_paint = 0; + this->_evaluated_status = StatusUnknown; + this->bbox_valid = 0; + this->freeze_stroke_width = false; + this->transform_center_x = 0; + this->transform_center_y = 0; + this->display = NULL; + this->mask_ref = NULL; -void SPItem::init() { sensitive = TRUE; bbox_valid = FALSE; @@ -159,6 +125,9 @@ void SPItem::init() { new (&_transformed_signal) sigc::signal(); } +SPItem::~SPItem() { +} + bool SPItem::isVisibleAndUnlocked() const { return (!isHidden() && !isLocked()); } @@ -415,8 +384,8 @@ void SPItem::moveTo(SPItem *target, gboolean intoafter) { } } -void CItem::build(SPDocument *document, Inkscape::XML::Node *repr) { - SPItem* object = this->spitem; +void SPItem::build(SPDocument *document, Inkscape::XML::Node *repr) { + SPItem* object = this; object->readAttr( "style" ); object->readAttr( "transform" ); @@ -432,8 +401,8 @@ void CItem::build(SPDocument *document, Inkscape::XML::Node *repr) { CObject::build(document, repr); } -void CItem::release() { - SPItem* item = this->spitem; +void SPItem::release() { + SPItem* item = this; // Note: do this here before the clip_ref is deleted, since calling // ensureUpToDate() for triggered routing may reference @@ -455,8 +424,8 @@ void CItem::release() { item->_transformed_signal.~signal(); } -void CItem::set(unsigned int key, gchar const* value) { - SPItem *item = this->spitem; +void SPItem::set(unsigned int key, gchar const* value) { + SPItem *item = this; SPItem* object = item; switch (key) { @@ -594,8 +563,8 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) } } -void CItem::update(SPCtx *ctx, guint flags) { - SPItem *item = this->spitem; +void SPItem::update(SPCtx *ctx, guint flags) { + SPItem *item = this; SPItem* object = item; // CObject::onUpdate(ctx, flags); @@ -652,8 +621,8 @@ void CItem::update(SPCtx *ctx, guint flags) { item->avoidRef->handleSettingChange(); } -Inkscape::XML::Node* CItem::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPItem *item = this->spitem; +Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPItem *item = this; SPItem* object = item; // in the case of SP_OBJECT_WRITE_BUILD, the item should always be newly created, @@ -718,7 +687,7 @@ Inkscape::XML::Node* CItem::write(Inkscape::XML::Document *xml_doc, Inkscape::XM } // CPPIFY: make pure virtual -Geom::OptRect CItem::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { +Geom::OptRect SPItem::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { //throw; return Geom::OptRect(); } @@ -732,7 +701,9 @@ Geom::OptRect SPItem::geometricBounds(Geom::Affine const &transform) const Geom::OptRect bbox; // call the subclass method - bbox = this->citem->bbox(transform, SPItem::GEOMETRIC_BBOX); + // CPPIFY + //bbox = this->bbox(transform, SPItem::GEOMETRIC_BBOX); + bbox = const_cast(this)->bbox(transform, SPItem::GEOMETRIC_BBOX); return bbox; } @@ -751,7 +722,9 @@ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const if ( style && style->filter.href && style->getFilter() && SP_IS_FILTER(style->getFilter())) { // call the subclass method - bbox = this->citem->bbox(Geom::identity(), SPItem::VISUAL_BBOX); + // CPPIFY + //bbox = this->bbox(Geom::identity(), SPItem::VISUAL_BBOX); + bbox = const_cast(this)->bbox(Geom::identity(), SPItem::VISUAL_BBOX); SPFilter *filter = SP_FILTER(style->getFilter()); // default filer area per the SVG spec: @@ -795,7 +768,9 @@ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const *bbox *= transform; } else { // call the subclass method - bbox = this->citem->bbox(transform, SPItem::VISUAL_BBOX); + // CPPIFY + //bbox = this->bbox(transform, SPItem::VISUAL_BBOX); + bbox = const_cast(this)->bbox(transform, SPItem::VISUAL_BBOX); } if (clip_ref->getObject()) { bbox.intersectWith(SP_CLIPPATH(clip_ref->getObject())->geometricBounds(transform)); @@ -894,7 +869,7 @@ unsigned SPItem::pos_in_parent() } // CPPIFY: make pure virtual, see below! -void CItem::snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { +void SPItem::snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { //throw; } /* This will only be called if the derived class doesn't override this. @@ -906,7 +881,9 @@ void CItem::snappoints(std::vector &p, Inkscape::S void SPItem::getSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const { // Get the snappoints of the item - this->citem->snappoints(p, snapprefs); + // CPPIFY + //this->snappoints(p, snapprefs); + const_cast(this)->snappoints(p, snapprefs); // Get the snappoints at the item's center if (snapprefs != NULL && snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER)) { @@ -942,7 +919,7 @@ void SPItem::getSnappoints(std::vector &p, Inkscap } // CPPIFY: make pure virtual -void CItem::print(SPPrintContext* ctx) { +void SPItem::print(SPPrintContext* ctx) { //throw; } @@ -951,16 +928,16 @@ void SPItem::invoke_print(SPPrintContext *ctx) if ( !isHidden() ) { if (!transform.isIdentity() || style->opacity.value != SP_SCALE24_MAX) { sp_print_bind(ctx, transform, SP_SCALE24_TO_FLOAT(style->opacity.value)); - this->citem->print(ctx); + this->print(ctx); sp_print_release(ctx); } else { - this->citem->print(ctx); + this->print(ctx); } } } // CPPIFY: is it possible to combine this method with "SPItem::description()"? -gchar* CItem::description() { +gchar* SPItem::description() { return g_strdup(_("Object")); } @@ -969,30 +946,36 @@ gchar* CItem::description() { * * Must be freed by caller. */ -gchar *SPItem::description() +gchar *SPItem::getDetailedDescription() { - gchar* s = this->citem->description(); + gchar* s = this->description(); + if (s && clip_ref->getObject()) { gchar *snew = g_strdup_printf (_("%s; clipped"), s); g_free (s); s = snew; } + if (s && mask_ref->getObject()) { gchar *snew = g_strdup_printf (_("%s; masked"), s); g_free (s); s = snew; } + if ( style && style->filter.href && style->filter.href->getObject() ) { const gchar *label = style->filter.href->getObject()->label(); gchar *snew = 0; + if (label) { snew = g_strdup_printf (_("%s; filtered (%s)"), s, _(label)); } else { snew = g_strdup_printf (_("%s; filtered"), s); } + g_free (s); s = snew; } + return s; } @@ -1026,7 +1009,7 @@ unsigned SPItem::display_key_new(unsigned numkeys) } // CPPIFY: make pure virtual -Inkscape::DrawingItem* CItem::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { +Inkscape::DrawingItem* SPItem::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { //throw; return 0; } @@ -1035,7 +1018,7 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned { Inkscape::DrawingItem *ai = NULL; - ai = this->citem->show(drawing, key, flags); + ai = this->show(drawing, key, flags); if (ai != NULL) { Geom::OptRect item_bbox = geometricBounds(); @@ -1085,13 +1068,13 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned } // CPPIFY: make pure virtual -void CItem::hide(unsigned int key) { +void SPItem::hide(unsigned int key) { //throw; } void SPItem::invoke_hide(unsigned key) { - this->citem->hide(key); + this->hide(key); SPItemView *ref = NULL; SPItemView *v = display; @@ -1318,7 +1301,7 @@ void SPItem::adjust_livepatheffect (Geom::Affine const &postmul, bool set) // CPPIFY:: make pure virtual? // Not all SPItems must necessarily have a set transform method! -Geom::Affine CItem::set_transform(Geom::Affine const &transform) { +Geom::Affine SPItem::set_transform(Geom::Affine const &transform) { // throw; return transform; } @@ -1398,7 +1381,7 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra !mask_ref->getObject() && // the object does not have a mask !(!transform.isTranslation() && style && style->getFilter()) // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) ) { - transform_attr = this->citem->set_transform(transform); + transform_attr = this->set_transform(transform); if (freeze_stroke_width) { freeze_stroke_width_recursive(false); @@ -1431,13 +1414,13 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra } // CPPIFY: see below, do not make pure? -gint CItem::event(SPEvent* event) { +gint SPItem::event(SPEvent* event) { return FALSE; } gint SPItem::emitEvent(SPEvent &event) { - return this->citem->event(&event); + return this->event(&event); } /** @@ -1455,10 +1438,10 @@ void SPItem::set_item_transform(Geom::Affine const &transform_matrix) } } -void CItem::convert_to_guides() { - // CPPIFY: If not overridden, call SPItem::convert_to_guides(), see below! - this->spitem->convert_to_guides(); -} +//void SPItem::convert_to_guides() { +// // CPPIFY: If not overridden, call SPItem::convert_to_guides(), see below! +// this->convert_to_guides(); +//} /** -- 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/sp-item.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 57c00d12d..c2e502e7e 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -80,10 +80,7 @@ static SPItemView* sp_item_view_list_remove(SPItemView *list, SPItemView *view); -SPItem::SPItem() : SPObject(), CObject(this) { - delete this->cobject; - this->cobject = this; - +SPItem::SPItem() : SPObject() { this->sensitive = 0; this->clip_ref = NULL; this->avoidRef = NULL; @@ -398,7 +395,7 @@ void SPItem::build(SPDocument *document, Inkscape::XML::Node *repr) { object->readAttr( "inkscape:connector-avoid" ); object->readAttr( "inkscape:connection-points" ); - CObject::build(document, repr); + SPObject::build(document, repr); } void SPItem::release() { @@ -415,7 +412,7 @@ void SPItem::release() { delete item->clip_ref; delete item->mask_ref; - CObject::release(); + SPObject::release(); while (item->display) { item->display = sp_item_view_list_remove(item->display, item->display); @@ -507,7 +504,7 @@ void SPItem::set(unsigned int key, gchar const* value) { sp_style_read_from_object(object->style, object); object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); } else { - CObject::set(key, value); + SPObject::set(key, value); } break; } @@ -567,7 +564,7 @@ void SPItem::update(SPCtx *ctx, guint flags) { SPItem *item = this; SPItem* object = item; -// CObject::onUpdate(ctx, flags); +// SPObject::onUpdate(ctx, flags); // any of the modifications defined in sp-object.h might change bbox, // so we invalidate it unconditionally @@ -681,7 +678,7 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X } } - CObject::write(xml_doc, repr, flags); + SPObject::write(xml_doc, repr, flags); return repr; } -- cgit v1.2.3 From 989abbac025a8b3349748d19a613a08586c5fdcd Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 31 Jul 2013 21:11:20 +0200 Subject: Fixed SPObject ctor and dtor; removed singleton.h; some smaller changes. (bzr r11608.1.110) --- src/sp-item.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index ed1a2ef79..f313ed7c1 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -117,9 +117,9 @@ SPItem::SPItem() : SPObject() { avoidRef = new SPAvoidRef(this); - new (&constraints) std::vector(); + //new (&constraints) std::vector(); - new (&_transformed_signal) sigc::signal(); + //new (&_transformed_signal) sigc::signal(); } SPItem::~SPItem() { -- cgit v1.2.3 From 127543bae3c0a76770e197c7058a783dea18fe3e Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 31 Jul 2013 23:23:10 +0200 Subject: Removed placement news / explicit destructor calls. (bzr r11608.1.113) --- src/sp-item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index f313ed7c1..9e44bda38 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -418,7 +418,7 @@ void SPItem::release() { item->display = sp_item_view_list_remove(item->display, item->display); } - item->_transformed_signal.~signal(); + //item->_transformed_signal.~signal(); } void SPItem::set(unsigned int key, gchar const* value) { -- cgit v1.2.3 From bf4a1d2d49850170b936c30cfe2b30e798716406 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 3 Aug 2013 03:03:43 +0200 Subject: Cleaned up. (bzr r11608.1.117) --- src/sp-item.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 9e44bda38..abff398e6 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -541,7 +541,7 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) if (old_mask) { /* Hide mask */ for (SPItemView *v = item->display; v != NULL; v = v->next) { - sp_mask_hide(SP_MASK(old_mask), v->arenaitem->key()); + SP_MASK(old_mask)->sp_mask_hide(v->arenaitem->key()); } } if (SP_IS_MASK(mask)) { @@ -550,11 +550,11 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) if (!v->arenaitem->key()) { v->arenaitem->setKey(SPItem::display_key_new(3)); } - Inkscape::DrawingItem *ai = sp_mask_show(SP_MASK(mask), + Inkscape::DrawingItem *ai = SP_MASK(mask)->sp_mask_show( v->arenaitem->drawing(), v->arenaitem->key()); v->arenaitem->setMask(ai); - sp_mask_set_bbox(SP_MASK(mask), v->arenaitem->key(), bbox); + SP_MASK(mask)->sp_mask_set_bbox(v->arenaitem->key(), bbox); mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } @@ -589,7 +589,7 @@ void SPItem::update(SPCtx *ctx, guint flags) { } if (mask) { for (SPItemView *v = item->display; v != NULL; v = v->next) { - sp_mask_set_bbox(mask, v->arenaitem->key(), bbox); + mask->sp_mask_set_bbox(v->arenaitem->key(), bbox); } } } @@ -1050,11 +1050,11 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned int mask_key = display->arenaitem->key(); // Show and set mask - Inkscape::DrawingItem *ac = sp_mask_show(mask, drawing, mask_key); + Inkscape::DrawingItem *ac = mask->sp_mask_show(drawing, mask_key); ai->setMask(ac); // Update bbox, in case the mask uses bbox units - sp_mask_set_bbox(SP_MASK(mask), mask_key, item_bbox); + SP_MASK(mask)->sp_mask_set_bbox(mask_key, item_bbox); mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } if (style->filter.set && display) { @@ -1086,7 +1086,7 @@ void SPItem::invoke_hide(unsigned key) v->arenaitem->setClip(NULL); } if (mask_ref->getObject()) { - sp_mask_hide(mask_ref->getObject(), v->arenaitem->key()); + mask_ref->getObject()->sp_mask_hide(v->arenaitem->key()); v->arenaitem->setMask(NULL); } if (!ref) { -- cgit v1.2.3