karbon
vpath.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __VPATH_H__
00021 #define __VPATH_H__
00022
00023
00024 #include <KoPoint.h>
00025
00026 #include "vobject.h"
00027 #include <koffice_export.h>
00028
00029 class QDomElement;
00030 class QWMatrix;
00031 class VSubpathIteratorList;
00032 class VSegment;
00033 class VVisitor;
00034
00035
00042 class KARBONBASE_EXPORT VSubpath : public VObject
00043 {
00044 friend class VSubpathIterator;
00045
00046 public:
00047 VSubpath( VObject* parent );
00048 VSubpath( const VSubpath& list );
00049 VSubpath( const VSegment& segment );
00050 virtual ~VSubpath();
00051
00052 const KoPoint& currentPoint() const;
00053
00054 bool moveTo( const KoPoint& p );
00055 bool lineTo( const KoPoint& p );
00056 bool curveTo(
00057 const KoPoint& p1, const KoPoint& p2, const KoPoint& p3 );
00058 bool curve1To(
00059 const KoPoint& p2, const KoPoint& p3 );
00060 bool curve2To(
00061 const KoPoint& p1, const KoPoint& p3 );
00062 bool arcTo(
00063 const KoPoint& p1, const KoPoint& p2, const double r );
00064
00065 bool isClosed() const
00066 {
00067 return m_isClosed;
00068 }
00069
00070 void close();
00071
00072
00077 bool pointIsInside( const KoPoint& p ) const;
00078
00082 bool intersects( const VSegment& segment ) const;
00083
00084
00088 bool counterClockwise() const;
00089
00093 void revert();
00094
00095
00100 bool isEmpty() const
00101 {
00102 return count() <= 1;
00103 }
00104
00105
00106 virtual const KoRect& boundingBox() const;
00107
00108
00109 virtual void save( QDomElement& ) const
00110 { }
00111
00112
00113 virtual void load( const QDomElement& element );
00114
00115 void saveSvgPath( QString & ) const;
00116
00117
00118 virtual VSubpath* clone() const;
00119
00120 virtual void accept( VVisitor& visitor );
00121
00122
00123
00124 VSubpath& operator=( const VSubpath& list );
00125
00126 bool insert( const VSegment* segment );
00127 bool insert( uint i, const VSegment* segment );
00128 void prepend( const VSegment* segment );
00129 void append( const VSegment* segment );
00130 void clear();
00131
00132 uint count() const
00133 {
00134 return m_number;
00135 }
00136
00137 VSegment* current() const
00138 {
00139 return m_current;
00140 }
00141
00142 VSegment* getFirst() const
00143 {
00144 return m_first;
00145 }
00146
00147 VSegment* getLast() const
00148 {
00149 return m_last;
00150 }
00151
00152 VSegment* first();
00153 VSegment* last();
00154 VSegment* prev();
00155 VSegment* next();
00156
00157 private:
00158 VSegment* locate( uint index );
00159
00160 VSegment* m_first;
00161 VSegment* m_last;
00162 VSegment* m_current;
00163
00164 int m_currentIndex;
00165 uint m_number : 31;
00166
00167 bool m_isClosed : 1;
00168
00169 VSubpathIteratorList* m_iteratorList;
00170 };
00171
00172
00179 class KARBONBASE_EXPORT VSubpathIterator
00180 {
00181 friend class VSubpathIteratorList;
00182
00183 public:
00184 VSubpathIterator( const VSubpath& list );
00185 VSubpathIterator( const VSubpathIterator& itr );
00186 ~VSubpathIterator();
00187
00188 VSubpathIterator& operator=( const VSubpathIterator& itr );
00189
00190 VSegment* current() const;
00191 VSegment* operator()();
00192 VSegment* operator++();
00193 VSegment* operator+=( uint i );
00194 VSegment* operator--();
00195 VSegment* operator-=( uint i );
00196
00197 private:
00198 VSubpath* m_list;
00199 VSegment* m_current;
00200 };
00201
00202 #endif
00203
|