summaryrefslogtreecommitdiffstats
path: root/doc/html/qcanvaspolygonalitem.html
blob: 213ffd47764f236509fb48d89fd2056a68f36613 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!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&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="qcanvas-h.html">qcanvas.h</a>&gt;</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&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="qcanvas.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 retquirements 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="qpen.html">TQPen</a> and <a href="qbrush.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="qcanvas.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="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="qpointarray.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="qpointarray.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="qrect.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="qbrush.html">TQBrush</a> <a name="brush"></a>TQCanvasPolygonalItem::brush () const
</h3>

<p> Returns the <a href="qbrush.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="qpainter.html">TQPainter</a>&nbsp;&amp;&nbsp;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="qpainter.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="qpainter.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="qpainter.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="qpen.html">TQPen</a> <a name="pen"></a>TQCanvasPolygonalItem::pen () const
</h3>

<p> Returns the <a href="qpen.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="qbrush.html">TQBrush</a>&nbsp;b )<tt> [virtual]</tt>
</h3>
Sets the <a href="qbrush.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="qpen.html">TQPen</a>&nbsp;p )<tt> [virtual]</tt>
</h3>
Sets the <a href="qpen.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>