1QPointArray(3qt) QPointArray(3qt)
2
3
4
6 QPointArray - Array of points
7
9 #include <qpointarray.h>
10
11 Inherits QMemArray<QPoint>.
12
13 Public Members
14 QPointArray ()
15 ~QPointArray ()
16 QPointArray ( int size )
17 QPointArray ( const QPointArray & a )
18 QPointArray ( const QRect & r, bool closed = FALSE )
19 QPointArray & operator= ( const QPointArray & a )
20 QPointArray copy () const
21 void translate ( int dx, int dy )
22 QRect boundingRect () const
23 void point ( uint index, int * x, int * y ) const
24 QPoint point ( uint index ) const
25 void setPoint ( uint index, int x, int y )
26 void setPoint ( uint i, const QPoint & p )
27 bool putPoints ( int index, int nPoints, int firstx, int firsty, ... )
28 bool putPoints ( int index, int nPoints, const QPointArray & from, int
29 fromIndex = 0 )
30 void makeArc ( int x, int y, int w, int h, int a1, int a2 )
31 void makeEllipse ( int x, int y, int w, int h )
32 void makeArc ( int x, int y, int w, int h, int a1, int a2, const
33 QWMatrix & xf )
34 QPointArray cubicBezier () const
35
37 QDataStream & operator<< ( QDataStream & s, const QPointArray & a )
38 QDataStream & operator>> ( QDataStream & s, QPointArray & a )
39
41 The QPointArray class provides an array of points.
42
43 A QPointArray is an array of QPoint objects. In addition to the
44 functions provided by QMemArray, QPointArray provides some point-
45 specific functions.
46
47 For convenient reading and writing of the point data use setPoints(),
48 putPoints(), point(), and setPoint().
49
50 For geometry operations use boundingRect() and translate(). There is
51 also the QWMatrix::map() function for more general transformations of
52 QPointArrays. You can also create arcs and ellipses with makeArc() and
53 makeEllipse().
54
55 Among others, QPointArray is used by QPainter::drawLineSegments(),
56 QPainter::drawPolyline(), QPainter::drawPolygon() and
57 QPainter::drawCubicBezier().
58
59 Note that because this class is a QMemArray, copying an array and
60 modifying the copy modifies the original as well, i.e. a shallow copy.
61 If you need a deep copy use copy() or detach(), for example:
62
63 void drawGiraffe( const QPointArray & r, QPainter * p )
64 {
65 QPointArray tmp = r;
66 tmp.detach();
67 // some code that modifies tmp
68 p->drawPoints( tmp );
69 }
70
71 If you forget the tmp.detach(), the const array will be modified.
72
73 See also QPainter, QWMatrix, QMemArray, Graphics Classes, Image
74 Processing Classes, and Implicitly and Explicitly Shared Classes.
75
78 Constructs a null point array.
79
80 See also isNull().
81
83 Constructs a point array with room for size points. Makes a null array
84 if size == 0.
85
86 See also resize() and isNull().
87
89 Constructs a shallow copy of the point array a.
90
91 See also copy() and detach().
92
94 Constructs a point array from the rectangle r.
95
96 If closed is FALSE, then the point array just contains the following
97 four points in the listed order: r.topLeft(), r.topRight(),
98 r.bottomRight() and r.bottomLeft().
99
100 If closed is TRUE, then a fifth point is set to r.topLeft().
101
103 Destroys the point array.
104
106 Returns the bounding rectangle of the points in the array, or
107 QRect(0,0,0,0) if the array is empty.
108
110 Creates a deep copy of the array.
111
112 See also detach().
113
115 Returns the Bezier points for the four control points in this array.
116
118 Sets the points of the array to those describing an arc of an ellipse
119 with size, width w by height h, and position (x, y), starting from
120 angle a1 and spanning by angle a2. The resulting array has sufficient
121 resolution for pixel accuracy (see the overloaded function which takes
122 an additional QWMatrix parameter).
123
124 Angles are specified in 16ths of a degree, i.e. a full circle equals
125 5760 (16*360). Positive values mean counter-clockwise, whereas negative
126 values mean the clockwise direction. Zero degrees is at the 3 o'clock
127 position.
128
129 See the angle diagram.
130
132 QWMatrix & xf )
133 This is an overloaded member function, provided for convenience. It
134 behaves essentially like the above function.
135
136 Sets the points of the array to those describing an arc of an ellipse
137 with width w and height h and position (x, y), starting from angle a1,
138 and spanning angle by a2, and transformed by the matrix xf. The
139 resulting array has sufficient resolution for pixel accuracy.
140
141 Angles are specified in 16ths of a degree, i.e. a full circle equals
142 5760 (16*360). Positive values mean counter-clockwise, whereas negative
143 values mean the clockwise direction. Zero degrees is at the 3 o'clock
144 position.
145
146 See the angle diagram.
147
149 Sets the points of the array to those describing an ellipse with size,
150 width w by height h, and position (x, y).
151
152 The returned array has sufficient resolution for use as pixels.
153
155 Assigns a shallow copy of a to this point array and returns a reference
156 to this point array.
157
158 Equivalent to assign(a).
159
160 See also copy() and detach().
161
163 Reads the coordinates of the point at position index within the array
164 and writes them into *x and *y.
165
167 This is an overloaded member function, provided for convenience. It
168 behaves essentially like the above function.
169
170 Returns the point at position index within the array.
171
173 ... )
174 Copies nPoints points from the variable argument list into this point
175 array from position index, and resizes the point array if index+nPoints
176 exceeds the size of the array.
177
178 Returns TRUE if successful, or FALSE if the array could not be resized
179 (typically due to lack of memory).
180
181 The example code creates an array with three points (4,5), (6,7) and
182 (8,9), by expanding the array from 1 to 3 points:
183
184 QPointArray a( 1 );
185 a[0] = QPoint( 4, 5 );
186 a.putPoints( 1, 2, 6,7, 8,9 ); // index == 1, points == 2
187
188 This has the same result, but here putPoints overwrites rather than
189 extends:
190
191 QPointArray a( 3 );
192 a.putPoints( 0, 3, 4,5, 0,0, 8,9 );
193 a.putPoints( 1, 1, 6,7 );
194
195 The points are given as a sequence of integers, starting with firstx
196 then firsty, and so on.
197
198 See also resize().
199
201 from, int fromIndex = 0 )
202 This is an overloaded member function, provided for convenience. It
203 behaves essentially like the above function.
204
205 This version of the function copies nPoints from from into this array,
206 starting at index in this array and fromIndex in from. fromIndex is 0
207 by default.
208
209 QPointArray a;
210 a.putPoints( 0, 3, 1,2, 0,0, 5,6 );
211 // a is now the three-point array ( 1,2, 0,0, 5,6 );
212 QPointArray b;
213 b.putPoints( 0, 3, 4,4, 5,5, 6,6 );
214 // b is now ( 4,4, 5,5, 6,6 );
215 a.putPoints( 2, 3, b );
216 // a is now ( 1,2, 0,0, 4,4, 5,5, 6,6 );
217
219 Sets the point at position index in the array to (x, y).
220
221 Example: themes/wood.cpp.
222
224 This is an overloaded member function, provided for convenience. It
225 behaves essentially like the above function.
226
227 Sets the point at array index i to p.
228
230 Translates all points in the array by (dx, dy).
231
234 Writes the point array, a to the stream s and returns a reference to
235 the stream.
236
237 See also Format of the QDataStream operators.
238
240 Reads a point array, a from the stream s and returns a reference to the
241 stream.
242
243 See also Format of the QDataStream operators.
244
245
247 http://doc.trolltech.com/qpointarray.html
248 http://www.trolltech.com/faq/tech.html
249
251 Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
252 license file included in the distribution for a complete license
253 statement.
254
256 Generated automatically from the source code.
257
259 If you find a bug in Qt, please report it as described in
260 http://doc.trolltech.com/bughowto.html. Good bug reports help us to
261 help you. Thank you.
262
263 The definitive Qt documentation is provided in HTML format; it is
264 located at $QTDIR/doc/html and can be read using Qt Assistant or with a
265 web browser. This man page is provided as a convenience for those users
266 who prefer man pages, although this format is not officially supported
267 by Trolltech.
268
269 If you find errors in this manual page, please report them to qt-
270 bugs@trolltech.com. Please include the name of the manual page
271 (qpointarray.3qt) and the Qt version (3.3.8).
272
273
274
275Trolltech AS 2 February 2007 QPointArray(3qt)