1 /*
2 * Copyright (C) Steren Giannini 2008 <steren.giannini@gmail.com>
3 * Abhishek Sharma
4 *
5 * Released under GNU GPL, read the file 'COPYING' for more information
6 */
8 #include "live_effects/lpegroupbbox.h"
10 #include "sp-item.h"
12 namespace Inkscape {
13 namespace LivePathEffect {
15 /**
16 * \brief Updates the \c boundingbox_X and \c boundingbox_Y values from the geometric bounding box of \c lpeitem.
17 *
18 * \pre lpeitem must have an existing geometric boundingbox (usually this is guaranteed when: \code SP_SHAPE(lpeitem)->curve != NULL \endcode )
19 It's not possible to run LPEs on items without their original-d having a bbox.
20 * \param lpeitem This is not allowed to be NULL.
21 * \param absolute Determines whether the bbox should be calculated of the untransformed lpeitem (\c absolute = \c false)
22 * or of the transformed lpeitem (\c absolute = \c true) using sp_item_i2doc_affine.
23 * \post Updated values of boundingbox_X and boundingbox_Y. These intervals are set to empty intervals when the precondition is not met.
24 */
25 void
26 GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute)
27 {
28 // Get item bounding box
29 SPItem* item = SP_ITEM(lpeitem);
31 Geom::Matrix transform;
32 if (absolute) {
33 transform = item->i2doc_affine();
34 }
35 else {
36 transform = Geom::identity();
37 }
39 Geom::OptRect bbox = item->getBounds(transform, SPItem::GEOMETRIC_BBOX);
40 if (bbox) {
41 boundingbox_X = (*bbox)[Geom::X];
42 boundingbox_Y = (*bbox)[Geom::Y];
43 } else {
44 boundingbox_X = Geom::Interval();
45 boundingbox_Y = Geom::Interval();
46 }
47 }
49 } // namespace LivePathEffect
50 } /* namespace Inkscape */
52 /*
53 Local Variables:
54 mode:c++
55 c-file-style:"stroustrup"
56 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
57 indent-tabs-mode:nil
58 fill-column:99
59 End:
60 */
61 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :