summaryrefslogtreecommitdiffstats
path: root/src/sp-item-group.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-09-20 17:43:57 +0000
committerJabiertxof <jtx@jtx.marker.es>2013-09-20 17:43:57 +0000
commit0a836d1870bb87d5be3e4d900718f903371c8e56 (patch)
tree7d218dc0e9d81e2f7d3eddcefad9640769dc89b3 /src/sp-item-group.cpp
parentCompact of SVG icons whith the help of ~suv and Martin Owens (diff)
parentMerge Google Summer of Code unit improvement. (diff)
downloadinkscape-0a836d1870bb87d5be3e4d900718f903371c8e56.tar.gz
inkscape-0a836d1870bb87d5be3e4d900718f903371c8e56.zip
Update to trunk
(bzr r11950.1.146)
Diffstat (limited to 'src/sp-item-group.cpp')
-rw-r--r--src/sp-item-group.cpp86
1 files changed, 83 insertions, 3 deletions
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index 010cc5449..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;
@@ -325,12 +328,14 @@ void SPGroup::print(SPPrintContext *ctx) {
}
}
+const char *SPGroup::display_name() {
+ return _("Group");
+}
+
gchar *SPGroup::description() {
gint len = this->getItemCount();
return g_strdup_printf(
- ngettext("<b>Group</b> of <b>%d</b> object",
- "<b>Group</b> of <b>%d</b> objects",
- len), len);
+ ngettext(_("of <b>%d</b> object"), _("of <b>%d</b> objects"), len), len);
}
void SPGroup::set(unsigned int key, gchar const* value) {
@@ -642,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() ) {