diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-04-07 23:42:04 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2011-04-07 23:42:04 +0000 |
| commit | 945ce419c806c73d70203dec33ececafbe108a92 (patch) | |
| tree | cfcdb59bf47e9db7f9e01f7eebb59924bdeaea94 /src/sp-item-group.cpp | |
| parent | Merge from trunk (again) (diff) | |
| parent | Extensions. SVG+media fix (see Bug #400356). (diff) | |
| download | inkscape-945ce419c806c73d70203dec33ececafbe108a92.tar.gz inkscape-945ce419c806c73d70203dec33ececafbe108a92.zip | |
Merge from trunk
(bzr r9508.1.73)
Diffstat (limited to 'src/sp-item-group.cpp')
| -rw-r--r-- | src/sp-item-group.cpp | 105 |
1 files changed, 53 insertions, 52 deletions
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 05ffc16ec..2ee57dbe5 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -64,7 +64,7 @@ static void sp_group_modified (SPObject *object, guint flags); static Inkscape::XML::Node *sp_group_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_group_set(SPObject *object, unsigned key, char const *value); -static void sp_group_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); +static void sp_group_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); static void sp_group_print (SPItem * item, SPPrintContext *ctx); static gchar * sp_group_description (SPItem * item); static NRArenaItem *sp_group_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); @@ -154,7 +154,7 @@ static void sp_group_build(SPObject *object, SPDocument *document, Inkscape::XML static void sp_group_release(SPObject *object) { if ( SP_GROUP(object)->_layer_mode == SPGroup::LAYER ) { - SP_OBJECT_DOCUMENT(object)->removeResource("layer", object); + object->document->removeResource("layer", object); } if (((SPObjectClass *)parent_class)->release) { ((SPObjectClass *)parent_class)->release(object); @@ -276,7 +276,7 @@ static Inkscape::XML::Node * sp_group_write(SPObject *object, Inkscape::XML::Doc } static void -sp_group_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags) +sp_group_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags) { SP_GROUP(item)->group->calculateBBox(bbox, transform, flags); } @@ -342,20 +342,20 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) g_return_if_fail (group != NULL); g_return_if_fail (SP_IS_GROUP (group)); - SPDocument *doc = SP_OBJECT_DOCUMENT (group); + SPDocument *doc = group->document; SPObject *root = doc->getRoot(); - SPObject *defs = SP_OBJECT (SP_ROOT (root)->defs); + SPObject *defs = SP_OBJECT(SP_ROOT(root)->defs); SPItem *gitem = SP_ITEM (group); - Inkscape::XML::Node *grepr = SP_OBJECT_REPR (gitem); + Inkscape::XML::Node *grepr = gitem->getRepr(); g_return_if_fail (!strcmp (grepr->name(), "svg:g") || !strcmp (grepr->name(), "svg:a") || !strcmp (grepr->name(), "svg:switch")); // this converts the gradient/pattern fill/stroke on the group, if any, to userSpaceOnUse gitem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false); - SPItem *pitem = SP_ITEM (SP_OBJECT_PARENT (gitem)); - Inkscape::XML::Node *prepr = SP_OBJECT_REPR (pitem); + SPItem *pitem = SP_ITEM(gitem->parent); + Inkscape::XML::Node *prepr = pitem->getRepr(); if (SP_IS_BOX3D(gitem)) { group = box3d_convert_to_group(SP_BOX3D(gitem)); @@ -378,7 +378,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) // it here _before_ the new transform is set, so as to use the pre-transform bbox citem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false); - sp_style_merge_from_dying_parent(SP_OBJECT_STYLE(child), SP_OBJECT_STYLE(gitem)); + sp_style_merge_from_dying_parent(child->style, gitem->style); /* * fixme: We currently make no allowance for the case where child is cloned * and the group has any style settings. @@ -403,33 +403,33 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) child->updateRepr(); - Inkscape::XML::Node *nrepr = SP_OBJECT_REPR (child)->duplicate(prepr->document()); + Inkscape::XML::Node *nrepr = child->getRepr()->duplicate(prepr->document()); // Merging transform - Geom::Matrix ctrans; - Geom::Matrix const g(gitem->transform); + Geom::Affine ctrans; + Geom::Affine const g(gitem->transform); if (SP_IS_USE(citem) && sp_use_get_original (SP_USE(citem)) && - SP_OBJECT_PARENT (sp_use_get_original (SP_USE(citem))) == SP_OBJECT(group)) { + sp_use_get_original( SP_USE(citem) )->parent == SP_OBJECT(group)) { // make sure a clone's effective transform is the same as was under group ctrans = g.inverse() * citem->transform * g; } else { - // We should not apply the group's transformation to both a linked offset AND to its source - if (SP_IS_OFFSET(citem)) { // Do we have an offset at hand (whether it's dynamic or linked)? - SPItem *source = sp_offset_get_source(SP_OFFSET(citem)); - // When dealing with a chain of linked offsets, the transformation of an offset will be - // tied to the transformation of the top-most source, not to any of the intermediate - // offsets. So let's find the top-most source - while (source != NULL && SP_IS_OFFSET(source)) { - source = sp_offset_get_source(SP_OFFSET(source)); - } - if (source != NULL && // If true then we must be dealing with a linked offset ... - SP_OBJECT(group)->isAncestorOf(SP_OBJECT(source)) == false) { // ... of which the source is not in the same group - ctrans = citem->transform * g; // then we should apply the transformation of the group to the offset - } else { - ctrans = citem->transform; - } + // We should not apply the group's transformation to both a linked offset AND to its source + if (SP_IS_OFFSET(citem)) { // Do we have an offset at hand (whether it's dynamic or linked)? + SPItem *source = sp_offset_get_source(SP_OFFSET(citem)); + // When dealing with a chain of linked offsets, the transformation of an offset will be + // tied to the transformation of the top-most source, not to any of the intermediate + // offsets. So let's find the top-most source + while (source != NULL && SP_IS_OFFSET(source)) { + source = sp_offset_get_source(SP_OFFSET(source)); + } + if (source != NULL && // If true then we must be dealing with a linked offset ... + group->isAncestorOf(source) == false) { // ... of which the source is not in the same group + ctrans = citem->transform * g; // then we should apply the transformation of the group to the offset + } else { + ctrans = citem->transform; + } } else { - ctrans = citem->transform * g; + ctrans = citem->transform * g; } } @@ -450,27 +450,28 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) items = g_slist_prepend (items, nrepr); } else { - Inkscape::XML::Node *nrepr = SP_OBJECT_REPR (child)->duplicate(prepr->document()); + Inkscape::XML::Node *nrepr = child->getRepr()->duplicate(prepr->document()); objects = g_slist_prepend (objects, nrepr); } } /* Step 2 - clear group */ // remember the position of the group - gint pos = SP_OBJECT_REPR(group)->position(); + gint pos = group->getRepr()->position(); // the group is leaving forever, no heir, clones should take note; its children however are going to reemerge - SP_OBJECT (group)->deleteObject(true, false); + group->deleteObject(true, false); /* Step 3 - add nonitems */ if (objects) { - Inkscape::XML::Node *last_def = SP_OBJECT_REPR(defs)->lastChild(); + Inkscape::XML::Node *last_def = defs->getRepr()->lastChild(); while (objects) { - Inkscape::XML::Node *repr = (Inkscape::XML::Node *) objects->data; - if (!sp_repr_is_meta_element(repr)) - SP_OBJECT_REPR(defs)->addChild(repr, last_def); - Inkscape::GC::release(repr); - objects = g_slist_remove (objects, objects->data); + Inkscape::XML::Node *repr = (Inkscape::XML::Node *) objects->data; + if (!sp_repr_is_meta_element(repr)) { + defs->getRepr()->addChild(repr, last_def); + } + Inkscape::GC::release(repr); + objects = g_slist_remove (objects, objects->data); } } @@ -532,9 +533,9 @@ SPObject *sp_item_group_get_child_by_name(SPGroup *group, SPObject *ref, const g void SPGroup::setLayerMode(LayerMode mode) { if ( _layer_mode != mode ) { if ( mode == LAYER ) { - SP_OBJECT_DOCUMENT(this)->addResource("layer", this); + this->document->addResource("layer", this); } else if ( _layer_mode == LAYER ) { - SP_OBJECT_DOCUMENT(this)->removeResource("layer", this); + this->document->removeResource("layer", this); } _layer_mode = mode; _updateLayerMode(); @@ -590,7 +591,7 @@ CGroup::~CGroup() { void CGroup::onChildAdded(Inkscape::XML::Node *child) { SPObject *last_child = _group->lastChild(); - if (last_child && SP_OBJECT_REPR(last_child) == child) { + if (last_child && last_child->getRepr() == child) { // optimization for the common special case where the child is being added at the end SPObject *ochild = last_child; if ( SP_IS_ITEM(ochild) ) { @@ -646,9 +647,9 @@ void CGroup::onUpdate(SPCtx *ctx, unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { - SPObject *object = SP_OBJECT(_group); - for (SPItemView *v = SP_ITEM(_group)->display; v != NULL; v = v->next) { - nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object)); + SPObject *object = _group; + for (SPItemView *v = _group->display; v != NULL; v = v->next) { + nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), object->style); } } @@ -677,9 +678,9 @@ void CGroup::onModified(guint flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { - SPObject *object = SP_OBJECT(_group); - for (SPItemView *v = SP_ITEM(_group)->display; v != NULL; v = v->next) { - nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object)); + SPObject *object = _group; + for (SPItemView *v = _group->display; v != NULL; v = v->next) { + nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), object->style); } } @@ -694,7 +695,7 @@ void CGroup::onModified(guint flags) { } } -void CGroup::calculateBBox(NRRect *bbox, Geom::Matrix const &transform, unsigned const flags) { +void CGroup::calculateBBox(NRRect *bbox, Geom::Affine const &transform, unsigned const flags) { Geom::OptRect dummy_bbox; @@ -703,7 +704,7 @@ void CGroup::calculateBBox(NRRect *bbox, Geom::Matrix const &transform, unsigned SPObject *o = SP_OBJECT (l->data); if (SP_IS_ITEM(o) && !SP_ITEM(o)->isHidden()) { SPItem *child = SP_ITEM(o); - Geom::Matrix const ct(child->transform * transform); + Geom::Affine const ct(child->transform * transform); child->invoke_bbox_full( dummy_bbox, ct, flags, FALSE); } l = g_slist_remove (l, o); @@ -744,14 +745,14 @@ gchar *CGroup::getDescription() { NRArenaItem *CGroup::show (NRArena *arena, unsigned int key, unsigned int flags) { NRArenaItem *ai; - SPObject *object = SP_OBJECT(_group); + SPObject *object = _group; ai = NRArenaGroup::create(arena); nr_arena_group_set_transparent(NR_ARENA_GROUP (ai), _group->effectiveLayerMode(key) == SPGroup::LAYER); - nr_arena_group_set_style(NR_ARENA_GROUP(ai), SP_OBJECT_STYLE(object)); + nr_arena_group_set_style(NR_ARENA_GROUP(ai), object->style); _showChildren(arena, ai, key, flags); return ai; @@ -861,7 +862,7 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) SP_SHAPE(subitem)->setCurve(c, TRUE); if (write) { - Inkscape::XML::Node *repr = SP_OBJECT_REPR(subitem); + Inkscape::XML::Node *repr = subitem->getRepr(); gchar *str = sp_svg_write_path(c->get_pathvector()); repr->setAttribute("d", str); #ifdef GROUP_VERBOSE |
