source: trunk/doc/html/qpointarray.html@ 203

Last change on this file since 203 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 15.7 KB
Line 
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"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { 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&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;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&nbsp;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 &lt;<a href="qpointarray-h.html">qpointarray.h</a>&gt;</tt>
37<p>Inherits <a href="qmemarray.html">QMemArray</a>&lt;QPoint&gt;.
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&nbsp;size )</li>
44<li class=fn><a href="#QPointArray-3"><b>QPointArray</b></a> ( const&nbsp;QPointArray&nbsp;&amp;&nbsp;a )</li>
45<li class=fn><a href="#QPointArray-4"><b>QPointArray</b></a> ( const&nbsp;QRect&nbsp;&amp;&nbsp;r, bool&nbsp;closed = FALSE )</li>
46<li class=fn>QPointArray &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QPointArray&nbsp;&amp;&nbsp;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&nbsp;dx, int&nbsp;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&nbsp;index, int&nbsp;*&nbsp;x, int&nbsp;*&nbsp;y ) const</li>
51<li class=fn>QPoint <a href="#point-2"><b>point</b></a> ( uint&nbsp;index ) const</li>
52<li class=fn>void <a href="#setPoint"><b>setPoint</b></a> ( uint&nbsp;index, int&nbsp;x, int&nbsp;y )</li>
53<li class=fn>void <a href="#setPoint-2"><b>setPoint</b></a> ( uint&nbsp;i, const&nbsp;QPoint&nbsp;&amp;&nbsp;p )</li>
54<li class=fn>bool <a href="#putPoints"><b>putPoints</b></a> ( int&nbsp;index, int&nbsp;nPoints, int&nbsp;firstx, int&nbsp;firsty, ... )</li>
55<li class=fn>bool <a href="#putPoints-3"><b>putPoints</b></a> ( int&nbsp;index, int&nbsp;nPoints, const&nbsp;QPointArray&nbsp;&amp;&nbsp;from, int&nbsp;fromIndex = 0 )</li>
56<li class=fn>void <a href="#makeArc"><b>makeArc</b></a> ( int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h, int&nbsp;a1, int&nbsp;a2 )</li>
57<li class=fn>void <a href="#makeEllipse"><b>makeEllipse</b></a> ( int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h )</li>
58<li class=fn>void <a href="#makeArc-2"><b>makeArc</b></a> ( int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h, int&nbsp;a1, int&nbsp;a2, const&nbsp;QWMatrix&nbsp;&amp;&nbsp;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 &amp; <a href="#operator-lt-lt"><b>operator&lt;&lt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, const&nbsp;QPointArray&nbsp;&amp;&nbsp;a )</li>
64<li class=fn>QDataStream &amp; <a href="#operator-gt-gt"><b>operator&gt;&gt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, QPointArray&nbsp;&amp;&nbsp;a )</li>
65</ul>
66<hr><a name="details"></a><h2>Detailed Description</h2>
67
68
69The 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
74functions provided by <a href="qmemarray.html">QMemArray</a>, QPointArray provides some
75point-specific functions.
76<p> For convenient reading and writing of the point data use
77setPoints(), <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
79is also the <a href="qwmatrix.html#map">QWMatrix::map</a>() function for more general
80transformations of QPointArrays. You can also create arcs and
81ellipses 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
86modifying 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 &amp; 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-&gt;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&nbsp;size )
108</h3>
109
110<p> Constructs a point array with room for <em>size</em> points. Makes a
111null 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&nbsp;<a href="qpointarray.html">QPointArray</a>&nbsp;&amp;&nbsp;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&nbsp;<a href="qrect.html">QRect</a>&nbsp;&amp;&nbsp;r, bool&nbsp;closed = FALSE )
121</h3>
122Constructs a point array from the rectangle <em>r</em>.
123<p> If <em>closed</em> is FALSE, then the point array just contains the
124following four points in the listed order: r.topLeft(),
125r.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>
135Returns 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>
146Returns the Bezier points for the four control points in this
147array.
148
149<h3 class=fn>void <a name="makeArc"></a>QPointArray::makeArc ( int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h, int&nbsp;a1, int&nbsp;a2 )
150</h3>
151Sets the points of the array to those describing an arc of an
152ellipse 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
154resulting array has sufficient resolution for pixel accuracy (see
155the overloaded function which takes an additional <a href="qwmatrix.html">QWMatrix</a>
156parameter).
157<p> Angles are specified in 16ths of a degree, i.e. a full circle
158equals 5760 (16*360). Positive values mean counter-clockwise,
159whereas negative values mean the clockwise direction. Zero degrees
160is 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&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h, int&nbsp;a1, int&nbsp;a2, const&nbsp;<a href="qwmatrix.html">QWMatrix</a>&nbsp;&amp;&nbsp;xf )
164</h3>
165This 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
167ellipse with width <em>w</em> and height <em>h</em> and position (<em>x</em>, <em>y</em>),
168starting from angle <em>a1</em>, and spanning angle by <em>a2</em>, and
169transformed by the matrix <em>xf</em>. The resulting array has
170sufficient resolution for pixel accuracy.
171<p> Angles are specified in 16ths of a degree, i.e. a full circle
172equals 5760 (16*360). Positive values mean counter-clockwise,
173whereas negative values mean the clockwise direction. Zero degrees
174is 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&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h )
178</h3>
179Sets the points of the array to those describing an ellipse with
180size, 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>&nbsp;&amp; <a name="operator-eq"></a>QPointArray::operator= ( const&nbsp;<a href="qpointarray.html">QPointArray</a>&nbsp;&amp;&nbsp;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
187reference 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&nbsp;index, int&nbsp;*&nbsp;x, int&nbsp;*&nbsp;y ) const
192</h3>
193Reads the coordinates of the point at position <em>index</em> within the
194array 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&nbsp;index ) const
197</h3>
198This 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&nbsp;index, int&nbsp;nPoints, int&nbsp;firstx, int&nbsp;firsty, ... )
202</h3>
203Copies <em>nPoints</em> points from the variable argument list into this
204point 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
207resized (typically due to lack of memory).
208<p> The example code creates an array with three points (4,5), (6,7)
209and (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
217than 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&nbsp;index, int&nbsp;nPoints, const&nbsp;<a href="qpointarray.html">QPointArray</a>&nbsp;&amp;&nbsp;from, int&nbsp;fromIndex = 0 )
228</h3>
229This 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
231this 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&nbsp;index, int&nbsp;x, int&nbsp;y )
246</h3>
247Sets 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&nbsp;i, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;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&nbsp;dx, int&nbsp;dy )
257</h3>
258Translates 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>&nbsp;&amp; <a name="operator-lt-lt"></a>operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a>&nbsp;&amp;&nbsp;s, const&nbsp;<a href="qpointarray.html">QPointArray</a>&nbsp;&amp;&nbsp;a )
262</h3>
263
264<p> Writes the point array, <em>a</em> to the stream <em>s</em> and returns a
265reference 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>&nbsp;&amp; <a name="operator-gt-gt"></a>operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a>&nbsp;&amp;&nbsp;s, <a href="qpointarray.html">QPointArray</a>&nbsp;&amp;&nbsp;a )
269</h3>
270
271<p> Reads a point array, <em>a</em> from the stream <em>s</em> and returns a
272reference to the stream.
273<p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
274
275<!-- eof -->
276<hr><p>
277This file is part of the <a href="index.html">Qt toolkit</a>.
278Copyright &copy; 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 &copy; 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>
Note: See TracBrowser for help on using the repository browser.