1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the Qt 3 compatibility classes of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
29
#include "q3pointarray.h"
30
#include "private/qbezier_p.h"
31
#include "private/qpainterpath_p.h"
35
The Q3PointArray class provides an array of points.
39
Q3PointArray is a QPolygon subclass that provides functions
40
to make it more source compatible with the \c QPointArray class
43
In Qt 4, we recommend that you use QPainterPath for representing
44
arcs, ellipses, and Bezier curves, rather than QPolygon.
48
Sets the points of the array to those describing an arc of an
49
ellipse with size, width \a w by height \a h, and position (\a x,
50
\a y), starting from angle \a a1 and spanning by angle \a a2. The
51
resulting array has sufficient resolution for pixel accuracy (see
52
the overloaded function which takes an additional QMatrix
55
Angles are specified in 16ths of a degree, i.e. a full circle
56
equals 5760 (16*360). Positive values mean counter-clockwise,
57
whereas negative values mean the clockwise direction. Zero degrees
58
is at the 3 o'clock position.
61
void Q3PointArray::makeArc(int x, int y, int w, int h, int a1, int a2)
65
qt_find_ellipse_coords(r, a1, a2, &startPoint, 0);
67
QPainterPath path(startPoint);
68
path.arcTo(r, a1, a2);
69
*this = path.toSubpathPolygons().at(0).toPolygon();
73
#ifndef QT_NO_TRANSFORMATIONS
77
Sets the points of the array to those describing an arc of an
78
ellipse with width \a w and height \a h and position (\a x, \a y),
79
starting from angle \a a1, and spanning angle by \a a2, and
80
transformed by the matrix \a xf. The resulting array has
81
sufficient resolution for pixel accuracy.
83
Angles are specified in 16ths of a degree, i.e. a full circle
84
equals 5760 (16 * 360). Positive values mean counter-clockwise,
85
whereas negative values mean the clockwise direction. Zero
86
degrees is at the 3 o'clock position.
88
void Q3PointArray::makeArc(int x, int y, int w, int h, int a1, int a2, const QMatrix &xf)
92
qt_find_ellipse_coords(r, a1, a2, &startPoint, 0);
94
QPainterPath path(startPoint);
95
path.arcTo(r, a1, a2);
97
*this = path.toSubpathPolygons().at(0).toPolygon();
100
#endif // QT_NO_TRANSFORMATIONS
103
\fn Q3PointArray::Q3PointArray()
105
Constructs an empty Q3PointArray.
109
\fn Q3PointArray::Q3PointArray(const QRect &r, bool closed)
111
Constructs a point array from the rectangle \a r.
113
If \a closed is false, then the point array just contains the
114
following four points of the rectangle ordered clockwise. The
115
bottom-right point is located at (r.x() + r.width(), r.y() +
120
\fn Q3PointArray::Q3PointArray(const QPolygon& other)
122
Constructs a copy of \a other.
126
\fn Q3PointArray Q3PointArray::copy() const
128
Returns a copy of this Q3PointArray.
132
\fn bool Q3PointArray::isNull()
138
Sets the points of the array to those describing an ellipse with
139
size, width \a w by height \a h, and position (\a x, \a y).
141
The returned array has sufficient resolution for use as pixels.
143
void Q3PointArray::makeEllipse(int x, int y, int w, int h)
146
path.addEllipse(x, y, w, h);
147
*this = path.toSubpathPolygons().at(0).toPolygon();
153
Returns the Bezier points for the four control points in this
156
Q3PointArray Q3PointArray::cubicBezier() const
159
qWarning( "Q3PointArray::bezier: The array must have 4 control points" );
162
QPolygonF polygon = QBezier(at(0), at(1), at(2), at(3)).toPolygon();
163
return polygon.toPolygon();
165
#endif //QT_NO_BEZIER