karbon
vcomposite.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __VCOMPOSITE_H__
00021 #define __VCOMPOSITE_H__
00022
00023
00024 #include <qptrlist.h>
00025
00026 #include <KoPoint.h>
00027
00028 #include "vobject.h"
00029 #include "svgpathparser.h"
00030 #include "vfillrule.h"
00031 #include <koffice_export.h>
00032
00033 class QDomElement;
00034 class VPainter;
00035 class VSegment;
00036 class VVisitor;
00037 class VSubpath;
00038
00039 typedef QPtrList<VSubpath> VSubpathList;
00040 typedef QPtrListIterator<VSubpath> VSubpathListIterator;
00041
00042
00047 class KARBONBASE_EXPORT VPath : public VObject, SVGPathParser
00048 {
00049 public:
00050 VPath( VObject* parent, VState state = normal );
00051 VPath( const VPath& path );
00052 virtual ~VPath();
00053
00054 virtual DCOPObject* dcopObject();
00055
00059 const KoPoint& currentPoint() const;
00060
00061
00062 bool moveTo( const KoPoint& p );
00063 bool lineTo( const KoPoint& p );
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 bool curveTo(
00077 const KoPoint& p1, const KoPoint& p2, const KoPoint& p3 );
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 bool curve1To( const KoPoint& p2, const KoPoint& p3 );
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 bool curve2To( const KoPoint& p1, const KoPoint& p3 );
00104
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 bool arcTo( const KoPoint& p1, const KoPoint& p2, double r );
00124
00128 void close();
00129
00130 bool isClosed() const;
00135 void combine( const VPath& path );
00136
00140 void combinePath( const VSubpath& path );
00141
00142
00146 bool pointIsInside( const KoPoint& p ) const;
00147
00148
00152 bool intersects( const VSegment& segment ) const;
00153
00154
00155 const VSubpathList& paths() const
00156 {
00157 return m_paths;
00158 }
00159
00160 virtual const KoRect& boundingBox() const;
00161
00162
00163 VFillRule fillMode() const;
00164
00165
00166 VFillRule fillRule() const
00167 {
00168 return m_fillRule;
00169 }
00170
00171 void setFillRule( VFillRule fillRule )
00172 {
00173 m_fillRule = fillRule;
00174 }
00175
00176
00177 virtual void draw( VPainter *painter, const KoRect* rect = 0L ) const;
00178
00179 bool drawCenterNode() const
00180 {
00181 return m_drawCenterNode;
00182 }
00183
00184 void setDrawCenterNode( bool drawCenterNode = true )
00185 {
00186 m_drawCenterNode = drawCenterNode;
00187 }
00188
00189
00190 virtual void save( QDomElement& element ) const;
00191 virtual void saveOasis( KoStore *store, KoXmlWriter *docWriter, KoGenStyles &mainStyles, int &index ) const;
00192 virtual void load( const QDomElement& element );
00193 virtual bool loadOasis( const QDomElement &element, KoOasisLoadingContext &context );
00194
00195 virtual VPath* clone() const;
00196
00197 virtual void accept( VVisitor& visitor );
00198
00199 void transform( const QString &transform );
00200 void transformOasis( const QString &transform );
00201
00202 static QWMatrix parseTransform( const QString &transform );
00203
00204 void transform( const QWMatrix &mat )
00205 {
00206 m_matrix *= mat;
00207 }
00208
00209
00210 void loadSvgPath( const QString & );
00211 void saveSvgPath( QString & ) const;
00212
00213 protected:
00214 QString buildSvgTransform() const;
00215 QString buildSvgTransform( const QWMatrix &mat ) const;
00216 QString buildOasisTransform() const;
00217 QString buildOasisTransform( const QWMatrix &mat ) const;
00218
00219 void transformByViewbox( const QDomElement &element, QString viewbox );
00220
00222 virtual void svgMoveTo( double x1, double y1, bool abs = true );
00223 virtual void svgLineTo( double x1, double y1, bool abs = true );
00224 virtual void svgCurveToCubic( double x1, double y1, double x2, double y2, double x, double y, bool abs = true );
00225 virtual void svgClosePath();
00226
00227 virtual void saveOasisFill( KoGenStyles &mainStyles, KoGenStyle &stylesojectauto ) const;
00228 QWMatrix parseOasisTransform( const QString &transform );
00229
00230 protected:
00231 QWMatrix m_matrix;
00232
00233 private:
00237 VSubpathList m_paths;
00238
00240 bool m_drawCenterNode;
00241 VFillRule m_fillRule : 1;
00242 };
00243
00244 #endif
|