1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qpointarray.cpp:47 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>QPointArray Class</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QPointArray Class Reference</h1>
|
---|
33 |
|
---|
34 | <p>The QPointArray class provides an array of points.
|
---|
35 | <a href="#details">More...</a>
|
---|
36 | <p><tt>#include <<a href="qpointarray-h.html">qpointarray.h</a>></tt>
|
---|
37 | <p>Inherits <a href="qmemarray.html">QMemArray</a><QPoint>.
|
---|
38 | <p><a href="qpointarray-members.html">List of all member functions.</a>
|
---|
39 | <h2>Public Members</h2>
|
---|
40 | <ul>
|
---|
41 | <li class=fn><a href="#QPointArray"><b>QPointArray</b></a> ()</li>
|
---|
42 | <li class=fn><a href="#~QPointArray"><b>~QPointArray</b></a> ()</li>
|
---|
43 | <li class=fn><a href="#QPointArray-2"><b>QPointArray</b></a> ( int size )</li>
|
---|
44 | <li class=fn><a href="#QPointArray-3"><b>QPointArray</b></a> ( const QPointArray & a )</li>
|
---|
45 | <li class=fn><a href="#QPointArray-4"><b>QPointArray</b></a> ( const QRect & r, bool closed = FALSE )</li>
|
---|
46 | <li class=fn>QPointArray & <a href="#operator-eq"><b>operator=</b></a> ( const QPointArray & a )</li>
|
---|
47 | <li class=fn>QPointArray <a href="#copy"><b>copy</b></a> () const</li>
|
---|
48 | <li class=fn>void <a href="#translate"><b>translate</b></a> ( int dx, int dy )</li>
|
---|
49 | <li class=fn>QRect <a href="#boundingRect"><b>boundingRect</b></a> () const</li>
|
---|
50 | <li class=fn>void <a href="#point"><b>point</b></a> ( uint index, int * x, int * y ) const</li>
|
---|
51 | <li class=fn>QPoint <a href="#point-2"><b>point</b></a> ( uint index ) const</li>
|
---|
52 | <li class=fn>void <a href="#setPoint"><b>setPoint</b></a> ( uint index, int x, int y )</li>
|
---|
53 | <li class=fn>void <a href="#setPoint-2"><b>setPoint</b></a> ( uint i, const QPoint & p )</li>
|
---|
54 | <li class=fn>bool <a href="#putPoints"><b>putPoints</b></a> ( int index, int nPoints, int firstx, int firsty, ... )</li>
|
---|
55 | <li class=fn>bool <a href="#putPoints-3"><b>putPoints</b></a> ( int index, int nPoints, const QPointArray & from, int fromIndex = 0 )</li>
|
---|
56 | <li class=fn>void <a href="#makeArc"><b>makeArc</b></a> ( int x, int y, int w, int h, int a1, int a2 )</li>
|
---|
57 | <li class=fn>void <a href="#makeEllipse"><b>makeEllipse</b></a> ( int x, int y, int w, int h )</li>
|
---|
58 | <li class=fn>void <a href="#makeArc-2"><b>makeArc</b></a> ( int x, int y, int w, int h, int a1, int a2, const QWMatrix & xf )</li>
|
---|
59 | <li class=fn>QPointArray <a href="#cubicBezier"><b>cubicBezier</b></a> () const</li>
|
---|
60 | </ul>
|
---|
61 | <h2>Related Functions</h2>
|
---|
62 | <ul>
|
---|
63 | <li class=fn>QDataStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( QDataStream & s, const QPointArray & a )</li>
|
---|
64 | <li class=fn>QDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( QDataStream & s, QPointArray & a )</li>
|
---|
65 | </ul>
|
---|
66 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
67 |
|
---|
68 |
|
---|
69 | The QPointArray class provides an array of points.
|
---|
70 | <p>
|
---|
71 |
|
---|
72 |
|
---|
73 | <p> A QPointArray is an array of <a href="qpoint.html">QPoint</a> objects. In addition to the
|
---|
74 | functions provided by <a href="qmemarray.html">QMemArray</a>, QPointArray provides some
|
---|
75 | point-specific functions.
|
---|
76 | <p> For convenient reading and writing of the point data use
|
---|
77 | setPoints(), <a href="#putPoints">putPoints</a>(), <a href="#point">point</a>(), and <a href="#setPoint">setPoint</a>().
|
---|
78 | <p> For geometry operations use <a href="#boundingRect">boundingRect</a>() and <a href="#translate">translate</a>(). There
|
---|
79 | is also the <a href="qwmatrix.html#map">QWMatrix::map</a>() function for more general
|
---|
80 | transformations of QPointArrays. You can also create arcs and
|
---|
81 | ellipses with <a href="#makeArc">makeArc</a>() and <a href="#makeEllipse">makeEllipse</a>().
|
---|
82 | <p> Among others, QPointArray is used by <a href="qpainter.html#drawLineSegments">QPainter::drawLineSegments</a>(),
|
---|
83 | <a href="qpainter.html#drawPolyline">QPainter::drawPolyline</a>(), <a href="qpainter.html#drawPolygon">QPainter::drawPolygon</a>() and
|
---|
84 | <a href="qpainter.html#drawCubicBezier">QPainter::drawCubicBezier</a>().
|
---|
85 | <p> Note that because this class is a QMemArray, copying an array and
|
---|
86 | modifying the copy modifies the original as well, i.e. a <a href="shclass.html#shallow-copy">shallow copy</a>. If you need a <a href="shclass.html#deep-copy">deep copy</a> use <a href="#copy">copy</a>() or <a href="qmemarray.html#detach">detach</a>(), for example:
|
---|
87 | <p> <pre>
|
---|
88 | void drawGiraffe( const QPointArray & r, QPainter * p )
|
---|
89 | {
|
---|
90 | QPointArray tmp = r;
|
---|
91 | tmp.<a href="qmemarray.html#detach">detach</a>();
|
---|
92 | // some code that modifies tmp
|
---|
93 | p->drawPoints( tmp );
|
---|
94 | }
|
---|
95 | </pre>
|
---|
96 |
|
---|
97 | <p> If you forget the tmp.detach(), the const array will be modified.
|
---|
98 | <p> <p>See also <a href="qpainter.html">QPainter</a>, <a href="qwmatrix.html">QWMatrix</a>, <a href="qmemarray.html">QMemArray</a>, <a href="graphics.html">Graphics Classes</a>, <a href="images.html">Image Processing Classes</a>, and <a href="shared.html">Implicitly and Explicitly Shared Classes</a>.
|
---|
99 |
|
---|
100 | <hr><h2>Member Function Documentation</h2>
|
---|
101 | <h3 class=fn><a name="QPointArray"></a>QPointArray::QPointArray ()
|
---|
102 | </h3>
|
---|
103 |
|
---|
104 | <p> Constructs a null point array.
|
---|
105 | <p> <p>See also <a href="qmemarray.html#isNull">isNull</a>().
|
---|
106 |
|
---|
107 | <h3 class=fn><a name="QPointArray-2"></a>QPointArray::QPointArray ( int size )
|
---|
108 | </h3>
|
---|
109 |
|
---|
110 | <p> Constructs a point array with room for <em>size</em> points. Makes a
|
---|
111 | null array if <em>size</em> == 0.
|
---|
112 | <p> <p>See also <a href="qmemarray.html#resize">resize</a>() and <a href="qmemarray.html#isNull">isNull</a>().
|
---|
113 |
|
---|
114 | <h3 class=fn><a name="QPointArray-3"></a>QPointArray::QPointArray ( const <a href="qpointarray.html">QPointArray</a> & a )
|
---|
115 | </h3>
|
---|
116 |
|
---|
117 | <p> Constructs a <a href="shclass.html#shallow-copy">shallow copy</a> of the point array <em>a</em>.
|
---|
118 | <p> <p>See also <a href="#copy">copy</a>() and <a href="qmemarray.html#detach">detach</a>().
|
---|
119 |
|
---|
120 | <h3 class=fn><a name="QPointArray-4"></a>QPointArray::QPointArray ( const <a href="qrect.html">QRect</a> & r, bool closed = FALSE )
|
---|
121 | </h3>
|
---|
122 | Constructs a point array from the rectangle <em>r</em>.
|
---|
123 | <p> If <em>closed</em> is FALSE, then the point array just contains the
|
---|
124 | following four points in the listed order: r.topLeft(),
|
---|
125 | r.topRight(), r.bottomRight() and r.bottomLeft().
|
---|
126 | <p> If <em>closed</em> is TRUE, then a fifth point is set to r.topLeft().
|
---|
127 |
|
---|
128 | <h3 class=fn><a name="~QPointArray"></a>QPointArray::~QPointArray ()
|
---|
129 | </h3>
|
---|
130 |
|
---|
131 | <p> Destroys the point array.
|
---|
132 |
|
---|
133 | <h3 class=fn><a href="qrect.html">QRect</a> <a name="boundingRect"></a>QPointArray::boundingRect () const
|
---|
134 | </h3>
|
---|
135 | Returns the bounding rectangle of the points in the array, or
|
---|
136 | <a href="qrect.html">QRect</a>(0,0,0,0) if the array is empty.
|
---|
137 |
|
---|
138 | <h3 class=fn><a href="qpointarray.html">QPointArray</a> <a name="copy"></a>QPointArray::copy () const
|
---|
139 | </h3>
|
---|
140 |
|
---|
141 | <p> Creates a <a href="shclass.html#deep-copy">deep copy</a> of the array.
|
---|
142 | <p> <p>See also <a href="qmemarray.html#detach">detach</a>().
|
---|
143 |
|
---|
144 | <h3 class=fn><a href="qpointarray.html">QPointArray</a> <a name="cubicBezier"></a>QPointArray::cubicBezier () const
|
---|
145 | </h3>
|
---|
146 | Returns the Bezier points for the four control points in this
|
---|
147 | array.
|
---|
148 |
|
---|
149 | <h3 class=fn>void <a name="makeArc"></a>QPointArray::makeArc ( int x, int y, int w, int h, int a1, int a2 )
|
---|
150 | </h3>
|
---|
151 | Sets the points of the array to those describing an arc of an
|
---|
152 | ellipse with size, width <em>w</em> by height <em>h</em>, and position (<em>x</em>,
|
---|
153 | <em>y</em>), starting from angle <em>a1</em> and spanning by angle <em>a2</em>. The
|
---|
154 | resulting array has sufficient resolution for pixel accuracy (see
|
---|
155 | the overloaded function which takes an additional <a href="qwmatrix.html">QWMatrix</a>
|
---|
156 | parameter).
|
---|
157 | <p> Angles are specified in 16ths of a degree, i.e. a full circle
|
---|
158 | equals 5760 (16*360). Positive values mean counter-clockwise,
|
---|
159 | whereas negative values mean the clockwise direction. Zero degrees
|
---|
160 | is at the 3 o'clock position.
|
---|
161 | <p> See the <a href="qcanvasellipse.html#anglediagram">angle diagram</a>.
|
---|
162 |
|
---|
163 | <h3 class=fn>void <a name="makeArc-2"></a>QPointArray::makeArc ( int x, int y, int w, int h, int a1, int a2, const <a href="qwmatrix.html">QWMatrix</a> & xf )
|
---|
164 | </h3>
|
---|
165 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
166 | <p> Sets the points of the array to those describing an arc of an
|
---|
167 | ellipse with width <em>w</em> and height <em>h</em> and position (<em>x</em>, <em>y</em>),
|
---|
168 | starting from angle <em>a1</em>, and spanning angle by <em>a2</em>, and
|
---|
169 | transformed by the matrix <em>xf</em>. The resulting array has
|
---|
170 | sufficient resolution for pixel accuracy.
|
---|
171 | <p> Angles are specified in 16ths of a degree, i.e. a full circle
|
---|
172 | equals 5760 (16*360). Positive values mean counter-clockwise,
|
---|
173 | whereas negative values mean the clockwise direction. Zero degrees
|
---|
174 | is at the 3 o'clock position.
|
---|
175 | <p> See the <a href="qcanvasellipse.html#anglediagram">angle diagram</a>.
|
---|
176 |
|
---|
177 | <h3 class=fn>void <a name="makeEllipse"></a>QPointArray::makeEllipse ( int x, int y, int w, int h )
|
---|
178 | </h3>
|
---|
179 | Sets the points of the array to those describing an ellipse with
|
---|
180 | size, width <em>w</em> by height <em>h</em>, and position (<em>x</em>, <em>y</em>).
|
---|
181 | <p> The returned array has sufficient resolution for use as pixels.
|
---|
182 |
|
---|
183 | <h3 class=fn><a href="qpointarray.html">QPointArray</a> & <a name="operator-eq"></a>QPointArray::operator= ( const <a href="qpointarray.html">QPointArray</a> & a )
|
---|
184 | </h3>
|
---|
185 |
|
---|
186 | <p> Assigns a <a href="shclass.html#shallow-copy">shallow copy</a> of <em>a</em> to this point array and returns a
|
---|
187 | reference to this point array.
|
---|
188 | <p> Equivalent to <a href="qmemarray.html#assign">assign</a>(a).
|
---|
189 | <p> <p>See also <a href="#copy">copy</a>() and <a href="qmemarray.html#detach">detach</a>().
|
---|
190 |
|
---|
191 | <h3 class=fn>void <a name="point"></a>QPointArray::point ( uint index, int * x, int * y ) const
|
---|
192 | </h3>
|
---|
193 | Reads the coordinates of the point at position <em>index</em> within the
|
---|
194 | array and writes them into <em>*x</em> and <em>*y</em>.
|
---|
195 |
|
---|
196 | <h3 class=fn><a href="qpoint.html">QPoint</a> <a name="point-2"></a>QPointArray::point ( uint index ) const
|
---|
197 | </h3>
|
---|
198 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
199 | <p> Returns the point at position <em>index</em> within the array.
|
---|
200 |
|
---|
201 | <h3 class=fn>bool <a name="putPoints"></a>QPointArray::putPoints ( int index, int nPoints, int firstx, int firsty, ... )
|
---|
202 | </h3>
|
---|
203 | Copies <em>nPoints</em> points from the variable argument list into this
|
---|
204 | point array from position <em>index</em>, and resizes the point array if
|
---|
205 | <tt>index+nPoints</tt> exceeds the size of the array.
|
---|
206 | <p> Returns TRUE if successful, or FALSE if the array could not be
|
---|
207 | resized (typically due to lack of memory).
|
---|
208 | <p> The example code creates an array with three points (4,5), (6,7)
|
---|
209 | and (8,9), by expanding the array from 1 to 3 points:
|
---|
210 | <p> <pre>
|
---|
211 | QPointArray a( 1 );
|
---|
212 | a[0] = QPoint( 4, 5 );
|
---|
213 | a.<a href="#putPoints">putPoints</a>( 1, 2, 6,7, 8,9 ); // index == 1, points == 2
|
---|
214 | </pre>
|
---|
215 |
|
---|
216 | <p> This has the same result, but here putPoints overwrites rather
|
---|
217 | than extends:
|
---|
218 | <pre>
|
---|
219 | QPointArray a( 3 );
|
---|
220 | a.<a href="#putPoints">putPoints</a>( 0, 3, 4,5, 0,0, 8,9 );
|
---|
221 | a.<a href="#putPoints">putPoints</a>( 1, 1, 6,7 );
|
---|
222 | </pre>
|
---|
223 |
|
---|
224 | <p> The points are given as a sequence of integers, starting with <em>firstx</em> then <em>firsty</em>, and so on.
|
---|
225 | <p> <p>See also <a href="qmemarray.html#resize">resize</a>().
|
---|
226 |
|
---|
227 | <h3 class=fn>bool <a name="putPoints-3"></a>QPointArray::putPoints ( int index, int nPoints, const <a href="qpointarray.html">QPointArray</a> & from, int fromIndex = 0 )
|
---|
228 | </h3>
|
---|
229 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
230 | <p> This version of the function copies <em>nPoints</em> from <em>from</em> into
|
---|
231 | this array, starting at <em>index</em> in this array and <em>fromIndex</em> in
|
---|
232 | <em>from</em>. <em>fromIndex</em> is 0 by default.
|
---|
233 | <p> <pre>
|
---|
234 | QPointArray a;
|
---|
235 | a.<a href="#putPoints">putPoints</a>( 0, 3, 1,2, 0,0, 5,6 );
|
---|
236 | // a is now the three-point array ( 1,2, 0,0, 5,6 );
|
---|
237 | QPointArray b;
|
---|
238 | b.<a href="#putPoints">putPoints</a>( 0, 3, 4,4, 5,5, 6,6 );
|
---|
239 | // b is now ( 4,4, 5,5, 6,6 );
|
---|
240 | a.<a href="#putPoints">putPoints</a>( 2, 3, b );
|
---|
241 | // a is now ( 1,2, 0,0, 4,4, 5,5, 6,6 );
|
---|
242 | </pre>
|
---|
243 |
|
---|
244 |
|
---|
245 | <h3 class=fn>void <a name="setPoint"></a>QPointArray::setPoint ( uint index, int x, int y )
|
---|
246 | </h3>
|
---|
247 | Sets the point at position <em>index</em> in the array to <em>(x, y)</em>.
|
---|
248 |
|
---|
249 | <p>Example: <a href="themes-example.html#x231">themes/wood.cpp</a>.
|
---|
250 | <h3 class=fn>void <a name="setPoint-2"></a>QPointArray::setPoint ( uint i, const <a href="qpoint.html">QPoint</a> & p )
|
---|
251 | </h3>
|
---|
252 |
|
---|
253 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
254 | <p> Sets the point at array index <em>i</em> to <em>p</em>.
|
---|
255 |
|
---|
256 | <h3 class=fn>void <a name="translate"></a>QPointArray::translate ( int dx, int dy )
|
---|
257 | </h3>
|
---|
258 | Translates all points in the array by <em>(dx, dy)</em>.
|
---|
259 |
|
---|
260 | <hr><h2>Related Functions</h2>
|
---|
261 | <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-lt-lt"></a>operator<< ( <a href="qdatastream.html">QDataStream</a> & s, const <a href="qpointarray.html">QPointArray</a> & a )
|
---|
262 | </h3>
|
---|
263 |
|
---|
264 | <p> Writes the point array, <em>a</em> to the stream <em>s</em> and returns a
|
---|
265 | reference to the stream.
|
---|
266 | <p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
|
---|
267 |
|
---|
268 | <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-gt-gt"></a>operator>> ( <a href="qdatastream.html">QDataStream</a> & s, <a href="qpointarray.html">QPointArray</a> & a )
|
---|
269 | </h3>
|
---|
270 |
|
---|
271 | <p> Reads a point array, <em>a</em> from the stream <em>s</em> and returns a
|
---|
272 | reference to the stream.
|
---|
273 | <p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
|
---|
274 |
|
---|
275 | <!-- eof -->
|
---|
276 | <hr><p>
|
---|
277 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
278 | Copyright © 1995-2007
|
---|
279 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
280 | <table width=100% cellspacing=0 border=0><tr>
|
---|
281 | <td>Copyright © 2007
|
---|
282 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
283 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
284 | </table></div></address></body>
|
---|
285 | </html>
|
---|