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
|
'\" t
.TH TQCanvasPolygonalItem 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
TQCanvasPolygonalItem \- Polygonal canvas item on a TQCanvas
.SH SYNOPSIS
\fC#include <tqcanvas.h>\fR
.PP
Inherits TQCanvasItem.
.PP
Inherited by TQCanvasRectangle, TQCanvasPolygon, TQCanvasLine, and TQCanvasEllipse.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBTQCanvasPolygonalItem\fR ( TQCanvas * canvas )"
.br
.ti -1c
.BI "virtual \fB~TQCanvasPolygonalItem\fR ()"
.br
.ti -1c
.BI "virtual void \fBsetPen\fR ( TQPen p )"
.br
.ti -1c
.BI "virtual void \fBsetBrush\fR ( TQBrush b )"
.br
.ti -1c
.BI "TQPen \fBpen\fR () const"
.br
.ti -1c
.BI "TQBrush \fBbrush\fR () const"
.br
.ti -1c
.BI "virtual TQPointArray \fBareaPoints\fR () const = 0"
.br
.ti -1c
.BI "virtual TQPointArray \fBareaPointsAdvanced\fR () const"
.br
.ti -1c
.BI "virtual TQRect \fBboundingRect\fR () const"
.br
.ti -1c
.BI "virtual int \fBrtti\fR () const"
.br
.in -1c
.SS "Protected Members"
.in +1c
.ti -1c
.BI "virtual void \fBdraw\fR ( TQPainter & p )"
.br
.ti -1c
.BI "virtual void \fBdrawShape\fR ( TQPainter & p ) = 0"
.br
.ti -1c
.BI "bool \fBwinding\fR () const"
.br
.ti -1c
.BI "void \fBsetWinding\fR ( bool enable )"
.br
.ti -1c
.BI "void \fBinvalidate\fR ()"
.br
.ti -1c
.BI "bool \fBisValid\fR () const"
.br
.in -1c
.SH DESCRIPTION
The TQCanvasPolygonalItem class provides a polygonal canvas item on a TQCanvas.
.PP
The mostly rectangular classes, such as TQCanvasSprite and TQCanvasText, 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.
.PP
Derived classes should try to define as small an area as possible to maximize efficiency, but the polygon must \fIdefinitely\fR 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.
.PP
Note that all subclasses \fImust\fR call hide() in their destructor since hide() needs to be able to access areaPoints().
.PP
Normally, TQCanvasPolygonalItem uses the odd-even algorithm for determining whether an object intersects this object. You can change this to the winding algorithm using setWinding().
.PP
The bounding rectangle is available using boundingRect(). The points bounding the polygonal item are retrieved with areaPoints(). Use areaPointsAdvanced() to retrieve the bounding points the polygonal item \fIwill\fR have after TQCanvasItem::advance(1) has been called.
.PP
If the shape of the polygonal item is about to change while the item is visible, call invalidate() before updating with a different result from areaPoints().
.PP
By default, TQCanvasPolygonalItem objects have a black pen and no brush (the default TQPen and TQBrush constructors). You can change this with setPen() and setBrush(), but note that some TQCanvasPolygonalItem subclasses only use the brush, ignoring the pen setting.
.PP
The polygonal item can be drawn on a painter with draw(). Subclasses must reimplement drawShape() to draw themselves.
.PP
Like any other canvas item polygonal items can be moved with TQCanvasItem::move() and TQCanvasItem::moveBy(), or by setting coordinates with TQCanvasItem::setX(), TQCanvasItem::setY() and TQCanvasItem::setZ().
.PP
See also Graphics Classes and Image Processing Classes.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "TQCanvasPolygonalItem::TQCanvasPolygonalItem ( TQCanvas * canvas )"
Constructs a TQCanvasPolygonalItem on the canvas \fIcanvas\fR.
.SH "TQCanvasPolygonalItem::~TQCanvasPolygonalItem ()\fC [virtual]\fR"
Note that all subclasses \fImust\fR call hide() in their destructor since hide() needs to be able to access areaPoints().
.SH "TQPointArray TQCanvasPolygonalItem::areaPoints () const\fC [pure virtual]\fR"
This function must be reimplemented by subclasses. It \fImust\fR return the points bounding (i.e. outside and not touching) the shape or drawing errors will occur.
.PP
Reimplemented in TQCanvasPolygon.
.SH "TQPointArray TQCanvasPolygonalItem::areaPointsAdvanced () const\fC [virtual]\fR"
Returns the points the polygonal item \fIwill\fR have after TQCanvasItem::advance(1) is called, i.e. what the points are when advanced by the current xVelocity() and yVelocity().
.SH "TQRect TQCanvasPolygonalItem::boundingRect () const\fC [virtual]\fR"
Returns the bounding rectangle of the polygonal item, based on areaPoints().
.PP
Reimplemented from TQCanvasItem.
.SH "TQBrush TQCanvasPolygonalItem::brush () const"
Returns the TQBrush used to fill the item, if filled.
.PP
See also setBrush().
.SH "void TQCanvasPolygonalItem::draw ( TQPainter & p )\fC [virtual protected]\fR"
Reimplemented from TQCanvasItem, this draws the polygonal item by setting the pen and brush for the item on the painter \fIp\fR and calling drawShape().
.PP
Reimplemented from TQCanvasItem.
.SH "void TQCanvasPolygonalItem::drawShape ( TQPainter & p )\fC [pure virtual protected]\fR"
Subclasses must reimplement this function to draw their shape. The pen and brush of \fIp\fR are already set to pen() and brush() prior to calling this function.
.PP
\fBWarning:\fR 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 TQPainter::translate(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 TQPainter::resetXForm() when you're done).
.PP
See also draw().
.PP
Reimplemented in TQCanvasRectangle, TQCanvasPolygon, and TQCanvasEllipse.
.SH "void TQCanvasPolygonalItem::invalidate ()\fC [protected]\fR"
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, move() or update(). Call this function if you are going to change the shape of the item (as returned by areaPoints()) while the item is visible.
.SH "bool TQCanvasPolygonalItem::isValid () const\fC [protected]\fR"
Returns TRUE if the polygonal item's area information has not been invalidated; otherwise returns FALSE.
.PP
See also invalidate().
.SH "TQPen TQCanvasPolygonalItem::pen () const"
Returns the TQPen used to draw the outline of the item, if any.
.PP
See also setPen().
.SH "int TQCanvasPolygonalItem::rtti () const\fC [virtual]\fR"
Returns 2 (TQCanvasItem::Rtti_PolygonalItem).
.PP
See also TQCanvasItem::rtti().
.PP
Reimplemented from TQCanvasItem.
.PP
Reimplemented in TQCanvasRectangle, TQCanvasPolygon, TQCanvasLine, and TQCanvasEllipse.
.SH "void TQCanvasPolygonalItem::setBrush ( TQBrush b )\fC [virtual]\fR"
Sets the TQBrush used when drawing the polygonal item to the brush \fIb\fR.
.PP
See also setPen(), brush(), and drawShape().
.PP
Examples:
.)l canvas/canvas.cpp and chart/chartform_canvas.cpp.
.SH "void TQCanvasPolygonalItem::setPen ( TQPen p )\fC [virtual]\fR"
Sets the TQPen used when drawing the item to the pen \fIp\fR. Note that many TQCanvasPolygonalItems do not use the pen value.
.PP
See also setBrush(), pen(), and drawShape().
.PP
Examples:
.)l canvas/canvas.cpp and chart/chartform_canvas.cpp.
.SH "void TQCanvasPolygonalItem::setWinding ( bool enable )\fC [protected]\fR"
If \fIenable\fR 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.
.PP
The default is to use the odd-even algorithm.
.PP
See also winding().
.SH "bool TQCanvasPolygonalItem::winding () const\fC [protected]\fR"
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.
.PP
The default is to use the odd-even algorithm.
.PP
See also setWinding().
.SH "SEE ALSO"
.BR http://doc.trolltech.com/tqcanvaspolygonalitem.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive TQt documentation is provided in HTML format; it is
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR [email protected] .
Please include the name of the manual page (tqcanvaspolygonalitem.3qt) and the Qt
version (3.3.8).
|