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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
|
<!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/kernel/qpoint.cpp:42 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQPoint 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 Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped 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>TQPoint Class Reference</h1>
<p>The TQPoint class defines a point in the plane.
<a href="#details">More...</a>
<p><tt>#include <<a href="qpoint-h.html">qpoint.h</a>></tt>
<p><a href="qpoint-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQPoint"><b>TQPoint</b></a> ()</li>
<li class=fn><a href="#TQPoint-2"><b>TQPoint</b></a> ( int xpos, int ypos )</li>
<li class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</li>
<li class=fn>int <a href="#x"><b>x</b></a> () const</li>
<li class=fn>int <a href="#y"><b>y</b></a> () const</li>
<li class=fn>void <a href="#setX"><b>setX</b></a> ( int x )</li>
<li class=fn>void <a href="#setY"><b>setY</b></a> ( int y )</li>
<li class=fn>int <a href="#manhattanLength"><b>manhattanLength</b></a> () const</li>
<li class=fn>TQCOORD & <a href="#rx"><b>rx</b></a> ()</li>
<li class=fn>TQCOORD & <a href="#ry"><b>ry</b></a> ()</li>
<li class=fn>TQPoint & <a href="#operator+-eq"><b>operator+=</b></a> ( const TQPoint & p )</li>
<li class=fn>TQPoint & <a href="#operator--eq"><b>operator-=</b></a> ( const TQPoint & p )</li>
<li class=fn>TQPoint & <a href="#operator*-eq"><b>operator*=</b></a> ( int c )</li>
<li class=fn>TQPoint & <a href="#operator*-eq-2"><b>operator*=</b></a> ( double c )</li>
<li class=fn>TQPoint & <a href="#operator/-eq"><b>operator/=</b></a> ( int c )</li>
<li class=fn>TQPoint & <a href="#operator/-eq-2"><b>operator/=</b></a> ( double c )</li>
</ul>
<h2>Related Functions</h2>
<ul>
<li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const TQPoint & p1, const TQPoint & p2 )</li>
<li class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const TQPoint & p1, const TQPoint & p2 )</li>
<li class=fn>const TQPoint <a href="#operator+"><b>operator+</b></a> ( const TQPoint & p1, const TQPoint & p2 )</li>
<li class=fn>const TQPoint <a href="#operator-"><b>operator-</b></a> ( const TQPoint & p1, const TQPoint & p2 )</li>
<li class=fn>const TQPoint <a href="#operator*"><b>operator*</b></a> ( const TQPoint & p, int c )</li>
<li class=fn>const TQPoint <a href="#operator*-2"><b>operator*</b></a> ( int c, const TQPoint & p )</li>
<li class=fn>const TQPoint <a href="#operator*-3"><b>operator*</b></a> ( const TQPoint & p, double c )</li>
<li class=fn>const TQPoint <a href="#operator*-4"><b>operator*</b></a> ( double c, const TQPoint & p )</li>
<li class=fn>const TQPoint <a href="#operator--2"><b>operator-</b></a> ( const TQPoint & p )</li>
<li class=fn>const TQPoint <a href="#operator/"><b>operator/</b></a> ( const TQPoint & p, int c )</li>
<li class=fn>const TQPoint <a href="#operator/-2"><b>operator/</b></a> ( const TQPoint & p, double c )</li>
<li class=fn>TQDataStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( TQDataStream & s, const TQPoint & p )</li>
<li class=fn>TQDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( TQDataStream & s, TQPoint & p )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQPoint class defines a point in the plane.
<p>
<p> A point is specified by an x coordinate and a y coordinate.
<p> The coordinate type is <tt>TQCOORD</tt> (a 32-bit integer). The minimum
value of <tt>TQCOORD</tt> is <tt>TQCOORD_MIN</tt> (-2147483648) and the maximum
value is <tt>TQCOORD_MAX</tt> (2147483647).
<p> The coordinates are accessed by the functions <a href="#x">x</a>() and <a href="#y">y</a>(); they
can be set by <a href="#setX">setX</a>() and <a href="#setY">setY</a>() or by the reference functions <a href="#rx">rx</a>()
and <a href="#ry">ry</a>().
<p> Given a point <em>p</em>, the following statements are all equivalent:
<pre>
p.setX( p.x() + 1 );
p += <a href="#TQPoint">TQPoint</a>( 1, 0 );
p.rx()++;
</pre>
<p> A TQPoint can also be used as a vector. Addition and subtraction
of TQPoints are defined as for vectors (each component is added
separately). You can divide or multiply a TQPoint by an <tt>int</tt> or a
<tt>double</tt>. The function <a href="#manhattanLength">manhattanLength</a>() gives an inexpensive
approximation of the length of the TQPoint interpreted as a vector.
<p> Example:
<pre>
//TQPoint oldPos is defined somewhere else
MyWidget::mouseMoveEvent( <a href="qmouseevent.html">TQMouseEvent</a> *e )
{
TQPoint vector = e-><a href="qmouseevent.html#pos">pos</a>() - oldPos;
if ( vector.<a href="#manhattanLength">manhattanLength</a>() > 3 )
... //mouse has moved more than 3 pixels since oldPos
}
</pre>
<p> TQPoints can be compared for equality or inequality, and they can
be written to and read from a TQStream.
<p> <p>See also <a href="qpointarray.html">TQPointArray</a>, <a href="qsize.html">TQSize</a>, <a href="qrect.html">TQRect</a>, <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="TQPoint"></a>TQPoint::TQPoint ()
</h3>
<p> Constructs a point with coordinates (0, 0) (<a href="#isNull">isNull</a>() returns TRUE).
<h3 class=fn><a name="TQPoint-2"></a>TQPoint::TQPoint ( int xpos, int ypos )
</h3>
<p> Constructs a point with x value <em>xpos</em> and y value <em>ypos</em>.
<h3 class=fn>bool <a name="isNull"></a>TQPoint::isNull () const
</h3>
<p> Returns TRUE if both the x value and the y value are 0; otherwise
returns FALSE.
<h3 class=fn>int <a name="manhattanLength"></a>TQPoint::manhattanLength () const
</h3>
Returns the sum of the absolute values of <a href="#x">x</a>() and <a href="#y">y</a>(),
traditionally known as the "Manhattan length" of the vector from
the origin to the point. The tradition arises because such
distances apply to travelers who can only travel on a rectangular
grid, like the streets of Manhattan.
<p> This is a useful, and tquick to calculate, approximation to the
true length: sqrt(pow(x(),2)+pow(y(),2)).
<h3 class=fn><a href="qpoint.html">TQPoint</a> & <a name="operator*-eq"></a>TQPoint::operator*= ( int c )
</h3>
<p> Multiplies this point's x and y by <em>c</em>, and returns a reference
to this point.
<p> Example:
<pre>
TQPoint p( -1, 4 );
p *= 2; // p becomes (-2,8)
</pre>
<h3 class=fn><a href="qpoint.html">TQPoint</a> & <a name="operator*-eq-2"></a>TQPoint::operator*= ( double c )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Multiplies this point's x and y by <em>c</em>, and returns a reference
to this point.
<p> Example:
<pre>
TQPoint p( -1, 4 );
p *= 2.5; // p becomes (-3,10)
</pre>
<p> Note that the result is truncated because points are held as
integers.
<h3 class=fn><a href="qpoint.html">TQPoint</a> & <a name="operator+-eq"></a>TQPoint::operator+= ( const <a href="qpoint.html">TQPoint</a> & p )
</h3>
<p> Adds point <em>p</em> to this point and returns a reference to this
point.
<p> Example:
<pre>
TQPoint p( 3, 7 );
TQPoint q( -1, 4 );
p += q; // p becomes (2,11)
</pre>
<h3 class=fn><a href="qpoint.html">TQPoint</a> & <a name="operator--eq"></a>TQPoint::operator-= ( const <a href="qpoint.html">TQPoint</a> & p )
</h3>
<p> Subtracts point <em>p</em> from this point and returns a reference to
this point.
<p> Example:
<pre>
TQPoint p( 3, 7 );
TQPoint q( -1, 4 );
p -= q; // p becomes (4,3)
</pre>
<h3 class=fn><a href="qpoint.html">TQPoint</a> & <a name="operator/-eq"></a>TQPoint::operator/= ( int c )
</h3>
<p> Divides both x and y by <em>c</em>, and returns a reference to this
point.
<p> Example:
<pre>
TQPoint p( -2, 8 );
p /= 2; // p becomes (-1,4)
</pre>
<h3 class=fn><a href="qpoint.html">TQPoint</a> & <a name="operator/-eq-2"></a>TQPoint::operator/= ( double c )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Divides both x and y by <em>c</em>, and returns a reference to this
point.
<p> Example:
<pre>
TQPoint p( -3, 10 );
p /= 2.5; // p becomes (-1,4)
</pre>
<p> Note that the result is truncated because points are held as
integers.
<h3 class=fn>TQCOORD & <a name="rx"></a>TQPoint::rx ()
</h3>
<p> Returns a reference to the x coordinate of the point.
<p> Using a reference makes it possible to directly manipulate x.
<p> Example:
<pre>
TQPoint p( 1, 2 );
p.<a href="#rx">rx</a>()--; // p becomes (0, 2)
</pre>
<p> <p>See also <a href="#ry">ry</a>().
<h3 class=fn>TQCOORD & <a name="ry"></a>TQPoint::ry ()
</h3>
<p> Returns a reference to the y coordinate of the point.
<p> Using a reference makes it possible to directly manipulate y.
<p> Example:
<pre>
TQPoint p( 1, 2 );
p.<a href="#ry">ry</a>()++; // p becomes (1, 3)
</pre>
<p> <p>See also <a href="#rx">rx</a>().
<h3 class=fn>void <a name="setX"></a>TQPoint::setX ( int x )
</h3>
<p> Sets the x coordinate of the point to <em>x</em>.
<p> <p>See also <a href="#x">x</a>() and <a href="#setY">setY</a>().
<p>Example: <a href="tutorial1-14.html#x2422">t14/cannon.cpp</a>.
<h3 class=fn>void <a name="setY"></a>TQPoint::setY ( int y )
</h3>
<p> Sets the y coordinate of the point to <em>y</em>.
<p> <p>See also <a href="#y">y</a>() and <a href="#setX">setX</a>().
<p>Example: <a href="tutorial1-14.html#x2423">t14/cannon.cpp</a>.
<h3 class=fn>int <a name="x"></a>TQPoint::x () const
</h3>
<p> Returns the x coordinate of the point.
<p> <p>See also <a href="#setX">setX</a>() and <a href="#y">y</a>().
<p>Examples: <a href="canvas-example.html#x2944">canvas/canvas.cpp</a>, <a href="tutorial2-06.html#x2581">chart/canvasview.cpp</a>, <a href="dirview-example.html#x1696">dirview/dirview.cpp</a>, <a href="fileiconview-example.html#x864">fileiconview/qfileiconview.cpp</a>, <a href="helpsystem-example.html#x2679">helpsystem/tooltip.cpp</a>, <a href="life-example.html#x1893">life/life.cpp</a>, and <a href="tutorial1-14.html#x2424">t14/cannon.cpp</a>.
<h3 class=fn>int <a name="y"></a>TQPoint::y () const
</h3>
<p> Returns the y coordinate of the point.
<p> <p>See also <a href="#setY">setY</a>() and <a href="#x">x</a>().
<p>Examples: <a href="canvas-example.html#x2945">canvas/canvas.cpp</a>, <a href="tutorial2-06.html#x2582">chart/canvasview.cpp</a>, <a href="fileiconview-example.html#x865">fileiconview/qfileiconview.cpp</a>, <a href="helpsystem-example.html#x2680">helpsystem/tooltip.cpp</a>, <a href="life-example.html#x1894">life/life.cpp</a>, <a href="tutorial1-14.html#x2425">t14/cannon.cpp</a>, and <a href="themes-example.html#x230">themes/wood.cpp</a>.
<hr><h2>Related Functions</h2>
<h3 class=fn>bool <a name="operator!-eq"></a>operator!= ( const <a href="qpoint.html">TQPoint</a> & p1, const <a href="qpoint.html">TQPoint</a> & p2 )
</h3>
<p>
<p> Returns TRUE if <em>p1</em> and <em>p2</em> are not equal; otherwise returns FALSE.
<h3 class=fn>const <a href="qpoint.html">TQPoint</a> <a name="operator*"></a>operator* ( const <a href="qpoint.html">TQPoint</a> & p, int c )
</h3>
<p>
<p> Returns the TQPoint formed by multiplying both components of <em>p</em>
by <em>c</em>.
<h3 class=fn>const <a href="qpoint.html">TQPoint</a> <a name="operator*-2"></a>operator* ( int c, const <a href="qpoint.html">TQPoint</a> & p )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p>
<p> Returns the TQPoint formed by multiplying both components of <em>p</em>
by <em>c</em>.
<h3 class=fn>const <a href="qpoint.html">TQPoint</a> <a name="operator*-3"></a>operator* ( const <a href="qpoint.html">TQPoint</a> & p, double c )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p>
<p> Returns the TQPoint formed by multiplying both components of <em>p</em>
by <em>c</em>.
<p> Note that the result is truncated because points are held as
integers.
<h3 class=fn>const <a href="qpoint.html">TQPoint</a> <a name="operator*-4"></a>operator* ( double c, const <a href="qpoint.html">TQPoint</a> & p )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p>
<p> Returns the TQPoint formed by multiplying both components of <em>p</em>
by <em>c</em>.
<p> Note that the result is truncated because points are held as
integers.
<h3 class=fn>const <a href="qpoint.html">TQPoint</a> <a name="operator+"></a>operator+ ( const <a href="qpoint.html">TQPoint</a> & p1, const <a href="qpoint.html">TQPoint</a> & p2 )
</h3>
<p>
<p> Returns the sum of <em>p1</em> and <em>p2</em>; each component is added separately.
<h3 class=fn>const <a href="qpoint.html">TQPoint</a> <a name="operator-"></a>operator- ( const <a href="qpoint.html">TQPoint</a> & p1, const <a href="qpoint.html">TQPoint</a> & p2 )
</h3>
<p>
<p> Returns <em>p2</em> subtracted from <em>p1</em>; each component is subtracted
separately.
<h3 class=fn>const <a href="qpoint.html">TQPoint</a> <a name="operator--2"></a>operator- ( const <a href="qpoint.html">TQPoint</a> & p )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p>
<p> Returns the TQPoint formed by changing the sign of both components
of <em>p</em>, equivalent to <tt>TQPoint(0,0) - p</tt>.
<h3 class=fn>const <a href="qpoint.html">TQPoint</a> <a name="operator/"></a>operator/ ( const <a href="qpoint.html">TQPoint</a> & p, int c )
</h3>
<p>
<p> Returns the TQPoint formed by dividing both components of <em>p</em> by
<em>c</em>.
<h3 class=fn>const <a href="qpoint.html">TQPoint</a> <a name="operator/-2"></a>operator/ ( const <a href="qpoint.html">TQPoint</a> & p, double c )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p>
<p> Returns the TQPoint formed by dividing both components of <em>p</em>
by <em>c</em>.
<p> Note that the result is truncated because points are held as
integers.
<h3 class=fn><a href="qdatastream.html">TQDataStream</a> & <a name="operator-lt-lt"></a>operator<< ( <a href="qdatastream.html">TQDataStream</a> & s, const <a href="qpoint.html">TQPoint</a> & p )
</h3>
<p> Writes point <em>p</em> to the stream <em>s</em> and returns a reference to
the stream.
<p> <p>See also <a href="datastreamformat.html">Format of the TQDataStream operators</a>.
<h3 class=fn>bool <a name="operator-eq-eq"></a>operator== ( const <a href="qpoint.html">TQPoint</a> & p1, const <a href="qpoint.html">TQPoint</a> & p2 )
</h3>
<p>
<p> Returns TRUE if <em>p1</em> and <em>p2</em> are equal; otherwise returns FALSE.
<h3 class=fn><a href="qdatastream.html">TQDataStream</a> & <a name="operator-gt-gt"></a>operator>> ( <a href="qdatastream.html">TQDataStream</a> & s, <a href="qpoint.html">TQPoint</a> & p )
</h3>
<p> Reads a TQPoint from the stream <em>s</em> into point <em>p</em> and returns a
reference to the stream.
<p> <p>See also <a href="datastreamformat.html">Format of the TQDataStream operators</a>.
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright © 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 © 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>
|