Code

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