source: trunk/doc/html/qcanvaspolygonalitem.html@ 201

Last change on this file since 201 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 13.7 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/canvas/qcanvas.cpp:3725 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QCanvasPolygonalItem Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QCanvasPolygonalItem Class Reference<br><small>[<a href="canvas.html">canvas module</a>]</small></h1>
33
34<p>The QCanvasPolygonalItem class provides a polygonal canvas item
35on a QCanvas.
36<a href="#details">More...</a>
37<p><tt>#include &lt;<a href="qcanvas-h.html">qcanvas.h</a>&gt;</tt>
38<p>Inherits <a href="qcanvasitem.html">QCanvasItem</a>.
39<p>Inherited by <a href="qcanvasrectangle.html">QCanvasRectangle</a>, <a href="qcanvaspolygon.html">QCanvasPolygon</a>, <a href="qcanvasline.html">QCanvasLine</a>, and <a href="qcanvasellipse.html">QCanvasEllipse</a>.
40<p><a href="qcanvaspolygonalitem-members.html">List of all member functions.</a>
41<h2>Public Members</h2>
42<ul>
43<li class=fn><a href="#QCanvasPolygonalItem"><b>QCanvasPolygonalItem</b></a> ( QCanvas&nbsp;*&nbsp;canvas )</li>
44<li class=fn>virtual <a href="#~QCanvasPolygonalItem"><b>~QCanvasPolygonalItem</b></a> ()</li>
45<li class=fn>virtual void <a href="#setPen"><b>setPen</b></a> ( QPen&nbsp;p )</li>
46<li class=fn>virtual void <a href="#setBrush"><b>setBrush</b></a> ( QBrush&nbsp;b )</li>
47<li class=fn>QPen <a href="#pen"><b>pen</b></a> () const</li>
48<li class=fn>QBrush <a href="#brush"><b>brush</b></a> () const</li>
49<li class=fn>virtual QPointArray <a href="#areaPoints"><b>areaPoints</b></a> () const = 0</li>
50<li class=fn>virtual QPointArray <a href="#areaPointsAdvanced"><b>areaPointsAdvanced</b></a> () const</li>
51<li class=fn>virtual QRect <a href="#boundingRect"><b>boundingRect</b></a> () const</li>
52<li class=fn>virtual int <a href="#rtti"><b>rtti</b></a> () const</li>
53</ul>
54<h2>Protected Members</h2>
55<ul>
56<li class=fn>virtual void <a href="#draw"><b>draw</b></a> ( QPainter&nbsp;&amp;&nbsp;p )</li>
57<li class=fn>virtual void <a href="#drawShape"><b>drawShape</b></a> ( QPainter&nbsp;&amp;&nbsp;p ) = 0</li>
58<li class=fn>bool <a href="#winding"><b>winding</b></a> () const</li>
59<li class=fn>void <a href="#setWinding"><b>setWinding</b></a> ( bool&nbsp;enable )</li>
60<li class=fn>void <a href="#invalidate"><b>invalidate</b></a> ()</li>
61<li class=fn>bool <a href="#isValid"><b>isValid</b></a> () const</li>
62</ul>
63<hr><a name="details"></a><h2>Detailed Description</h2>
64
65
66The QCanvasPolygonalItem class provides a polygonal canvas item
67on a <a href="qcanvas.html">QCanvas</a>.
68
69<p>
70
71
72<p> The mostly rectangular classes, such as <a href="qcanvassprite.html">QCanvasSprite</a> and
73<a href="qcanvastext.html">QCanvasText</a>, use the object's bounding rectangle for movement,
74repainting and collision calculations. For most other items, the
75bounding rectangle can be far too large -- a diagonal line being
76the worst case, and there are many other cases which are also bad.
77QCanvasPolygonalItem provides polygon-based bounding rectangle
78handling, etc., which is much faster for non-rectangular items.
79<p> Derived classes should try to define as small an area as possible
80to maximize efficiency, but the polygon must <em>definitely</em> be
81contained completely within the polygonal area. Calculating the
82exact requirements is usually difficult, but if you allow a small
83overestimate it can be easy and quick, while still getting almost
84all of QCanvasPolygonalItem's speed.
85<p> Note that all subclasses <em>must</em> call <a href="qcanvasitem.html#hide">hide</a>() in their destructor
86since hide() needs to be able to access <a href="#areaPoints">areaPoints</a>().
87<p> Normally, QCanvasPolygonalItem uses the odd-even algorithm for
88determining whether an object intersects this object. You can
89change this to the winding algorithm using <a href="#setWinding">setWinding</a>().
90<p> The bounding rectangle is available using <a href="#boundingRect">boundingRect</a>(). The
91points bounding the polygonal item are retrieved with
92areaPoints(). Use <a href="#areaPointsAdvanced">areaPointsAdvanced</a>() to retrieve the bounding
93points the polygonal item <em>will</em> have after
94<a href="qcanvasitem.html#advance">QCanvasItem::advance</a>(1) has been called.
95<p> If the shape of the polygonal item is about to change while the
96item is visible, call <a href="#invalidate">invalidate</a>() before updating with a
97different result from <a href="#areaPoints">areaPoints</a>().
98<p> By default, QCanvasPolygonalItem objects have a black pen and no
99brush (the default <a href="qpen.html">QPen</a> and <a href="qbrush.html">QBrush</a> constructors). You can change
100this with <a href="#setPen">setPen</a>() and <a href="#setBrush">setBrush</a>(), but note that some
101QCanvasPolygonalItem subclasses only use the brush, ignoring the
102pen setting.
103<p> The polygonal item can be drawn on a painter with <a href="#draw">draw</a>().
104Subclasses must reimplement <a href="#drawShape">drawShape</a>() to draw themselves.
105<p> Like any other canvas item polygonal items can be moved with
106<a href="qcanvasitem.html#move">QCanvasItem::move</a>() and <a href="qcanvasitem.html#moveBy">QCanvasItem::moveBy</a>(), or by setting coordinates
107with <a href="qcanvasitem.html#setX">QCanvasItem::setX</a>(), <a href="qcanvasitem.html#setY">QCanvasItem::setY</a>() and <a href="qcanvasitem.html#setZ">QCanvasItem::setZ</a>().
108<p> <p>See also <a href="graphics.html">Graphics Classes</a> and <a href="images.html">Image Processing Classes</a>.
109
110<hr><h2>Member Function Documentation</h2>
111<h3 class=fn><a name="QCanvasPolygonalItem"></a>QCanvasPolygonalItem::QCanvasPolygonalItem ( <a href="qcanvas.html">QCanvas</a>&nbsp;*&nbsp;canvas )
112</h3>
113Constructs a QCanvasPolygonalItem on the canvas <em>canvas</em>.
114
115<h3 class=fn><a name="~QCanvasPolygonalItem"></a>QCanvasPolygonalItem::~QCanvasPolygonalItem ()<tt> [virtual]</tt>
116</h3>
117Note that all subclasses <em>must</em> call <a href="qcanvasitem.html#hide">hide</a>() in their destructor
118since hide() needs to be able to access <a href="#areaPoints">areaPoints</a>().
119
120<h3 class=fn><a href="qpointarray.html">QPointArray</a> <a name="areaPoints"></a>QCanvasPolygonalItem::areaPoints () const<tt> [pure virtual]</tt>
121</h3>
122
123<p> This function must be reimplemented by subclasses. It <em>must</em>
124return the points bounding (i.e. outside and not touching) the
125shape or drawing errors will occur.
126
127<p>Reimplemented in <a href="qcanvaspolygon.html#areaPoints">QCanvasPolygon</a>.
128<h3 class=fn><a href="qpointarray.html">QPointArray</a> <a name="areaPointsAdvanced"></a>QCanvasPolygonalItem::areaPointsAdvanced () const<tt> [virtual]</tt>
129</h3>
130Returns the points the polygonal item <em>will</em> have after
131<a href="qcanvasitem.html#advance">QCanvasItem::advance</a>(1) is called, i.e. what the points are when
132advanced by the current <a href="qcanvasitem.html#xVelocity">xVelocity</a>() and <a href="qcanvasitem.html#yVelocity">yVelocity</a>().
133
134<h3 class=fn><a href="qrect.html">QRect</a> <a name="boundingRect"></a>QCanvasPolygonalItem::boundingRect () const<tt> [virtual]</tt>
135</h3>
136Returns the bounding rectangle of the polygonal item, based on
137<a href="#areaPoints">areaPoints</a>().
138
139<p>Reimplemented from <a href="qcanvasitem.html#boundingRect">QCanvasItem</a>.
140<h3 class=fn><a href="qbrush.html">QBrush</a> <a name="brush"></a>QCanvasPolygonalItem::brush () const
141</h3>
142
143<p> Returns the <a href="qbrush.html">QBrush</a> used to fill the item, if filled.
144<p> <p>See also <a href="#setBrush">setBrush</a>().
145
146<h3 class=fn>void <a name="draw"></a>QCanvasPolygonalItem::draw ( <a href="qpainter.html">QPainter</a>&nbsp;&amp;&nbsp;p )<tt> [virtual protected]</tt>
147</h3>
148Reimplemented from <a href="qcanvasitem.html">QCanvasItem</a>, this draws the polygonal item by
149setting the pen and brush for the item on the painter <em>p</em> and
150calling <a href="#drawShape">drawShape</a>().
151
152<p>Reimplemented from <a href="qcanvasitem.html#draw">QCanvasItem</a>.
153<h3 class=fn>void <a name="drawShape"></a>QCanvasPolygonalItem::drawShape ( <a href="qpainter.html">QPainter</a>&nbsp;&amp;&nbsp;p )<tt> [pure virtual protected]</tt>
154</h3>
155
156<p> Subclasses must reimplement this function to draw their shape. The
157pen and brush of <em>p</em> are already set to <a href="#pen">pen</a>() and <a href="#brush">brush</a>() prior
158to calling this function.
159<p> <b>Warning:</b> When you reimplement this function, make sure that you
160leave the painter in the same state as you found it. For example,
161if you start by calling <a href="qpainter.html#translate">QPainter::translate</a>(50, 50), end your
162code by calling QPainter::translate(-50, -50). Be also aware that
163the painter might already have some transformations set (i.e.,
164don't call <a href="qpainter.html#resetXForm">QPainter::resetXForm</a>() when you're done).
165<p> <p>See also <a href="#draw">draw</a>().
166
167<p>Reimplemented in <a href="qcanvasrectangle.html#drawShape">QCanvasRectangle</a>, <a href="qcanvaspolygon.html#drawShape">QCanvasPolygon</a>, and <a href="qcanvasellipse.html#drawShape">QCanvasEllipse</a>.
168<h3 class=fn>void <a name="invalidate"></a>QCanvasPolygonalItem::invalidate ()<tt> [protected]</tt>
169</h3>
170Invalidates all information about the area covered by the canvas
171item. The item will be updated automatically on the next call that
172changes the item's status, for example, <a href="qcanvasitem.html#move">move</a>() or <a href="qcanvasitem.html#update">update</a>(). Call
173this function if you are going to change the shape of the item (as
174returned by <a href="#areaPoints">areaPoints</a>()) while the item is visible.
175
176<h3 class=fn>bool <a name="isValid"></a>QCanvasPolygonalItem::isValid () const<tt> [protected]</tt>
177</h3>
178
179<p> Returns TRUE if the polygonal item's area information has not been
180invalidated; otherwise returns FALSE.
181<p> <p>See also <a href="#invalidate">invalidate</a>().
182
183<h3 class=fn><a href="qpen.html">QPen</a> <a name="pen"></a>QCanvasPolygonalItem::pen () const
184</h3>
185
186<p> Returns the <a href="qpen.html">QPen</a> used to draw the outline of the item, if any.
187<p> <p>See also <a href="#setPen">setPen</a>().
188
189<h3 class=fn>int <a name="rtti"></a>QCanvasPolygonalItem::rtti () const<tt> [virtual]</tt>
190</h3>
191Returns 2 (QCanvasItem::Rtti_PolygonalItem).
192<p> <p>See also <a href="qcanvasitem.html#rtti">QCanvasItem::rtti</a>().
193
194<p>Reimplemented from <a href="qcanvasitem.html#rtti">QCanvasItem</a>.
195<p>Reimplemented in <a href="qcanvasrectangle.html#rtti">QCanvasRectangle</a>, <a href="qcanvaspolygon.html#rtti">QCanvasPolygon</a>, <a href="qcanvasline.html#rtti">QCanvasLine</a>, and <a href="qcanvasellipse.html#rtti">QCanvasEllipse</a>.
196<h3 class=fn>void <a name="setBrush"></a>QCanvasPolygonalItem::setBrush ( <a href="qbrush.html">QBrush</a>&nbsp;b )<tt> [virtual]</tt>
197</h3>
198Sets the <a href="qbrush.html">QBrush</a> used when drawing the polygonal item to the brush <em>b</em>.
199<p> <p>See also <a href="#setPen">setPen</a>(), <a href="#brush">brush</a>(), and <a href="#drawShape">drawShape</a>().
200
201<p>Examples: <a href="canvas-example.html#x2923">canvas/canvas.cpp</a> and <a href="tutorial2-06.html#x2572">chart/chartform_canvas.cpp</a>.
202<h3 class=fn>void <a name="setPen"></a>QCanvasPolygonalItem::setPen ( <a href="qpen.html">QPen</a>&nbsp;p )<tt> [virtual]</tt>
203</h3>
204Sets the <a href="qpen.html">QPen</a> used when drawing the item to the pen <em>p</em>.
205Note that many QCanvasPolygonalItems do not use the pen value.
206<p> <p>See also <a href="#setBrush">setBrush</a>(), <a href="#pen">pen</a>(), and <a href="#drawShape">drawShape</a>().
207
208<p>Examples: <a href="canvas-example.html#x2924">canvas/canvas.cpp</a> and <a href="tutorial2-06.html#x2573">chart/chartform_canvas.cpp</a>.
209<h3 class=fn>void <a name="setWinding"></a>QCanvasPolygonalItem::setWinding ( bool&nbsp;enable )<tt> [protected]</tt>
210</h3>
211If <em>enable</em> is TRUE, the polygonal item will use the winding
212algorithm to determine the "inside" of the polygon; otherwise the
213odd-even algorithm will be used.
214<p> The default is to use the odd-even algorithm.
215<p> <p>See also <a href="#winding">winding</a>().
216
217<h3 class=fn>bool <a name="winding"></a>QCanvasPolygonalItem::winding () const<tt> [protected]</tt>
218</h3>
219Returns TRUE if the polygonal item uses the winding algorithm to
220determine the "inside" of the polygon. Returns FALSE if it uses
221the odd-even algorithm.
222<p> The default is to use the odd-even algorithm.
223<p> <p>See also <a href="#setWinding">setWinding</a>().
224
225<!-- eof -->
226<hr><p>
227This file is part of the <a href="index.html">Qt toolkit</a>.
228Copyright &copy; 1995-2007
229<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
230<table width=100% cellspacing=0 border=0><tr>
231<td>Copyright &copy; 2007
232<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
233<td align=right><div align=right>Qt 3.3.8</div>
234</table></div></address></body>
235</html>
Note: See TracBrowser for help on using the repository browser.