1
/* This file is part of the KDE project
2
Copyright (C) 2001, 2002, 2003 The Karbon Developers
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.
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.
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., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, USA.
20
#ifndef __VCOMPOSITE_H__
21
#define __VCOMPOSITE_H__
29
#include "svgpathparser.h"
30
#include "vfillrule.h"
39
typedef QPtrList<VSubpath> VSubpathList;
40
typedef QPtrListIterator<VSubpath> VSubpathListIterator;
44
* A composite path consists of one or many subpaths.
47
class VPath : public VObject, SVGPathParser
50
VPath( VObject* parent, VState state = normal );
51
VPath( const VPath& path );
54
virtual DCOPObject* dcopObject();
57
* Returns the knot of the last segment of the last subpath.
59
const KoPoint& currentPoint() const;
62
bool moveTo( const KoPoint& p );
63
bool lineTo( const KoPoint& p );
77
const KoPoint& p1, const KoPoint& p2, const KoPoint& p3 );
90
bool curve1To( const KoPoint& p2, const KoPoint& p3 );
103
bool curve2To( const KoPoint& p1, const KoPoint& p3 );
106
* A convenience function to aproximate a circular arc with a
107
* bezier curve. Input: 2 tangent vectors and a radius (same as in PostScript).
113
p1 x....__--x....x p2
123
bool arcTo( const KoPoint& p1, const KoPoint& p2, double r );
126
* Closes the current subpath.
131
* Combines two composite paths. For example, the letter "O" is a combination
132
* of a larger and a smaller ellipitical path.
134
void combine( const VPath& path );
137
* Adds a path to the composite path.
139
void combinePath( const VSubpath& path );
143
* Returns true if point p is located inside the composite.
145
bool pointIsInside( const KoPoint& p ) const;
149
* Returns true if the segment intersects this composite.
151
bool intersects( const VSegment& segment ) const;
154
const VSubpathList& paths() const
159
virtual const KoRect& boundingBox() const;
162
VFillRule fillMode() const;
164
// TODO remove these functions.
165
VFillRule fillRule() const
170
void setFillRule( VFillRule fillRule )
172
m_fillRule = fillRule;
176
virtual void draw( VPainter *painter, const KoRect* rect = 0L ) const;
178
bool drawCenterNode() const
180
return m_drawCenterNode;
183
void setDrawCenterNode( bool drawCenterNode = true )
185
m_drawCenterNode = drawCenterNode;
189
virtual void save( QDomElement& element ) const;
190
virtual void load( const QDomElement& element );
192
virtual VPath* clone() const;
194
virtual void accept( VVisitor& visitor );
196
void transform( const QString &transform );
197
static QWMatrix parseTransform( const QString &transform );
199
void transform( const QWMatrix &mat )
205
void loadSvgPath( const QString & );
206
void saveSvgPath( QString & ) const;
209
void writeTransform( QDomElement & ) const;
211
/// For svg path data parsing.
212
virtual void svgMoveTo( double x1, double y1, bool abs = true );
213
virtual void svgLineTo( double x1, double y1, bool abs = true );
214
virtual void svgCurveToCubic( double x1, double y1, double x2, double y2, double x, double y, bool abs = true );
215
virtual void svgClosePath();
224
VSubpathList m_paths;
226
/// Should a center node be drawn?
227
bool m_drawCenterNode;
228
VFillRule m_fillRule : 1;