From 0a552113158ad325ffafc7668b8b01149043c338 Mon Sep 17 00:00:00 2001 From: johanengelen Date: Fri, 1 Aug 2008 20:07:58 +0000 Subject: [PATCH] SPItem::getBounds now always returns a Geom::Rect boundingbox. --- src/live_effects/lpe-mirror_symmetry.cpp | 6 +++--- src/live_effects/lpegroupbbox.cpp | 9 +++------ src/sp-item.cpp | 11 +++++++++-- src/sp-item.h | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index a70ab507f..834877f36 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -47,10 +47,10 @@ LPEMirrorSymmetry::doOnApply (SPLPEItem *lpeitem) SPItem *item = SP_ITEM(lpeitem); Geom::Matrix t = sp_item_i2d_affine(item); - NR::Maybe bbox = item->getBounds(t); + Geom::Rect bbox = item->getBounds(t); - Point A(bbox->left(), bbox->bottom()); - Point B(bbox->left(), bbox->top()); + Point A(bbox.left(), bbox.bottom()); + Point B(bbox.left(), bbox.top()); A *= t; B *= t; Piecewise > rline = Piecewise >(D2(Linear(A[X], B[X]), Linear(A[Y], B[Y]))); diff --git a/src/live_effects/lpegroupbbox.cpp b/src/live_effects/lpegroupbbox.cpp index 2ea839892..c0f1222f2 100644 --- a/src/live_effects/lpegroupbbox.cpp +++ b/src/live_effects/lpegroupbbox.cpp @@ -28,13 +28,10 @@ GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute) else { transform = Geom::identity(); } - - NR::Maybe itemBBox = item->getBounds(from_2geom(transform), SPItem::GEOMETRIC_BBOX); - // NR to Geom glue - Geom::Rect geomBBox = Geom::Rect(itemBBox->min(), itemBBox->max()); - boundingbox_X = geomBBox[Geom::X]; - boundingbox_Y = geomBBox[Geom::Y]; + Geom::Rect itemBBox = item->getBounds(transform, SPItem::GEOMETRIC_BBOX); + boundingbox_X = itemBBox[Geom::X]; + boundingbox_Y = itemBBox[Geom::Y]; } } // namespace LivePathEffect diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 691d471ca..5d7177253 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -702,13 +702,20 @@ NR::Maybe SPItem::getBounds(NR::Matrix const &transform, return r; } -NR::Maybe +/* + * If the item is empty, or has an empty boundingbox for another reason, this method will + * return an empty rectangle. I.e. "getBounds(...).isEmpty() == true". + */ +Geom::Rect SPItem::getBounds(Geom::Matrix const &transform, SPItem::BBoxType type, unsigned int /*dkey*/) const { NR::Maybe r = NR::Nothing(); sp_item_invoke_bbox_full(this, &r, from_2geom(transform), type, TRUE); - return NR::Maybe(to_2geom(*r)); + if (r) + return to_2geom(*r); + else + return Geom::Rect(); // return empty rectangle } void diff --git a/src/sp-item.h b/src/sp-item.h index 814581a5d..39907999f 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -155,7 +155,7 @@ struct SPItem : public SPObject { void lowerToBottom(); NR::Maybe getBounds(NR::Matrix const &transform, BBoxType type=APPROXIMATE_BBOX, unsigned int dkey=0) const; - NR::Maybe getBounds(Geom::Matrix const &transform, BBoxType type=APPROXIMATE_BBOX, unsigned int dkey=0) const; + Geom::Rect getBounds(Geom::Matrix const &transform, BBoxType type=APPROXIMATE_BBOX, unsigned int dkey=0) const; sigc::connection _clip_ref_connection; sigc::connection _mask_ref_connection; -- 2.30.2