From 25d3298c964cd227bcf31d09539899ac0e6b9060 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 19 Aug 2012 03:11:45 +0200 Subject: Added "virtual pad" to SPSymbol. (bzr r11608.1.21) --- src/sp-symbol.cpp | 168 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 112 insertions(+), 56 deletions(-) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 87cd210e4..bd8a0ea53 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -85,32 +85,53 @@ static void sp_symbol_class_init(SPSymbolClass *klass) sp_item_class->print = sp_symbol_print; } +CSymbol::CSymbol(SPSymbol* symbol) : CGroup(symbol) { + this->spsymbol = symbol; +} + +CSymbol::~CSymbol() { +} + static void sp_symbol_init(SPSymbol *symbol) { - symbol->viewBox_set = FALSE; + symbol->csymbol = new CSymbol(symbol); + symbol->cgroup = symbol->csymbol; + symbol->clpeitem = symbol->csymbol; + symbol->citem = symbol->csymbol; + symbol->cobject = symbol->csymbol; + symbol->viewBox_set = FALSE; symbol->c2p = Geom::identity(); } -static void sp_symbol_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -{ +void CSymbol::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { + SPSymbol* object = this->spsymbol; + object->readAttr( "viewBox" ); object->readAttr( "preserveAspectRatio" ); - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build (object, document, repr); - } + CGroup::onBuild(document, repr); } -static void sp_symbol_release(SPObject *object) +// CPPIFY: remove +static void sp_symbol_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release (object); - } + ((SPSymbol*)object)->csymbol->onBuild(document, repr); } -static void sp_symbol_set(SPObject *object, unsigned int key, const gchar *value) +void CSymbol::onRelease() { + CGroup::onRelease(); +} + +// CPPIFY: remove +static void sp_symbol_release(SPObject *object) { + ((SPSymbol*)object)->csymbol->onRelease(); +} + +void CSymbol::onSet(unsigned int key, const gchar* value) { + SPSymbol* object = this->spsymbol; + SPSymbol *symbol = SP_SYMBOL(object); switch (key) { @@ -202,22 +223,31 @@ static void sp_symbol_set(SPObject *object, unsigned int key, const gchar *value } break; default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + CGroup::onSet(key, value); break; } } -static void sp_symbol_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +// CPPIFY: remove +static void sp_symbol_set(SPObject *object, unsigned int key, const gchar *value) { - if (((SPObjectClass *) (parent_class))->child_added) { - ((SPObjectClass *) (parent_class))->child_added (object, child, ref); - } + ((SPSymbol*)object)->csymbol->onSet(key, value); } -static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) +void CSymbol::onChildAdded(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { + CGroup::onChildAdded(child, ref); +} + +// CPPIFY: remove +static void sp_symbol_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - SPSymbol *symbol = SP_SYMBOL(object); + ((SPSymbol*)object)->csymbol->onChildAdded(child, ref); +} + +void CSymbol::onUpdate(SPCtx *ctx, guint flags) { + SPSymbol* object = this->spsymbol; + SPSymbol *symbol = object; + SPItemCtx *ictx = (SPItemCtx *) ctx; SPItemCtx rctx; @@ -315,9 +345,7 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) } // And invoke parent method - if (((SPObjectClass *) (parent_class))->update) { - ((SPObjectClass *) (parent_class))->update (object, (SPCtx *) &rctx, flags); - } + CGroup::onUpdate((SPCtx *) &rctx, flags); // As last step set additional transform of drawing group for (SPItemView *v = symbol->display; v != NULL; v = v->next) { @@ -326,24 +354,28 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) } } else { // No-op - if (((SPObjectClass *) (parent_class))->update) { - ((SPObjectClass *) (parent_class))->update (object, ctx, flags); - } + CGroup::onUpdate(ctx, flags); } } -static void sp_symbol_modified(SPObject *object, guint flags) +// CPPIFY: remove +static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) { - SP_SYMBOL(object); + ((SPSymbol*)object)->csymbol->onUpdate(ctx, flags); +} - if (((SPObjectClass *) (parent_class))->modified) { - (* ((SPObjectClass *) (parent_class))->modified) (object, flags); - } +void CSymbol::onModified(unsigned int flags) { + CGroup::onModified(flags); } -static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +// CPPIFY: remove +static void sp_symbol_modified(SPObject *object, guint flags) { - SP_SYMBOL(object); + ((SPSymbol*)object)->csymbol->onModified(flags); +} + +Inkscape::XML::Node* CSymbol::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPSymbol* object = this->spsymbol; if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:symbol"); @@ -355,72 +387,96 @@ static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Doc //XML Tree being used directly here while it shouldn't be. repr->setAttribute("preserveAspectRatio", object->getRepr()->attribute("preserveAspectRatio")); - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); - } + CGroup::onWrite(xml_doc, repr, flags); return repr; } -static Inkscape::DrawingItem *sp_symbol_show(SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) +// CPPIFY: remove +static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + return ((SPSymbol*)object)->csymbol->onWrite(xml_doc, repr, flags); +} + +Inkscape::DrawingItem* CSymbol::onShow(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { + SPSymbol* item = this->spsymbol; + SPSymbol *symbol = SP_SYMBOL(item); Inkscape::DrawingItem *ai = 0; if (symbol->cloned) { // Cloned is actually renderable - if (((SPItemClass *) (parent_class))->show) { - ai = ((SPItemClass *) (parent_class))->show (item, drawing, key, flags); - Inkscape::DrawingGroup *g = dynamic_cast(ai); - if (g) { - g->setChildTransform(symbol->c2p); - } - } + ai = CGroup::onShow(drawing, key, flags); + Inkscape::DrawingGroup *g = dynamic_cast(ai); + if (g) { + g->setChildTransform(symbol->c2p); + } } return ai; } -static void sp_symbol_hide(SPItem *item, unsigned int key) +// CPPIFY: remove +static Inkscape::DrawingItem *sp_symbol_show(SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { + return ((SPSymbol*)item)->csymbol->onShow(drawing, key, flags); +} + +void CSymbol::onHide(unsigned int key) { + SPSymbol* item = this->spsymbol; + SPSymbol *symbol = SP_SYMBOL(item); if (symbol->cloned) { /* Cloned is actually renderable */ - if (((SPItemClass *) (parent_class))->hide) { - ((SPItemClass *) (parent_class))->hide (item, key); - } + CGroup::onHide(key); } } -static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) +// CPPIFY: remove +static void sp_symbol_hide(SPItem *item, unsigned int key) { + ((SPSymbol*)item)->csymbol->onHide(key); +} + +Geom::OptRect CSymbol::onBbox(Geom::Affine const &transform, SPItem::BBoxType type) { + SPSymbol* item = this->spsymbol; + SPSymbol const *symbol = SP_SYMBOL(item); Geom::OptRect bbox; if (symbol->cloned) { // Cloned is actually renderable + Geom::Affine const a( symbol->c2p * transform ); + bbox = CGroup::onBbox(a, type); - if (((SPItemClass *) (parent_class))->bbox) { - Geom::Affine const a( symbol->c2p * transform ); - bbox = ((SPItemClass *) (parent_class))->bbox(item, a, type); - } } return bbox; } -static void sp_symbol_print(SPItem *item, SPPrintContext *ctx) +// CPPIFY: remove +static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) { + return ((SPSymbol*)item)->csymbol->onBbox(transform, type); +} + +void CSymbol::onPrint(SPPrintContext* ctx) { + SPSymbol* item = this->spsymbol; + SPSymbol *symbol = SP_SYMBOL(item); if (symbol->cloned) { // Cloned is actually renderable sp_print_bind(ctx, symbol->c2p, 1.0); - if (((SPItemClass *) (parent_class))->print) { - ((SPItemClass *) (parent_class))->print (item, ctx); - } + CGroup::onPrint(ctx); sp_print_release (ctx); } } + +// CPPIFY: remove +static void sp_symbol_print(SPItem *item, SPPrintContext *ctx) +{ + ((SPSymbol*)item)->csymbol->onPrint(ctx); +} -- 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-symbol.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index bd8a0ea53..11c14bc4e 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -79,10 +79,10 @@ static void sp_symbol_class_init(SPSymbolClass *klass) sp_object_class->modified = sp_symbol_modified; sp_object_class->write = sp_symbol_write; - sp_item_class->show = sp_symbol_show; - sp_item_class->hide = sp_symbol_hide; - sp_item_class->bbox = sp_symbol_bbox; - sp_item_class->print = sp_symbol_print; +// sp_item_class->show = sp_symbol_show; +// sp_item_class->hide = sp_symbol_hide; +// sp_item_class->bbox = sp_symbol_bbox; +// sp_item_class->print = sp_symbol_print; } CSymbol::CSymbol(SPSymbol* symbol) : CGroup(symbol) { -- cgit v1.2.3 From f304ab600788b02cb02a4413f68f466e35cf1539 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 11 Oct 2012 19:54:14 +0200 Subject: Add symbols dialog. See: http://wiki.inkscape.org/wiki/index.php/SymbolsDialog (bzr r11782) --- src/sp-symbol.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 87cd210e4..56f862bf3 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -405,6 +405,11 @@ static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &tran Geom::Affine const a( symbol->c2p * transform ); bbox = ((SPItemClass *) (parent_class))->bbox(item, a, type); } + } else { + // Need bounding box for Symbols dialog + + Geom::Affine const a; + bbox = ((SPItemClass *) (parent_class))->bbox(item, a, type); } return bbox; } -- cgit v1.2.3 From 55b2e59196c6e980bdb3f03379de6707dd91082b Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 26 Jan 2013 16:18:08 +0000 Subject: More GObject boilerplate reduction (bzr r12064) --- src/sp-symbol.cpp | 77 +++++++++++++++++++------------------------------------ 1 file changed, 26 insertions(+), 51 deletions(-) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 56f862bf3..d4db403e3 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -26,9 +26,6 @@ #include "sp-symbol.h" #include "document.h" -static void sp_symbol_class_init (SPSymbolClass *klass); -static void sp_symbol_init (SPSymbol *symbol); - static void sp_symbol_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_symbol_release (SPObject *object); static void sp_symbol_set (SPObject *object, unsigned int key, const gchar *value); @@ -42,35 +39,13 @@ static void sp_symbol_hide (SPItem *item, unsigned int key); static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); static void sp_symbol_print (SPItem *item, SPPrintContext *ctx); -static SPGroupClass *parent_class; - -GType -sp_symbol_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (SPSymbolClass), - NULL, NULL, - (GClassInitFunc) sp_symbol_class_init, - NULL, NULL, - sizeof (SPSymbol), - 16, - (GInstanceInitFunc) sp_symbol_init, - NULL, /* value_table */ - }; - type = g_type_register_static (SP_TYPE_GROUP, "SPSymbol", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPSymbol, sp_symbol, SP_TYPE_GROUP); static void sp_symbol_class_init(SPSymbolClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *) klass; SPItemClass *sp_item_class = (SPItemClass *) klass; - parent_class = (SPGroupClass *)g_type_class_ref (SP_TYPE_GROUP); - sp_object_class->build = sp_symbol_build; sp_object_class->release = sp_symbol_release; sp_object_class->set = sp_symbol_set; @@ -97,15 +72,15 @@ static void sp_symbol_build(SPObject *object, SPDocument *document, Inkscape::XM object->readAttr( "viewBox" ); object->readAttr( "preserveAspectRatio" ); - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build (object, document, repr); + if (((SPObjectClass *) sp_symbol_parent_class)->build) { + ((SPObjectClass *) sp_symbol_parent_class)->build (object, document, repr); } } static void sp_symbol_release(SPObject *object) { - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release (object); + if (((SPObjectClass *) sp_symbol_parent_class)->release) { + ((SPObjectClass *) sp_symbol_parent_class)->release (object); } } @@ -202,16 +177,16 @@ static void sp_symbol_set(SPObject *object, unsigned int key, const gchar *value } break; default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + if (((SPObjectClass *) sp_symbol_parent_class)->set) + ((SPObjectClass *) sp_symbol_parent_class)->set (object, key, value); break; } } static void sp_symbol_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - if (((SPObjectClass *) (parent_class))->child_added) { - ((SPObjectClass *) (parent_class))->child_added (object, child, ref); + if (((SPObjectClass *) (sp_symbol_parent_class))->child_added) { + ((SPObjectClass *) (sp_symbol_parent_class))->child_added (object, child, ref); } } @@ -315,8 +290,8 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) } // And invoke parent method - if (((SPObjectClass *) (parent_class))->update) { - ((SPObjectClass *) (parent_class))->update (object, (SPCtx *) &rctx, flags); + if (((SPObjectClass *) (sp_symbol_parent_class))->update) { + ((SPObjectClass *) (sp_symbol_parent_class))->update (object, (SPCtx *) &rctx, flags); } // As last step set additional transform of drawing group @@ -326,8 +301,8 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) } } else { // No-op - if (((SPObjectClass *) (parent_class))->update) { - ((SPObjectClass *) (parent_class))->update (object, ctx, flags); + if (((SPObjectClass *) (sp_symbol_parent_class))->update) { + ((SPObjectClass *) (sp_symbol_parent_class))->update (object, ctx, flags); } } } @@ -336,8 +311,8 @@ static void sp_symbol_modified(SPObject *object, guint flags) { SP_SYMBOL(object); - if (((SPObjectClass *) (parent_class))->modified) { - (* ((SPObjectClass *) (parent_class))->modified) (object, flags); + if (((SPObjectClass *) (sp_symbol_parent_class))->modified) { + (* ((SPObjectClass *) (sp_symbol_parent_class))->modified) (object, flags); } } @@ -355,8 +330,8 @@ static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Doc //XML Tree being used directly here while it shouldn't be. repr->setAttribute("preserveAspectRatio", object->getRepr()->attribute("preserveAspectRatio")); - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_symbol_parent_class))->write) { + ((SPObjectClass *) (sp_symbol_parent_class))->write (object, xml_doc, repr, flags); } return repr; @@ -369,8 +344,8 @@ static Inkscape::DrawingItem *sp_symbol_show(SPItem *item, Inkscape::Drawing &dr if (symbol->cloned) { // Cloned is actually renderable - if (((SPItemClass *) (parent_class))->show) { - ai = ((SPItemClass *) (parent_class))->show (item, drawing, key, flags); + if (((SPItemClass *) (sp_symbol_parent_class))->show) { + ai = ((SPItemClass *) (sp_symbol_parent_class))->show (item, drawing, key, flags); Inkscape::DrawingGroup *g = dynamic_cast(ai); if (g) { g->setChildTransform(symbol->c2p); @@ -387,8 +362,8 @@ static void sp_symbol_hide(SPItem *item, unsigned int key) if (symbol->cloned) { /* Cloned is actually renderable */ - if (((SPItemClass *) (parent_class))->hide) { - ((SPItemClass *) (parent_class))->hide (item, key); + if (((SPItemClass *) (sp_symbol_parent_class))->hide) { + ((SPItemClass *) (sp_symbol_parent_class))->hide (item, key); } } } @@ -401,15 +376,15 @@ static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &tran if (symbol->cloned) { // Cloned is actually renderable - if (((SPItemClass *) (parent_class))->bbox) { + if (((SPItemClass *) (sp_symbol_parent_class))->bbox) { Geom::Affine const a( symbol->c2p * transform ); - bbox = ((SPItemClass *) (parent_class))->bbox(item, a, type); + bbox = ((SPItemClass *) (sp_symbol_parent_class))->bbox(item, a, type); } } else { // Need bounding box for Symbols dialog Geom::Affine const a; - bbox = ((SPItemClass *) (parent_class))->bbox(item, a, type); + bbox = ((SPItemClass *) (sp_symbol_parent_class))->bbox(item, a, type); } return bbox; } @@ -422,8 +397,8 @@ static void sp_symbol_print(SPItem *item, SPPrintContext *ctx) sp_print_bind(ctx, symbol->c2p, 1.0); - if (((SPItemClass *) (parent_class))->print) { - ((SPItemClass *) (parent_class))->print (item, ctx); + if (((SPItemClass *) (sp_symbol_parent_class))->print) { + ((SPItemClass *) (sp_symbol_parent_class))->print (item, ctx); } sp_print_release (ctx); -- 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-symbol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 11c14bc4e..62b306078 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -71,7 +71,7 @@ static void sp_symbol_class_init(SPSymbolClass *klass) parent_class = (SPGroupClass *)g_type_class_ref (SP_TYPE_GROUP); - sp_object_class->build = sp_symbol_build; + //sp_object_class->build = sp_symbol_build; sp_object_class->release = sp_symbol_release; sp_object_class->set = sp_symbol_set; sp_object_class->child_added = sp_symbol_child_added; -- cgit v1.2.3 From efa9bdd372b89848165dc575fafff45851514e69 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 16 Mar 2013 12:20:26 +0000 Subject: Warning cleanup (bzr r12211) --- src/sp-symbol.cpp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index d4db403e3..989a5b7f3 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -307,19 +307,19 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) } } -static void sp_symbol_modified(SPObject *object, guint flags) +static void +sp_symbol_modified(SPObject *object, + guint flags) { - SP_SYMBOL(object); - - if (((SPObjectClass *) (sp_symbol_parent_class))->modified) { - (* ((SPObjectClass *) (sp_symbol_parent_class))->modified) (object, flags); - } + SP_OBJECT_CLASS(sp_symbol_parent_class)->modified (object, flags); } -static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +static Inkscape::XML::Node * +sp_symbol_write(SPObject *object, + Inkscape::XML::Document *xml_doc, + Inkscape::XML::Node *repr, + guint flags) { - SP_SYMBOL(object); - if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:symbol"); } @@ -330,9 +330,7 @@ static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Doc //XML Tree being used directly here while it shouldn't be. repr->setAttribute("preserveAspectRatio", object->getRepr()->attribute("preserveAspectRatio")); - if (((SPObjectClass *) (sp_symbol_parent_class))->write) { - ((SPObjectClass *) (sp_symbol_parent_class))->write (object, xml_doc, repr, flags); - } + SP_OBJECT_CLASS(sp_symbol_parent_class)->write (object, xml_doc, repr, flags); return repr; } @@ -404,3 +402,14 @@ static void sp_symbol_print(SPItem *item, SPPrintContext *ctx) sp_print_release (ctx); } } + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- 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-symbol.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 62b306078..b28816741 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -72,12 +72,12 @@ static void sp_symbol_class_init(SPSymbolClass *klass) parent_class = (SPGroupClass *)g_type_class_ref (SP_TYPE_GROUP); //sp_object_class->build = sp_symbol_build; - sp_object_class->release = sp_symbol_release; - sp_object_class->set = sp_symbol_set; - sp_object_class->child_added = sp_symbol_child_added; - sp_object_class->update = sp_symbol_update; - sp_object_class->modified = sp_symbol_modified; - sp_object_class->write = sp_symbol_write; +// sp_object_class->release = sp_symbol_release; +// sp_object_class->set = sp_symbol_set; +// sp_object_class->child_added = sp_symbol_child_added; +// sp_object_class->update = sp_symbol_update; +// sp_object_class->modified = sp_symbol_modified; +// sp_object_class->write = sp_symbol_write; // sp_item_class->show = sp_symbol_show; // sp_item_class->hide = sp_symbol_hide; -- 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-symbol.cpp | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 5889ee899..896e5b3a8 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -53,20 +53,20 @@ static void sp_symbol_init(SPSymbol *symbol) symbol->c2p = Geom::identity(); } -void CSymbol::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { +void CSymbol::build(SPDocument *document, Inkscape::XML::Node *repr) { SPSymbol* object = this->spsymbol; object->readAttr( "viewBox" ); object->readAttr( "preserveAspectRatio" ); - CGroup::onBuild(document, repr); + CGroup::build(document, repr); } -void CSymbol::onRelease() { - CGroup::onRelease(); +void CSymbol::release() { + CGroup::release(); } -void CSymbol::onSet(unsigned int key, const gchar* value) { +void CSymbol::set(unsigned int key, const gchar* value) { SPSymbol* object = this->spsymbol; SPSymbol *symbol = SP_SYMBOL(object); @@ -160,17 +160,17 @@ void CSymbol::onSet(unsigned int key, const gchar* value) { } break; default: - CGroup::onSet(key, value); + CGroup::set(key, value); break; } } -void CSymbol::onChildAdded(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - CGroup::onChildAdded(child, ref); +void CSymbol::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { + CGroup::child_added(child, ref); } -void CSymbol::onUpdate(SPCtx *ctx, guint flags) { +void CSymbol::update(SPCtx *ctx, guint flags) { SPSymbol* object = this->spsymbol; SPSymbol *symbol = object; @@ -271,7 +271,7 @@ void CSymbol::onUpdate(SPCtx *ctx, guint flags) { } // And invoke parent method - CGroup::onUpdate((SPCtx *) &rctx, flags); + CGroup::update((SPCtx *) &rctx, flags); // As last step set additional transform of drawing group for (SPItemView *v = symbol->display; v != NULL; v = v->next) { @@ -280,16 +280,16 @@ void CSymbol::onUpdate(SPCtx *ctx, guint flags) { } } else { // No-op - CGroup::onUpdate(ctx, flags); + CGroup::update(ctx, flags); } } -void CSymbol::onModified(unsigned int flags) { - CGroup::onModified(flags); +void CSymbol::modified(unsigned int flags) { + CGroup::modified(flags); } -Inkscape::XML::Node* CSymbol::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +Inkscape::XML::Node* CSymbol::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPSymbol* object = this->spsymbol; if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { @@ -302,12 +302,12 @@ Inkscape::XML::Node* CSymbol::onWrite(Inkscape::XML::Document *xml_doc, Inkscape //XML Tree being used directly here while it shouldn't be. repr->setAttribute("preserveAspectRatio", object->getRepr()->attribute("preserveAspectRatio")); - CGroup::onWrite(xml_doc, repr, flags); + CGroup::write(xml_doc, repr, flags); return repr; } -Inkscape::DrawingItem* CSymbol::onShow(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { +Inkscape::DrawingItem* CSymbol::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { SPSymbol* item = this->spsymbol; SPSymbol *symbol = SP_SYMBOL(item); @@ -315,7 +315,7 @@ Inkscape::DrawingItem* CSymbol::onShow(Inkscape::Drawing &drawing, unsigned int if (symbol->cloned) { // Cloned is actually renderable - ai = CGroup::onShow(drawing, key, flags); + ai = CGroup::show(drawing, key, flags); Inkscape::DrawingGroup *g = dynamic_cast(ai); if (g) { g->setChildTransform(symbol->c2p); @@ -325,19 +325,19 @@ Inkscape::DrawingItem* CSymbol::onShow(Inkscape::Drawing &drawing, unsigned int return ai; } -void CSymbol::onHide(unsigned int key) { +void CSymbol::hide(unsigned int key) { SPSymbol* item = this->spsymbol; SPSymbol *symbol = SP_SYMBOL(item); if (symbol->cloned) { /* Cloned is actually renderable */ - CGroup::onHide(key); + CGroup::hide(key); } } -Geom::OptRect CSymbol::onBbox(Geom::Affine const &transform, SPItem::BBoxType type) { +Geom::OptRect CSymbol::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { SPSymbol* item = this->spsymbol; SPSymbol const *symbol = SP_SYMBOL(item); @@ -346,12 +346,12 @@ Geom::OptRect CSymbol::onBbox(Geom::Affine const &transform, SPItem::BBoxType ty if (symbol->cloned) { // Cloned is actually renderable Geom::Affine const a( symbol->c2p * transform ); - bbox = CGroup::onBbox(a, type); + bbox = CGroup::bbox(a, type); } return bbox; } -void CSymbol::onPrint(SPPrintContext* ctx) { +void CSymbol::print(SPPrintContext* ctx) { SPSymbol* item = this->spsymbol; SPSymbol *symbol = SP_SYMBOL(item); @@ -360,7 +360,7 @@ void CSymbol::onPrint(SPPrintContext* ctx) { sp_print_bind(ctx, symbol->c2p, 1.0); - CGroup::onPrint(ctx); + CGroup::print(ctx); sp_print_release (ctx); } -- 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-symbol.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 896e5b3a8..43d86c746 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -42,6 +42,7 @@ CSymbol::~CSymbol() { static void sp_symbol_init(SPSymbol *symbol) { symbol->csymbol = new CSymbol(symbol); + symbol->typeHierarchy.insert(typeid(SPSymbol)); delete symbol->cgroup; symbol->cgroup = symbol->csymbol; -- 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-symbol.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 43d86c746..6c1212d71 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -26,7 +26,7 @@ #include "sp-symbol.h" #include "document.h" -G_DEFINE_TYPE(SPSymbol, sp_symbol, SP_TYPE_GROUP); +G_DEFINE_TYPE(SPSymbol, sp_symbol, G_TYPE_OBJECT); static void sp_symbol_class_init(SPSymbolClass *klass) { @@ -39,8 +39,9 @@ CSymbol::CSymbol(SPSymbol* symbol) : CGroup(symbol) { CSymbol::~CSymbol() { } -static void sp_symbol_init(SPSymbol *symbol) -{ +SPSymbol::SPSymbol() : SPGroup() { + SPSymbol* symbol = this; + symbol->csymbol = new CSymbol(symbol); symbol->typeHierarchy.insert(typeid(SPSymbol)); @@ -50,10 +51,19 @@ static void sp_symbol_init(SPSymbol *symbol) symbol->citem = symbol->csymbol; symbol->cobject = symbol->csymbol; + symbol->aspect_align = 0; + symbol->aspect_clip = 0; + symbol->aspect_set = 0; + symbol->viewBox_set = FALSE; symbol->c2p = Geom::identity(); } +static void sp_symbol_init(SPSymbol *symbol) +{ + new (symbol) SPSymbol(); +} + void CSymbol::build(SPDocument *document, Inkscape::XML::Node *repr) { SPSymbol* object = this->spsymbol; -- 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/sp-symbol.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 6c1212d71..4e5b53e48 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -26,6 +26,16 @@ #include "sp-symbol.h" #include "document.h" +#include "sp-factory.h" + +namespace { + SPObject* createSymbol() { + return new SPSymbol(); + } + + bool symbolRegistered = SPFactory::instance().registerObject("svg:symbol", createSymbol); +} + G_DEFINE_TYPE(SPSymbol, sp_symbol, G_TYPE_OBJECT); static void sp_symbol_class_init(SPSymbolClass *klass) -- cgit v1.2.3 From dbda80349e95767e390a178cda7c05787fbce1fe Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Fri, 5 Apr 2013 17:51:29 +0200 Subject: Merged Group and subclasses. (bzr r11608.1.77) --- src/sp-symbol.cpp | 264 +++++++++++++++++++++++++++--------------------------- 1 file changed, 134 insertions(+), 130 deletions(-) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 4e5b53e48..9429046be 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -36,110 +36,119 @@ namespace { bool symbolRegistered = SPFactory::instance().registerObject("svg:symbol", createSymbol); } -G_DEFINE_TYPE(SPSymbol, sp_symbol, G_TYPE_OBJECT); - -static void sp_symbol_class_init(SPSymbolClass *klass) -{ -} - -CSymbol::CSymbol(SPSymbol* symbol) : CGroup(symbol) { - this->spsymbol = symbol; -} - -CSymbol::~CSymbol() { -} - SPSymbol::SPSymbol() : SPGroup() { - SPSymbol* symbol = this; - - symbol->csymbol = new CSymbol(symbol); - symbol->typeHierarchy.insert(typeid(SPSymbol)); + this->clpeitem = this; + this->citem = this; + this->cobject = this; - delete symbol->cgroup; - symbol->cgroup = symbol->csymbol; - symbol->clpeitem = symbol->csymbol; - symbol->citem = symbol->csymbol; - symbol->cobject = symbol->csymbol; + this->aspect_align = 0; + this->aspect_clip = 0; + this->aspect_set = 0; - symbol->aspect_align = 0; - symbol->aspect_clip = 0; - symbol->aspect_set = 0; - - symbol->viewBox_set = FALSE; - symbol->c2p = Geom::identity(); + this->viewBox_set = FALSE; + this->c2p = Geom::identity(); } -static void sp_symbol_init(SPSymbol *symbol) -{ - new (symbol) SPSymbol(); +SPSymbol::~SPSymbol() { } -void CSymbol::build(SPDocument *document, Inkscape::XML::Node *repr) { - SPSymbol* object = this->spsymbol; - - object->readAttr( "viewBox" ); - object->readAttr( "preserveAspectRatio" ); +void SPSymbol::build(SPDocument *document, Inkscape::XML::Node *repr) { + this->readAttr( "viewBox" ); + this->readAttr( "preserveAspectRatio" ); - CGroup::build(document, repr); + SPGroup::build(document, repr); } -void CSymbol::release() { - CGroup::release(); +void SPSymbol::release() { + SPGroup::release(); } -void CSymbol::set(unsigned int key, const gchar* value) { - SPSymbol* object = this->spsymbol; - - SPSymbol *symbol = SP_SYMBOL(object); - +void SPSymbol::set(unsigned int key, const gchar* value) { switch (key) { case SP_ATTR_VIEWBOX: if (value) { double x, y, width, height; char *eptr; + /* fixme: We have to take original item affine into account */ /* fixme: Think (Lauris) */ eptr = (gchar *) value; x = g_ascii_strtod (eptr, &eptr); - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++; + + while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { + eptr++; + } + y = g_ascii_strtod (eptr, &eptr); - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++; + + while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { + eptr++; + } + width = g_ascii_strtod (eptr, &eptr); - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++; + + while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { + eptr++; + } + height = g_ascii_strtod (eptr, &eptr); - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++; + + while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { + eptr++; + } + if ((width > 0) && (height > 0)) { /* Set viewbox */ - symbol->viewBox = Geom::Rect::from_xywh(x, y, width, height); - symbol->viewBox_set = TRUE; + this->viewBox = Geom::Rect::from_xywh(x, y, width, height); + this->viewBox_set = TRUE; } else { - symbol->viewBox_set = FALSE; + this->viewBox_set = FALSE; } } else { - symbol->viewBox_set = FALSE; + this->viewBox_set = FALSE; } - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); break; + case SP_ATTR_PRESERVEASPECTRATIO: /* Do setup before, so we can use break to escape */ - symbol->aspect_set = FALSE; - symbol->aspect_align = SP_ASPECT_NONE; - symbol->aspect_clip = SP_ASPECT_MEET; - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + this->aspect_set = FALSE; + this->aspect_align = SP_ASPECT_NONE; + this->aspect_clip = SP_ASPECT_MEET; + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + if (value) { int len; gchar c[256]; const gchar *p, *e; unsigned int align, clip; p = value; - while (*p && *p == 32) p += 1; - if (!*p) break; + + while (*p && *p == 32) { + p += 1; + } + + if (!*p) { + break; + } + e = p; - while (*e && *e != 32) e += 1; + + while (*e && *e != 32) { + e += 1; + } + len = e - p; - if (len > 8) break; + + if (len > 8) { + break; + } + memcpy (c, value, len); + c[len] = 0; + /* Now the actual part */ if (!strcmp (c, "none")) { align = SP_ASPECT_NONE; @@ -164,8 +173,13 @@ void CSymbol::set(unsigned int key, const gchar* value) { } else { break; } + clip = SP_ASPECT_MEET; - while (*e && *e == 32) e += 1; + + while (*e && *e == 32) { + e += 1; + } + if (*e) { if (!strcmp (e, "meet")) { clip = SP_ASPECT_MEET; @@ -175,30 +189,29 @@ void CSymbol::set(unsigned int key, const gchar* value) { break; } } - symbol->aspect_set = TRUE; - symbol->aspect_align = align; - symbol->aspect_clip = clip; + + this->aspect_set = TRUE; + this->aspect_align = align; + this->aspect_clip = clip; } break; + default: - CGroup::set(key, value); + SPGroup::set(key, value); break; } } -void CSymbol::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - CGroup::child_added(child, ref); +void SPSymbol::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { + SPGroup::child_added(child, ref); } -void CSymbol::update(SPCtx *ctx, guint flags) { - SPSymbol* object = this->spsymbol; - SPSymbol *symbol = object; - +void SPSymbol::update(SPCtx *ctx, guint flags) { SPItemCtx *ictx = (SPItemCtx *) ctx; SPItemCtx rctx; - if (object->cloned) { + if (this->cloned) { /* Cloned is actually renderable */ /* fixme: We have to set up clip here too */ @@ -208,12 +221,13 @@ void CSymbol::update(SPCtx *ctx, guint flags) { /* Calculate child to parent transformation */ /* Apply parent translation (set up as vewport) */ - symbol->c2p = Geom::Translate(rctx.viewport.min()); + this->c2p = Geom::Translate(rctx.viewport.min()); - if (symbol->viewBox_set) { + if (this->viewBox_set) { double x, y, width, height; + /* Determine actual viewbox in viewport coordinates */ - if (symbol->aspect_align == SP_ASPECT_NONE) { + if (this->aspect_align == SP_ASPECT_NONE) { x = 0.0; y = 0.0; width = rctx.viewport.width(); @@ -221,13 +235,14 @@ void CSymbol::update(SPCtx *ctx, guint flags) { } else { double scalex, scaley, scale; /* Things are getting interesting */ - scalex = rctx.viewport.width() / symbol->viewBox.width(); - scaley = rctx.viewport.height() / symbol->viewBox.height(); - scale = (symbol->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley); - width = symbol->viewBox.width() * scale; - height = symbol->viewBox.height() * scale; + scalex = rctx.viewport.width() / this->viewBox.width(); + scaley = rctx.viewport.height() / this->viewBox.height(); + scale = (this->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley); + width = this->viewBox.width() * scale; + height = this->viewBox.height() * scale; + /* Now place viewbox to requested position */ - switch (symbol->aspect_align) { + switch (this->aspect_align) { case SP_ASPECT_XMIN_YMIN: x = 0.0; y = 0.0; @@ -270,118 +285,107 @@ void CSymbol::update(SPCtx *ctx, guint flags) { break; } } + /* Compose additional transformation from scale and position */ Geom::Affine q; - q[0] = width / symbol->viewBox.width(); + q[0] = width / this->viewBox.width(); q[1] = 0.0; q[2] = 0.0; - q[3] = height / symbol->viewBox.height(); - q[4] = -symbol->viewBox.left() * q[0] + x; - q[5] = -symbol->viewBox.top() * q[3] + y; + q[3] = height / this->viewBox.height(); + q[4] = -this->viewBox.left() * q[0] + x; + q[5] = -this->viewBox.top() * q[3] + y; + /* Append viewbox transformation */ - symbol->c2p = q * symbol->c2p; + this->c2p = q * this->c2p; } - rctx.i2doc = symbol->c2p * (Geom::Affine)rctx.i2doc; + rctx.i2doc = this->c2p * (Geom::Affine)rctx.i2doc; /* If viewBox is set initialize child viewport */ /* Otherwise has set it up already */ - if (symbol->viewBox_set) { - rctx.viewport = symbol->viewBox; + if (this->viewBox_set) { + rctx.viewport = this->viewBox; rctx.i2vp = Geom::identity(); } // And invoke parent method - CGroup::update((SPCtx *) &rctx, flags); + SPGroup::update((SPCtx *) &rctx, flags); // As last step set additional transform of drawing group - for (SPItemView *v = symbol->display; v != NULL; v = v->next) { + for (SPItemView *v = this->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); - g->setChildTransform(symbol->c2p); + g->setChildTransform(this->c2p); } } else { // No-op - CGroup::update(ctx, flags); + SPGroup::update(ctx, flags); } } -void CSymbol::modified(unsigned int flags) { - CGroup::modified(flags); +void SPSymbol::modified(unsigned int flags) { + SPGroup::modified(flags); } -Inkscape::XML::Node* CSymbol::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPSymbol* object = this->spsymbol; - +Inkscape::XML::Node* SPSymbol::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:symbol"); } //XML Tree being used directly here while it shouldn't be. - repr->setAttribute("viewBox", object->getRepr()->attribute("viewBox")); + repr->setAttribute("viewBox", this->getRepr()->attribute("viewBox")); //XML Tree being used directly here while it shouldn't be. - repr->setAttribute("preserveAspectRatio", object->getRepr()->attribute("preserveAspectRatio")); + repr->setAttribute("preserveAspectRatio", this->getRepr()->attribute("preserveAspectRatio")); - CGroup::write(xml_doc, repr, flags); + SPGroup::write(xml_doc, repr, flags); return repr; } -Inkscape::DrawingItem* CSymbol::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { - SPSymbol* item = this->spsymbol; - - SPSymbol *symbol = SP_SYMBOL(item); +Inkscape::DrawingItem* SPSymbol::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { Inkscape::DrawingItem *ai = 0; - if (symbol->cloned) { + if (this->cloned) { // Cloned is actually renderable - ai = CGroup::show(drawing, key, flags); + ai = SPGroup::show(drawing, key, flags); Inkscape::DrawingGroup *g = dynamic_cast(ai); + if (g) { - g->setChildTransform(symbol->c2p); + g->setChildTransform(this->c2p); } } return ai; } -void CSymbol::hide(unsigned int key) { - SPSymbol* item = this->spsymbol; - - SPSymbol *symbol = SP_SYMBOL(item); - - if (symbol->cloned) { +void SPSymbol::hide(unsigned int key) { + if (this->cloned) { /* Cloned is actually renderable */ - CGroup::hide(key); + SPGroup::hide(key); } } -Geom::OptRect CSymbol::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { - SPSymbol* item = this->spsymbol; - - SPSymbol const *symbol = SP_SYMBOL(item); +Geom::OptRect SPSymbol::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { Geom::OptRect bbox; - if (symbol->cloned) { + if (this->cloned) { // Cloned is actually renderable - Geom::Affine const a( symbol->c2p * transform ); - bbox = CGroup::bbox(a, type); + Geom::Affine const a( this->c2p * transform ); + bbox = SPGroup::bbox(a, type); } + return bbox; } -void CSymbol::print(SPPrintContext* ctx) { - SPSymbol* item = this->spsymbol; - - SPSymbol *symbol = SP_SYMBOL(item); - if (symbol->cloned) { +void SPSymbol::print(SPPrintContext* ctx) { + if (this->cloned) { // Cloned is actually renderable - sp_print_bind(ctx, symbol->c2p, 1.0); + sp_print_bind(ctx, this->c2p, 1.0); - CGroup::print(ctx); + SPGroup::print(ctx); sp_print_release (ctx); } -- 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/sp-symbol.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 9429046be..a9a8ed639 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -37,7 +37,6 @@ namespace { } SPSymbol::SPSymbol() : SPGroup() { - 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/sp-symbol.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index a9a8ed639..989b6ea15 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -37,7 +37,6 @@ namespace { } SPSymbol::SPSymbol() : SPGroup() { - this->citem = this; this->cobject = this; this->aspect_align = 0; -- 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-symbol.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 989b6ea15..6ee377bc6 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -37,8 +37,6 @@ namespace { } SPSymbol::SPSymbol() : SPGroup() { - this->cobject = this; - this->aspect_align = 0; this->aspect_clip = 0; this->aspect_set = 0; -- cgit v1.2.3 From c403397e07cf418588296f1f6fb479aca862c518 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sat, 15 Jun 2013 09:29:48 -0400 Subject: Big change in symbols ui and selection chemistry. (bzr r12374) --- src/sp-symbol.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 989a5b7f3..a56de2e5a 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -371,6 +371,8 @@ static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &tran SPSymbol const *symbol = SP_SYMBOL(item); Geom::OptRect bbox; + // We don't need a bounding box for Symbols dialog when selecting + // symbols. They have no canvas location. But cloned symbols are. if (symbol->cloned) { // Cloned is actually renderable @@ -378,11 +380,6 @@ static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &tran Geom::Affine const a( symbol->c2p * transform ); bbox = ((SPItemClass *) (sp_symbol_parent_class))->bbox(item, a, type); } - } else { - // Need bounding box for Symbols dialog - - Geom::Affine const a; - bbox = ((SPItemClass *) (sp_symbol_parent_class))->bbox(item, a, type); } return bbox; } -- cgit v1.2.3 From 73edade30f70b4c0ad94c9561b4e4ec0675465b0 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 27 Oct 2013 00:00:51 +0200 Subject: Added some consts. (bzr r12729) --- src/sp-symbol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index b2346ac91..8ffc2ab2c 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -363,7 +363,7 @@ void SPSymbol::hide(unsigned int key) { } -Geom::OptRect SPSymbol::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { +Geom::OptRect SPSymbol::bbox(Geom::Affine const &transform, SPItem::BBoxType type) const { Geom::OptRect bbox; // We don't need a bounding box for Symbols dialog when selecting -- cgit v1.2.3 From 7dd239eed97761b22ef635b6896a8f65c4939462 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 6 Feb 2014 15:29:15 +0100 Subject: Added new base class to handle viewBox and preserveAspectRatio. Updated sp-root, sp-symbol, sp-image, sp-pattern, marker to use new class. Fixed some viewport issues when % used. (bzr r13002) --- src/sp-symbol.cpp | 234 ++---------------------------------------------------- 1 file changed, 7 insertions(+), 227 deletions(-) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 8ffc2ab2c..817411a32 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -36,13 +36,7 @@ namespace { bool symbolRegistered = SPFactory::instance().registerObject("svg:symbol", createSymbol); } -SPSymbol::SPSymbol() : SPGroup() { - this->aspect_align = 0; - this->aspect_clip = 0; - this->aspect_set = 0; - - this->viewBox_set = FALSE; - this->c2p = Geom::identity(); +SPSymbol::SPSymbol() : SPGroup(), SPViewBox() { } SPSymbol::~SPSymbol() { @@ -62,134 +56,15 @@ void SPSymbol::release() { void SPSymbol::set(unsigned int key, const gchar* value) { switch (key) { case SP_ATTR_VIEWBOX: - if (value) { - double x, y, width, height; - char *eptr; - - /* fixme: We have to take original item affine into account */ - /* fixme: Think (Lauris) */ - eptr = (gchar *) value; - x = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - y = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - width = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - height = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - if ((width > 0) && (height > 0)) { - /* Set viewbox */ - this->viewBox = Geom::Rect::from_xywh(x, y, width, height); - this->viewBox_set = TRUE; - } else { - this->viewBox_set = FALSE; - } - } else { - this->viewBox_set = FALSE; - } - + set_viewBox( value ); + std::cout << "Symbol: ViewBox: " << viewBox << std::endl; this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); break; case SP_ATTR_PRESERVEASPECTRATIO: - /* Do setup before, so we can use break to escape */ - this->aspect_set = FALSE; - this->aspect_align = SP_ASPECT_NONE; - this->aspect_clip = SP_ASPECT_MEET; + set_preserveAspectRatio( value ); + std::cout << "Symbol: Preserve aspect ratio: " << aspect_align << ", " << aspect_clip << std::endl; this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); - - if (value) { - int len; - gchar c[256]; - const gchar *p, *e; - unsigned int align, clip; - p = value; - - while (*p && *p == 32) { - p += 1; - } - - if (!*p) { - break; - } - - e = p; - - while (*e && *e != 32) { - e += 1; - } - - len = e - p; - - if (len > 8) { - break; - } - - memcpy (c, value, len); - - c[len] = 0; - - /* Now the actual part */ - if (!strcmp (c, "none")) { - align = SP_ASPECT_NONE; - } else if (!strcmp (c, "xMinYMin")) { - align = SP_ASPECT_XMIN_YMIN; - } else if (!strcmp (c, "xMidYMin")) { - align = SP_ASPECT_XMID_YMIN; - } else if (!strcmp (c, "xMaxYMin")) { - align = SP_ASPECT_XMAX_YMIN; - } else if (!strcmp (c, "xMinYMid")) { - align = SP_ASPECT_XMIN_YMID; - } else if (!strcmp (c, "xMidYMid")) { - align = SP_ASPECT_XMID_YMID; - } else if (!strcmp (c, "xMaxYMid")) { - align = SP_ASPECT_XMAX_YMID; - } else if (!strcmp (c, "xMinYMax")) { - align = SP_ASPECT_XMIN_YMAX; - } else if (!strcmp (c, "xMidYMax")) { - align = SP_ASPECT_XMID_YMAX; - } else if (!strcmp (c, "xMaxYMax")) { - align = SP_ASPECT_XMAX_YMAX; - } else { - break; - } - - clip = SP_ASPECT_MEET; - - while (*e && *e == 32) { - e += 1; - } - - if (*e) { - if (!strcmp (e, "meet")) { - clip = SP_ASPECT_MEET; - } else if (!strcmp (e, "slice")) { - clip = SP_ASPECT_SLICE; - } else { - break; - } - } - - this->aspect_set = TRUE; - this->aspect_align = align; - this->aspect_clip = clip; - } break; default: @@ -204,105 +79,10 @@ void SPSymbol::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) void SPSymbol::update(SPCtx *ctx, guint flags) { - SPItemCtx *ictx = (SPItemCtx *) ctx; - SPItemCtx rctx; - if (this->cloned) { - /* Cloned is actually renderable */ - - /* fixme: We have to set up clip here too */ - - /* Create copy of item context */ - rctx = *ictx; - - /* Calculate child to parent transformation */ - /* Apply parent translation (set up as vewport) */ - this->c2p = Geom::Translate(rctx.viewport.min()); - - if (this->viewBox_set) { - double x, y, width, height; - - /* Determine actual viewbox in viewport coordinates */ - if (this->aspect_align == SP_ASPECT_NONE) { - x = 0.0; - y = 0.0; - width = rctx.viewport.width(); - height = rctx.viewport.height(); - } else { - double scalex, scaley, scale; - /* Things are getting interesting */ - scalex = rctx.viewport.width() / this->viewBox.width(); - scaley = rctx.viewport.height() / this->viewBox.height(); - scale = (this->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley); - width = this->viewBox.width() * scale; - height = this->viewBox.height() * scale; - - /* Now place viewbox to requested position */ - switch (this->aspect_align) { - case SP_ASPECT_XMIN_YMIN: - x = 0.0; - y = 0.0; - break; - case SP_ASPECT_XMID_YMIN: - x = 0.5 * (rctx.viewport.width() - width); - y = 0.0; - break; - case SP_ASPECT_XMAX_YMIN: - x = 1.0 * (rctx.viewport.width() - width); - y = 0.0; - break; - case SP_ASPECT_XMIN_YMID: - x = 0.0; - y = 0.5 * (rctx.viewport.height() - height); - break; - case SP_ASPECT_XMID_YMID: - x = 0.5 * (rctx.viewport.width() - width); - y = 0.5 * (rctx.viewport.height() - height); - break; - case SP_ASPECT_XMAX_YMID: - x = 1.0 * (rctx.viewport.width() - width); - y = 0.5 * (rctx.viewport.height() - height); - break; - case SP_ASPECT_XMIN_YMAX: - x = 0.0; - y = 1.0 * (rctx.viewport.height() - height); - break; - case SP_ASPECT_XMID_YMAX: - x = 0.5 * (rctx.viewport.width() - width); - y = 1.0 * (rctx.viewport.height() - height); - break; - case SP_ASPECT_XMAX_YMAX: - x = 1.0 * (rctx.viewport.width() - width); - y = 1.0 * (rctx.viewport.height() - height); - break; - default: - x = 0.0; - y = 0.0; - break; - } - } - - /* Compose additional transformation from scale and position */ - Geom::Affine q; - q[0] = width / this->viewBox.width(); - q[1] = 0.0; - q[2] = 0.0; - q[3] = height / this->viewBox.height(); - q[4] = -this->viewBox.left() * q[0] + x; - q[5] = -this->viewBox.top() * q[3] + y; - - /* Append viewbox transformation */ - this->c2p = q * this->c2p; - } - rctx.i2doc = this->c2p * (Geom::Affine)rctx.i2doc; - - /* If viewBox is set initialize child viewport */ - /* Otherwise has set it up already */ - if (this->viewBox_set) { - rctx.viewport = this->viewBox; - rctx.i2vp = Geom::identity(); - } + SPItemCtx *ictx = (SPItemCtx *) ctx; + SPItemCtx rctx = get_rctx( ictx ); // And invoke parent method SPGroup::update((SPCtx *) &rctx, flags); -- cgit v1.2.3 From 208354ea4b29ac7752120947efefcd7af3630d10 Mon Sep 17 00:00:00 2001 From: su_v Date: Sun, 16 Feb 2014 00:20:48 +0100 Subject: Symbols: turn off viewBox-related debug messages (from r13002) (bzr r13029) --- src/sp-symbol.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sp-symbol.cpp') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 817411a32..3156680b3 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -57,13 +57,13 @@ void SPSymbol::set(unsigned int key, const gchar* value) { switch (key) { case SP_ATTR_VIEWBOX: set_viewBox( value ); - std::cout << "Symbol: ViewBox: " << viewBox << std::endl; + // std::cout << "Symbol: ViewBox: " << viewBox << std::endl; this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); break; case SP_ATTR_PRESERVEASPECTRATIO: set_preserveAspectRatio( value ); - std::cout << "Symbol: Preserve aspect ratio: " << aspect_align << ", " << aspect_clip << std::endl; + // std::cout << "Symbol: Preserve aspect ratio: " << aspect_align << ", " << aspect_clip << std::endl; this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); break; -- cgit v1.2.3