diff options
Diffstat (limited to 'src/live_effects/lpegroupbbox.cpp')
| -rw-r--r-- | src/live_effects/lpegroupbbox.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/live_effects/lpegroupbbox.cpp b/src/live_effects/lpegroupbbox.cpp index 79e6857f0..3b1ece2ad 100644 --- a/src/live_effects/lpegroupbbox.cpp +++ b/src/live_effects/lpegroupbbox.cpp @@ -13,6 +13,16 @@ namespace Inkscape { namespace LivePathEffect { +/** + * \brief Updates the \c boundingbox_X and \c boundingbox_Y values from the geometric bounding box of \c lpeitem. + * + * \pre lpeitem must have an existing geometric boundingbox (usually this is guaranteed when: \code SP_SHAPE(lpeitem)->curve != NULL \endcode ) + It's not possible to run LPEs on items without their original-d having a bbox. + * \param lpeitem This is not allowed to be NULL. + * \param absolute Determines whether the bbox should be calculated of the untransformed lpeitem (\c absolute = \c false) + * or of the transformed lpeitem (\c absolute = \c true) using sp_item_i2doc_affine. + * \post Updated values of boundingbox_X and boundingbox_Y. These intervals are set to empty intervals when the precondition is not met. + */ void GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute) { @@ -27,9 +37,14 @@ GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute) transform = Geom::identity(); } - Geom::Rect itemBBox = *item->getBounds(transform, SPItem::GEOMETRIC_BBOX); // fixme: fix for when getBounds returns invalid Rect - boundingbox_X = itemBBox[Geom::X]; - boundingbox_Y = itemBBox[Geom::Y]; + boost::optional<Geom::Rect> bbox = item->getBounds(transform, SPItem::GEOMETRIC_BBOX); + if (bbox) { + boundingbox_X = (*bbox)[Geom::X]; + boundingbox_Y = (*bbox)[Geom::Y]; + } else { + boundingbox_X = Geom::Interval(); + boundingbox_Y = Geom::Interval(); + } } } // namespace LivePathEffect |
