diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index 9f1126185213dec8af9ed99f95f9196fb2bc6c27..0e45bc7f43df067a961ba81326effdf2cc51ddcd 100644 (file)
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
nr_arena_item_set_mask(v->arenaitem, ai);
nr_arena_item_unref(ai);
sp_mask_set_bbox(SP_MASK(mask), NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox);
+ SP_OBJECT(mask)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
}
}
@@ -664,6 +665,10 @@ sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transfor
sp_item_invoke_bbox_full(item, bbox, transform, 0, clear);
}
+/** Calls \a item's subclass' bounding box method; clips it by the bbox of clippath, if any; and
+ * unions the resulting bbox with \a bbox. If \a clear is true, empties \a bbox first. Passes the
+ * transform and the flags to the actual bbox methods. Note that many of subclasses (e.g. groups,
+ * clones), in turn, call this function in their bbox methods. */
void
sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags, unsigned const clear)
{
@@ -676,15 +681,25 @@ sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, NR::Matrix const &tra
bbox->x1 = bbox->y1 = -1e18;
}
+ NRRect this_bbox;
+ this_bbox.x0 = this_bbox.y0 = 1e18;
+ this_bbox.x1 = this_bbox.y1 = -1e18;
+
+ // call the subclass method
if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox) {
- ((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox(item, bbox, transform, flags);
+ ((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox(item, &this_bbox, transform, flags);
}
// crop the bbox by clip path, if any
if (item->clip_ref->getObject()) {
NRRect b;
sp_clippath_get_bbox(SP_CLIPPATH(item->clip_ref->getObject()), &b, transform, flags);
- nr_rect_d_intersect (bbox, bbox, &b);
+ nr_rect_d_intersect (&this_bbox, &this_bbox, &b);
+ }
+
+ // if non-empty (with some tolerance - ?) union this_bbox with the bbox we've got passed
+ if ( fabs(this_bbox.x1-this_bbox.x0) > -0.00001 && fabs(this_bbox.y1-this_bbox.y0) > -0.00001 ) {
+ nr_rect_d_union (bbox, bbox, &this_bbox);
}
}
g_assert(SP_IS_ITEM(item));
if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->description) {
- return ((SPItemClass *) G_OBJECT_GET_CLASS(item))->description(item);
+ gchar *s = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->description(item);
+ if (s && item->clip_ref->getObject()) {
+ gchar *snew = g_strdup_printf ("%s; <i>clipped</i>", s);
+ g_free (s);
+ s = snew;
+ }
+ if (s && item->mask_ref->getObject()) {
+ gchar *snew = g_strdup_printf ("%s; <i>masked</i>", s);
+ g_free (s);
+ s = snew;
+ }
+ return s;
}
g_assert_not_reached();
@@ -830,18 +856,42 @@ sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags)
nr_arena_item_set_visible(ai, !item->isHidden());
nr_arena_item_set_sensitive(ai, item->sensitive);
if (item->clip_ref->getObject()) {
- NRArenaItem *ac;
- if (!item->display->arenaitem->key) NR_ARENA_ITEM_SET_KEY(item->display->arenaitem, sp_item_display_key_new(3));
- ac = sp_clippath_show(item->clip_ref->getObject(), arena, NR_ARENA_ITEM_GET_KEY(item->display->arenaitem));
+ SPClipPath *cp = item->clip_ref->getObject();
+
+ if (!item->display->arenaitem->key) {
+ NR_ARENA_ITEM_SET_KEY(item->display->arenaitem, sp_item_display_key_new(3));
+ }
+ int clip_key = NR_ARENA_ITEM_GET_KEY(item->display->arenaitem);
+
+ // Show and set clip
+ NRArenaItem *ac = sp_clippath_show(cp, arena, clip_key);
nr_arena_item_set_clip(ai, ac);
nr_arena_item_unref(ac);
+
+ // Update bbox, in case the clip uses bbox units
+ NRRect bbox;
+ sp_item_invoke_bbox(item, &bbox, NR::identity(), TRUE);
+ sp_clippath_set_bbox(SP_CLIPPATH(cp), clip_key, &bbox);
+ SP_OBJECT(cp)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
if (item->mask_ref->getObject()) {
- NRArenaItem *ac;
- if (!item->display->arenaitem->key) NR_ARENA_ITEM_SET_KEY(item->display->arenaitem, sp_item_display_key_new(3));
- ac = sp_mask_show(item->mask_ref->getObject(), arena, NR_ARENA_ITEM_GET_KEY(item->display->arenaitem));
+ SPMask *mask = item->mask_ref->getObject();
+
+ if (!item->display->arenaitem->key) {
+ NR_ARENA_ITEM_SET_KEY(item->display->arenaitem, sp_item_display_key_new(3));
+ }
+ int mask_key = NR_ARENA_ITEM_GET_KEY(item->display->arenaitem);
+
+ // Show and set mask
+ NRArenaItem *ac = sp_mask_show(mask, arena, mask_key);
nr_arena_item_set_mask(ai, ac);
nr_arena_item_unref(ac);
+
+ // Update bbox, in case the mask uses bbox units
+ NRRect bbox;
+ sp_item_invoke_bbox(item, &bbox, NR::identity(), TRUE);
+ sp_mask_set_bbox(SP_MASK(mask), mask_key, &bbox);
+ SP_OBJECT(mask)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
NR_ARENA_ITEM_SET_DATA(ai, item);
}
@@ -1111,10 +1161,11 @@ sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix cons
sp_item_adjust_paint_recursive (item, NR::identity(), NR::identity(), false);
}
- // run the object's set_transform if transforms are stored optimized
+ // run the object's set_transform if transforms are stored optimized and there's no clippath or mask
gint preserve = prefs_get_int_attribute("options.preservetransform", "value", 0);
NR::Matrix transform_attr (transform);
- if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform && !preserve) {
+ if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform
+ && !preserve && !item->clip_ref->getObject() && !item->mask_ref->getObject()) {
transform_attr = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform(item, transform);
}
sp_item_set_item_transform(item, transform_attr);