You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tqt3/doc/html/tqcanvaspolygonalitem.html

236 lines
14 KiB

<!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/tqcanvas.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&nbsp;Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped&nbsp;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 &lt;<a href="tqcanvas-h.html">tqcanvas.h</a>&gt;</tt>
<p>Inherits <a href="tqcanvasitem.html">TQCanvasItem</a>.
<p>Inherited by <a href="tqcanvasrectangle.html">TQCanvasRectangle</a>, <a href="tqcanvaspolygon.html">TQCanvasPolygon</a>, <a href="tqcanvasline.html">TQCanvasLine</a>, and <a href="tqcanvasellipse.html">TQCanvasEllipse</a>.
<p><a href="tqcanvaspolygonalitem-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQCanvasPolygonalItem"><b>TQCanvasPolygonalItem</b></a> ( TQCanvas&nbsp;*&nbsp;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&nbsp;p )</li>
<li class=fn>virtual void <a href="#setBrush"><b>setBrush</b></a> ( TQBrush&nbsp;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&nbsp;&amp;&nbsp;p )</li>
<li class=fn>virtual void <a href="#drawShape"><b>drawShape</b></a> ( TQPainter&nbsp;&amp;&nbsp;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&nbsp;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="tqcanvas.html">TQCanvas</a>.
<p>
<p> The mostly rectangular classes, such as <a href="tqcanvassprite.html">TQCanvasSprite</a> and
<a href="tqcanvastext.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 quick, while still getting almost
all of TQCanvasPolygonalItem's speed.
<p> Note that all subclasses <em>must</em> call <a href="tqcanvasitem.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="tqcanvasitem.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="tqpen.html">TQPen</a> and <a href="tqbrush.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="tqcanvasitem.html#move">TQCanvasItem::move</a>() and <a href="tqcanvasitem.html#moveBy">TQCanvasItem::moveBy</a>(), or by setting coordinates
with <a href="tqcanvasitem.html#setX">TQCanvasItem::setX</a>(), <a href="tqcanvasitem.html#setY">TQCanvasItem::setY</a>() and <a href="tqcanvasitem.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="tqcanvas.html">TQCanvas</a>&nbsp;*&nbsp;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="tqcanvasitem.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="tqpointarray.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="tqcanvaspolygon.html#areaPoints">TQCanvasPolygon</a>.
<h3 class=fn><a href="tqpointarray.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="tqcanvasitem.html#advance">TQCanvasItem::advance</a>(1) is called, i.e. what the points are when
advanced by the current <a href="tqcanvasitem.html#xVelocity">xVelocity</a>() and <a href="tqcanvasitem.html#yVelocity">yVelocity</a>().
<h3 class=fn><a href="tqrect.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="tqcanvasitem.html#boundingRect">TQCanvasItem</a>.
<h3 class=fn><a href="tqbrush.html">TQBrush</a> <a name="brush"></a>TQCanvasPolygonalItem::brush () const
</h3>
<p> Returns the <a href="tqbrush.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="tqpainter.html">TQPainter</a>&nbsp;&amp;&nbsp;p )<tt> [virtual protected]</tt>
</h3>
Reimplemented from <a href="tqcanvasitem.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="tqcanvasitem.html#draw">TQCanvasItem</a>.
<h3 class=fn>void <a name="drawShape"></a>TQCanvasPolygonalItem::drawShape ( <a href="tqpainter.html">TQPainter</a>&nbsp;&amp;&nbsp;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="tqpainter.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="tqpainter.html#resetXForm">TQPainter::resetXForm</a>() when you're done).
<p> <p>See also <a href="#draw">draw</a>().
<p>Reimplemented in <a href="tqcanvasrectangle.html#drawShape">TQCanvasRectangle</a>, <a href="tqcanvaspolygon.html#drawShape">TQCanvasPolygon</a>, and <a href="tqcanvasellipse.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="tqcanvasitem.html#move">move</a>() or <a href="tqcanvasitem.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="tqpen.html">TQPen</a> <a name="pen"></a>TQCanvasPolygonalItem::pen () const
</h3>
<p> Returns the <a href="tqpen.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="tqcanvasitem.html#rtti">TQCanvasItem::rtti</a>().
<p>Reimplemented from <a href="tqcanvasitem.html#rtti">TQCanvasItem</a>.
<p>Reimplemented in <a href="tqcanvasrectangle.html#rtti">TQCanvasRectangle</a>, <a href="tqcanvaspolygon.html#rtti">TQCanvasPolygon</a>, <a href="tqcanvasline.html#rtti">TQCanvasLine</a>, and <a href="tqcanvasellipse.html#rtti">TQCanvasEllipse</a>.
<h3 class=fn>void <a name="setBrush"></a>TQCanvasPolygonalItem::setBrush ( <a href="tqbrush.html">TQBrush</a>&nbsp;b )<tt> [virtual]</tt>
</h3>
Sets the <a href="tqbrush.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="tqpen.html">TQPen</a>&nbsp;p )<tt> [virtual]</tt>
</h3>
Sets the <a href="tqpen.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&nbsp;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 &copy; 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 &copy; 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>