vcomputeboundingbox.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2006 Jan Hambrecht <jaham@gmx.net>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20
21#include "vcomputeboundingbox.h"
22#include "vdocument.h"
23#include "vlayer.h"
24#include "vgroup.h"
25#include "vcomposite.h"
26#include "vtext.h"
27#include "vimage.h"
28
29VComputeBoundingBox::VComputeBoundingBox( bool omitHidden )
30: m_omitHidden( omitHidden )
31{
32}
33
34void
36{
37 VLayerListIterator itr( document.layers() );
38
39 for( ; itr.current(); ++itr )
40 {
41 if( itr.current()->state() == VObject::deleted )
42 continue;
43 // do not use hidden layers
44 if( m_omitHidden && ! isVisible( itr.current() ) )
45 continue;
46 itr.current()->accept( *this );
47 }
48}
49
50void
52{
53 VObjectListIterator itr( layer.objects() );
54
55 for( ; itr.current(); ++itr )
56 {
57 if( itr.current()->state() == VObject::deleted )
58 continue;
59 // do not export hidden objects
60 if( m_omitHidden && ! isVisible( itr.current() ) )
61 continue;
62 itr.current()->accept( *this );
63 }
64}
65
66void
68{
69 VObjectListIterator itr( group.objects() );
70
71 for( ; itr.current(); ++itr )
72 {
73 if( itr.current()->state() == VObject::deleted )
74 continue;
75 // do not use hidden child objects
76 if( m_omitHidden && ! isVisible( itr.current() ) )
77 continue;
78 itr.current()->accept( *this );
79 }
80}
81
82void
84{
85 m_boundingBox |= composite.boundingBox();
86}
87
88void
90{
91 m_boundingBox |= text.boundingBox();
92}
93
94void
96{
97 m_boundingBox |= img.boundingBox();
98}
99
100bool
101VComputeBoundingBox::isVisible( const VObject* object ) const
102{
103 return object->state() != VObject::hidden && object->state() != VObject::hidden_locked;
104}
105
106const KoRect&
107VComputeBoundingBox::boundingRect() const
108{
109 return m_boundingBox;
110}
virtual void visitVText(VText &text)
Visit method for a VText.
virtual void visitVPath(VPath &composite)
Visit method for a VPath.
virtual void visitVLayer(VLayer &layer)
Visit method for a VLayer.
virtual void visitVGroup(VGroup &group)
Visit method for a VGroup.
virtual void visitVImage(VImage &img)
Visit method for a VImage.
virtual void visitVDocument(VDocument &document)
Visit method for a VDocument.
All non-visual, static doc info is in here.
Definition vdocument.h:53
const VLayerList & layers() const
Returns the list of layers.
Definition vdocument.h:217
Base class for all sort of VObject conglomerats.
Definition vgroup.h:35
const VObjectList & objects() const
Read only access to the grouped objects.
Definition vgroup.h:110
VLayer manages a set of vobjects.
Definition vlayer.h:37
The base class for all karbon objects.
Definition vobject.h:50
@ hidden_locked
hidden and locked (r/o)
Definition vobject.h:57
@ deleted
deleted, nearly dead
Definition vobject.h:58
@ hidden
hidden
Definition vobject.h:56
A composite path consists of one or many subpaths.
Definition vcomposite.h:48
virtual const KoRect & boundingBox() const
Calculates the tightest bounding box around the object.