Q3PointArray Class Reference

#include <q3pointarray.h>

Inheritance diagram for Q3PointArray:

Inheritance graph
[legend]
Collaboration diagram for Q3PointArray:

Collaboration graph
[legend]
List of all members.

Detailed Description

The Q3PointArray class provides an array of points.

Q3PointArray is a QPolygon subclass that provides functions to make it more source compatible with the QPointArray class in Qt 3.

In Qt 4, we recommend that you use QPainterPath for representing arcs, ellipses, and Bezier curves, rather than QPolygon.

Definition at line 33 of file q3pointarray.h.

Public Member Functions

 Q3PointArray ()
 Q3PointArray (const QRect &r, bool closed=false)
 Q3PointArray (const QPolygon &a)
Q3PointArray copy () const
bool isNull ()
void makeEllipse (int x, int y, int w, int h)
void makeArc (int x, int y, int w, int h, int a1, int a2)
void makeArc (int x, int y, int w, int h, int a1, int a2, const QMatrix &matrix)
Q3PointArray cubicBezier () const


Constructor & Destructor Documentation

Q3PointArray::Q3PointArray (  )  [inline]

Constructs an empty Q3PointArray.

Definition at line 36 of file q3pointarray.h.

Referenced by makeArc().

00036 : QPolygon() {}

Q3PointArray::Q3PointArray ( const QRect r,
bool  closed = false 
) [inline]

Constructs a point array from the rectangle r.

If closed is false, then the point array just contains the following four points of the rectangle ordered clockwise. The bottom-right point is located at (r.x() + r.width(), r.y() + r.height()).

Definition at line 37 of file q3pointarray.h.

00037 : QPolygon(r, closed) {}

Q3PointArray::Q3PointArray ( const QPolygon other  )  [inline]

Constructs a copy of other.

Definition at line 38 of file q3pointarray.h.

00038 : QPolygon(a) {}


Member Function Documentation

Q3PointArray Q3PointArray::copy (  )  const [inline]

Returns a copy of this Q3PointArray.

Definition at line 40 of file q3pointarray.h.

Referenced by Q3CanvasPolygon::areaPoints().

00040 { return *this; }

bool Q3PointArray::isNull (  )  [inline]

Same as isEmpty().

Definition at line 41 of file q3pointarray.h.

References isEmpty().

00041 { return isEmpty(); }

Here is the call graph for this function:

void Q3PointArray::makeEllipse ( int  x,
int  y,
int  w,
int  h 
)

Sets the points of the array to those describing an ellipse with size, width w by height h, and position (x, y).

The returned array has sufficient resolution for use as pixels.

Definition at line 145 of file q3pointarray.cpp.

References path.

00146 {
00147     QPainterPath path;
00148     path.addEllipse(x, y, w, h);
00149     *this = path.toSubpathPolygons().at(0).toPolygon();
00150 }

void Q3PointArray::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, width w by height h, and position (x, y), starting from angle a1 and spanning by angle a2. The resulting array has sufficient resolution for pixel accuracy (see the overloaded function which takes an additional QMatrix parameter).

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 the clockwise direction. Zero degrees is at the 3 o'clock position.

Definition at line 56 of file q3pointarray.cpp.

References path, Q3PointArray(), and qt_find_ellipse_coords().

Referenced by Q3CanvasEllipse::areaPoints().

00057 {
00058     QRectF r(x, y, w, h);
00059     QPointF startPoint;
00060     qt_find_ellipse_coords(r, a1 / 16.0, a2 / 16.0, &startPoint, 0);
00061 
00062     QPainterPath path(startPoint);
00063     path.arcTo(r, a1 / 16.0, a2 / 16.0);
00064 
00065     if (path.isEmpty())
00066         *this = Q3PointArray();
00067     else
00068         *this = path.toSubpathPolygons().at(0).toPolygon();
00069 }

Here is the call graph for this function:

void Q3PointArray::makeArc ( int  x,
int  y,
int  w,
int  h,
int  a1,
int  a2,
const QMatrix xf 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the points of the array to those describing an arc of an ellipse with width w and height h and position (x, y), starting from angle a1, and spanning angle by a2, and 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, whereas negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.

Definition at line 87 of file q3pointarray.cpp.

References path, Q3PointArray(), and qt_find_ellipse_coords().

00088 {
00089     QRectF r(x, y, w, h);
00090     QPointF startPoint;
00091     qt_find_ellipse_coords(r, a1 / 16.0, a2 / 16.0, &startPoint, 0);
00092 
00093     QPainterPath path(startPoint);
00094     path.arcTo(r, a1 / 16.0, a2 / 16.0);
00095     path = path * xf;
00096     if (path.isEmpty())
00097         *this = Q3PointArray();
00098     else
00099         *this = path.toSubpathPolygons().at(0).toPolygon();
00100 }

Here is the call graph for this function:

Q3PointArray Q3PointArray::cubicBezier (  )  const

Returns the Bezier points for the four control points in this array.

Definition at line 158 of file q3pointarray.cpp.

References QVector< QPoint >::at(), QBezier::fromPoints(), QPolygon::QPolygon(), qWarning(), QVector< QPoint >::size(), QBezier::toPolygon(), and QPolygonF::toPolygon().

00159 {
00160     if (size() != 4) {
00161   qWarning( "Q3PointArray::bezier: The array must have 4 control points" );
00162         return QPolygon();
00163     }
00164     QPolygonF polygon = QBezier::fromPoints(at(0), at(1), at(2), at(3)).toPolygon();
00165     return polygon.toPolygon();
00166 }

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 16:13:00 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1