HomeHome

ClassesAnnotated - TreeFunctionsHomeStructure

QCanvasPolygonalItem Class Reference
[ canvas module ]


A QCanvasItem which renders itself in a polygonal area. More...

#include <qcanvas.h>

Inherits QCanvasItem.

Inherited by QCanvasEllipse, QCanvasLine, QCanvasPolygon and QCanvasRectangle.

List of all member functions.

Public Members

Protected Members


Detailed Description

A QCanvasItem which renders itself in a polygonal area.

QCanvasPolygonalItem is an abstract class that is useful for all items which cover a polygonal area of the canvas. QCanvasSprite and QCanvasText, the other branches of QCanvasItem derivatives usually cover a simple rectangular area and are dealt with specially, but typical geometric shapes such as lines and circles would be too inefficiently bounded by rectangular areas - a diagonal line from one corner of the canvas area to the other bound be bounded by a rectangle covering the entire area! QCanvasPolygonalItem objects allow the area to be defined by a polygon - a sequence of points bounding the area covered by the item.

Derived classes should try to define as small as possible an area to maximize efficiency, but must definately be contained completely within the polygonal area. Calculating the exact requirements may be difficult, but a small amount of over-estimation is better than any under-estimation, which will give drawing errors.

All subclasses must call hide() in their destructor while the functions numAreaPoints() and getAreaPoints() are valid.


Member Function Documentation

QCanvasPolygonalItem::QCanvasPolygonalItem ( QCanvas * canvas )

Constructs a QCanvasPolygonalItem on canvas.

QCanvasPolygonalItem::~QCanvasPolygonalItem () [virtual]

Destruct the QCanvasPolygonalItem. Derived classes must call hide() in their destructor, as this destructor cannot call the virtual methods.

QPointArray QCanvasPolygonalItem::areaPoints () const [virtual]

Must return the points bounding the shape. Note that the returned points are outside the object, not touching it.

Reimplemented in QCanvasPolygon, QCanvasEllipse, QCanvasRectangle and QCanvasLine.

QPointArray QCanvasPolygonalItem::areaPointsAdvanced () const [virtual]

Returns the points advanced by the current xVelocity() and yVelocity().

QRect QCanvasPolygonalItem::boundingRect () const [virtual]

Returns the bounding rectangle of the polygonal item, based on areaPoints().

Reimplemented from QCanvasItem.

QBrush QCanvasPolygonalItem::brush () const

Returns the QBrush used to fill the item, if filled.

See also setBrush().

bool QCanvasPolygonalItem::collidesWith ( const QCanvasItem * i ) const [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QCanvasItem.

void QCanvasPolygonalItem::draw ( QPainter & p ) [virtual protected]

Reimplemented from QCanvasItem, this draws the item by setting the pen and brush on p and calling drawShape().

Reimplemented from QCanvasItem.

void QCanvasPolygonalItem::drawShape ( QPainter & p ) [virtual protected]

Subclasses must reimplement this function to draw their shape. The pen and brush of p are already set to pen() and brush() prior to calling this function.

See also draw().

Reimplemented in QCanvasRectangle, QCanvasPolygon, QCanvasEllipse and QCanvasLine.

QPen QCanvasPolygonalItem::pen () const

Returns the QPen used to draw the outline of the item, if any.

See also setPen().

int QCanvasPolygonalItem::rtti () const [virtual]

Returns 2.

See also QCanvasItem::rtti().

Reimplemented from QCanvasItem.

void QCanvasPolygonalItem::setBrush ( QBrush b ) [virtual]

Sets the QBrush used when drawing item.

See also setPen(), brush() and drawShape().

void QCanvasPolygonalItem::setPen ( QPen p ) [virtual]

Sets the QPen used when drawing the item. Note that many QCanvasPolygonalItem do not use the pen value.

See also setBrush(), pen() and drawShape().

Reimplemented in QCanvasLine.

void QCanvasPolygonalItem::setWinding ( bool enable ) [protected]

Sets whether the polygonal item to use winding algorithm for determine the "inside" of the polygon, rather than the odd-even algorithm.

See also winding().

bool QCanvasPolygonalItem::winding () const [protected]

Returns TRUE if the polygonal item uses the winding algorithm for determine the "inside" of the polygon, of FALSE if it uses the odd-even algorithm.

See also setWinding().


Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):


This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.


Copyright © 2000 TrolltechTrademarks
Qt version 2.2.1