diff options
| author | Matthew Petroff <matthew@mpetroff.net> | 2013-09-20 17:09:19 +0000 |
|---|---|---|
| committer | Matthew Petroff <matthew@mpetroff.net> | 2013-09-20 17:09:19 +0000 |
| commit | cf74f053a081f6f4b460da9cd72afaab23d54d13 (patch) | |
| tree | 427aa22ba3dcad9b55edb90522b5ab0208074e06 /src/sp-item-group.cpp | |
| parent | Using inkscape compact settings to save the icons.svg file (diff) | |
| parent | Merge from trunk. (diff) | |
| download | inkscape-cf74f053a081f6f4b460da9cd72afaab23d54d13.tar.gz inkscape-cf74f053a081f6f4b460da9cd72afaab23d54d13.zip | |
Merge Google Summer of Code unit improvement.
(bzr r12554)
Diffstat (limited to 'src/sp-item-group.cpp')
| -rw-r--r-- | src/sp-item-group.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 5c176d2dc..720f6857a 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -50,6 +50,9 @@ #include "sp-switch.h" #include "sp-defs.h" #include "verbs.h" +#include "layer-model.h" +#include "sp-textpath.h" +#include "sp-flowtext.h" using Inkscape::DocumentUndo; @@ -644,6 +647,81 @@ 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) +{ + if ( hasChildren() ) { + 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); + } else { + SPItem *item = SP_ITEM(o); + Geom::OptRect bbox = item->desktopVisualBounds(); + if (bbox) { + // Scale item + Geom::Translate const s(p); + Geom::Affine final = s.inverse() * sc * s; + + Geom::Point old_center(0,0); + if (item->isCenterSet()) { + old_center = item->getCenter(); + } + + 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"); + } + + 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()) { + // Save and reset current transform + Geom::Affine tmp(item->transform); + item->transform = Geom::Affine(); + // Apply scale + item->set_i2d_affine(item->i2dt_affine() * sc); + item->doWriteTransform(item->getRepr(), item->transform, NULL, true); + // Scale translation and restore original transform + tmp[4] *= sc[0]; + tmp[5] *= sc[1]; + item->doWriteTransform(item->getRepr(), tmp, NULL, true); + } else if (SP_IS_USE(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; + item->doWriteTransform(item->getRepr(), move, &move, true); + } else { + item->set_i2d_affine(item->i2dt_affine() * final); + item->doWriteTransform(item->getRepr(), item->transform, NULL, true); + } + + if (conn_type != NULL) { + item->setAttribute("inkscape:connector-type", conn_type); + } + + if (item->isCenterSet() && !(final.isTranslation() || final.isIdentity())) { + item->setCenter(old_center * final); + item->updateRepr(); + } + } + } + } + } + } +} + gint SPGroup::getItemCount() { gint len = 0; for (SPObject *o = this->firstChild() ; o ; o = o->getNext() ) { |
