From 9bfba5c24a89f0d2ae75fc78a0aa21743a29e978 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Sun, 2 Mar 2014 11:56:51 -0500 Subject: Experimental merge of Ponyscape features into trunk (will not compile) (bzr r13090.1.2) --- src/sp-item-group.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 2cfe97db8..fbd9a6538 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -616,6 +616,18 @@ SPGroup::LayerMode SPGroup::layerDisplayMode(unsigned int dkey) const { } } +void SPGroup::setExpanded(bool isexpanded) { + if ( _expanded != isexpanded ){ + _expanded = isexpanded; + } +} + +void SPGroup::setInsertBottom(bool insertbottom) { + if ( _insertBottom != insertbottom) { + _insertBottom = insertbottom; + } +} + void SPGroup::setLayerDisplayMode(unsigned int dkey, SPGroup::LayerMode mode) { if ( layerDisplayMode(dkey) != mode ) { _display_modes[dkey] = mode; -- cgit v1.2.3 From 5b67a95f4477d1a69e9a0f100d71a77277d86ef2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 7 Jun 2014 13:15:07 +0200 Subject: Fix for Bug #1241902 - (bzr r13341.1.52) --- src/sp-item-group.cpp | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 2cfe97db8..b3db0c1d7 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -778,17 +778,31 @@ void SPGroup::update_patheffect(bool write) { } } + +void +sp_gslist_update_by_clip_or_mask(GSList *item_list,SPItem * item) +{ + if(item->mask_ref->getObject()) { + SPObject * clipormask = item->mask_ref->getObject()->firstChild(); + item_list = g_slist_append(item_list,clipormask); + } + if(item->clip_ref->getObject()) { + SPObject * clipormask = item->clip_ref->getObject()->firstChild(); + item_list = g_slist_append(item_list,clipormask); + } +} + static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) { - GSList const *item_list = sp_item_group_item_list(SP_GROUP(group)); - - for ( GSList const *iter = item_list; iter; iter = iter->next ) { + GSList *item_list = sp_item_group_item_list(group); + sp_gslist_update_by_clip_or_mask(item_list,group); + for ( GSList *iter = item_list; iter; iter = iter->next ) { SPObject *subitem = static_cast(iter->data); - if (SP_IS_GROUP(subitem)) { sp_group_perform_patheffect(SP_GROUP(subitem), topgroup, write); } else if (SP_IS_SHAPE(subitem)) { + sp_gslist_update_by_clip_or_mask(item_list,SP_ITEM(subitem)); SPCurve * c = NULL; if (SP_IS_PATH(subitem)) { @@ -799,9 +813,17 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) // only run LPEs when the shape has a curve defined if (c) { - c->transform(i2anc_affine(subitem, topgroup)); + if(SP_IS_MASK(subitem->parent) || SP_IS_CLIPPATH(subitem->parent)) { + c->transform(i2anc_affine(group, topgroup)); + } else { + c->transform(i2anc_affine(subitem, topgroup)); + } SP_LPE_ITEM(topgroup)->performPathEffect(c); - c->transform(i2anc_affine(subitem, topgroup).inverse()); + if(SP_IS_MASK(subitem->parent) || SP_IS_CLIPPATH(subitem->parent)) { + c->transform(i2anc_affine(group, topgroup).inverse()); + } else { + c->transform(i2anc_affine(subitem, topgroup).inverse()); + } SP_SHAPE(subitem)->setCurve(c, TRUE); if (write) { @@ -809,7 +831,7 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) gchar *str = sp_svg_write_path(c->get_pathvector()); repr->setAttribute("d", str); #ifdef GROUP_VERBOSE -g_message("sp_group_perform_patheffect writes 'd' attribute"); + g_message("sp_group_perform_patheffect writes 'd' attribute"); #endif g_free(str); } -- cgit v1.2.3 From ce72482fe0e31786dbb2c6d3273cafe9b11f0800 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 11 Jun 2014 17:18:58 +0200 Subject: Fix for bug #1241902 (bzr r13418) --- src/sp-item-group.cpp | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 2cfe97db8..b3db0c1d7 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -778,17 +778,31 @@ void SPGroup::update_patheffect(bool write) { } } + +void +sp_gslist_update_by_clip_or_mask(GSList *item_list,SPItem * item) +{ + if(item->mask_ref->getObject()) { + SPObject * clipormask = item->mask_ref->getObject()->firstChild(); + item_list = g_slist_append(item_list,clipormask); + } + if(item->clip_ref->getObject()) { + SPObject * clipormask = item->clip_ref->getObject()->firstChild(); + item_list = g_slist_append(item_list,clipormask); + } +} + static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) { - GSList const *item_list = sp_item_group_item_list(SP_GROUP(group)); - - for ( GSList const *iter = item_list; iter; iter = iter->next ) { + GSList *item_list = sp_item_group_item_list(group); + sp_gslist_update_by_clip_or_mask(item_list,group); + for ( GSList *iter = item_list; iter; iter = iter->next ) { SPObject *subitem = static_cast(iter->data); - if (SP_IS_GROUP(subitem)) { sp_group_perform_patheffect(SP_GROUP(subitem), topgroup, write); } else if (SP_IS_SHAPE(subitem)) { + sp_gslist_update_by_clip_or_mask(item_list,SP_ITEM(subitem)); SPCurve * c = NULL; if (SP_IS_PATH(subitem)) { @@ -799,9 +813,17 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) // only run LPEs when the shape has a curve defined if (c) { - c->transform(i2anc_affine(subitem, topgroup)); + if(SP_IS_MASK(subitem->parent) || SP_IS_CLIPPATH(subitem->parent)) { + c->transform(i2anc_affine(group, topgroup)); + } else { + c->transform(i2anc_affine(subitem, topgroup)); + } SP_LPE_ITEM(topgroup)->performPathEffect(c); - c->transform(i2anc_affine(subitem, topgroup).inverse()); + if(SP_IS_MASK(subitem->parent) || SP_IS_CLIPPATH(subitem->parent)) { + c->transform(i2anc_affine(group, topgroup).inverse()); + } else { + c->transform(i2anc_affine(subitem, topgroup).inverse()); + } SP_SHAPE(subitem)->setCurve(c, TRUE); if (write) { @@ -809,7 +831,7 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) gchar *str = sp_svg_write_path(c->get_pathvector()); repr->setAttribute("d", str); #ifdef GROUP_VERBOSE -g_message("sp_group_perform_patheffect writes 'd' attribute"); + g_message("sp_group_perform_patheffect writes 'd' attribute"); #endif g_free(str); } -- cgit v1.2.3 From f2ffaaab1e5733120394ca2bbf24403f435e47c4 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 27 Jun 2014 18:22:51 +0200 Subject: Remove the incorrect fix for the bug 1241902 (bzr r13341.1.69) --- src/sp-item-group.cpp | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index b3db0c1d7..2cfe97db8 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -778,31 +778,17 @@ void SPGroup::update_patheffect(bool write) { } } - -void -sp_gslist_update_by_clip_or_mask(GSList *item_list,SPItem * item) -{ - if(item->mask_ref->getObject()) { - SPObject * clipormask = item->mask_ref->getObject()->firstChild(); - item_list = g_slist_append(item_list,clipormask); - } - if(item->clip_ref->getObject()) { - SPObject * clipormask = item->clip_ref->getObject()->firstChild(); - item_list = g_slist_append(item_list,clipormask); - } -} - static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) { - GSList *item_list = sp_item_group_item_list(group); - sp_gslist_update_by_clip_or_mask(item_list,group); - for ( GSList *iter = item_list; iter; iter = iter->next ) { + GSList const *item_list = sp_item_group_item_list(SP_GROUP(group)); + + for ( GSList const *iter = item_list; iter; iter = iter->next ) { SPObject *subitem = static_cast(iter->data); + if (SP_IS_GROUP(subitem)) { sp_group_perform_patheffect(SP_GROUP(subitem), topgroup, write); } else if (SP_IS_SHAPE(subitem)) { - sp_gslist_update_by_clip_or_mask(item_list,SP_ITEM(subitem)); SPCurve * c = NULL; if (SP_IS_PATH(subitem)) { @@ -813,17 +799,9 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) // only run LPEs when the shape has a curve defined if (c) { - if(SP_IS_MASK(subitem->parent) || SP_IS_CLIPPATH(subitem->parent)) { - c->transform(i2anc_affine(group, topgroup)); - } else { - c->transform(i2anc_affine(subitem, topgroup)); - } + c->transform(i2anc_affine(subitem, topgroup)); SP_LPE_ITEM(topgroup)->performPathEffect(c); - if(SP_IS_MASK(subitem->parent) || SP_IS_CLIPPATH(subitem->parent)) { - c->transform(i2anc_affine(group, topgroup).inverse()); - } else { - c->transform(i2anc_affine(subitem, topgroup).inverse()); - } + c->transform(i2anc_affine(subitem, topgroup).inverse()); SP_SHAPE(subitem)->setCurve(c, TRUE); if (write) { @@ -831,7 +809,7 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) gchar *str = sp_svg_write_path(c->get_pathvector()); repr->setAttribute("d", str); #ifdef GROUP_VERBOSE - g_message("sp_group_perform_patheffect writes 'd' attribute"); +g_message("sp_group_perform_patheffect writes 'd' attribute"); #endif g_free(str); } -- cgit v1.2.3 From 6829ce76e2ab77859c1a5fdacbb2fa71109d65b0 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 27 Jun 2014 18:28:46 +0200 Subject: Remove the incorrect fix for the bug 1241902 (bzr r13441) --- src/sp-item-group.cpp | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index b3db0c1d7..2cfe97db8 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -778,31 +778,17 @@ void SPGroup::update_patheffect(bool write) { } } - -void -sp_gslist_update_by_clip_or_mask(GSList *item_list,SPItem * item) -{ - if(item->mask_ref->getObject()) { - SPObject * clipormask = item->mask_ref->getObject()->firstChild(); - item_list = g_slist_append(item_list,clipormask); - } - if(item->clip_ref->getObject()) { - SPObject * clipormask = item->clip_ref->getObject()->firstChild(); - item_list = g_slist_append(item_list,clipormask); - } -} - static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) { - GSList *item_list = sp_item_group_item_list(group); - sp_gslist_update_by_clip_or_mask(item_list,group); - for ( GSList *iter = item_list; iter; iter = iter->next ) { + GSList const *item_list = sp_item_group_item_list(SP_GROUP(group)); + + for ( GSList const *iter = item_list; iter; iter = iter->next ) { SPObject *subitem = static_cast(iter->data); + if (SP_IS_GROUP(subitem)) { sp_group_perform_patheffect(SP_GROUP(subitem), topgroup, write); } else if (SP_IS_SHAPE(subitem)) { - sp_gslist_update_by_clip_or_mask(item_list,SP_ITEM(subitem)); SPCurve * c = NULL; if (SP_IS_PATH(subitem)) { @@ -813,17 +799,9 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) // only run LPEs when the shape has a curve defined if (c) { - if(SP_IS_MASK(subitem->parent) || SP_IS_CLIPPATH(subitem->parent)) { - c->transform(i2anc_affine(group, topgroup)); - } else { - c->transform(i2anc_affine(subitem, topgroup)); - } + c->transform(i2anc_affine(subitem, topgroup)); SP_LPE_ITEM(topgroup)->performPathEffect(c); - if(SP_IS_MASK(subitem->parent) || SP_IS_CLIPPATH(subitem->parent)) { - c->transform(i2anc_affine(group, topgroup).inverse()); - } else { - c->transform(i2anc_affine(subitem, topgroup).inverse()); - } + c->transform(i2anc_affine(subitem, topgroup).inverse()); SP_SHAPE(subitem)->setCurve(c, TRUE); if (write) { @@ -831,7 +809,7 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) gchar *str = sp_svg_write_path(c->get_pathvector()); repr->setAttribute("d", str); #ifdef GROUP_VERBOSE - g_message("sp_group_perform_patheffect writes 'd' attribute"); +g_message("sp_group_perform_patheffect writes 'd' attribute"); #endif g_free(str); } -- cgit v1.2.3 From f50d13ff0fa4de4abf81251ec855ca0166db9050 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 12 Jul 2014 15:32:27 +0200 Subject: Fix moving of item center: 1) at paste and 2) at changing document units Fixed bugs: - https://launchpad.net/bugs/1247799 (bzr r13452) --- src/sp-item-group.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 2cfe97db8..7af4e3320 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -664,7 +664,8 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) Geom::Point old_center(0,0); if (item->isCenterSet()) { - old_center = item->getCenter(); + item->scaleCenter(sc.inverse()); // Convert the old relative center position to the new coordinates already now + old_center = item->getCenter(); // because getCenter() will use the bbox midpoint, which is also already in the new coordinates } gchar const *conn_type = NULL; -- cgit v1.2.3 From 653be18705548ae8ab5a0358ecf77feca1b22e54 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 28 Jul 2014 21:34:56 +0200 Subject: noop: remove commented-out code that is dangerous and should not come back (bzr r13475) --- src/sp-item-group.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 7af4e3320..657aca692 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -70,11 +70,9 @@ namespace { SPGroup::SPGroup() : SPLPEItem() { this->_layer_mode = SPGroup::GROUP; - //new (&this->_display_modes) std::map(); } SPGroup::~SPGroup() { - //this->_display_modes.~map(); } void SPGroup::build(SPDocument *document, Inkscape::XML::Node *repr) { -- cgit v1.2.3 From 9fdd8f25ee0f04d337864c7ec5e3216dae727e3c Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Thu, 14 Aug 2014 22:09:10 +0200 Subject: Fix some transformation center regressions, related to the viewbox/units changes (bzr r13512) --- src/sp-item-group.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 657aca692..bb52b0c55 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -660,12 +660,6 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) Geom::Translate const s(p); Geom::Affine final = s.inverse() * sc * s; - Geom::Point old_center(0,0); - if (item->isCenterSet()) { - item->scaleCenter(sc.inverse()); // Convert the old relative center position to the new coordinates already now - old_center = item->getCenter(); // because getCenter() will use the bbox midpoint, which is also already in the new coordinates - } - gchar const *conn_type = NULL; if (SP_IS_TEXT_TEXTPATH(item)) { SP_TEXT(item)->optimizeTextpathText(); @@ -710,7 +704,7 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) } if (item->isCenterSet() && !(final.isTranslation() || final.isIdentity())) { - item->setCenter(old_center * final); + item->scaleCenter(sc); // All coordinates have been scaled, so also the center must be scaled item->updateRepr(); } } -- cgit v1.2.3 From 018c346b862ccd7dafcbf0e35b757735446821f7 Mon Sep 17 00:00:00 2001 From: mathog <> Date: Thu, 4 Sep 2014 13:50:55 -0700 Subject: resolves bug 1348417 and implements addition features for bug 1302857 (bzr r13544) --- src/sp-item-group.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index bb52b0c55..3d03edd85 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -651,7 +651,25 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) for (SPObject *o = firstChild() ; o ; o = o->getNext() ) { if ( SP_IS_ITEM(o) ) { if (SP_IS_GROUP(o) && !SP_IS_BOX3D(o)) { - SP_GROUP(o)->scaleChildItemsRec(sc, p); + // Doing it this way breaks clipping because transforms are applied + // in coordinates for draws but nothing in defs is changed + // SP_GROUP(o)->scaleChildItemsRec(sc, p); + // instead change the transform on the entire group, and the transform + // is applied after any references to clipping paths. + SPItem *item = SP_ITEM(o); + Geom::Translate const s(p); + Geom::Affine final = s.inverse() * sc * s; + Geom::Affine tAff = item->i2dt_affine() * final; + item->set_i2d_affine(tAff); + tAff = item->transform; + // Eliminate common rounding error affecting EMF/WMF input. + // When the rounding error persists it converts the simple + // transform=scale() to transform=matrix(). + if(std::abs(tAff[4]) < 1.0e-5 && std::abs(tAff[5]) < 1.0e-5){ + tAff[4] = 0.0; + tAff[5] = 0.0; + } + item->doWriteTransform(item->getRepr(), tAff, NULL, true); } else { SPItem *item = SP_ITEM(o); Geom::OptRect bbox = item->desktopVisualBounds(); -- cgit v1.2.3 From 71c3b0398381d4bace1427bbda11f486fcbcc307 Mon Sep 17 00:00:00 2001 From: mathog <> Date: Mon, 8 Sep 2014 10:13:03 -0700 Subject: partial rollback of r13544, allow old recursive behavior for some locations, but not EMF import (bzr r13549) --- src/sp-item-group.cpp | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 3d03edd85..5936cfbe5 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -644,32 +644,41 @@ void SPGroup::translateChildItems(Geom::Translate const &tr) } } -// Recursively scale child items around a point -void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) +// Recursively (or not) scale child items around a point +void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bool noRecurse) { if ( hasChildren() ) { for (SPObject *o = firstChild() ; o ; o = o->getNext() ) { if ( SP_IS_ITEM(o) ) { if (SP_IS_GROUP(o) && !SP_IS_BOX3D(o)) { - // Doing it this way breaks clipping because transforms are applied - // in coordinates for draws but nothing in defs is changed - // SP_GROUP(o)->scaleChildItemsRec(sc, p); - // instead change the transform on the entire group, and the transform - // is applied after any references to clipping paths. - SPItem *item = SP_ITEM(o); - Geom::Translate const s(p); - Geom::Affine final = s.inverse() * sc * s; - Geom::Affine tAff = item->i2dt_affine() * final; - item->set_i2d_affine(tAff); - tAff = item->transform; - // Eliminate common rounding error affecting EMF/WMF input. - // When the rounding error persists it converts the simple - // transform=scale() to transform=matrix(). - if(std::abs(tAff[4]) < 1.0e-5 && std::abs(tAff[5]) < 1.0e-5){ - tAff[4] = 0.0; - tAff[5] = 0.0; + /* Using recursion breaks clipping because transforms are applied + in coordinates for draws but nothing in defs is changed + instead change the transform on the entire group, and the transform + is applied after any references to clipping paths. However NOT using + recursion apparently breaks as of r13544 other parts of Inkscape + involved with showing/modifying units. So offer both for use + in different contexts. + */ + if(noRecurse) { + // used for EMF import + SPItem *item = SP_ITEM(o); + Geom::Translate const s(p); + Geom::Affine final = s.inverse() * sc * s; + Geom::Affine tAff = item->i2dt_affine() * final; + item->set_i2d_affine(tAff); + tAff = item->transform; + // Eliminate common rounding error affecting EMF/WMF input. + // When the rounding error persists it converts the simple + // transform=scale() to transform=matrix(). + if(std::abs(tAff[4]) < 1.0e-5 && std::abs(tAff[5]) < 1.0e-5){ + tAff[4] = 0.0; + tAff[5] = 0.0; + } + item->doWriteTransform(item->getRepr(), tAff, NULL, true); + } else { + // used for other import + SP_GROUP(o)->scaleChildItemsRec(sc, p, false); } - item->doWriteTransform(item->getRepr(), tAff, NULL, true); } else { SPItem *item = SP_ITEM(o); Geom::OptRect bbox = item->desktopVisualBounds(); -- cgit v1.2.3 From b91f59f850cf88b2c5a4579cbb4a515189f96b24 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Fri, 19 Sep 2014 15:10:08 -0400 Subject: scale clip or mask upon unit change (Bug 1287288) Fixed bugs: - https://launchpad.net/bugs/1287288 (bzr r13561) --- src/sp-item-group.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 5936cfbe5..a24056630 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -677,6 +677,18 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo item->doWriteTransform(item->getRepr(), tAff, NULL, true); } else { // used for other import + SPItem *item = NULL; + if (SP_ITEM(o)->clip_ref->getObject()) { + item = SP_ITEM(SP_ITEM(o)->clip_ref->getObject()->firstChild()); + } else if (SP_ITEM(o)->mask_ref->getObject()) { + item = SP_ITEM(SP_ITEM(o)->mask_ref->getObject()->firstChild()); + } + if (item != NULL) { + Geom::Affine tdoc2dt = Geom::Scale(1, -1) * Geom::Translate(p); // re-create doc2dt() + Geom::Affine ti2doc = SP_ITEM(o)->i2doc_affine(); + item->set_i2d_affine(ti2doc * sc * ti2doc.inverse() * tdoc2dt); + item->doWriteTransform(item->getRepr(), item->transform, NULL, true); + } SP_GROUP(o)->scaleChildItemsRec(sc, p, false); } } else { -- cgit v1.2.3 From 44d5ffff67f726c355a28492a427a55d6e6387fd Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Fri, 19 Sep 2014 17:47:25 -0400 Subject: improved version of rev 13561, to allow transforming both clip and mask on the same group Fixed bugs: - https://launchpad.net/bugs/1287288 (bzr r13562) --- src/sp-item-group.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index a24056630..b65be8f22 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -680,7 +680,15 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo SPItem *item = NULL; if (SP_ITEM(o)->clip_ref->getObject()) { item = SP_ITEM(SP_ITEM(o)->clip_ref->getObject()->firstChild()); - } else if (SP_ITEM(o)->mask_ref->getObject()) { + } + if (item != NULL) { + Geom::Affine tdoc2dt = Geom::Scale(1, -1) * Geom::Translate(p); // re-create doc2dt() + Geom::Affine ti2doc = SP_ITEM(o)->i2doc_affine(); + item->set_i2d_affine(ti2doc * sc * ti2doc.inverse() * tdoc2dt); + item->doWriteTransform(item->getRepr(), item->transform, NULL, true); + } + item = NULL; + if (SP_ITEM(o)->mask_ref->getObject()) { item = SP_ITEM(SP_ITEM(o)->mask_ref->getObject()->firstChild()); } if (item != NULL) { -- cgit v1.2.3 From 601a9a118cf80672d71e503e86827d17c5043590 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Fri, 3 Oct 2014 15:15:18 -0400 Subject: modify scaling procedure for uniform scaling of flowed text (Bug 1278561) Fixed bugs: - https://launchpad.net/bugs/1278561 (bzr r13578) --- src/sp-item-group.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index b65be8f22..3fd6a1e80 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -725,7 +725,7 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo if (SP_IS_PERSP3D(item)) { persp3d_apply_affine_transformation(SP_PERSP3D(item), final); - } else if ((SP_IS_TEXT_TEXTPATH(item) || SP_IS_FLOWTEXT(item)) && !item->transform.isIdentity()) { + } else if (SP_IS_TEXT_TEXTPATH(item) && !item->transform.isIdentity()) { // Save and reset current transform Geom::Affine tmp(item->transform); item->transform = Geom::Affine(); -- cgit v1.2.3 From e2ae473da92a1f96e307e3f1f3e206cad7bd1c38 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 23 Oct 2014 19:33:47 -0700 Subject: Initial removal of box3d outdated GTKish macros. (bzr r13634) --- src/sp-item-group.cpp | 285 ++++++++++++++++++++++++++------------------------ 1 file changed, 150 insertions(+), 135 deletions(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 3fd6a1e80..02359baa3 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -96,14 +96,14 @@ void SPGroup::child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref) 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) ) { + SPItem *item = dynamic_cast(last_child); + if ( item ) { /* TODO: this should be moved into SPItem somehow */ SPItemView *v; Inkscape::DrawingItem *ac; for (v = this->display; v != NULL; v = v->next) { - ac = SP_ITEM (ochild)->invoke_show (v->arenaitem->drawing(), v->key, v->flags); + ac = item->invoke_show (v->arenaitem->drawing(), v->key, v->flags); if (ac) { v->arenaitem->appendChild(ac); @@ -111,16 +111,16 @@ void SPGroup::child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref) } } } else { // general case - SPObject *ochild = this->get_child_by_repr(child); - if ( ochild && SP_IS_ITEM(ochild) ) { + SPItem *item = dynamic_cast(get_child_by_repr(child)); + if ( item ) { /* TODO: this should be moved into SPItem somehow */ SPItemView *v; Inkscape::DrawingItem *ac; - unsigned position = SP_ITEM(ochild)->pos_in_parent(); + unsigned position = item->pos_in_parent(); for (v = this->display; v != NULL; v = v->next) { - ac = SP_ITEM (ochild)->invoke_show (v->arenaitem->drawing(), v->key, v->flags); + ac = item->invoke_show (v->arenaitem->drawing(), v->key, v->flags); if (ac) { v->arenaitem->prependChild(ac); @@ -145,12 +145,12 @@ void SPGroup::order_changed (Inkscape::XML::Node *child, Inkscape::XML::Node *ol { SPLPEItem::order_changed(child, old_ref, new_ref); - SPObject *ochild = this->get_child_by_repr(child); - if ( ochild && SP_IS_ITEM(ochild) ) { + SPItem *item = dynamic_cast(get_child_by_repr(child)); + if ( item ) { /* TODO: this should be moved into SPItem somehow */ SPItemView *v; - unsigned position = SP_ITEM(ochild)->pos_in_parent(); - for ( v = SP_ITEM (ochild)->display ; v != NULL ; v = v->next ) { + unsigned position = item->pos_in_parent(); + for ( v = item->display ; v != NULL ; v = v->next ) { v->arenaitem->setZOrder(position); } } @@ -177,10 +177,10 @@ void SPGroup::update(SPCtx *ctx, unsigned int flags) { l = g_slist_remove (l, child); if (childflags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { - if (SP_IS_ITEM (child)) { - SPItem const &chi = *SP_ITEM(child); - cctx.i2doc = chi.transform * ictx->i2doc; - cctx.i2vp = chi.transform * ictx->i2vp; + SPItem *item = dynamic_cast(child); + if (item) { + cctx.i2doc = item->transform * ictx->i2doc; + cctx.i2vp = item->transform * ictx->i2vp; child->updateDisplay((SPCtx *)&cctx, childflags); } else { child->updateDisplay(ctx, childflags); @@ -230,14 +230,11 @@ void SPGroup::modified(guint flags) { } Inkscape::XML::Node* SPGroup::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPGroup* object = this; - SPGroup *group = SP_GROUP(object); - if (flags & SP_OBJECT_WRITE_BUILD) { - GSList *l; + GSList *l = NULL; if (!repr) { - if (SP_IS_SWITCH(object)) { + if (dynamic_cast(this)) { repr = xml_doc->createElement("svg:switch"); } else { repr = xml_doc->createElement("svg:g"); @@ -246,8 +243,8 @@ Inkscape::XML::Node* SPGroup::write(Inkscape::XML::Document *xml_doc, Inkscape:: l = NULL; - for (SPObject *child = object->firstChild(); child; child = child->getNext() ) { - if ( !SP_IS_TITLE(child) && !SP_IS_DESC(child) ) { + for (SPObject *child = firstChild(); child; child = child->getNext() ) { + if ( !dynamic_cast(child) && !dynamic_cast(child) ) { Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); if (crepr) { @@ -262,8 +259,8 @@ Inkscape::XML::Node* SPGroup::write(Inkscape::XML::Document *xml_doc, Inkscape:: l = g_slist_remove (l, l->data); } } else { - for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { - if ( !SP_IS_TITLE(child) && !SP_IS_DESC(child) ) { + for (SPObject *child = firstChild() ; child ; child = child->getNext() ) { + if ( !dynamic_cast(child) && !dynamic_cast(child) ) { child->updateRepr(flags); } } @@ -271,9 +268,9 @@ Inkscape::XML::Node* SPGroup::write(Inkscape::XML::Document *xml_doc, Inkscape:: if ( flags & SP_OBJECT_WRITE_EXT ) { const char *value; - if ( group->_layer_mode == SPGroup::LAYER ) { + if ( _layer_mode == SPGroup::LAYER ) { value = "layer"; - } else if ( group->_layer_mode == SPGroup::MASK_HELPER ) { + } else if ( _layer_mode == SPGroup::MASK_HELPER ) { value = "maskhelper"; } else if ( flags & SP_OBJECT_WRITE_ALL ) { value = "group"; @@ -293,16 +290,16 @@ Geom::OptRect SPGroup::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox { Geom::OptRect bbox; - // CPPIFY: replace this const_cast later + // TODO CPPIFY: replace this const_cast later GSList *l = const_cast(this)->childList(false, SPObject::ActionBBox); while (l) { SPObject *o = SP_OBJECT (l->data); - if (SP_IS_ITEM(o) && !SP_ITEM(o)->isHidden()) { - SPItem *child = SP_ITEM(o); - Geom::Affine const ct(child->transform * transform); - bbox |= child->bounds(bboxtype, ct); + SPItem *item = dynamic_cast(o); + if (item && !item->isHidden()) { + Geom::Affine const ct(item->transform * transform); + bbox |= item->bounds(bboxtype, ct); } l = g_slist_remove (l, o); @@ -317,8 +314,9 @@ void SPGroup::print(SPPrintContext *ctx) { while (l) { SPObject *o = SP_OBJECT (l->data); - if (SP_IS_ITEM(o)) { - SP_ITEM(o)->invoke_print (ctx); + SPItem *item = dynamic_cast(o); + if (item) { + item->invoke_print(ctx); } l = g_slist_remove (l, o); @@ -365,16 +363,14 @@ Inkscape::DrawingItem *SPGroup::show (Inkscape::Drawing &drawing, unsigned int k } void SPGroup::hide (unsigned int key) { - SPItem * child; - GSList *l = g_slist_reverse(this->childList(false, SPObject::ActionShow)); while (l) { SPObject *o = SP_OBJECT (l->data); - if (SP_IS_ITEM (o)) { - child = SP_ITEM (o); - child->invoke_hide (key); + SPItem *item = dynamic_cast(o); + if (item) { + item->invoke_hide(key); } l = g_slist_remove (l, o); @@ -387,8 +383,9 @@ void SPGroup::hide (unsigned int key) { void SPGroup::snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const { for ( SPObject const *o = this->firstChild(); o; o = o->getNext() ) { - if (SP_IS_ITEM(o)) { - SP_ITEM(o)->getSnappoints(p, snapprefs); + SPItem const *item = dynamic_cast(o); + if (item) { + item->getSnappoints(p, snapprefs); } } } @@ -398,14 +395,12 @@ void 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 = group->document; SPRoot *root = doc->getRoot(); SPObject *defs = root->defs; - SPItem *gitem = group; - Inkscape::XML::Node *grepr = gitem->getRepr(); + Inkscape::XML::Node *grepr = group->getRepr(); g_return_if_fail (!strcmp (grepr->name(), "svg:g") || !strcmp (grepr->name(), "svg:a") @@ -413,33 +408,34 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) || !strcmp (grepr->name(), "svg:svg")); // this converts the gradient/pattern fill/stroke on the group, if any, to userSpaceOnUse - gitem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false); + group->adjust_paint_recursive (Geom::identity(), Geom::identity(), false); - SPItem *pitem = SP_ITEM(gitem->parent); + SPItem *pitem = dynamic_cast(group->parent); + g_assert(pitem); Inkscape::XML::Node *prepr = pitem->getRepr(); - if (SP_IS_BOX3D(gitem)) { - group = box3d_convert_to_group(SP_BOX3D(gitem)); - gitem = group; - } + { + SPBox3D *box = dynamic_cast(group); + if (box) { + group = box3d_convert_to_group(box); + } + } - SP_LPE_ITEM(group)->removeAllPathEffects(false); + group->removeAllPathEffects(false); /* Step 1 - generate lists of children objects */ GSList *items = NULL; GSList *objects = NULL; for (SPObject *child = group->firstChild() ; child; child = child->getNext() ) { - if (SP_IS_ITEM (child)) { - - SPItem *citem = SP_ITEM (child); - + SPItem *citem = dynamic_cast(child); + if (citem) { /* Merging of style */ // this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do // 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(child->style, gitem->style); + sp_style_merge_from_dying_parent(child->style, group->style); /* * fixme: We currently make no allowance for the case where child is cloned * and the group has any style settings. @@ -468,20 +464,21 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) // Merging transform Geom::Affine ctrans; - Geom::Affine const g(gitem->transform); - if (SP_IS_USE(citem) && SP_USE(citem)->get_original() && - SP_USE(citem)->get_original()->parent == SP_OBJECT(group)) { + Geom::Affine const g(group->transform); + SPUse *useitem = dynamic_cast(citem); + if (useitem && useitem->get_original() && + useitem->get_original()->parent == dynamic_cast(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)); + if (dynamic_cast(citem)) { // Do we have an offset at hand (whether it's dynamic or linked)? + SPItem *source = sp_offset_get_source(dynamic_cast(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)); + while (source != NULL && dynamic_cast(source)) { + source = sp_offset_get_source(dynamic_cast(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 @@ -548,10 +545,14 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) // fill in the children list if non-null SPItem *item = static_cast(doc->getObjectByRepr(repr)); - item->doWriteTransform(repr, item->transform, NULL, false); + if (item) { + item->doWriteTransform(repr, item->transform, NULL, false); + } else { + g_assert_not_reached(); + } Inkscape::GC::release(repr); - if (children && SP_IS_ITEM(item)) { + if (children && item) { *children = g_slist_prepend(*children, item); } @@ -570,12 +571,11 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) GSList *sp_item_group_item_list(SPGroup * group) { g_return_val_if_fail(group != NULL, NULL); - g_return_val_if_fail(SP_IS_GROUP(group), NULL); GSList *s = NULL; for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { - if ( SP_IS_ITEM(o) ) { + if ( dynamic_cast(o) ) { s = g_slist_prepend(s, o); } } @@ -637,8 +637,9 @@ void SPGroup::translateChildItems(Geom::Translate const &tr) { if ( hasChildren() ) { for (SPObject *o = firstChild() ; o ; o = o->getNext() ) { - if ( SP_IS_ITEM(o) ) { - sp_item_move_rel(reinterpret_cast(o), tr); + SPItem *item = dynamic_cast(o); + if ( item ) { + sp_item_move_rel(item, tr); } } } @@ -649,8 +650,10 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo { if ( hasChildren() ) { for (SPObject *o = firstChild() ; o ; o = o->getNext() ) { - if ( SP_IS_ITEM(o) ) { - if (SP_IS_GROUP(o) && !SP_IS_BOX3D(o)) { + SPItem *item = dynamic_cast(o); + if ( item ) { + SPGroup *group = dynamic_cast(item); + if (group && !dynamic_cast(item)) { /* Using recursion breaks clipping because transforms are applied in coordinates for draws but nothing in defs is changed instead change the transform on the entire group, and the transform @@ -661,7 +664,6 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo */ if(noRecurse) { // used for EMF import - SPItem *item = SP_ITEM(o); Geom::Translate const s(p); Geom::Affine final = s.inverse() * sc * s; Geom::Affine tAff = item->i2dt_affine() * final; @@ -677,30 +679,29 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo item->doWriteTransform(item->getRepr(), tAff, NULL, true); } else { // used for other import - SPItem *item = NULL; - if (SP_ITEM(o)->clip_ref->getObject()) { - item = SP_ITEM(SP_ITEM(o)->clip_ref->getObject()->firstChild()); + SPItem *subItem = NULL; + if (item->clip_ref->getObject()) { + subItem = dynamic_cast(item->clip_ref->getObject()->firstChild()); } - if (item != NULL) { + if (subItem != NULL) { Geom::Affine tdoc2dt = Geom::Scale(1, -1) * Geom::Translate(p); // re-create doc2dt() - Geom::Affine ti2doc = SP_ITEM(o)->i2doc_affine(); - item->set_i2d_affine(ti2doc * sc * ti2doc.inverse() * tdoc2dt); - item->doWriteTransform(item->getRepr(), item->transform, NULL, true); + Geom::Affine ti2doc = item->i2doc_affine(); + subItem->set_i2d_affine(ti2doc * sc * ti2doc.inverse() * tdoc2dt); + subItem->doWriteTransform(subItem->getRepr(), subItem->transform, NULL, true); } - item = NULL; - if (SP_ITEM(o)->mask_ref->getObject()) { - item = SP_ITEM(SP_ITEM(o)->mask_ref->getObject()->firstChild()); + subItem = NULL; + if (item->mask_ref->getObject()) { + subItem = dynamic_cast(item->mask_ref->getObject()->firstChild()); } - if (item != NULL) { + if (subItem != NULL) { Geom::Affine tdoc2dt = Geom::Scale(1, -1) * Geom::Translate(p); // re-create doc2dt() - Geom::Affine ti2doc = SP_ITEM(o)->i2doc_affine(); - item->set_i2d_affine(ti2doc * sc * ti2doc.inverse() * tdoc2dt); - item->doWriteTransform(item->getRepr(), item->transform, NULL, true); + Geom::Affine ti2doc = item->i2doc_affine(); + subItem->set_i2d_affine(ti2doc * sc * ti2doc.inverse() * tdoc2dt); + subItem->doWriteTransform(item->getRepr(), item->transform, NULL, true); } - SP_GROUP(o)->scaleChildItemsRec(sc, p, false); + group->scaleChildItemsRec(sc, p, false); } } else { - SPItem *item = SP_ITEM(o); Geom::OptRect bbox = item->desktopVisualBounds(); if (bbox) { // Scale item @@ -708,24 +709,33 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo Geom::Affine final = s.inverse() * sc * s; gchar const *conn_type = NULL; - if (SP_IS_TEXT_TEXTPATH(item)) { - SP_TEXT(item)->optimizeTextpathText(); - } else if (SP_IS_FLOWTEXT(item)) { - SP_FLOWTEXT(item)->optimizeScaledText(); - } else if (SP_IS_BOX3D(item)) { - // Force recalculation from perspective - box3d_position_set(SP_BOX3D(item)); - } else if (item->getAttribute("inkscape:connector-type") != NULL - && (item->getAttribute("inkscape:connection-start") == NULL - || item->getAttribute("inkscape:connection-end") == NULL)) { - // Remove and store connector type for transform if disconnected - conn_type = item->getAttribute("inkscape:connector-type"); - item->removeAttribute("inkscape:connector-type"); + SPText *textItem = dynamic_cast(item); + bool isTextTextpath = textItem && textItem->firstChild() && dynamic_cast(textItem->firstChild()); + if (isTextTextpath) { + textItem->optimizeTextpathText(); + } else { + SPFlowtext *flowText = dynamic_cast(item); + if (flowText) { + flowText->optimizeScaledText(); + } else { + SPBox3D *box = dynamic_cast(item); + if (box) { + // Force recalculation from perspective + box3d_position_set(box); + } else if (item->getAttribute("inkscape:connector-type") != NULL + && (item->getAttribute("inkscape:connection-start") == NULL + || item->getAttribute("inkscape:connection-end") == NULL)) { + // Remove and store connector type for transform if disconnected + conn_type = item->getAttribute("inkscape:connector-type"); + item->removeAttribute("inkscape:connector-type"); + } + } } - if (SP_IS_PERSP3D(item)) { - persp3d_apply_affine_transformation(SP_PERSP3D(item), final); - } else if (SP_IS_TEXT_TEXTPATH(item) && !item->transform.isIdentity()) { + Persp3D *persp = dynamic_cast(item); + if (persp) { + persp3d_apply_affine_transformation(persp, final); + } else if (isTextTextpath && !item->transform.isIdentity()) { // Save and reset current transform Geom::Affine tmp(item->transform); item->transform = Geom::Affine(); @@ -736,7 +746,7 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo tmp[4] *= sc[0]; tmp[5] *= sc[1]; item->doWriteTransform(item->getRepr(), tmp, NULL, true); - } else if (SP_IS_USE(item)) { + } else if (dynamic_cast(item)) { // calculate the matrix we need to apply to the clone // to cancel its induced transform from its original Geom::Affine move = final.inverse() * item->transform * final; @@ -764,7 +774,7 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo gint SPGroup::getItemCount() const { gint len = 0; for (SPObject const *o = this->firstChild() ; o ; o = o->getNext() ) { - if (SP_IS_ITEM(o)) { + if (dynamic_cast(o)) { len++; } } @@ -774,12 +784,11 @@ gint SPGroup::getItemCount() const { void SPGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { Inkscape::DrawingItem *ac = NULL; - SPItem * child = NULL; GSList *l = g_slist_reverse(this->childList(false, SPObject::ActionShow)); while (l) { SPObject *o = SP_OBJECT (l->data); - if (SP_IS_ITEM (o)) { - child = SP_ITEM (o); + SPItem * child = dynamic_cast(o); + if (child) { ac = child->invoke_show (drawing, key, flags); if (ac) { ai->appendChild(ac); @@ -799,8 +808,9 @@ void SPGroup::update_patheffect(bool write) { for ( GSList const *iter = item_list; iter; iter = iter->next ) { SPObject *subitem = static_cast(iter->data); - if (SP_IS_LPE_ITEM(subitem)) { - ((SPLPEItem*)subitem)->update_patheffect(write); + SPLPEItem *lpeItem = dynamic_cast(subitem); + if (lpeItem) { + lpeItem->update_patheffect(write); } } @@ -821,40 +831,45 @@ void SPGroup::update_patheffect(bool write) { static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) { - GSList const *item_list = sp_item_group_item_list(SP_GROUP(group)); + GSList const *item_list = sp_item_group_item_list(group); for ( GSList const *iter = item_list; iter; iter = iter->next ) { SPObject *subitem = static_cast(iter->data); - if (SP_IS_GROUP(subitem)) { - sp_group_perform_patheffect(SP_GROUP(subitem), topgroup, write); - } else if (SP_IS_SHAPE(subitem)) { - SPCurve * c = NULL; + SPGroup *subGroup = dynamic_cast(subitem); + if (subGroup) { + sp_group_perform_patheffect(subGroup, topgroup, write); + } else { + SPShape *subShape = dynamic_cast(subitem); + if (subShape) { + SPCurve * c = NULL; - if (SP_IS_PATH(subitem)) { - c = SP_PATH(subitem)->get_original_curve(); - } else { - c = SP_SHAPE(subitem)->getCurve(); - } + SPPath *subPath = dynamic_cast(subShape); + if (subPath) { + c = subPath->get_original_curve(); + } else { + c = subShape->getCurve(); + } - // only run LPEs when the shape has a curve defined - if (c) { - c->transform(i2anc_affine(subitem, topgroup)); - SP_LPE_ITEM(topgroup)->performPathEffect(c); - c->transform(i2anc_affine(subitem, topgroup).inverse()); - SP_SHAPE(subitem)->setCurve(c, TRUE); - - if (write) { - Inkscape::XML::Node *repr = subitem->getRepr(); - gchar *str = sp_svg_write_path(c->get_pathvector()); - repr->setAttribute("d", str); + // only run LPEs when the shape has a curve defined + if (c) { + c->transform(i2anc_affine(subitem, topgroup)); + topgroup->performPathEffect(c); + c->transform(i2anc_affine(subitem, topgroup).inverse()); + subShape->setCurve(c, TRUE); + + if (write) { + Inkscape::XML::Node *repr = subitem->getRepr(); + gchar *str = sp_svg_write_path(c->get_pathvector()); + repr->setAttribute("d", str); #ifdef GROUP_VERBOSE -g_message("sp_group_perform_patheffect writes 'd' attribute"); + g_message("sp_group_perform_patheffect writes 'd' attribute"); #endif - g_free(str); - } + g_free(str); + } - c->unref(); + c->unref(); + } } } } -- cgit v1.2.3 From 510c80b1b2d9a4ee700bd152d320c6963bccd358 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sat, 15 Nov 2014 07:52:51 -0500 Subject: scale symbols when changing document units (Bug 1365451) Fixed bugs: - https://launchpad.net/bugs/1365451 (bzr r13709) --- src/sp-item-group.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 613ace5c1..992bca631 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -662,8 +662,13 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo { if ( hasChildren() ) { for (SPObject *o = firstChild() ; o ; o = o->getNext() ) { - SPItem *item = dynamic_cast(o); - if ( item ) { + if ( SPDefs *defs = dynamic_cast(o) ) { // select symbols from defs, ignore clips, masks, patterns + for (SPObject *defschild = defs->firstChild() ; defschild ; defschild = defschild->getNext() ) { + SPGroup *defsgroup = dynamic_cast(defschild); + if (defsgroup) + defsgroup->scaleChildItemsRec(sc, p, false); + } + } else if ( SPItem *item = dynamic_cast(o) ) { SPGroup *group = dynamic_cast(item); if (group && !dynamic_cast(item)) { /* Using recursion breaks clipping because transforms are applied -- cgit v1.2.3