Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 112b0974ad288f6cd55bf971ee6026a9 > files > 1636

libqt3-devel-3.0.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/kernel/qpointarray.cpp:47 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QPointArray Class</title>
<style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<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>

<p>The QPointArray class provides an array of points.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qpointarray-h.html">qpointarray.h</a>&gt;</tt>
<p>Inherits <a href="qmemarray.html">QMemArray</a>&lt;QPoint&gt;.
<p><a href="qpointarray-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class=fn><a href="#QPointArray"><b>QPointArray</b></a> ()</div></li>
<li><div class=fn><a href="#~QPointArray"><b>~QPointArray</b></a> ()</div></li>
<li><div class=fn><a href="#QPointArray-2"><b>QPointArray</b></a> ( int&nbsp;size )</div></li>
<li><div class=fn><a href="#QPointArray-3"><b>QPointArray</b></a> ( const&nbsp;QPointArray&nbsp;&amp;&nbsp;a )</div></li>
<li><div class=fn><a href="#QPointArray-4"><b>QPointArray</b></a> ( const&nbsp;QRect&nbsp;&amp;&nbsp;r, bool&nbsp;closed = FALSE )</div></li>
<li><div class=fn><a href="#QPointArray-5"><b>QPointArray</b></a> ( int&nbsp;nPoints, const&nbsp;QCOORD&nbsp;*&nbsp;points )</div></li>
<li><div class=fn>QPointArray &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QPointArray&nbsp;&amp;&nbsp;a )</div></li>
<li><div class=fn>QPointArray <a href="#copy"><b>copy</b></a> () const</div></li>
<li><div class=fn>void <a href="#translate"><b>translate</b></a> ( int&nbsp;dx, int&nbsp;dy )</div></li>
<li><div class=fn>QRect <a href="#boundingRect"><b>boundingRect</b></a> () const</div></li>
<li><div class=fn>void <a href="#point"><b>point</b></a> ( uint&nbsp;index, int&nbsp;*&nbsp;x, int&nbsp;*&nbsp;y ) const</div></li>
<li><div class=fn>QPoint <a href="#point-2"><b>point</b></a> ( uint&nbsp;index ) const</div></li>
<li><div class=fn>void <a href="#setPoint"><b>setPoint</b></a> ( uint&nbsp;index, int&nbsp;x, int&nbsp;y )</div></li>
<li><div class=fn>void <a href="#setPoint-2"><b>setPoint</b></a> ( uint&nbsp;i, const&nbsp;QPoint&nbsp;&amp;&nbsp;p )</div></li>
<li><div class=fn>bool <a href="#setPoints"><b>setPoints</b></a> ( int&nbsp;nPoints, const&nbsp;QCOORD&nbsp;*&nbsp;points )</div></li>
<li><div class=fn>bool <a href="#setPoints-2"><b>setPoints</b></a> ( int&nbsp;nPoints, int&nbsp;firstx, int&nbsp;firsty, ... )</div></li>
<li><div class=fn>bool <a href="#putPoints-2"><b>putPoints</b></a> ( int&nbsp;index, int&nbsp;nPoints, const&nbsp;QCOORD&nbsp;*&nbsp;points )</div></li>
<li><div class=fn>bool <a href="#putPoints"><b>putPoints</b></a> ( int&nbsp;index, int&nbsp;nPoints, int&nbsp;firstx, int&nbsp;firsty, ... )</div></li>
<li><div 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 )</div></li>
<li><div 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 )</div></li>
<li><div class=fn>void <a href="#makeEllipse"><b>makeEllipse</b></a> ( int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h )</div></li>
<li><div 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 )</div></li>
<li><div class=fn>QPointArray <a href="#cubicBezier"><b>cubicBezier</b></a> () const</div></li>
</ul>
<h2>Related Functions</h2>
<ul>
<li><div 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 )</div></li>
<li><div 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 )</div></li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The QPointArray class provides an array of points.
<p> 


<p> The QPointArray is an array of <a href="qpoint.html">QPoint</a> objects. In addition to the
functions provided by <a href="qmemarray.html">QMemArray</a>, QPointArray provides some
point-specific functions.
<p> For convenient reading and writing of the point data use <a href="#setPoints">setPoints</a>(),
<a href="#putPoints">putPoints</a>(), <a href="#point">point</a>(), and <a href="#setPoint">setPoint</a>().
<p> For geometry operations: <a href="#boundingRect">boundingRect</a>() and <a href="#translate">translate</a>(). There is
also a <a href="qwmatrix.html#map">QWMatrix::map</a>() function for more general transformation of
QPointArrays. You can also create arcs and ellipses with <a href="#makeArc">makeArc</a>()
and <a href="#makeEllipse">makeEllipse</a>().
<p> Among others, QPointArray is used by <a href="qpainter.html#drawLineSegments">QPainter::drawLineSegments</a>(),
<a href="qpainter.html#drawPolyline">QPainter::drawPolyline</a>(), <a href="qpainter.html#drawPolygon">QPainter::drawPolygon</a>() and
<a href="qpainter.html#drawCubicBezier">QPainter::drawCubicBezier</a>().
<p> Note that because this class is a <a href="qmemarray.html">QMemArray</a>, copying an array and 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:
<p> <pre>
    void drawGiraffe( const QPointArray &amp; r, QPainter * p )
    {
        QPointArray tmp = r;
        tmp.<a href="qmemarray.html#detach">detach</a>();
        // some code that modifies tmp
        p-&gt;drawPoints( tmp );
    }
  </pre>
 
<p> If you forget the tmp.detach(), the const array will be modified.
<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>.

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QPointArray"></a>QPointArray::QPointArray ()
</h3>

Constructs a null point array.
<p> <p>See also <a href="qmemarray.html#isNull">isNull</a>().

<h3 class=fn><a name="QPointArray-2"></a>QPointArray::QPointArray ( int&nbsp;size )
</h3>

<p> Constructs a point array with room for <em>size</em> points. Makes a null
array if <em>size</em> == 0.
<p> <p>See also <a href="qmemarray.html#resize">resize</a>() and <a href="qmemarray.html#isNull">isNull</a>().

<h3 class=fn><a name="QPointArray-3"></a>QPointArray::QPointArray ( const&nbsp;<a href="qpointarray.html">QPointArray</a>&nbsp;&amp;&nbsp;a )
</h3>

<p> Constructs a <a href="shclass.html#shallow-copy">shallow copy</a> of the point array <em>a</em>.
<p> <p>See also <a href="#copy">copy</a>().

<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 )
</h3>
Constructs a point array from the rectangle <em>r</em>.
<p> If <em>closed</em> is FALSE, then the point array just contains the
following four points in the listed order: r.topLeft(),
r.topRight(), r.bottomRight() and r.bottomLeft().
<p> If <em>closed</em> is TRUE, then a fifth point is set to r.topLeft().

<h3 class=fn><a name="QPointArray-5"></a>QPointArray::QPointArray ( int&nbsp;nPoints, const&nbsp;QCOORD&nbsp;*&nbsp;points )
</h3>
Constructs a point array with <em>nPoints</em> points, taken from the
<em>points</em> array.
<p> Equivalent to <a href="#setPoints">setPoints</a>(nPoints, points).

<h3 class=fn><a name="~QPointArray"></a>QPointArray::~QPointArray ()
</h3>

<p> Destroys the point array.

<h3 class=fn><a href="qrect.html">QRect</a> <a name="boundingRect"></a>QPointArray::boundingRect () const
</h3>
Returns the bounding rectangle of the points in the array, or
<a href="qrect.html">QRect</a>(0,0,0,0) if the array is empty.

<h3 class=fn><a href="qpointarray.html">QPointArray</a> <a name="copy"></a>QPointArray::copy () const
</h3>

<p> Creates a <a href="shclass.html#deep-copy">deep copy</a> of the array.

<h3 class=fn><a href="qpointarray.html">QPointArray</a> <a name="cubicBezier"></a>QPointArray::cubicBezier () const
</h3>
Returns the Bezier points for the four control points in this array.

<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 )
</h3>
Sets the points of the array to those describing an arc of an
ellipse with size <em>w</em> by <em>h</em> and position (<em>x</em>, <em>y</em>), starting
from angle <em>a1</em> and spanning <em>a2</em>.  The resulting array has sufficient
resolution for pixel accuracy (see the overloaded function which
takes an additional <a href="qwmatrix.html">QWMatrix</a> parameter).
<p> Angles are specified in 16ths of a degree, i.e. a full circle equals
5760 (16*360).  Positive values mean counter-clockwise, whereas
negative values mean a clockwise direction.  Zero degrees is at the 3
o'clock position.
<p> See the <a href="qcanvas.html#anglediagram">angle diagram</a>.

<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 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Sets the points of the array to those describing an arc of an
ellipse with width <em>w</em> and height <em>h</em> and position (<em>x</em>, <em>y</em>), starting
from angle <em>a1</em>, spanning angle <em>a2</em> and transformed by the matrix <em>xf</em>.
The resulting array has sufficient resolution for pixel accuracy.
<p> Angles are specified in 16ths of a degree, i.e. a full circle equals
5760 (16*360). Positive values mean counter-clockwise, whereas negative
values mean a clockwise direction.  Zero degrees is at the 3 o'clock
position.
<p> See the <a href="qcanvas.html#anglediagram">angle diagram</a>.

<h3 class=fn>void <a name="makeEllipse"></a>QPointArray::makeEllipse ( int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h )
</h3>
Sets the points of the array to those describing an ellipse with
size <em>w</em> by <em>h</em> and position (<em>x</em>, <em>y</em>).
<p> The returned array has sufficient resolution for use as pixels.

<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 )
</h3>

<p> Assigns a <a href="shclass.html#shallow-copy">shallow copy</a> of <em>a</em> to this point array and returns a
reference to this point array.
<p> Equivalent to <a href="qmemarray.html#assign">assign</a>(a).
<p> <p>See also <a href="#copy">copy</a>().

<h3 class=fn>void <a name="point"></a>QPointArray::point ( uint&nbsp;index, int&nbsp;*&nbsp;x, int&nbsp;*&nbsp;y ) const
</h3>
Reads the coordinates of the point at position <em>index</em> within the array
and writes them into <em>*x</em> and <em>*y</em>.

<h3 class=fn><a href="qpoint.html">QPoint</a> <a name="point-2"></a>QPointArray::point ( uint&nbsp;index ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns the point at position <em>index</em> within the array.

<h3 class=fn>bool <a name="putPoints"></a>QPointArray::putPoints ( int&nbsp;index, int&nbsp;nPoints, int&nbsp;firstx, int&nbsp;firsty, ... )
</h3>  Copies <em>nPoints</em> points from the variable argument list into
this point array from position <em>index</em>, and resizes the point array
if <tt>index+nPoints</tt> exceeds the size of the array.
<p> Returns TRUE if successful, or FALSE if the array could not be
resized (typically due to lack of memory).
<p> The example code creates an array with three points (1,2), (3,4) and
(5,6), by expanding the array from 1 to 3 points:
<p> <pre>
    QPointArray a( 1 );
    a[0] = QPoint( 1, 2 );
    a.<a href="#putPoints">putPoints</a>( 1, 2, 3,4, 5,6 ); // index == 1, points == 2
  </pre>
 
<p> This has the same result, but here putPoints overwrites rather than
extends:
<pre>
    QPointArray a( 3 );
    a.<a href="#putPoints">putPoints</a>( 0, 3, 1,2, 0,0, 5,6 );
    a.<a href="#putPoints">putPoints</a>( 1, 1, 3,4 );
  </pre>
 
<p> The points are given as a sequence of integers, starting with <em>firstx</em> then <em>firsty</em>, and so on.
<p> <p>See also <a href="qmemarray.html#resize">resize</a>() and <a href="#setPoints">setPoints</a>().

<h3 class=fn>bool <a name="putPoints-2"></a>QPointArray::putPoints ( int&nbsp;index, int&nbsp;nPoints, const&nbsp;QCOORD&nbsp;*&nbsp;points )
</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Copies <em>nPoints</em> points from the <em>points</em> coord array into
this point array, and resizes the point array if
<tt>index+nPoints</tt> exceeds the size of the array.
<p> Returns TRUE if successful, or FALSE if the array could not be
resized (typically due to lack of memory).
<p> 
<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 )
</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> This version of the function copies <em>nPoints</em> from <em>from</em> into
this array, starting at <em>index</em> in this array and <em>fromIndex</em> in
<em>from</em>.  <em>fromIndex</em> is 0 by default.
<p> <pre>
    QPointArray a;
    a.<a href="#putPoints">putPoints</a>( 0, 3, 1,2, 0,0, 5,6 );
    // a is now the three-point array ( 1,2, 0,0, 5,6 );
    QPointArray b;
    b.<a href="#putPoints">putPoints</a>( 0, 3, 4,4, 5,5, 6,6 );
    // b is now ( 4,4, 5,5, 6,6 );
    a.<a href="#putPoints">putPoints</a>( 2, 3, b );
    // a is now ( 1,2, 0,0, 4,4, 5,5, 6,6 );
  </pre>
 

<h3 class=fn>void <a name="setPoint"></a>QPointArray::setPoint ( uint&nbsp;index, int&nbsp;x, int&nbsp;y )
</h3>
Sets the point at position <em>index</em> in the array to <em>(x, y)</em>.

<p>Example: <a href="themes-example.html#x246">themes/wood.cpp</a>.
<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 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Sets the point at array index <em>i</em> to <em>p</em>.

<h3 class=fn>bool <a name="setPoints"></a>QPointArray::setPoints ( int&nbsp;nPoints, const&nbsp;QCOORD&nbsp;*&nbsp;points )
</h3>
Resizes the array to <em>nPoints</em> and sets the points in the array to
the values taken from <em>points</em>.
<p> Returns TRUE if successful, or FALSE if the array could not be
resized (normally due to lack of memory).
<p> The example code creates an array with two points (1,2) and (3,4):
<pre>
    static QCOORD points[] = { 1,2, 3,4 };
    QPointArray a;
    a.<a href="#setPoints">setPoints</a>( 2, points );
  </pre>
 
<p> <p>See also <a href="qmemarray.html#resize">resize</a>() and <a href="#putPoints">putPoints</a>().

<p>Examples: <a href="coordsys.html#x2422">aclock/aclock.cpp</a>, <a href="picture-example.html#x922">picture/picture.cpp</a>, <a href="themes-example.html#x310">themes/metal.cpp</a> and <a href="themes-example.html#x247">themes/wood.cpp</a>.
<h3 class=fn>bool <a name="setPoints-2"></a>QPointArray::setPoints ( int&nbsp;nPoints, int&nbsp;firstx, int&nbsp;firsty, ... )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Resizes the array to <em>nPoints</em> and sets the points in the array to
the values taken from the variable argument list.
<p> Returns TRUE if successful, or FALSE if the array could not be
resized (typically due to lack of memory).
<p> The example code creates an array with two points (1,2) and (3,4):
<p> <pre>
    QPointArray a;
    a.<a href="#setPoints">setPoints</a>( 2, 1,2, 3,4 );
  </pre>
 
<p> The points are given as a sequence of integers, starting with <em>firstx</em> then <em>firsty</em>, and so on.
<p> <p>See also <a href="qmemarray.html#resize">resize</a>() and <a href="#putPoints">putPoints</a>().

<h3 class=fn>void <a name="translate"></a>QPointArray::translate ( int&nbsp;dx, int&nbsp;dy )
</h3>
Translates all points in the array <em>(dx, dy)</em>.

<hr><h2>Related Functions</h2>
<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 )
</h3>

Writes the point array, <em>a</em> to the stream <em>s</em> and returns a
reference to the stream.
<p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.

<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 )
</h3>

Reads a point array, <em>a</em> from the stream <em>s</em> and returns a
reference to the stream.
<p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.

<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2001
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2001 
<a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt version 3.0.2</div>
</table></div></address></body>
</html>