#include <base.h>
Collaboration diagram for fgl::FGPointArray:

A FGPointArray is an array of FGPoint objects. In addition to the functions provided by QMemArray, FGPointArray provides some point-specific functions.
For convenient reading and writing of the point data use setPoints(), putPoints(), point(), and setPoint().
For geometry operations use boundingRect() and translate(). There is also the FGMatrix::map() function for more general transformations of FGPointArrays. You can also create arcs and ellipses with makeArc() and makeEllipse().
Among others, FGPointArray is used by QPainter::drawLineSegments(), QPainter::drawPolyline(), QPainter::drawPolygon() and QPainter::drawCubicBezier().
Note that because this class is a QMemArray, copying an array and modifying the copy modifies the original as well, i.e. a shallow copy. If you need a deep copy use copy() or detach(), for example:
void drawGiraffe( const FGPointArray & r, QPainter * p ) { FGPointArray tmp = r; tmp.detach(); // some code that modifies tmp p->drawPoints( tmp ); }
If you forget the tmp.detach(), the const array will be modified.
Public Member Functions | |
| void | resize (unsigned new_size) |
| bool | isEmpty (void) const |
| FGPointArray () | |
| ~FGPointArray () | |
| FGPointArray (unsigned int nPoints) | |
| FGPointArray (const FGPointArray &old) | |
| FGPointArray (unsigned int nPoints, FGPoint *points) | |
| FGPointArray (unsigned int nPoints, FGCOORD points[][2]) | |
| FGPointArray (const FGRect &r, bool closed=false) | |
| FGPointArray (unsigned int nPoints, const FGCOORD *points) | |
| void | SetPoints (unsigned int nPoints, const FGCOORD *points) |
| void | SetPoints (unsigned nPoints, int firstx, int firsty,...) |
| void | SetPoints (unsigned int nPoints, const double *points) |
| void | translate (int dx, int dy) |
| FGRect | BoundingRect () const |
| bool | contains (const FGPoint &p) const |
| bool | contains (int x, int y) const |
Public Attributes | |
| unsigned int | vertices |
| FGPoint * | array |
| bool | allocated |
|
|
Constructs a null point array.
|
|
|
Destroys the point array. |
|
|
Constructs a point array with room for size points. Makes a null array if size == 0.
|
|
|
Constructs a deep copy of the point array a. |
|
||||||||||||
|
Constructs a point array with nPoints points, taken from the FGPoint array. Equivalent to setPoints(nPoints, points). |
|
||||||||||||
|
Constructs a point array with nPoints points, taken from the points array. Equivalent to SetPoints(nPoints, points). |
|
||||||||||||
|
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(). |
|
||||||||||||
|
Constructs a point array with nPoints points, taken from the points array. Equivalent to SetPoints(nPoints, points). |
|
|
Compute the bounding rect of polygon vertices. |
|
||||||||||||
|
Returns TRUE if the point x, y is inside this rectangle; otherwise returns FALSE. |
|
|
|
|
|
Returns TRUE if the array is empty; otherwise returns FALSE. An empty rectangle has a zero number of vertices. |
|
|
Resizes the array of the FGPoints. |
|
||||||||||||
|
|
|
||||||||||||||||||||
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. 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):
FGPointArray a; a.SetPoints( 2, 1,2, 3,4 ); The points are given as a sequence of integers, starting with firstx then firsty, and so on.
|
|
||||||||||||
|
|
|
||||||||||||
|
Translates all points in the array by (dx, dy). |
1.4.0