]>
Commit | Line | Data |
---|---|---|
72e7876b SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: geometry.h | |
3 | // Purpose: Common Geometry Classes | |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 08/05/99 | |
7 | // RCS-ID: | |
8 | // Copyright: (c) | |
c3a4297c | 9 | // Licence: wxWindows licence |
72e7876b SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
c3a4297c VZ |
12 | #ifndef _WX_GEOMETRY_H_ |
13 | #define _WX_GEOMETRY_H_ | |
72e7876b SC |
14 | |
15 | #ifdef __GNUG__ | |
6c7873e1 | 16 | #pragma interface "geometry.cpp" |
72e7876b SC |
17 | #endif |
18 | ||
510fc784 | 19 | #include "wx/defs.h" |
c3a4297c | 20 | |
c3a4297c VZ |
21 | #if wxUSE_GEOMETRY |
22 | ||
510fc784 RR |
23 | #include "wx/utils.h" |
24 | #include "wx/gdicmn.h" | |
25 | #include <math.h> | |
26 | ||
72e7876b | 27 | #ifdef __WXMSW__ |
c3a4297c | 28 | #define wxMulDivInt32( a , b , c ) ::MulDiv( a , b , c ) |
72e7876b | 29 | #elif defined( __WXMAC__ ) |
c3a4297c VZ |
30 | #include "Math64.h" |
31 | #define wxMulDivInt32( a , b , c ) S32Set( S64Div( S64Multiply( S64Set(a) , S64Set(b) ) , S64Set(c) ) ) | |
72e7876b | 32 | #else |
c3a4297c | 33 | #define wxMulDivInt32( a , b , c ) ((wxInt32)((a)*(((wxDouble)b)/((wxDouble)c)))) |
72e7876b SC |
34 | #endif |
35 | ||
36 | class wxDataInputStream ; | |
37 | class wxDataOutputStream ; | |
38 | ||
39 | // clipping from Cohen-Sutherland | |
40 | ||
41 | enum wxOutCode | |
42 | { | |
c3a4297c VZ |
43 | wxInside = 0x00 , |
44 | wxOutLeft = 0x01 , | |
45 | wxOutRight = 0x02 , | |
46 | wxOutTop = 0x08 , | |
47 | wxOutBottom = 0x04 | |
72e7876b SC |
48 | } ; |
49 | ||
50 | // wxPoint2Ds represent a point or a vector in a 2d coordinate system | |
51 | ||
52 | class WXDLLEXPORT wxPoint2DDouble | |
53 | { | |
54 | public : | |
c3a4297c VZ |
55 | wxPoint2DDouble(); |
56 | wxPoint2DDouble( wxDouble x , wxDouble y ) ; | |
57 | wxPoint2DDouble( const wxPoint2DDouble &pt ) ; | |
58 | ||
59 | // two different conversions to integers, floor and rounding | |
60 | void GetFloor( wxInt32 *x , wxInt32 *y ) ; | |
61 | void GetRounded( wxInt32 *x , wxInt32 *y ) ; | |
62 | ||
63 | wxDouble GetVectorLength() ; | |
64 | wxDouble GetVectorAngle() ; | |
65 | void SetVectorLength( wxDouble length ) ; | |
66 | void SetVectorAngle( wxDouble degrees ) ; | |
67 | void SetPolarCoordinates( wxDouble angle , wxDouble length ) ; | |
68 | // set the vector length to 1.0, preserving the angle | |
69 | void Normalize() ; | |
70 | ||
71 | wxDouble GetDistance( const wxPoint2DDouble &pt ) ; | |
72 | wxDouble GetDistanceSquare( const wxPoint2DDouble &pt ) ; | |
73 | wxDouble GetDotProduct( const wxPoint2DDouble &vec ) ; | |
74 | wxDouble GetCrossProduct( const wxPoint2DDouble &vec ) ; | |
75 | ||
76 | // the reflection of this point | |
77 | wxPoint2DDouble operator-() ; | |
78 | ||
79 | wxPoint2DDouble& operator=(const wxPoint2DDouble& pt) ; | |
80 | wxPoint2DDouble& operator+=(const wxPoint2DDouble& pt) ; | |
81 | wxPoint2DDouble& operator-=(const wxPoint2DDouble& pt) ; | |
82 | wxPoint2DDouble& operator*=(const wxPoint2DDouble& pt) ; | |
83 | wxPoint2DDouble& operator*=(wxDouble n) ; | |
84 | wxPoint2DDouble& operator*=(wxInt32 n) ; | |
85 | wxPoint2DDouble& operator/=(const wxPoint2DDouble& pt) ; | |
86 | wxPoint2DDouble& operator/=(wxDouble n) ; | |
87 | wxPoint2DDouble& operator/=(wxInt32 n) ; | |
88 | ||
89 | bool operator==(const wxPoint2DDouble& pt) const ; | |
90 | bool operator!=(const wxPoint2DDouble& pt) const ; | |
91 | ||
92 | wxDouble m_x ; | |
93 | wxDouble m_y ; | |
72e7876b SC |
94 | } ; |
95 | ||
96 | wxPoint2DDouble operator+(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2) ; | |
97 | wxPoint2DDouble operator-(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2) ; | |
98 | wxPoint2DDouble operator*(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2) ; | |
99 | wxPoint2DDouble operator*(wxDouble n , const wxPoint2DDouble& pt) ; | |
100 | wxPoint2DDouble operator*(wxInt32 n , const wxPoint2DDouble& pt) ; | |
101 | wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxDouble n) ; | |
102 | wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxInt32 n) ; | |
103 | wxPoint2DDouble operator/(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2) ; | |
104 | wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxDouble n) ; | |
105 | wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxInt32 n) ; | |
106 | ||
107 | inline wxPoint2DDouble::wxPoint2DDouble() | |
108 | { | |
c3a4297c VZ |
109 | m_x = 0.0 ; |
110 | m_y = 0.0 ; | |
72e7876b SC |
111 | } |
112 | ||
113 | inline wxPoint2DDouble::wxPoint2DDouble( wxDouble x , wxDouble y ) | |
114 | { | |
c3a4297c VZ |
115 | m_x = x ; |
116 | m_y = y ; | |
72e7876b SC |
117 | } |
118 | ||
119 | inline wxPoint2DDouble::wxPoint2DDouble( const wxPoint2DDouble &pt ) | |
120 | { | |
c3a4297c VZ |
121 | m_x = pt.m_x ; |
122 | m_y = pt.m_y ; | |
72e7876b | 123 | } |
c3a4297c | 124 | |
72e7876b SC |
125 | inline void wxPoint2DDouble::GetFloor( wxInt32 *x , wxInt32 *y ) |
126 | { | |
c3a4297c VZ |
127 | *x = (wxInt32) floor( m_x ) ; |
128 | *y = (wxInt32) floor( m_y ) ; | |
72e7876b SC |
129 | } |
130 | ||
131 | inline void wxPoint2DDouble::GetRounded( wxInt32 *x , wxInt32 *y ) | |
132 | { | |
c3a4297c VZ |
133 | *x = (wxInt32) floor( m_x + 0.5 ) ; |
134 | *y = (wxInt32) floor( m_y + 0.5) ; | |
72e7876b SC |
135 | } |
136 | ||
72e7876b SC |
137 | inline wxDouble wxPoint2DDouble::GetDistance( const wxPoint2DDouble &pt ) |
138 | { | |
c3a4297c | 139 | return sqrt( GetDistanceSquare( pt ) ); |
72e7876b SC |
140 | } |
141 | ||
142 | inline wxDouble wxPoint2DDouble::GetDistanceSquare( const wxPoint2DDouble &pt ) | |
143 | { | |
c3a4297c | 144 | return ( (pt.m_x-m_x)*(pt.m_x-m_x) + (pt.m_y-m_y)*(pt.m_y-m_y) ) ; |
72e7876b SC |
145 | } |
146 | ||
147 | inline wxDouble wxPoint2DDouble::GetDotProduct( const wxPoint2DDouble &vec ) | |
148 | { | |
c3a4297c | 149 | return ( m_x * vec.m_x + m_y * vec.m_y ) ; |
72e7876b SC |
150 | } |
151 | ||
152 | inline wxDouble wxPoint2DDouble::GetCrossProduct( const wxPoint2DDouble &vec ) | |
153 | { | |
c3a4297c | 154 | return ( m_x * vec.m_y - vec.m_x * m_y ) ; |
72e7876b SC |
155 | } |
156 | ||
157 | inline wxPoint2DDouble wxPoint2DDouble::operator-() | |
158 | { | |
c3a4297c | 159 | return wxPoint2DDouble( -m_x, -m_y); |
72e7876b SC |
160 | } |
161 | ||
162 | inline wxPoint2DDouble& wxPoint2DDouble::operator=(const wxPoint2DDouble& pt) | |
163 | { | |
c3a4297c VZ |
164 | m_x = pt.m_x ; |
165 | m_y = pt.m_y; | |
166 | return *this ; | |
72e7876b SC |
167 | } |
168 | ||
169 | inline wxPoint2DDouble& wxPoint2DDouble::operator+=(const wxPoint2DDouble& pt) | |
170 | { | |
c3a4297c VZ |
171 | m_x = m_x + pt.m_x ; |
172 | m_y = m_y + pt.m_y; | |
173 | return *this ; | |
72e7876b SC |
174 | } |
175 | ||
176 | inline wxPoint2DDouble& wxPoint2DDouble::operator-=(const wxPoint2DDouble& pt) | |
177 | { | |
c3a4297c VZ |
178 | m_x = m_x - pt.m_x ; |
179 | m_y = m_y - pt.m_y; | |
180 | return *this ; | |
72e7876b SC |
181 | } |
182 | ||
183 | inline wxPoint2DDouble& wxPoint2DDouble::operator*=(const wxPoint2DDouble& pt) | |
184 | { | |
da052901 RR |
185 | m_x = m_x * pt.m_x ; |
186 | m_y = m_y * pt.m_y; | |
c3a4297c | 187 | return *this ; |
72e7876b SC |
188 | } |
189 | ||
190 | inline wxPoint2DDouble& wxPoint2DDouble::operator/=(const wxPoint2DDouble& pt) | |
191 | { | |
da052901 RR |
192 | m_x = m_x / pt.m_x ; |
193 | m_y = m_y / pt.m_y; | |
c3a4297c | 194 | return *this ; |
72e7876b SC |
195 | } |
196 | ||
197 | inline bool wxPoint2DDouble::operator==(const wxPoint2DDouble& pt) const | |
198 | { | |
c3a4297c | 199 | return m_x == pt.m_x && m_y == pt.m_y; |
72e7876b SC |
200 | } |
201 | ||
202 | inline bool wxPoint2DDouble::operator!=(const wxPoint2DDouble& pt) const | |
203 | { | |
c3a4297c | 204 | return m_x != pt.m_x || m_y != pt.m_y; |
72e7876b SC |
205 | } |
206 | ||
207 | inline wxPoint2DDouble operator+(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2) | |
208 | { | |
c3a4297c | 209 | return wxPoint2DDouble( pt1.m_x + pt2.m_x , pt1.m_y + pt2.m_y ) ; |
72e7876b SC |
210 | } |
211 | ||
212 | inline wxPoint2DDouble operator-(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2) | |
213 | { | |
c3a4297c | 214 | return wxPoint2DDouble( pt1.m_x - pt2.m_x , pt1.m_y - pt2.m_y ) ; |
72e7876b SC |
215 | } |
216 | ||
217 | ||
218 | inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2) | |
219 | { | |
c3a4297c | 220 | return wxPoint2DDouble( pt1.m_x * pt2.m_x , pt1.m_y * pt2.m_y ) ; |
72e7876b SC |
221 | } |
222 | ||
223 | inline wxPoint2DDouble operator*(wxDouble n , const wxPoint2DDouble& pt) | |
224 | { | |
c3a4297c | 225 | return wxPoint2DDouble( pt.m_x * n , pt.m_y * n ) ; |
72e7876b SC |
226 | } |
227 | ||
228 | inline wxPoint2DDouble operator*(wxInt32 n , const wxPoint2DDouble& pt) | |
229 | { | |
c3a4297c | 230 | return wxPoint2DDouble( pt.m_x * n , pt.m_y * n ) ; |
72e7876b SC |
231 | } |
232 | ||
233 | inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxDouble n) | |
234 | { | |
c3a4297c | 235 | return wxPoint2DDouble( pt.m_x * n , pt.m_y * n ) ; |
72e7876b SC |
236 | } |
237 | ||
238 | inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxInt32 n) | |
239 | { | |
c3a4297c | 240 | return wxPoint2DDouble( pt.m_x * n , pt.m_y * n ) ; |
72e7876b SC |
241 | } |
242 | ||
243 | inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2) | |
244 | { | |
c3a4297c | 245 | return wxPoint2DDouble( pt1.m_x / pt2.m_x , pt1.m_y / pt2.m_y ) ; |
72e7876b SC |
246 | } |
247 | ||
248 | inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxDouble n) | |
249 | { | |
c3a4297c | 250 | return wxPoint2DDouble( pt.m_x / n , pt.m_y / n ) ; |
72e7876b SC |
251 | } |
252 | ||
253 | inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxInt32 n) | |
254 | { | |
c3a4297c | 255 | return wxPoint2DDouble( pt.m_x / n , pt.m_y / n ) ; |
72e7876b SC |
256 | } |
257 | ||
258 | // wxRect2Ds are a axis-aligned rectangles, each side of the rect is parallel to the x- or m_y- axis. The rectangle is either defined by the | |
259 | // top left and bottom right corner, or by the top left corner and size. A point is contained within the rectangle if | |
260 | // left <= x < right and top <= m_y < bottom , thus it is a half open interval. | |
261 | ||
262 | class WXDLLEXPORT wxRect2DDouble | |
263 | { | |
264 | public: | |
6c7873e1 RR |
265 | wxRect2DDouble() |
266 | { m_x = m_y = m_width = m_height = 0 ; } | |
267 | wxRect2DDouble(wxDouble x, wxDouble y, wxDouble w, wxDouble h) | |
268 | { m_x = x ; m_y = y ; m_width = w ; m_height = h ; } | |
269 | /* | |
270 | wxRect2DDouble(const wxPoint2DDouble& topLeft, const wxPoint2DDouble& bottomRight); | |
271 | wxRect2DDouble(const wxPoint2DDouble& pos, const wxSize& size); | |
272 | wxRect2DDouble(const wxRect2DDouble& rect); | |
273 | */ | |
c3a4297c VZ |
274 | // single attribute accessors |
275 | ||
6c7873e1 RR |
276 | inline wxPoint2DDouble GetPosition() |
277 | { return wxPoint2DDouble(m_x, m_y); } | |
278 | inline wxSize GetSize() | |
279 | { return wxSize(m_width, m_height); } | |
c3a4297c | 280 | |
6c7873e1 | 281 | // for the edge and corner accessors there are two setters conterparts, the Set.. functions keep the other corners at their |
c3a4297c VZ |
282 | // position whenever sensible, the Move.. functions keep the size of the rect and move the other corners apropriately |
283 | ||
6c7873e1 RR |
284 | inline wxDouble GetLeft() const { return m_x; } |
285 | inline void SetLeft( wxDouble n ) { m_width += m_x - n ; m_x = n ; } | |
286 | inline void MoveLeftTo( wxDouble n ) { m_x = n ; } | |
287 | inline wxDouble GetTop() const { return m_y; } | |
288 | inline void SetTop( wxDouble n ) { m_height += m_y - n ; m_y = n ; } | |
289 | inline void MoveTopTo( wxDouble n ) { m_y = n ; } | |
290 | inline wxDouble GetBottom() const { return m_y + m_height; } | |
291 | inline void SetBottom( wxDouble n ) { m_height += n - (m_y+m_height) ;} | |
292 | inline void MoveBottomTo( wxDouble n ) { m_y = n - m_height ; } | |
293 | inline wxDouble GetRight() const { return m_x + m_width; } | |
294 | inline void SetRight( wxDouble n ) { m_width += n - (m_x+m_width) ; } | |
295 | inline void MoveRightTo( wxDouble n ) { m_x = n - m_width ; } | |
296 | ||
297 | inline wxPoint2DDouble GetLeftTop() const | |
298 | { return wxPoint2DDouble( m_x , m_y ) ; } | |
299 | inline void SetLeftTop( const wxPoint2DDouble &pt ) | |
300 | { m_width += m_x - pt.m_x ; m_height += m_y - pt.m_y ; m_x = pt.m_x ; m_y = pt.m_y ; } | |
301 | inline void MoveLeftTopTo( const wxPoint2DDouble &pt ) | |
302 | { m_x = pt.m_x ; m_y = pt.m_y ; } | |
303 | inline wxPoint2DDouble GetLeftBottom() const | |
304 | { return wxPoint2DDouble( m_x , m_y + m_height ) ; } | |
305 | inline void SetLeftBottom( const wxPoint2DDouble &pt ) | |
306 | { m_width += m_x - pt.m_x ; m_height += pt.m_y - (m_y+m_height) ; m_x = pt.m_x ; } | |
307 | inline void MoveLeftBottomTo( const wxPoint2DDouble &pt ) | |
308 | { m_x = pt.m_x ; m_y = pt.m_y - m_height; } | |
309 | inline wxPoint2DDouble GetRightTop() const | |
310 | { return wxPoint2DDouble( m_x+m_width , m_y ) ; } | |
311 | inline void SetRightTop( const wxPoint2DDouble &pt ) | |
312 | { m_width += pt.m_x - ( m_x + m_width ) ; m_height += m_y - pt.m_y ; m_y = pt.m_y ; } | |
313 | inline void MoveRightTopTo( const wxPoint2DDouble &pt ) | |
314 | { m_x = pt.m_x - m_width ; m_y = pt.m_y ; } | |
315 | inline wxPoint2DDouble GetRightBottom() const | |
316 | { return wxPoint2DDouble( m_x+m_width , m_y + m_height ) ; } | |
317 | inline void SetRightBottom( const wxPoint2DDouble &pt ) | |
318 | { m_width += pt.m_x - ( m_x + m_width ) ; m_height += pt.m_y - (m_y+m_height) ;} | |
319 | inline void MoveRightBottomTo( const wxPoint2DDouble &pt ) | |
320 | { m_x = pt.m_x - m_width ; m_y = pt.m_y - m_height; } | |
321 | inline wxPoint2DDouble GetCentre() const | |
322 | { return wxPoint2DDouble( m_x+m_width/2 , m_y+m_height/2 ) ; } | |
323 | inline void SetCentre( const wxPoint2DDouble &pt ) | |
324 | { MoveCentreTo( pt ) ; } // since this is impossible without moving... | |
325 | inline void MoveCentreTo( const wxPoint2DDouble &pt ) | |
326 | { m_x += pt.m_x - (m_x+m_width/2) , m_y += pt.m_y -(m_y+m_height/2) ; } | |
327 | inline wxOutCode GetOutcode( const wxPoint2DDouble &pt ) const | |
328 | { return (wxOutCode) (( ( pt.m_x < m_x ) ? wxOutLeft : 0 ) + | |
c3a4297c VZ |
329 | ( ( pt.m_x >= m_x + m_width ) ? wxOutRight : 0 ) + |
330 | ( ( pt.m_y < m_y ) ? wxOutTop : 0 ) + | |
331 | ( ( pt.m_y >= m_y + m_height ) ? wxOutBottom : 0 )) ; } | |
6c7873e1 RR |
332 | inline bool Contains( const wxPoint2DDouble &pt ) const |
333 | { return GetOutcode( pt ) == wxInside ; } | |
334 | inline bool Contains( const wxRect2DDouble &rect ) const | |
335 | { return ( ( ( m_x <= rect.m_x ) && ( rect.m_x + rect.m_width <= m_x + m_width ) ) && | |
c3a4297c | 336 | ( ( m_y <= rect.m_y ) && ( rect.m_y + rect.m_height <= m_y + m_height ) ) ) ; } |
6c7873e1 RR |
337 | inline bool IsEmpty() const |
338 | { return ( m_width <= 0 || m_height <= 0 ) ; } | |
339 | inline bool HaveEqualSize( const wxRect2DDouble &rect ) const | |
340 | { return ( rect.m_width == m_width && rect.m_height == m_height ) ; } | |
341 | ||
342 | inline void Inset( wxDouble x , wxDouble y ) | |
343 | { m_x += x ; m_y += y ; m_width -= 2 * x ; m_height -= 2 * y ; } | |
344 | inline void Inset( wxDouble left , wxDouble top ,wxDouble right , wxDouble bottom ) | |
345 | { m_x += left ; m_y += top ; m_width -= left + right ; m_height -= top + bottom ;} | |
346 | inline void Offset( const wxPoint2DDouble &pt ) | |
347 | { m_x += pt.m_x ; m_y += pt.m_y ; } | |
c3a4297c | 348 | |
6c7873e1 RR |
349 | void ConstrainTo( const wxRect2DDouble &rect ); |
350 | ||
351 | inline wxPoint2DDouble Interpolate( wxInt32 widthfactor , wxInt32 heightfactor ) | |
352 | { return wxPoint2DDouble( m_x + m_width * widthfactor , m_y + m_height * heightfactor ) ; } | |
353 | ||
354 | static void Intersect( const wxRect2DDouble &src1 , const wxRect2DDouble &src2 , wxRect2DDouble *dest ) ; | |
355 | inline void Intersect( const wxRect2DDouble &otherRect ) | |
356 | { Intersect( *this , otherRect , this ) ; } | |
357 | inline wxRect2DDouble CreateIntersection( const wxRect2DDouble &otherRect ) const | |
358 | { wxRect2DDouble result ; Intersect( *this , otherRect , &result) ; return result ; } | |
359 | bool Intersects( const wxRect2DDouble &rect ) const ; | |
360 | ||
361 | static void Union( const wxRect2DDouble &src1 , const wxRect2DDouble &src2 , wxRect2DDouble *dest ) ; | |
362 | void Union( const wxRect2DDouble &otherRect ) | |
363 | { Union( *this , otherRect , this ) ; } | |
364 | void Union( const wxPoint2DDouble &pt ) ; | |
365 | inline wxRect2DDouble CreateUnion( const wxRect2DDouble &otherRect ) const | |
366 | { wxRect2DDouble result ; Union( *this , otherRect , &result) ; return result ; } | |
367 | ||
368 | inline void Scale( wxDouble f ) | |
369 | { m_x *= f ; m_y *= f ; m_width *= f ; m_height *= f ;} | |
370 | inline void Scale( wxInt32 num , wxInt32 denum ) | |
371 | { m_x *= ((wxDouble)num)/((wxDouble)denum) ; m_y *= ((wxDouble)num)/((wxDouble)denum) ; | |
c3a4297c VZ |
372 | m_width *= ((wxDouble)num)/((wxDouble)denum) ; m_height *= ((wxDouble)num)/((wxDouble)denum) ;} |
373 | ||
6c7873e1 RR |
374 | /* |
375 | wxRect2DDouble& operator = (const wxRect2DDouble& rect); | |
376 | bool operator == (const wxRect2DDouble& rect); | |
377 | bool operator != (const wxRect2DDouble& rect); | |
378 | */ | |
c3a4297c | 379 | |
6c7873e1 RR |
380 | wxDouble m_x; |
381 | wxDouble m_y ; | |
382 | wxDouble m_width; | |
383 | wxDouble m_height; | |
72e7876b SC |
384 | }; |
385 | ||
386 | class WXDLLEXPORT wxPoint2DInt | |
387 | { | |
388 | public : | |
c3a4297c VZ |
389 | wxPoint2DInt(); |
390 | wxPoint2DInt( wxInt32 x , wxInt32 y ) ; | |
391 | wxPoint2DInt( const wxPoint2DInt &pt ) ; | |
392 | wxPoint2DInt( const wxPoint &pt ) ; | |
393 | ||
394 | // two different conversions to integers, floor and rounding | |
395 | void GetFloor( wxInt32 *x , wxInt32 *y ) ; | |
396 | void GetRounded( wxInt32 *x , wxInt32 *y ) ; | |
397 | ||
398 | wxDouble GetVectorLength() ; | |
399 | wxDouble GetVectorAngle() ; | |
400 | void SetVectorLength( wxDouble length ) ; | |
401 | void SetVectorAngle( wxDouble degrees ) ; | |
402 | void SetPolarCoordinates( wxInt32 angle , wxInt32 length ) ; | |
403 | // set the vector length to 1.0, preserving the angle | |
404 | void Normalize() ; | |
405 | ||
406 | wxDouble GetDistance( const wxPoint2DInt &pt ) const ; | |
407 | wxDouble GetDistanceSquare( const wxPoint2DInt &pt ) const; | |
408 | wxInt32 GetDotProduct( const wxPoint2DInt &vec ) const; | |
409 | wxInt32 GetCrossProduct( const wxPoint2DInt &vec ) const; | |
410 | ||
411 | // the reflection of this point | |
412 | wxPoint2DInt operator-() ; | |
413 | ||
414 | wxPoint2DInt& operator=(const wxPoint2DInt& pt) ; | |
415 | wxPoint2DInt& operator+=(const wxPoint2DInt& pt) ; | |
416 | wxPoint2DInt& operator-=(const wxPoint2DInt& pt) ; | |
417 | wxPoint2DInt& operator*=(const wxPoint2DInt& pt) ; | |
418 | wxPoint2DInt& operator*=(wxDouble n) ; | |
419 | wxPoint2DInt& operator*=(wxInt32 n) ; | |
420 | wxPoint2DInt& operator/=(const wxPoint2DInt& pt) ; | |
421 | wxPoint2DInt& operator/=(wxDouble n) ; | |
422 | wxPoint2DInt& operator/=(wxInt32 n) ; | |
423 | operator wxPoint() const ; | |
424 | bool operator==(const wxPoint2DInt& pt) const ; | |
425 | bool operator!=(const wxPoint2DInt& pt) const ; | |
426 | ||
427 | void WriteTo( wxDataOutputStream &stream ) const ; | |
428 | void ReadFrom( wxDataInputStream &stream ) ; | |
429 | ||
430 | wxInt32 m_x ; | |
431 | wxInt32 m_y ; | |
72e7876b SC |
432 | } ; |
433 | ||
434 | wxPoint2DInt operator+(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2) ; | |
435 | wxPoint2DInt operator-(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2) ; | |
436 | wxPoint2DInt operator*(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2) ; | |
437 | wxPoint2DInt operator*(wxInt32 n , const wxPoint2DInt& pt) ; | |
438 | wxPoint2DInt operator*(wxInt32 n , const wxPoint2DInt& pt) ; | |
439 | wxPoint2DInt operator*(const wxPoint2DInt& pt , wxInt32 n) ; | |
440 | wxPoint2DInt operator*(const wxPoint2DInt& pt , wxInt32 n) ; | |
441 | wxPoint2DInt operator/(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2) ; | |
442 | wxPoint2DInt operator/(const wxPoint2DInt& pt , wxInt32 n) ; | |
443 | wxPoint2DInt operator/(const wxPoint2DInt& pt , wxInt32 n) ; | |
444 | ||
445 | inline wxPoint2DInt::wxPoint2DInt() | |
446 | { | |
c3a4297c VZ |
447 | m_x = 0 ; |
448 | m_y = 0 ; | |
72e7876b SC |
449 | } |
450 | ||
451 | inline wxPoint2DInt::wxPoint2DInt( wxInt32 x , wxInt32 y ) | |
452 | { | |
c3a4297c VZ |
453 | m_x = x ; |
454 | m_y = y ; | |
72e7876b SC |
455 | } |
456 | ||
457 | inline wxPoint2DInt::wxPoint2DInt( const wxPoint2DInt &pt ) | |
458 | { | |
c3a4297c VZ |
459 | m_x = pt.m_x ; |
460 | m_y = pt.m_y ; | |
72e7876b | 461 | } |
c3a4297c | 462 | |
72e7876b SC |
463 | inline wxPoint2DInt::wxPoint2DInt( const wxPoint &pt ) |
464 | { | |
c3a4297c VZ |
465 | m_x = pt.x ; |
466 | m_y = pt.y ; | |
72e7876b | 467 | } |
c3a4297c | 468 | |
72e7876b SC |
469 | inline void wxPoint2DInt::GetFloor( wxInt32 *x , wxInt32 *y ) |
470 | { | |
c3a4297c VZ |
471 | *x = (wxInt32) floor( m_x ) ; |
472 | *y = (wxInt32) floor( m_y ) ; | |
72e7876b SC |
473 | } |
474 | ||
475 | inline void wxPoint2DInt::GetRounded( wxInt32 *x , wxInt32 *y ) | |
476 | { | |
c3a4297c VZ |
477 | *x = (wxInt32) floor( m_x + 0.5 ) ; |
478 | *y = (wxInt32) floor( m_y + 0.5) ; | |
72e7876b SC |
479 | } |
480 | ||
481 | inline wxDouble wxPoint2DInt::GetVectorLength() | |
482 | { | |
c3a4297c | 483 | return sqrt( (m_x)*(m_x) + (m_y)*(m_y) ) ; |
72e7876b SC |
484 | } |
485 | ||
486 | inline void wxPoint2DInt::SetVectorLength( wxDouble length ) | |
487 | { | |
c3a4297c VZ |
488 | wxDouble before = GetVectorLength() ; |
489 | m_x = (wxInt32)(m_x * length / before) ; | |
490 | m_y = (wxInt32)(m_y * length / before) ; | |
72e7876b SC |
491 | } |
492 | ||
72e7876b SC |
493 | inline void wxPoint2DInt::Normalize() |
494 | { | |
c3a4297c | 495 | SetVectorLength( 1 ) ; |
72e7876b SC |
496 | } |
497 | ||
498 | inline wxDouble wxPoint2DInt::GetDistance( const wxPoint2DInt &pt ) const | |
499 | { | |
c3a4297c | 500 | return sqrt( GetDistanceSquare( pt ) ); |
72e7876b SC |
501 | } |
502 | ||
503 | inline wxDouble wxPoint2DInt::GetDistanceSquare( const wxPoint2DInt &pt ) const | |
504 | { | |
c3a4297c | 505 | return ( (pt.m_x-m_x)*(pt.m_x-m_x) + (pt.m_y-m_y)*(pt.m_y-m_y) ) ; |
72e7876b SC |
506 | } |
507 | ||
508 | inline wxInt32 wxPoint2DInt::GetDotProduct( const wxPoint2DInt &vec ) const | |
509 | { | |
c3a4297c | 510 | return ( m_x * vec.m_x + m_y * vec.m_y ) ; |
72e7876b SC |
511 | } |
512 | ||
513 | inline wxInt32 wxPoint2DInt::GetCrossProduct( const wxPoint2DInt &vec ) const | |
514 | { | |
c3a4297c | 515 | return ( m_x * vec.m_y - vec.m_x * m_y ) ; |
72e7876b SC |
516 | } |
517 | ||
518 | inline wxPoint2DInt::operator wxPoint() const | |
519 | { | |
c3a4297c | 520 | return wxPoint( m_x, m_y); |
72e7876b SC |
521 | } |
522 | ||
523 | inline wxPoint2DInt wxPoint2DInt::operator-() | |
524 | { | |
c3a4297c | 525 | return wxPoint2DInt( -m_x, -m_y); |
72e7876b SC |
526 | } |
527 | ||
528 | inline wxPoint2DInt& wxPoint2DInt::operator=(const wxPoint2DInt& pt) | |
529 | { | |
c3a4297c VZ |
530 | m_x = pt.m_x ; |
531 | m_y = pt.m_y; | |
532 | return *this ; | |
72e7876b SC |
533 | } |
534 | ||
535 | inline wxPoint2DInt& wxPoint2DInt::operator+=(const wxPoint2DInt& pt) | |
536 | { | |
c3a4297c VZ |
537 | m_x = m_x + pt.m_x ; |
538 | m_y = m_y + pt.m_y; | |
539 | return *this ; | |
72e7876b SC |
540 | } |
541 | ||
542 | inline wxPoint2DInt& wxPoint2DInt::operator-=(const wxPoint2DInt& pt) | |
543 | { | |
c3a4297c VZ |
544 | m_x = m_x - pt.m_x ; |
545 | m_y = m_y - pt.m_y; | |
546 | return *this ; | |
72e7876b SC |
547 | } |
548 | ||
549 | inline wxPoint2DInt& wxPoint2DInt::operator*=(const wxPoint2DInt& pt) | |
550 | { | |
c3a4297c VZ |
551 | m_x = m_x + pt.m_x ; |
552 | m_y = m_y + pt.m_y; | |
553 | return *this ; | |
72e7876b SC |
554 | } |
555 | ||
556 | inline wxPoint2DInt& wxPoint2DInt::operator/=(const wxPoint2DInt& pt) | |
557 | { | |
c3a4297c VZ |
558 | m_x = m_x - pt.m_x ; |
559 | m_y = m_y - pt.m_y; | |
560 | return *this ; | |
72e7876b SC |
561 | } |
562 | ||
563 | inline bool wxPoint2DInt::operator==(const wxPoint2DInt& pt) const | |
564 | { | |
c3a4297c | 565 | return m_x == pt.m_x && m_y == pt.m_y; |
72e7876b SC |
566 | } |
567 | ||
568 | inline bool wxPoint2DInt::operator!=(const wxPoint2DInt& pt) const | |
569 | { | |
c3a4297c | 570 | return m_x != pt.m_x || m_y != pt.m_y; |
72e7876b SC |
571 | } |
572 | ||
573 | inline wxPoint2DInt operator+(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2) | |
574 | { | |
c3a4297c | 575 | return wxPoint2DInt( pt1.m_x + pt2.m_x , pt1.m_y + pt2.m_y ) ; |
72e7876b SC |
576 | } |
577 | ||
578 | inline wxPoint2DInt operator-(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2) | |
579 | { | |
c3a4297c | 580 | return wxPoint2DInt( pt1.m_x - pt2.m_x , pt1.m_y - pt2.m_y ) ; |
72e7876b SC |
581 | } |
582 | ||
583 | ||
584 | inline wxPoint2DInt operator*(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2) | |
585 | { | |
c3a4297c | 586 | return wxPoint2DInt( pt1.m_x * pt2.m_x , pt1.m_y * pt2.m_y ) ; |
72e7876b SC |
587 | } |
588 | ||
589 | inline wxPoint2DInt operator*(wxInt32 n , const wxPoint2DInt& pt) | |
590 | { | |
c3a4297c | 591 | return wxPoint2DInt( pt.m_x * n , pt.m_y * n ) ; |
72e7876b SC |
592 | } |
593 | ||
594 | inline wxPoint2DInt operator*(wxDouble n , const wxPoint2DInt& pt) | |
595 | { | |
c3a4297c | 596 | return wxPoint2DInt( pt.m_x * n , pt.m_y * n ) ; |
72e7876b SC |
597 | } |
598 | ||
599 | inline wxPoint2DInt operator*(const wxPoint2DInt& pt , wxInt32 n) | |
600 | { | |
c3a4297c | 601 | return wxPoint2DInt( pt.m_x * n , pt.m_y * n ) ; |
72e7876b SC |
602 | } |
603 | ||
604 | inline wxPoint2DInt operator*(const wxPoint2DInt& pt , wxDouble n) | |
605 | { | |
c3a4297c | 606 | return wxPoint2DInt( pt.m_x * n , pt.m_y * n ) ; |
72e7876b SC |
607 | } |
608 | ||
609 | inline wxPoint2DInt operator/(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2) | |
610 | { | |
c3a4297c | 611 | return wxPoint2DInt( pt1.m_x / pt2.m_x , pt1.m_y / pt2.m_y ) ; |
72e7876b SC |
612 | } |
613 | ||
614 | inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxInt32 n) | |
615 | { | |
c3a4297c | 616 | return wxPoint2DInt( pt.m_x / n , pt.m_y / n ) ; |
72e7876b SC |
617 | } |
618 | ||
619 | inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxDouble n) | |
620 | { | |
c3a4297c | 621 | return wxPoint2DInt( pt.m_x / n , pt.m_y / n ) ; |
72e7876b SC |
622 | } |
623 | ||
624 | // wxRect2Ds are a axis-aligned rectangles, each side of the rect is parallel to the x- or m_y- axis. The rectangle is either defined by the | |
625 | // top left and bottom right corner, or by the top left corner and size. A point is contained within the rectangle if | |
626 | // left <= x < right and top <= m_y < bottom , thus it is a half open interval. | |
627 | ||
628 | class WXDLLEXPORT wxRect2DInt | |
629 | { | |
630 | public: | |
c3a4297c VZ |
631 | wxRect2DInt() { m_x = m_y = m_width = m_height = 0 ; } |
632 | wxRect2DInt(wxInt32 x, wxInt32 y, wxInt32 w, wxInt32 h) { m_x = x ; m_y = y ; m_width = w ; m_height = h ; } | |
633 | wxRect2DInt(const wxPoint2DInt& topLeft, const wxPoint2DInt& bottomRight); | |
634 | wxRect2DInt(const wxPoint2DInt& pos, const wxSize& size); | |
635 | wxRect2DInt(const wxRect2DInt& rect); | |
636 | ||
637 | // single attribute accessors | |
638 | ||
639 | inline wxPoint2DInt GetPosition() { return wxPoint2DInt(m_x, m_y); } | |
640 | inline wxSize GetSize() { return wxSize(m_width, m_height); } | |
641 | ||
642 | // for the edge and corner accessors there are two setters conterparts, the Set.. functions keep the other corners at their | |
643 | // position whenever sensible, the Move.. functions keep the size of the rect and move the other corners apropriately | |
644 | ||
645 | inline wxInt32 GetLeft() const { return m_x; } | |
646 | inline void SetLeft( wxInt32 n ) { m_width += m_x - n ; m_x = n ; } | |
647 | inline void MoveLeftTo( wxInt32 n ) { m_x = n ; } | |
648 | inline wxInt32 GetTop() const { return m_y; } | |
649 | inline void SetTop( wxInt32 n ) { m_height += m_y - n ; m_y = n ; } | |
650 | inline void MoveTopTo( wxInt32 n ) { m_y = n ; } | |
651 | inline wxInt32 GetBottom() const { return m_y + m_height; } | |
652 | inline void SetBottom( wxInt32 n ) { m_height += n - (m_y+m_height) ;} | |
653 | inline void MoveBottomTo( wxInt32 n ) { m_y = n - m_height ; } | |
654 | inline wxInt32 GetRight() const { return m_x + m_width; } | |
655 | inline void SetRight( wxInt32 n ) { m_width += n - (m_x+m_width) ; } | |
656 | inline void MoveRightTo( wxInt32 n ) { m_x = n - m_width ; } | |
657 | ||
658 | inline wxPoint2DInt GetLeftTop() const { return wxPoint2DInt( m_x , m_y ) ; } | |
659 | inline void SetLeftTop( const wxPoint2DInt &pt ) { m_width += m_x - pt.m_x ; m_height += m_y - pt.m_y ; m_x = pt.m_x ; m_y = pt.m_y ; } | |
660 | inline void MoveLeftTopTo( const wxPoint2DInt &pt ) { m_x = pt.m_x ; m_y = pt.m_y ; } | |
661 | inline wxPoint2DInt GetLeftBottom() const { return wxPoint2DInt( m_x , m_y + m_height ) ; } | |
662 | inline void SetLeftBottom( const wxPoint2DInt &pt ) { m_width += m_x - pt.m_x ; m_height += pt.m_y - (m_y+m_height) ; m_x = pt.m_x ; } | |
663 | inline void MoveLeftBottomTo( const wxPoint2DInt &pt ) { m_x = pt.m_x ; m_y = pt.m_y - m_height; } | |
664 | inline wxPoint2DInt GetRightTop() const { return wxPoint2DInt( m_x+m_width , m_y ) ; } | |
665 | inline void SetRightTop( const wxPoint2DInt &pt ) { m_width += pt.m_x - ( m_x + m_width ) ; m_height += m_y - pt.m_y ; m_y = pt.m_y ; } | |
666 | inline void MoveRightTopTo( const wxPoint2DInt &pt ) { m_x = pt.m_x - m_width ; m_y = pt.m_y ; } | |
667 | inline wxPoint2DInt GetRightBottom() const { return wxPoint2DInt( m_x+m_width , m_y + m_height ) ; } | |
668 | inline void SetRightBottom( const wxPoint2DInt &pt ) { m_width += pt.m_x - ( m_x + m_width ) ; m_height += pt.m_y - (m_y+m_height) ;} | |
669 | inline void MoveRightBottomTo( const wxPoint2DInt &pt ) { m_x = pt.m_x - m_width ; m_y = pt.m_y - m_height; } | |
670 | inline wxPoint2DInt GetCentre() const { return wxPoint2DInt( m_x+m_width/2 , m_y+m_height/2 ) ; } | |
671 | inline void SetCentre( const wxPoint2DInt &pt ) { MoveCentreTo( pt ) ; } // since this is impossible without moving... | |
672 | inline void MoveCentreTo( const wxPoint2DInt &pt ) { m_x += pt.m_x - (m_x+m_width/2) , m_y += pt.m_y -(m_y+m_height/2) ; } | |
673 | inline wxOutCode GetOutcode( const wxPoint2DInt &pt ) const | |
674 | { return (wxOutCode) (( ( pt.m_x < m_x ) ? wxOutLeft : 0 ) + | |
675 | ( ( pt.m_x >= m_x + m_width ) ? wxOutRight : 0 ) + | |
676 | ( ( pt.m_y < m_y ) ? wxOutTop : 0 ) + | |
677 | ( ( pt.m_y >= m_y + m_height ) ? wxOutBottom : 0 )) ; } | |
678 | inline bool Contains( const wxPoint2DInt &pt ) const | |
679 | { return GetOutcode( pt ) == wxInside ; } | |
680 | inline bool Contains( const wxRect2DInt &rect ) const | |
681 | { return ( ( ( m_x <= rect.m_x ) && ( rect.m_x + rect.m_width <= m_x + m_width ) ) && | |
682 | ( ( m_y <= rect.m_y ) && ( rect.m_y + rect.m_height <= m_y + m_height ) ) ) ; } | |
683 | inline bool IsEmpty() const | |
684 | { return ( m_width <= 0 || m_height <= 0 ) ; } | |
685 | inline bool HaveEqualSize( const wxRect2DInt &rect ) const | |
686 | { return ( rect.m_width == m_width && rect.m_height == m_height ) ; } | |
687 | ||
688 | inline void Inset( wxInt32 x , wxInt32 y ) { m_x += x ; m_y += y ; m_width -= 2 * x ; m_height -= 2 * y ; } | |
689 | inline void Inset( wxInt32 left , wxInt32 top ,wxInt32 right , wxInt32 bottom ) | |
690 | { m_x += left ; m_y += top ; m_width -= left + right ; m_height -= top + bottom ;} | |
691 | inline void Offset( const wxPoint2DInt &pt ) { m_x += pt.m_x ; m_y += pt.m_y ; } | |
692 | void ConstrainTo( const wxRect2DInt &rect ) ; | |
693 | inline wxPoint2DInt Interpolate( wxInt32 widthfactor , wxInt32 heightfactor ) { return wxPoint2DInt( m_x + m_width * widthfactor , m_y + m_height * heightfactor ) ; } | |
694 | ||
695 | static void Intersect( const wxRect2DInt &src1 , const wxRect2DInt &src2 , wxRect2DInt *dest ) ; | |
696 | inline void Intersect( const wxRect2DInt &otherRect ) { Intersect( *this , otherRect , this ) ; } | |
697 | inline wxRect2DInt CreateIntersection( const wxRect2DInt &otherRect ) const { wxRect2DInt result ; Intersect( *this , otherRect , &result) ; return result ; } | |
698 | bool Intersects( const wxRect2DInt &rect ) const ; | |
699 | ||
700 | static void Union( const wxRect2DInt &src1 , const wxRect2DInt &src2 , wxRect2DInt *dest ) ; | |
701 | void Union( const wxRect2DInt &otherRect ) { Union( *this , otherRect , this ) ; } | |
702 | void Union( const wxPoint2DInt &pt ) ; | |
703 | inline wxRect2DInt CreateUnion( const wxRect2DInt &otherRect ) const { wxRect2DInt result ; Union( *this , otherRect , &result) ; return result ; } | |
704 | ||
705 | inline void Scale( wxInt32 f ) { m_x *= f ; m_y *= f ; m_width *= f ; m_height *= f ;} | |
706 | inline void Scale( wxInt32 num , wxInt32 denum ) | |
707 | { m_x *= ((wxInt32)num)/((wxInt32)denum) ; m_y *= ((wxInt32)num)/((wxInt32)denum) ; | |
708 | m_width *= ((wxInt32)num)/((wxInt32)denum) ; m_height *= ((wxInt32)num)/((wxInt32)denum) ;} | |
709 | ||
710 | wxRect2DInt& operator = (const wxRect2DInt& rect); | |
711 | bool operator == (const wxRect2DInt& rect); | |
712 | bool operator != (const wxRect2DInt& rect); | |
713 | ||
714 | void WriteTo( wxDataOutputStream &stream ) const ; | |
715 | void ReadFrom( wxDataInputStream &stream ) ; | |
716 | ||
717 | wxInt32 m_x ; | |
718 | wxInt32 m_y ; | |
719 | wxInt32 m_width; | |
720 | wxInt32 m_height; | |
72e7876b SC |
721 | }; |
722 | ||
723 | inline wxRect2DInt::wxRect2DInt( const wxRect2DInt &r ) | |
724 | { | |
c3a4297c VZ |
725 | m_x = r.m_x ; |
726 | m_y = r.m_y ; | |
727 | m_width = r.m_width ; | |
728 | m_height = r.m_height ; | |
72e7876b | 729 | } |
c3a4297c | 730 | |
72e7876b SC |
731 | inline wxRect2DInt::wxRect2DInt( const wxPoint2DInt &a , const wxPoint2DInt &b) |
732 | { | |
c3a4297c VZ |
733 | m_x = wxMin( a.m_x , b.m_x ) ; |
734 | m_y = wxMin( a.m_y , b.m_y ) ; | |
735 | m_width = abs( a.m_x - b.m_x ) ; | |
736 | m_height = abs( a.m_y - b.m_y ) ; | |
72e7876b SC |
737 | } |
738 | ||
739 | class wxTransform2D | |
740 | { | |
741 | public : | |
c3a4297c VZ |
742 | virtual void Transform( wxPoint2DInt* pt )const = 0 ; |
743 | virtual void Transform( wxRect2DInt* r ) const ; | |
744 | virtual wxPoint2DInt Transform( const wxPoint2DInt &pt ) const ; | |
745 | virtual wxRect2DInt Transform( const wxRect2DInt &r ) const ; | |
746 | ||
747 | virtual void InverseTransform( wxPoint2DInt* pt ) const = 0; | |
748 | virtual void InverseTransform( wxRect2DInt* r ) const ; | |
749 | virtual wxPoint2DInt InverseTransform( const wxPoint2DInt &pt ) const ; | |
750 | virtual wxRect2DInt InverseTransform( const wxRect2DInt &r ) const ; | |
72e7876b SC |
751 | } ; |
752 | ||
c3a4297c | 753 | inline void wxTransform2D::Transform( wxRect2DInt* r ) const |
72e7876b SC |
754 | { wxPoint2DInt a = r->GetLeftTop() , b = r->GetRightBottom() ; Transform( &a ) ; Transform( &b ) ; *r = wxRect2DInt( a , b ) ; } |
755 | ||
c3a4297c | 756 | inline wxPoint2DInt wxTransform2D::Transform( const wxPoint2DInt &pt ) const |
72e7876b SC |
757 | { wxPoint2DInt res = pt ; Transform( &res ) ; return res ; } |
758 | ||
c3a4297c | 759 | inline wxRect2DInt wxTransform2D::Transform( const wxRect2DInt &r ) const |
72e7876b SC |
760 | { wxRect2DInt res = r ; Transform( &res ) ; return res ; } |
761 | ||
c3a4297c | 762 | inline void wxTransform2D::InverseTransform( wxRect2DInt* r ) const |
72e7876b SC |
763 | { wxPoint2DInt a = r->GetLeftTop() , b = r->GetRightBottom() ; InverseTransform( &a ) ; InverseTransform( &b ) ; *r = wxRect2DInt( a , b ) ; } |
764 | ||
c3a4297c | 765 | inline wxPoint2DInt wxTransform2D::InverseTransform( const wxPoint2DInt &pt ) const |
72e7876b SC |
766 | { wxPoint2DInt res = pt ; InverseTransform( &res ) ; return res ; } |
767 | ||
c3a4297c | 768 | inline wxRect2DInt wxTransform2D::InverseTransform( const wxRect2DInt &r ) const |
72e7876b SC |
769 | { wxRect2DInt res = r ; InverseTransform( &res ) ; return res ; } |
770 | ||
c3a4297c VZ |
771 | |
772 | #endif // wxUSE_GEOMETRY | |
773 | ||
774 | #endif // _WX_GEOMETRY_H_ |