summaryrefslogtreecommitdiffstats
path: root/src/sp-item-group.cpp
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-09-24 21:32:23 +0000
committerMarkus Engel <markus.engel@tum.de>2013-09-24 21:32:23 +0000
commit2f017d2ef4974eba04515b9a155656ce9f2f7822 (patch)
tree33aac031c85048c2129e191e45c7667773f34c68 /src/sp-item-group.cpp
parentRefactored SPGenericEllipse::set_shape (diff)
downloadinkscape-2f017d2ef4974eba04515b9a155656ce9f2f7822.tar.gz
inkscape-2f017d2ef4974eba04515b9a155656ce9f2f7822.zip
Refactored SPUse.
(bzr r11608.1.128)
Diffstat (limited to 'src/sp-item-group.cpp')
-rw-r--r--src/sp-item-group.cpp90
1 files changed, 85 insertions, 5 deletions
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index 010cc5449..2becf7139 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::displayName() {
+ 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) {
@@ -467,8 +472,8 @@ 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_get_original (SP_USE(citem)) &&
- sp_use_get_original( SP_USE(citem) )->parent == SP_OBJECT(group)) {
+ if (SP_IS_USE(citem) && SP_USE(citem)->get_original() &&
+ SP_USE(citem)->get_original()->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 {
@@ -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() ) {