From 2d81d5b269b98e3c6c1e4285c7adc2a23f0f7749 Mon Sep 17 00:00:00 2001 From: johanengelen Date: Wed, 13 Dec 2006 20:42:26 +0000 Subject: [PATCH] Fixed ungrouping bug where the changed transformation of items was not written to XML. --- src/sp-item-group.cpp | 21 +++------------ src/sp-item.cpp | 59 +++++++++++++++++++++++-------------------- src/sp-item.h | 5 ++-- 3 files changed, 39 insertions(+), 46 deletions(-) diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index ba96ed0d1..5cbf68fff 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -6,8 +6,9 @@ * Authors: * Lauris Kaplinski * bulia byak + * Johan Engelen * - * Copyright (C) 1999-2005 authors + * Copyright (C) 1999-2006 authors * Copyright (C) 2000-2001 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -428,22 +429,8 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) // fill in the children list if non-null SPItem *item = (SPItem *) doc->getObjectByRepr(repr); - /* Optimize the transform matrix if requested. */ - // No compensations are required because this is supposed to be a non-transformation visually. - // FIXME: this if is wholly lifted from sp_item_write_transform and should stay in sync - NR::Matrix transform_attr (item->transform); - if ( // run the object's set_transform (i.e. embed transform) only if: - ((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform && // it does have a set_transform method - !preserve && // user did not chose to preserve all transforms - !item->clip_ref->getObject() && // the object does not have a clippath - !item->mask_ref->getObject() && // the object does not have a mask - !(!transform_attr.is_translation() && SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->filter.filter) - // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) - ) { - transform_attr = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform(item, item->transform); - } - sp_item_set_item_transform(item, transform_attr); - + sp_item_write_transform(item, repr, item->transform, NULL, false); + Inkscape::GC::release(repr); if (children && SP_IS_ITEM (item)) *children = g_slist_prepend (*children, item); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 5a138c866..e5e2bb085 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -7,8 +7,9 @@ * Authors: * Lauris Kaplinski * bulia byak + * Johan Engelen * - * Copyright (C) 2001-2005 authors + * Copyright (C) 2001-2006 authors * Copyright (C) 2001 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -1180,7 +1181,7 @@ sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NRMatrix const * the repr is updated with the new transform. */ void -sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix const &transform, NR::Matrix const *adv) +sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix const &transform, NR::Matrix const *adv, bool compensate) { g_return_if_fail(item != NULL); g_return_if_fail(SP_IS_ITEM(item)); @@ -1193,31 +1194,35 @@ sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix cons } else { advertized_transform = sp_item_transform_repr (item).inverse() * transform; } - - // recursively compensate for stroke scaling, depending on user preference - if (prefs_get_int_attribute("options.transform", "stroke", 1) == 0) { - double const expansion = 1. / NR::expansion(advertized_transform); - sp_item_adjust_stroke_width_recursive(item, expansion); - } - - // recursively compensate rx/ry of a rect if requested - if (prefs_get_int_attribute("options.transform", "rectcorners", 1) == 0) { - sp_item_adjust_rects_recursive(item, advertized_transform); - } - - // recursively compensate pattern fill if it's not to be transformed - if (prefs_get_int_attribute("options.transform", "pattern", 1) == 0) { - sp_item_adjust_paint_recursive (item, advertized_transform.inverse(), NR::identity(), true); - } - /// \todo FIXME: add the same else branch as for gradients below, to convert patterns to userSpaceOnUse as well - /// recursively compensate gradient fill if it's not to be transformed - if (prefs_get_int_attribute("options.transform", "gradient", 1) == 0) { - sp_item_adjust_paint_recursive (item, advertized_transform.inverse(), NR::identity(), false); - } else { - // this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do - // it here _before_ the new transform is set, so as to use the pre-transform bbox - sp_item_adjust_paint_recursive (item, NR::identity(), NR::identity(), false); - } + + if (compensate) { + + // recursively compensate for stroke scaling, depending on user preference + if (prefs_get_int_attribute("options.transform", "stroke", 1) == 0) { + double const expansion = 1. / NR::expansion(advertized_transform); + sp_item_adjust_stroke_width_recursive(item, expansion); + } + + // recursively compensate rx/ry of a rect if requested + if (prefs_get_int_attribute("options.transform", "rectcorners", 1) == 0) { + sp_item_adjust_rects_recursive(item, advertized_transform); + } + + // recursively compensate pattern fill if it's not to be transformed + if (prefs_get_int_attribute("options.transform", "pattern", 1) == 0) { + sp_item_adjust_paint_recursive (item, advertized_transform.inverse(), NR::identity(), true); + } + /// \todo FIXME: add the same else branch as for gradients below, to convert patterns to userSpaceOnUse as well + /// recursively compensate gradient fill if it's not to be transformed + if (prefs_get_int_attribute("options.transform", "gradient", 1) == 0) { + sp_item_adjust_paint_recursive (item, advertized_transform.inverse(), NR::identity(), false); + } else { + // this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do + // it here _before_ the new transform is set, so as to use the pre-transform bbox + sp_item_adjust_paint_recursive (item, NR::identity(), NR::identity(), false); + } + + } // endif(compensate) gint preserve = prefs_get_int_attribute("options.preservetransform", "value", 0); NR::Matrix transform_attr (transform); diff --git a/src/sp-item.h b/src/sp-item.h index 43d2d8aa3..fc368d5b9 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -9,8 +9,9 @@ * Authors: * Lauris Kaplinski * bulia byak + * Johan Engelen * - * Copyright (C) 1999-2005 authors + * Copyright (C) 1999-2006 authors * Copyright (C) 2001-2002 Ximian, Inc. * Copyright (C) 2004 Monash University * @@ -219,7 +220,7 @@ void sp_item_adjust_stroke_width_recursive(SPItem *item, gdouble ex); void sp_item_adjust_paint_recursive(SPItem *item, NR::Matrix advertized_transform, NR::Matrix t_ancestors, bool is_pattern); void sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NRMatrix const *transform, NR::Matrix const *adv = NULL); -void sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix const &transform, NR::Matrix const *adv = NULL); +void sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix const &transform, NR::Matrix const *adv = NULL, bool compensate = true); void sp_item_set_item_transform(SPItem *item, NR::Matrix const &transform); -- 2.39.5