QPointArray(3qt)

NAME
QPointArray - Array of points

#include <qpointarray.h>

Inherits QArray.

  Public Members
QPointArray ()
~QPointArray ()
QPointArray ( int size )
QPointArray ( const QPointArray & a )
QPointArray ( const QRect & r, bool closed=FALSE )
QPointArray ( int nPoints, const QCOORD * points )
QPointArray& operator= ( const QPointArray & a )
QPointArray copy () const
void translate ( int dx, int dy )
QRect boundingRect () const
void point ( uint i, int * x, int * y ) const
QPoint point ( uint i ) const
void setPoint ( uint i, int x, int y )
void setPoint ( uint i, const QPoint & p )
bool setPoints ( int nPoints, const QCOORD * points )
bool setPoints ( int nPoints, int firstx, int firsty, ... )
bool putPoints ( int index, int nPoints, const QCOORD * points )
bool putPoints ( int index, int nPoints, int firstx, int firsty, ... )
void makeArc ( int x, int y, int w, int h, int a1, int a2 )
void makeEllipse ( int x, int y, int w, int h )
void makeArc ( int x, int y, int w, int h, int a1, int a2, const QWMatrix & )
QPointArray quadBezier () const
void* shortPoints ( int index = 0, int nPoints = -1 ) const (internal)

  Static Public Members
void cleanBuffers () (internal)

RELATED FUNCTION DOCUMENTATION
(Note that these are not member functions.)
QDataStream & operator<< (QDataStream & s, const QPointArray & a)
QDataStream & operator>> (QDataStream & s, QPointArray & a)

DESCRIPTION
The QPointArray class provides an array of points.

The QPointArray is an array of QPoint objects. In addition to the functions provided by QArray, QPointArray provides some point-specific functions.

For convenient reading and writing of the point data: setPoints(), putPoints(), point(), and setPoint().

For geometry operations: boundingRect() and translate(). There is also a QWMatrix::map() function for more general transformation of QPointArrays.

QPointArray is used by QPainter::drawLineSegments(), QPainter::drawPolyline(), QPainter::drawPolygon() and QPainter::drawQuadBezier(), among other things.

Note that since this class is a QArray, it is explicitly shared and works with shallow copies by default.

See also QPainter, QWMatrix and QArray.

Examples: desktop/desktop.cpp picture/picture.cpp

MEMBER FUNCTION DOCUMENTATION

QPointArray::QPointArray ()
Constructs a null point array.

See also isNull().

QPointArray::QPointArray ( const QRect & r, bool closed=FALSE )
Constructs a point array from the rectangle r.

If closed 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().

If closed is TRUE, then a fifth point is set to r.topLeft().

QPointArray::QPointArray ( const QPointArray & a )
Constructs a shallow copy of the point array a.

See also copy().

QPointArray::QPointArray ( int nPoints, const QCOORD * points )
Constructs a point array with nPoints points, taken from the points array.

Equivalent to setPoints(nPoints,points).

QPointArray::QPointArray ( int size )
Constructs a point array with room for size points. Makes a null array if size == 0.

See also resize() and isNull().

QPointArray::~QPointArray ()
Destructs the point array.

QRect QPointArray::boundingRect () const
Returns the bounding rectangle of the points in the array, or QRect(0,0,0,0) if the array is empty.

QPointArray QPointArray::copy () const
Creates a deep copy of the array.

void QPointArray::makeArc ( int x, int y, int w, int h, int a1, int a2 )
Sets the points of the array to those describing an arc of an ellipse with size w by h and position (x, y ), starting from angle a1, spanning a2. The resulting array has sufficient resolution for pixel accuracy (see the overloaded function which takes an additional QWMatrix parameter).

Angles are specified in 16ths of a degree, i.e. a full circle equals 5760 (16*360). Positive values mean counter-clockwise while negative values mean clockwise direction. Zero degrees is at the 3 o'clock position.

void QPointArray::makeArc ( int x, int y, int w, int h, int a1, int a2, const QWMatrix & xf )
Sets the points of the array to those describing an arc of an ellipse with size w by h and position (x, y ), starting from angle a1, spanning a2, transformed by the matrix xf. The resulting array has sufficient resolution for pixel accuracy.

Angles are specified in 16ths of a degree, i.e. a full circle equals 5760 (16*360). Positive values mean counter-clockwise while negative values mean clockwise direction. Zero degrees is at the 3 o'clock position.

void QPointArray::makeEllipse ( int xx, int yy, int w, int h )
Sets the points of the array to those describing an ellipse with size w by h and position (x, y ).

The returned array has sufficient resolution for use as pixels.

QPointArray & QPointArray::operator= ( const QPointArray & a )
Assigns a shallow copy of a to this point array and returns a reference to this point array.

Equivalent to assign( a ).

See also copy().

QPoint QPointArray::point ( uint index ) const
Returns the point at position index in the array.

void QPointArray::point ( uint index, int * x, int * y ) const
Returns the point at position index in the array in *x and *y.

bool QPointArray::putPoints ( int index, int nPoints, const QCOORD * points )
Copies nPoints points from the points array into this point array. Will resize this point array if index+nPoints exceeds the size of the array.

Returns TRUE if successful, or FALSE if the array could not be resized (typcailly due to lack of memory).

The example code creates an array with three points: (1,2), (3,4) and (5,6):

    QPointArray a( 1 );
    a[0] = QPoint( 1, 2 );
    static QCOORD points[] = { 3,4, 5,6 };
    a.putPoints( 1, 2, points );

This function differs from setPoints() in that it does not resize the array unless the array size is exceeded.

See also resize() and setPoints().

bool QPointArray::putPoints ( int index, int nPoints, int firstx, int firsty, ... )
Copies nPoints points from the variable argument list into this point array. Will resize this point array if index+nPoints exceeds the size of the array.

Returns TRUE if successful, or FALSE if the array could not be resized (typically due to lack of memory).

The example code creates an array with two points (1,2), (3,4) and (5,6):

    QPointArray a( 1 );
    a[0] = QPoint( 1, 2 );
    a.putPoints( 1, 2, 3,4, 5,6 );

This function differs from setPoints() in that it does not resize the array unless the array size is exceeded.

See also resize() and setPoints().

QPointArray QPointArray::quadBezier () const
Returns the Bezier points for the four control points in this array.

void QPointArray::setPoint ( uint i, const QPoint & p )
Equivalent to setPoint( i, p.x(), p.y() ).

void QPointArray::setPoint ( uint index, int x, int y )
Sets the point at position index in the array to (x,y).

bool QPointArray::setPoints ( int nPoints, const QCOORD * points )
Resizes the array to nPoints and sets the points in the array to the values taken from points.

Returns TRUE if successful, or FALSE if the array could not be resized (normally due to lack of memory).

The example code creates an array with two points (1,2) and (3,4):

    static QCOORD points[] = { 1,2, 3,4 };
    QPointArray a;
    a.setPoints( 2, points );

See also resize() and putPoints().

bool QPointArray::setPoints ( int nPoints, int firstx, int firsty, ... )
Resizes the array to nPoints and sets the points in the array to the values taken from the variable argument list.

Returns TRUE if successful, or FALSE if the array could not be resized (typically due to lack of memory).

The example code creates an array with two points (1,2) and (3,4):

    QPointArray a;
    a.setPoints( 2, 1,2, 3,4 );

See also resize() and putPoints().

void QPointArray::translate ( int dx, int dy )
Translates all points in the array (dx,dy).

void QPointArray::cleanBuffers () [static]
For internal use only.

void* QPointArray::shortPoints ( int index = 0, int nPoints = -1 ) const
For internal use only.

RELATED FUNCTION DOCUMENTATION

QDataStream & operator<< (QDataStream & s, const QPointArray & a)
Writes a point array to the stream and returns a reference to the stream.

See also Format of the QDataStream operators

QDataStream & operator>> (QDataStream & s, QPointArray & a)
Reads a point array from the stream and returns a reference to the stream.

See also Format of the QDataStream operators

SEE ALSO
http://doc.trolltech.com/qpointarray.html http://www.trolltech.com/faq/tech.html

COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.

BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports make our job much simpler. Thank you.

In case of content or formattting problems with this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qpointarray.3qt) and the Qt version (2.3.5).