<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt - 3.3.8 - espenr - 2499/qt - x11 - free - 3.3.8/src/canvas/qcanvas.cpp:3725 -->
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=ISO-8859-1" >
< title > TQCanvasPolygonalItem Class< / title >
< style type = "text/css" > < ! - -
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
-->< / style >
< / head >
< body >
< table border = "0" cellpadding = "0" cellspacing = "0" width = "100%" >
< tr bgcolor = "#E5E5E5" >
< td valign = center >
< a href = "index.html" >
< font color = "#004faf" > Home< / font > < / a >
| < a href = "classes.html" >
< font color = "#004faf" > All Classes< / font > < / a >
| < a href = "mainclasses.html" >
< font color = "#004faf" > Main Classes< / font > < / a >
| < a href = "annotated.html" >
< font color = "#004faf" > Annotated< / font > < / a >
| < a href = "groups.html" >
< font color = "#004faf" > Grouped Classes< / font > < / a >
| < a href = "functions.html" >
< font color = "#004faf" > Functions< / font > < / a >
< / td >
< td align = "right" valign = "center" > < img src = "logo32.png" align = "right" width = "64" height = "32" border = "0" > < / td > < / tr > < / table > < h1 align = center > TQCanvasPolygonalItem Class Reference< br > < small > [< a href = "canvas.html" > canvas module< / a > ]< / small > < / h1 >
< p > The TQCanvasPolygonalItem class provides a polygonal canvas item
on a TQCanvas.
< a href = "#details" > More...< / a >
< p > < tt > #include < < a href = "qcanvas-h.html" > ntqcanvas.h< / a > > < / tt >
< p > Inherits < a href = "qcanvasitem.html" > TQCanvasItem< / a > .
< p > Inherited by < a href = "qcanvasrectangle.html" > TQCanvasRectangle< / a > , < a href = "qcanvaspolygon.html" > TQCanvasPolygon< / a > , < a href = "qcanvasline.html" > TQCanvasLine< / a > , and < a href = "qcanvasellipse.html" > TQCanvasEllipse< / a > .
< p > < a href = "qcanvaspolygonalitem-members.html" > List of all member functions.< / a >
< h2 > Public Members< / h2 >
< ul >
< li class = fn > < a href = "#TQCanvasPolygonalItem" > < b > TQCanvasPolygonalItem< / b > < / a > ( TQCanvas * canvas )< / li >
< li class = fn > virtual < a href = "#~TQCanvasPolygonalItem" > < b > ~TQCanvasPolygonalItem< / b > < / a > ()< / li >
< li class = fn > virtual void < a href = "#setPen" > < b > setPen< / b > < / a > ( TQPen p )< / li >
< li class = fn > virtual void < a href = "#setBrush" > < b > setBrush< / b > < / a > ( TQBrush b )< / li >
< li class = fn > TQPen < a href = "#pen" > < b > pen< / b > < / a > () const< / li >
< li class = fn > TQBrush < a href = "#brush" > < b > brush< / b > < / a > () const< / li >
< li class = fn > virtual TQPointArray < a href = "#areaPoints" > < b > areaPoints< / b > < / a > () const = 0< / li >
< li class = fn > virtual TQPointArray < a href = "#areaPointsAdvanced" > < b > areaPointsAdvanced< / b > < / a > () const< / li >
< li class = fn > virtual TQRect < a href = "#boundingRect" > < b > boundingRect< / b > < / a > () const< / li >
< li class = fn > virtual int < a href = "#rtti" > < b > rtti< / b > < / a > () const< / li >
< / ul >
< h2 > Protected Members< / h2 >
< ul >
< li class = fn > virtual void < a href = "#draw" > < b > draw< / b > < / a > ( TQPainter & p )< / li >
< li class = fn > virtual void < a href = "#drawShape" > < b > drawShape< / b > < / a > ( TQPainter & p ) = 0< / li >
< li class = fn > bool < a href = "#winding" > < b > winding< / b > < / a > () const< / li >
< li class = fn > void < a href = "#setWinding" > < b > setWinding< / b > < / a > ( bool enable )< / li >
< li class = fn > void < a href = "#invalidate" > < b > invalidate< / b > < / a > ()< / li >
< li class = fn > bool < a href = "#isValid" > < b > isValid< / b > < / a > () const< / li >
< / ul >
< hr > < a name = "details" > < / a > < h2 > Detailed Description< / h2 >
The TQCanvasPolygonalItem class provides a polygonal canvas item
on a < a href = "ntqcanvas.html" > TQCanvas< / a > .
< p >
< p > The mostly rectangular classes, such as < a href = "qcanvassprite.html" > TQCanvasSprite< / a > and
< a href = "qcanvastext.html" > TQCanvasText< / a > , 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.
< p > Derived classes should try to define as small an area as possible
to maximize efficiency, but the polygon must < em > definitely< / em > 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.
< p > Note that all subclasses < em > must< / em > call < a href = "qcanvasitem.html#hide" > hide< / a > () in their destructor
since hide() needs to be able to access < a href = "#areaPoints" > areaPoints< / a > ().
< p > Normally, TQCanvasPolygonalItem uses the odd-even algorithm for
determining whether an object intersects this object. You can
change this to the winding algorithm using < a href = "#setWinding" > setWinding< / a > ().
< p > The bounding rectangle is available using < a href = "#boundingRect" > boundingRect< / a > (). The
points bounding the polygonal item are retrieved with
areaPoints(). Use < a href = "#areaPointsAdvanced" > areaPointsAdvanced< / a > () to retrieve the bounding
points the polygonal item < em > will< / em > have after
< a href = "qcanvasitem.html#advance" > TQCanvasItem::advance< / a > (1) has been called.
< p > If the shape of the polygonal item is about to change while the
item is visible, call < a href = "#invalidate" > invalidate< / a > () before updating with a
different result from < a href = "#areaPoints" > areaPoints< / a > ().
< p > By default, TQCanvasPolygonalItem objects have a black pen and no
brush (the default < a href = "ntqpen.html" > TQPen< / a > and < a href = "ntqbrush.html" > TQBrush< / a > constructors). You can change
this with < a href = "#setPen" > setPen< / a > () and < a href = "#setBrush" > setBrush< / a > (), but note that some
TQCanvasPolygonalItem subclasses only use the brush, ignoring the
pen setting.
< p > The polygonal item can be drawn on a painter with < a href = "#draw" > draw< / a > ().
Subclasses must reimplement < a href = "#drawShape" > drawShape< / a > () to draw themselves.
< p > Like any other canvas item polygonal items can be moved with
< a href = "qcanvasitem.html#move" > TQCanvasItem::move< / a > () and < a href = "qcanvasitem.html#moveBy" > TQCanvasItem::moveBy< / a > (), or by setting coordinates
with < a href = "qcanvasitem.html#setX" > TQCanvasItem::setX< / a > (), < a href = "qcanvasitem.html#setY" > TQCanvasItem::setY< / a > () and < a href = "qcanvasitem.html#setZ" > TQCanvasItem::setZ< / a > ().
< p > < p > See also < a href = "graphics.html" > Graphics Classes< / a > and < a href = "images.html" > Image Processing Classes< / a > .
< hr > < h2 > Member Function Documentation< / h2 >
< h3 class = fn > < a name = "TQCanvasPolygonalItem" > < / a > TQCanvasPolygonalItem::TQCanvasPolygonalItem ( < a href = "ntqcanvas.html" > TQCanvas< / a > * canvas )
< / h3 >
Constructs a TQCanvasPolygonalItem on the canvas < em > canvas< / em > .
< h3 class = fn > < a name = "~TQCanvasPolygonalItem" > < / a > TQCanvasPolygonalItem::~TQCanvasPolygonalItem ()< tt > [virtual]< / tt >
< / h3 >
Note that all subclasses < em > must< / em > call < a href = "qcanvasitem.html#hide" > hide< / a > () in their destructor
since hide() needs to be able to access < a href = "#areaPoints" > areaPoints< / a > ().
< h3 class = fn > < a href = "ntqpointarray.html" > TQPointArray< / a > < a name = "areaPoints" > < / a > TQCanvasPolygonalItem::areaPoints () const< tt > [pure virtual]< / tt >
< / h3 >
< p > This function must be reimplemented by subclasses. It < em > must< / em >
return the points bounding (i.e. outside and not touching) the
shape or drawing errors will occur.
< p > Reimplemented in < a href = "qcanvaspolygon.html#areaPoints" > TQCanvasPolygon< / a > .
< h3 class = fn > < a href = "ntqpointarray.html" > TQPointArray< / a > < a name = "areaPointsAdvanced" > < / a > TQCanvasPolygonalItem::areaPointsAdvanced () const< tt > [virtual]< / tt >
< / h3 >
Returns the points the polygonal item < em > will< / em > have after
< a href = "qcanvasitem.html#advance" > TQCanvasItem::advance< / a > (1) is called, i.e. what the points are when
advanced by the current < a href = "qcanvasitem.html#xVelocity" > xVelocity< / a > () and < a href = "qcanvasitem.html#yVelocity" > yVelocity< / a > ().
< h3 class = fn > < a href = "ntqrect.html" > TQRect< / a > < a name = "boundingRect" > < / a > TQCanvasPolygonalItem::boundingRect () const< tt > [virtual]< / tt >
< / h3 >
Returns the bounding rectangle of the polygonal item, based on
< a href = "#areaPoints" > areaPoints< / a > ().
< p > Reimplemented from < a href = "qcanvasitem.html#boundingRect" > TQCanvasItem< / a > .
< h3 class = fn > < a href = "ntqbrush.html" > TQBrush< / a > < a name = "brush" > < / a > TQCanvasPolygonalItem::brush () const
< / h3 >
< p > Returns the < a href = "ntqbrush.html" > TQBrush< / a > used to fill the item, if filled.
< p > < p > See also < a href = "#setBrush" > setBrush< / a > ().
< h3 class = fn > void < a name = "draw" > < / a > TQCanvasPolygonalItem::draw ( < a href = "ntqpainter.html" > TQPainter< / a > & p )< tt > [virtual protected]< / tt >
< / h3 >
Reimplemented from < a href = "qcanvasitem.html" > TQCanvasItem< / a > , this draws the polygonal item by
setting the pen and brush for the item on the painter < em > p< / em > and
calling < a href = "#drawShape" > drawShape< / a > ().
< p > Reimplemented from < a href = "qcanvasitem.html#draw" > TQCanvasItem< / a > .
< h3 class = fn > void < a name = "drawShape" > < / a > TQCanvasPolygonalItem::drawShape ( < a href = "ntqpainter.html" > TQPainter< / a > & p )< tt > [pure virtual protected]< / tt >
< / h3 >
< p > Subclasses must reimplement this function to draw their shape. The
pen and brush of < em > p< / em > are already set to < a href = "#pen" > pen< / a > () and < a href = "#brush" > brush< / a > () prior
to calling this function.
< p > < b > Warning:< / b > 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 < a href = "ntqpainter.html#translate" > TQPainter::translate< / a > (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 < a href = "ntqpainter.html#resetXForm" > TQPainter::resetXForm< / a > () when you're done).
< p > < p > See also < a href = "#draw" > draw< / a > ().
< p > Reimplemented in < a href = "qcanvasrectangle.html#drawShape" > TQCanvasRectangle< / a > , < a href = "qcanvaspolygon.html#drawShape" > TQCanvasPolygon< / a > , and < a href = "qcanvasellipse.html#drawShape" > TQCanvasEllipse< / a > .
< h3 class = fn > void < a name = "invalidate" > < / a > TQCanvasPolygonalItem::invalidate ()< tt > [protected]< / tt >
< / h3 >
Invalidates all information about the area covered by the canvas
item. The item will be updated automatically on the next call that
changes the item's status, for example, < a href = "qcanvasitem.html#move" > move< / a > () or < a href = "qcanvasitem.html#update" > update< / a > (). Call
this function if you are going to change the shape of the item (as
returned by < a href = "#areaPoints" > areaPoints< / a > ()) while the item is visible.
< h3 class = fn > bool < a name = "isValid" > < / a > TQCanvasPolygonalItem::isValid () const< tt > [protected]< / tt >
< / h3 >
< p > Returns TRUE if the polygonal item's area information has not been
invalidated; otherwise returns FALSE.
< p > < p > See also < a href = "#invalidate" > invalidate< / a > ().
< h3 class = fn > < a href = "ntqpen.html" > TQPen< / a > < a name = "pen" > < / a > TQCanvasPolygonalItem::pen () const
< / h3 >
< p > Returns the < a href = "ntqpen.html" > TQPen< / a > used to draw the outline of the item, if any.
< p > < p > See also < a href = "#setPen" > setPen< / a > ().
< h3 class = fn > int < a name = "rtti" > < / a > TQCanvasPolygonalItem::rtti () const< tt > [virtual]< / tt >
< / h3 >
Returns 2 (TQCanvasItem::Rtti_PolygonalItem).
< p > < p > See also < a href = "qcanvasitem.html#rtti" > TQCanvasItem::rtti< / a > ().
< p > Reimplemented from < a href = "qcanvasitem.html#rtti" > TQCanvasItem< / a > .
< p > Reimplemented in < a href = "qcanvasrectangle.html#rtti" > TQCanvasRectangle< / a > , < a href = "qcanvaspolygon.html#rtti" > TQCanvasPolygon< / a > , < a href = "qcanvasline.html#rtti" > TQCanvasLine< / a > , and < a href = "qcanvasellipse.html#rtti" > TQCanvasEllipse< / a > .
< h3 class = fn > void < a name = "setBrush" > < / a > TQCanvasPolygonalItem::setBrush ( < a href = "ntqbrush.html" > TQBrush< / a > b )< tt > [virtual]< / tt >
< / h3 >
Sets the < a href = "ntqbrush.html" > TQBrush< / a > used when drawing the polygonal item to the brush < em > b< / em > .
< p > < p > See also < a href = "#setPen" > setPen< / a > (), < a href = "#brush" > brush< / a > (), and < a href = "#drawShape" > drawShape< / a > ().
< p > Examples: < a href = "canvas-example.html#x2923" > canvas/canvas.cpp< / a > and < a href = "tutorial2-06.html#x2572" > chart/chartform_canvas.cpp< / a > .
< h3 class = fn > void < a name = "setPen" > < / a > TQCanvasPolygonalItem::setPen ( < a href = "ntqpen.html" > TQPen< / a > p )< tt > [virtual]< / tt >
< / h3 >
Sets the < a href = "ntqpen.html" > TQPen< / a > used when drawing the item to the pen < em > p< / em > .
Note that many TQCanvasPolygonalItems do not use the pen value.
< p > < p > See also < a href = "#setBrush" > setBrush< / a > (), < a href = "#pen" > pen< / a > (), and < a href = "#drawShape" > drawShape< / a > ().
< p > Examples: < a href = "canvas-example.html#x2924" > canvas/canvas.cpp< / a > and < a href = "tutorial2-06.html#x2573" > chart/chartform_canvas.cpp< / a > .
< h3 class = fn > void < a name = "setWinding" > < / a > TQCanvasPolygonalItem::setWinding ( bool enable )< tt > [protected]< / tt >
< / h3 >
If < em > enable< / em > is TRUE, the polygonal item will use the winding
algorithm to determine the "inside" of the polygon; otherwise the
odd-even algorithm will be used.
< p > The default is to use the odd-even algorithm.
< p > < p > See also < a href = "#winding" > winding< / a > ().
< h3 class = fn > bool < a name = "winding" > < / a > TQCanvasPolygonalItem::winding () const< tt > [protected]< / tt >
< / h3 >
Returns TRUE if the polygonal item uses the winding algorithm to
determine the "inside" of the polygon. Returns FALSE if it uses
the odd-even algorithm.
< p > The default is to use the odd-even algorithm.
< p > < p > See also < a href = "#setWinding" > setWinding< / a > ().
<!-- eof -->
< hr > < p >
This file is part of the < a href = "index.html" > TQt toolkit< / a > .
Copyright © 1995-2007
< a href = "http://www.trolltech.com/" > Trolltech< / a > . All Rights Reserved.< p > < address > < hr > < div align = center >
< table width = 100% cellspacing = 0 border = 0 > < tr >
< td > Copyright © 2007
< a href = "troll.html" > Trolltech< / a > < td align = center > < a href = "trademarks.html" > Trademarks< / a >
< td align = right > < div align = right > TQt 3.3.8< / div >
< / table > < / div > < / address > < / body >
< / html >