Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
lpegroupbbox.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (C) Steren Giannini 2008 <steren.giannini@gmail.com>
4 * Abhishek Sharma
5 *
6 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
7 */
8
9#include "lpegroupbbox.h"
10
11#include "object/sp-clippath.h"
12#include "object/sp-mask.h"
14#include "object/sp-lpe-item.h"
15
16namespace Inkscape {
17namespace LivePathEffect {
18
32{
33 Geom::OptRect bbox;
34 Geom::Affine affine = transform * item->transform;
35 SPClipPath *clip_path = item->getClipObject();
36 if(clip_path) {
37 bbox.unionWith(clip_path->geometricBounds(affine));
38 }
39 SPMask * mask_path = item->getMaskObject();
40 if(mask_path) {
41 bbox.unionWith(mask_path->visualBounds(affine));
42 }
43 auto group = cast<SPGroup>(item);
44 if (group) {
45 std::vector<SPItem*> item_list = group->item_list();
46 for (auto iter : item_list) {
47 auto subitem = cast<SPLPEItem>(iter);
48 if (subitem) {
49 bbox.unionWith(clip_mask_bbox(subitem, affine));
50 }
51 }
52 }
53 return bbox;
54}
55
56void GroupBBoxEffect::original_bbox(SPLPEItem const* lpeitem, bool absolute, bool clip_mask, Geom::Affine base_transform)
57{
58 // Get item bounding box
59 Geom::Affine transform;
60 if (absolute) {
61 transform = lpeitem->i2doc_affine();
62 }
63 else {
64 transform = base_transform;
65 }
66
67 Geom::OptRect bbox = lpeitem->geometricBounds(transform);
68 if (clip_mask) {
69 SPLPEItem * item = const_cast<SPLPEItem *>(lpeitem);
70 bbox.unionWith(clip_mask_bbox(item, transform * item->transform.inverse()));
71 }
72 if (bbox) {
73 boundingbox_X = (*bbox)[Geom::X];
74 boundingbox_Y = (*bbox)[Geom::Y];
75 } else {
78 }
79}
80
81} // namespace LivePathEffect
82} /* namespace Inkscape */
83
84/*
85 Local Variables:
86 mode:c++
87 c-file-style:"stroustrup"
88 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
89 indent-tabs-mode:nil
90 fill-column:99
91 End:
92*/
93// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
3x3 matrix representing an affine transformation.
Definition affine.h:70
Affine inverse() const
Compute the inverse matrix.
Definition affine.cpp:388
void unionWith(CRect const &b)
Enlarge the rectangle to contain the argument.
Range of real numbers that is never empty.
Definition interval.h:59
Axis-aligned rectangle that can be empty.
Definition rect.h:203
void original_bbox(SPLPEItem const *lpeitem, bool absolute=false, bool clip_mask=false, Geom::Affine base_transform=Geom::identity())
Geom::OptRect clip_mask_bbox(SPLPEItem *item, Geom::Affine transform)
Updates the boundingbox_X and boundingbox_Y values from the geometric bounding box of lpeitem.
Geom::OptRect geometricBounds(Geom::Affine const &transform) const
SPMask * getMaskObject() const
Definition sp-item.cpp:177
Geom::Affine transform
Definition sp-item.h:138
Geom::OptRect geometricBounds(Geom::Affine const &transform=Geom::identity()) const
Get item's geometric bounding box in this item's coordinate system.
Definition sp-item.cpp:927
Geom::Affine i2doc_affine() const
Returns the accumulated transformation of the item and all its ancestors, including root's viewport.
Definition sp-item.cpp:1823
SPClipPath * getClipObject() const
Definition sp-item.cpp:102
Geom::OptRect visualBounds(Geom::Affine const &transform) const
Definition sp-mask.cpp:116
@ Y
Definition coord.h:48
@ X
Definition coord.h:48
auto absolute(Geom::Point const &a)
Definition geom.h:92
SPItem * item
Helper class to stream background task notifications as a series of messages.
Base class for live path effect items.