]> git.tokkee.org Git - inkscape.git/commitdiff

Code

Fixed ungrouping bug where the changed transformation of items was not written to...
authorjohanengelen <johanengelen@users.sourceforge.net>
Wed, 13 Dec 2006 20:42:26 +0000 (20:42 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Wed, 13 Dec 2006 20:42:26 +0000 (20:42 +0000)
src/sp-item-group.cpp
src/sp-item.cpp
src/sp-item.h

index ba96ed0d1b37364187bff01509aca25bdf3ac2b5..5cbf68fff2eea21c878dbf1b6b1ce534c9cf8e4f 100644 (file)
@@ -6,8 +6,9 @@
  * Authors:
  *   Lauris Kaplinski <lauris@kaplinski.com>
  *   bulia byak <buliabyak@users.sf.net>
+ *   Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
  *
- * 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);
index 5a138c866082a1f759dc64125979510094ba50c2..e5e2bb0853492b17b03f90456419ef2d33f803b1 100644 (file)
@@ -7,8 +7,9 @@
  * Authors:
  *   Lauris Kaplinski <lauris@kaplinski.com>
  *   bulia byak <buliabyak@users.sf.net>
+ *   Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
  *
- * 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);
index 43d2d8aa3f67685d15c07077dccf5c4a2e2a1e98..fc368d5b9223ffad5c13b0bf215dc6703b0ea82d 100644 (file)
@@ -9,8 +9,9 @@
  * Authors:
  *   Lauris Kaplinski <lauris@kaplinski.com>
  *   bulia byak <buliabyak@users.sf.net>
+ *   Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
  *
- * 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);