1QCanvasPolygonalItem(3qt) QCanvasPolygonalItem(3qt)
2
3
4
6 QCanvasPolygonalItem - Polygonal canvas item on a QCanvas
7
9 #include <qcanvas.h>
10
11 Inherits QCanvasItem.
12
13 Inherited by QCanvasRectangle, QCanvasPolygon, QCanvasLine, and
14 QCanvasEllipse.
15
16 Public Members
17 QCanvasPolygonalItem ( QCanvas * canvas )
18 virtual ~QCanvasPolygonalItem ()
19 virtual void setPen ( QPen p )
20 virtual void setBrush ( QBrush b )
21 QPen pen () const
22 QBrush brush () const
23 virtual QPointArray areaPoints () const = 0
24 virtual QPointArray areaPointsAdvanced () const
25 virtual QRect boundingRect () const
26 virtual int rtti () const
27
28 Protected Members
29 virtual void draw ( QPainter & p )
30 virtual void drawShape ( QPainter & p ) = 0
31 bool winding () const
32 void setWinding ( bool enable )
33 void invalidate ()
34 bool isValid () const
35
37 The QCanvasPolygonalItem class provides a polygonal canvas item on a
38 QCanvas.
39
40 The mostly rectangular classes, such as QCanvasSprite and QCanvasText,
41 use the object's bounding rectangle for movement, repainting and
42 collision calculations. For most other items, the bounding rectangle
43 can be far too large -- a diagonal line being the worst case, and there
44 are many other cases which are also bad. QCanvasPolygonalItem provides
45 polygon-based bounding rectangle handling, etc., which is much faster
46 for non-rectangular items.
47
48 Derived classes should try to define as small an area as possible to
49 maximize efficiency, but the polygon must definitely be contained
50 completely within the polygonal area. Calculating the exact
51 requirements is usually difficult, but if you allow a small
52 overestimate it can be easy and quick, while still getting almost all
53 of QCanvasPolygonalItem's speed.
54
55 Note that all subclasses must call hide() in their destructor since
56 hide() needs to be able to access areaPoints().
57
58 Normally, QCanvasPolygonalItem uses the odd-even algorithm for
59 determining whether an object intersects this object. You can change
60 this to the winding algorithm using setWinding().
61
62 The bounding rectangle is available using boundingRect(). The points
63 bounding the polygonal item are retrieved with areaPoints(). Use
64 areaPointsAdvanced() to retrieve the bounding points the polygonal item
65 will have after QCanvasItem::advance(1) has been called.
66
67 If the shape of the polygonal item is about to change while the item is
68 visible, call invalidate() before updating with a different result from
69 areaPoints().
70
71 By default, QCanvasPolygonalItem objects have a black pen and no brush
72 (the default QPen and QBrush constructors). You can change this with
73 setPen() and setBrush(), but note that some QCanvasPolygonalItem
74 subclasses only use the brush, ignoring the pen setting.
75
76 The polygonal item can be drawn on a painter with draw(). Subclasses
77 must reimplement drawShape() to draw themselves.
78
79 Like any other canvas item polygonal items can be moved with
80 QCanvasItem::move() and QCanvasItem::moveBy(), or by setting
81 coordinates with QCanvasItem::setX(), QCanvasItem::setY() and
82 QCanvasItem::setZ().
83
84 See also Graphics Classes and Image Processing Classes.
85
88 Constructs a QCanvasPolygonalItem on the canvas canvas.
89
91 Note that all subclasses must call hide() in their destructor since
92 hide() needs to be able to access areaPoints().
93
95 This function must be reimplemented by subclasses. It must return the
96 points bounding (i.e. outside and not touching) the shape or drawing
97 errors will occur.
98
99 Reimplemented in QCanvasPolygon.
100
102 Returns the points the polygonal item will have after
103 QCanvasItem::advance(1) is called, i.e. what the points are when
104 advanced by the current xVelocity() and yVelocity().
105
107 Returns the bounding rectangle of the polygonal item, based on
108 areaPoints().
109
110 Reimplemented from QCanvasItem.
111
113 Returns the QBrush used to fill the item, if filled.
114
115 See also setBrush().
116
118 Reimplemented from QCanvasItem, this draws the polygonal item by
119 setting the pen and brush for the item on the painter p and calling
120 drawShape().
121
122 Reimplemented from QCanvasItem.
123
125
126 Subclasses must reimplement this function to draw their shape. The pen
127 and brush of p are already set to pen() and brush() prior to calling
128 this function.
129
130 Warning: When you reimplement this function, make sure that you leave
131 the painter in the same state as you found it. For example, if you
132 start by calling QPainter::translate(50, 50), end your code by calling
133 QPainter::translate(-50, -50). Be also aware that the painter might
134 already have some transformations set (i.e., don't call
135 QPainter::resetXForm() when you're done).
136
137 See also draw().
138
139 Reimplemented in QCanvasRectangle, QCanvasPolygon, and QCanvasEllipse.
140
142 Invalidates all information about the area covered by the canvas item.
143 The item will be updated automatically on the next call that changes
144 the item's status, for example, move() or update(). Call this function
145 if you are going to change the shape of the item (as returned by
146 areaPoints()) while the item is visible.
147
149 Returns TRUE if the polygonal item's area information has not been
150 invalidated; otherwise returns FALSE.
151
152 See also invalidate().
153
155 Returns the QPen used to draw the outline of the item, if any.
156
157 See also setPen().
158
160 Returns 2 (QCanvasItem::Rtti_PolygonalItem).
161
162 See also QCanvasItem::rtti().
163
164 Reimplemented from QCanvasItem.
165
166 Reimplemented in QCanvasRectangle, QCanvasPolygon, QCanvasLine, and
167 QCanvasEllipse.
168
170 Sets the QBrush used when drawing the polygonal item to the brush b.
171
172 See also setPen(), brush(), and drawShape().
173
174 Examples:
175
177 Sets the QPen used when drawing the item to the pen p. Note that many
178 QCanvasPolygonalItems do not use the pen value.
179
180 See also setBrush(), pen(), and drawShape().
181
182 Examples:
183
185 If enable is TRUE, the polygonal item will use the winding algorithm to
186 determine the "inside" of the polygon; otherwise the odd-even algorithm
187 will be used.
188
189 The default is to use the odd-even algorithm.
190
191 See also winding().
192
194 Returns TRUE if the polygonal item uses the winding algorithm to
195 determine the "inside" of the polygon. Returns FALSE if it uses the
196 odd-even algorithm.
197
198 The default is to use the odd-even algorithm.
199
200 See also setWinding().
201
202
204 http://doc.trolltech.com/qcanvaspolygonalitem.html
205 http://www.trolltech.com/faq/tech.html
206
208 Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
209 license file included in the distribution for a complete license
210 statement.
211
213 Generated automatically from the source code.
214
216 If you find a bug in Qt, please report it as described in
217 http://doc.trolltech.com/bughowto.html. Good bug reports help us to
218 help you. Thank you.
219
220 The definitive Qt documentation is provided in HTML format; it is
221 located at $QTDIR/doc/html and can be read using Qt Assistant or with a
222 web browser. This man page is provided as a convenience for those users
223 who prefer man pages, although this format is not officially supported
224 by Trolltech.
225
226 If you find errors in this manual page, please report them to qt-
227 bugs@trolltech.com. Please include the name of the manual page
228 (qcanvaspolygonalitem.3qt) and the Qt version (3.3.8).
229
230
231
232Trolltech AS 2 February 2007 QCanvasPolygonalItem(3qt)