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