From f10048be170a45921ae8fc65ccd2588a9ad2897d Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 27 Aug 2013 12:32:55 -0400 Subject: Added viewBox implement document unit support. (bzr r12475.1.2) --- src/sp-item-group.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index a2eda6625..1b3a53828 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -50,6 +50,8 @@ #include "sp-switch.h" #include "sp-defs.h" #include "verbs.h" +#include "layer-model.h" +#include "selection-chemistry.h" using Inkscape::DocumentUndo; @@ -561,6 +563,35 @@ 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_GROUP(o)->scaleChildItemsRec(sc, p); + } else { + SPItem *item = reinterpret_cast(o); + Geom::OptRect bbox = item->desktopVisualBounds(); + if (bbox) { + // Clear selection (TODO: save and restore selection) + sp_desktop_selection(SP_ACTIVE_DESKTOP)->clear(); + + // Scale item + Geom::Translate const s(p); + Geom::Affine final = s.inverse() * sc * s; + Inkscape::LayerModel layers = Inkscape::LayerModel(); + Inkscape::Selection selection(&layers, SP_ACTIVE_DESKTOP); + selection.add(item); + sp_selection_apply_affine(&selection, final, true, true); + } + } + } + } + } +} + CGroup::CGroup(SPGroup *group) { _group = group; } -- cgit v1.2.3 From 282e965e030e7a1e9ae3455f877f7e8f8e1ea8dd Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 10 Sep 2013 23:50:49 -0400 Subject: Fix document unit change for 3d boxes and (mostly) for text on path. (bzr r12475.1.12) --- src/sp-item-group.cpp | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 1b3a53828..ec368bbac 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -52,6 +52,7 @@ #include "verbs.h" #include "layer-model.h" #include "selection-chemistry.h" +#include "sp-textpath.h" using Inkscape::DocumentUndo; @@ -569,22 +570,46 @@ 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)) { + if (SP_IS_GROUP(o) && !SP_IS_BOX3D(o)) { SP_GROUP(o)->scaleChildItemsRec(sc, p); } else { - SPItem *item = reinterpret_cast(o); + SPItem *item = SP_ITEM(o); Geom::OptRect bbox = item->desktopVisualBounds(); if (bbox) { - // Clear selection (TODO: save and restore selection) - sp_desktop_selection(SP_ACTIVE_DESKTOP)->clear(); - // Scale item Geom::Translate const s(p); Geom::Affine final = s.inverse() * sc * s; - Inkscape::LayerModel layers = Inkscape::LayerModel(); - Inkscape::Selection selection(&layers, SP_ACTIVE_DESKTOP); - selection.add(item); - sp_selection_apply_affine(&selection, final, true, true); + + Geom::Point old_center(0,0); + if (item->isCenterSet()) { + old_center = item->getCenter(); + } + + if (SP_IS_TEXT_TEXTPATH(item) && item->transform.isIdentity()) { + if (item->transform.isIdentity()) { + SP_TEXT(item)->optimizeTextpathText(); + } else { + // TODO: transformed text on textpath + } + } + + if (SP_IS_BOX3D(item)) { + // Force recalculation from perspective + box3d_position_set(SP_BOX3D(item)); + } 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 (item->isCenterSet() && !(final.isTranslation() || final.isIdentity())) { + item->setCenter(old_center * final); + item->updateRepr(); + } } } } -- cgit v1.2.3 From 93167c446a8a8e5574e94cda37dc91c17072513b Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 11 Sep 2013 19:35:54 -0400 Subject: Finish fixing document unit change undo bug. (bzr r12475.1.15) --- src/sp-item-group.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index ec368bbac..be62764c3 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -591,12 +591,12 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) } else { // TODO: transformed text on textpath } - } - - if (SP_IS_BOX3D(item)) { + } else if (SP_IS_BOX3D(item)) { // Force recalculation from perspective box3d_position_set(SP_BOX3D(item)); - } else if (SP_IS_USE(item)) { + } + + 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; -- cgit v1.2.3 From 803e249e999ab90caf2e3d61cc6782aa7dd3caba Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 15 Sep 2013 15:00:40 -0400 Subject: Fix document unit change for transformed flow text and transformed text on path. (bzr r12475.1.18) --- src/sp-item-group.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index be62764c3..1b8af43e1 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -51,8 +51,8 @@ #include "sp-defs.h" #include "verbs.h" #include "layer-model.h" -#include "selection-chemistry.h" #include "sp-textpath.h" +#include "sp-flowtext.h" using Inkscape::DocumentUndo; @@ -585,18 +585,27 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) old_center = item->getCenter(); } - if (SP_IS_TEXT_TEXTPATH(item) && item->transform.isIdentity()) { - if (item->transform.isIdentity()) { - SP_TEXT(item)->optimizeTextpathText(); - } else { - // TODO: transformed text on textpath - } + 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)); } - if (SP_IS_USE(item)) { + 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; -- cgit v1.2.3 From d3b5c51c6781c24933d941f26abe5a4b5cd9ccdb Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 15 Sep 2013 15:23:28 -0400 Subject: Fix document unit change for disconnected connectors. (bzr r12475.1.19) --- src/sp-item-group.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 1b8af43e1..e355c6cea 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -585,6 +585,7 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) 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)) { @@ -592,6 +593,12 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) } 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_TEXT_TEXTPATH(item) || SP_IS_FLOWTEXT(item)) && !item->transform.isIdentity()) { @@ -615,6 +622,10 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) 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(); -- cgit v1.2.3 From 677d56171814daeffec32f9db135a0585a033f93 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Mon, 16 Sep 2013 15:46:30 -0400 Subject: Fix 3d box document unit change undo bug. (bzr r12475.1.26) --- src/sp-item-group.cpp | 4 +++- 1 file changed, 3 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 e355c6cea..2d4c097c8 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -601,7 +601,9 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) item->removeAttribute("inkscape:connector-type"); } - if ((SP_IS_TEXT_TEXTPATH(item) || SP_IS_FLOWTEXT(item)) && !item->transform.isIdentity()) { + 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(); -- cgit v1.2.3 From eb3598e7e27619c759ef33bb9ec4ffb8898523de Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 20 Sep 2013 00:45:16 -0400 Subject: Refactor status-bar text for multiple items, was very broken Fixed bugs: - https://launchpad.net/bugs/1199192 (bzr r12550) --- src/sp-item-group.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/sp-item-group.cpp') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 010cc5449..5c176d2dc 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -325,12 +325,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("Group of %d object", - "Group of %d objects", - len), len); + ngettext(_("of %d object"), _("of %d objects"), len), len); } void SPGroup::set(unsigned int key, gchar const* value) { -- cgit v1.2.3