karbon
vcomputeboundingbox.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "vcomputeboundingbox.h"
00022 #include "vdocument.h"
00023 #include "vlayer.h"
00024 #include "vgroup.h"
00025 #include "vcomposite.h"
00026 #include "vtext.h"
00027 #include "vimage.h"
00028
00029 VComputeBoundingBox::VComputeBoundingBox( bool omitHidden )
00030 : m_omitHidden( omitHidden )
00031 {
00032 }
00033
00034 void
00035 VComputeBoundingBox::visitVDocument( VDocument& document )
00036 {
00037 VLayerListIterator itr( document.layers() );
00038
00039 for( ; itr.current(); ++itr )
00040 {
00041 if( itr.current()->state() == VObject::deleted )
00042 continue;
00043
00044 if( m_omitHidden && ! isVisible( itr.current() ) )
00045 continue;
00046 itr.current()->accept( *this );
00047 }
00048 }
00049
00050 void
00051 VComputeBoundingBox::visitVLayer( VLayer& layer )
00052 {
00053 VObjectListIterator itr( layer.objects() );
00054
00055 for( ; itr.current(); ++itr )
00056 {
00057 if( itr.current()->state() == VObject::deleted )
00058 continue;
00059
00060 if( m_omitHidden && ! isVisible( itr.current() ) )
00061 continue;
00062 itr.current()->accept( *this );
00063 }
00064 }
00065
00066 void
00067 VComputeBoundingBox::visitVGroup( VGroup& group )
00068 {
00069 VObjectListIterator itr( group.objects() );
00070
00071 for( ; itr.current(); ++itr )
00072 {
00073 if( itr.current()->state() == VObject::deleted )
00074 continue;
00075
00076 if( m_omitHidden && ! isVisible( itr.current() ) )
00077 continue;
00078 itr.current()->accept( *this );
00079 }
00080 }
00081
00082 void
00083 VComputeBoundingBox::visitVPath( VPath& composite )
00084 {
00085 m_boundingBox |= composite.boundingBox();
00086 }
00087
00088 void
00089 VComputeBoundingBox::visitVText( VText& text )
00090 {
00091 m_boundingBox |= text.boundingBox();
00092 }
00093
00094 void
00095 VComputeBoundingBox::visitVImage( VImage& img )
00096 {
00097 m_boundingBox |= img.boundingBox();
00098 }
00099
00100 bool
00101 VComputeBoundingBox::isVisible( const VObject* object ) const
00102 {
00103 return object->state() != VObject::hidden && object->state() != VObject::hidden_locked;
00104 }
00105
00106 const KoRect&
00107 VComputeBoundingBox::boundingRect() const
00108 {
00109 return m_boundingBox;
00110 }
|