Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The TQCanvasPolygonalItem class provides a polygonal canvas item on a TQCanvas. More...
#include <qcanvas.h>
Inherits TQCanvasItem.
Inherited by TQCanvasRectangle, TQCanvasPolygon, TQCanvasLine, and TQCanvasEllipse.
The mostly rectangular classes, such as TQCanvasSprite and TQCanvasText, use the object's bounding rectangle for movement, repainting and collision calculations. For most other items, the bounding rectangle can be far too large -- a diagonal line being the worst case, and there are many other cases which are also bad. TQCanvasPolygonalItem provides polygon-based bounding rectangle handling, etc., which is much faster for non-rectangular items.
Derived classes should try to define as small an area as possible to maximize efficiency, but the polygon must definitely be contained completely within the polygonal area. Calculating the exact requirements is usually difficult, but if you allow a small overestimate it can be easy and tquick, while still getting almost all of TQCanvasPolygonalItem's speed.
Note that all subclasses must call hide() in their destructor since hide() needs to be able to access areaPoints().
Normally, TQCanvasPolygonalItem uses the odd-even algorithm for determining whether an object intersects this object. You can change this to the winding algorithm using setWinding().
The bounding rectangle is available using boundingRect(). The points bounding the polygonal item are retrieved with areaPoints(). Use areaPointsAdvanced() to retrieve the bounding points the polygonal item will have after TQCanvasItem::advance(1) has been called.
If the shape of the polygonal item is about to change while the item is visible, call invalidate() before updating with a different result from areaPoints().
By default, TQCanvasPolygonalItem objects have a black pen and no brush (the default TQPen and TQBrush constructors). You can change this with setPen() and setBrush(), but note that some TQCanvasPolygonalItem subclasses only use the brush, ignoring the pen setting.
The polygonal item can be drawn on a painter with draw(). Subclasses must reimplement drawShape() to draw themselves.
Like any other canvas item polygonal items can be moved with TQCanvasItem::move() and TQCanvasItem::moveBy(), or by setting coordinates with TQCanvasItem::setX(), TQCanvasItem::setY() and TQCanvasItem::setZ().
See also Graphics Classes and Image Processing Classes.
This function must be reimplemented by subclasses. It must return the points bounding (i.e. outside and not touching) the shape or drawing errors will occur.
Reimplemented in TQCanvasPolygon.
Reimplemented from TQCanvasItem.
Returns the TQBrush used to fill the item, if filled.
See also setBrush().
Reimplemented from TQCanvasItem.
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.
Warning: When you reimplement this function, make sure that you leave the painter in the same state as you found it. For example, if you start by calling TQPainter::translate(50, 50), end your code by calling TQPainter::translate(-50, -50). Be also aware that the painter might already have some transformations set (i.e., don't call TQPainter::resetXForm() when you're done).
See also draw().
Reimplemented in TQCanvasRectangle, TQCanvasPolygon, and TQCanvasEllipse.
Returns TRUE if the polygonal item's area information has not been invalidated; otherwise returns FALSE.
See also invalidate().
Returns the TQPen used to draw the outline of the item, if any.
See also setPen().
See also TQCanvasItem::rtti().
Reimplemented from TQCanvasItem.
Reimplemented in TQCanvasRectangle, TQCanvasPolygon, TQCanvasLine, and TQCanvasEllipse.
See also setPen(), brush(), and drawShape().
Examples: canvas/canvas.cpp and chart/chartform_canvas.cpp.
See also setBrush(), pen(), and drawShape().
Examples: canvas/canvas.cpp and chart/chartform_canvas.cpp.
The default is to use the odd-even algorithm.
See also winding().
The default is to use the odd-even algorithm.
See also setWinding().
This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.
Copyright © 2007 Trolltech | Trademarks | TQt 3.3.8
|