]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/geometry.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of geometry classes
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
24 wxPoint2DInt( wxInt32 x
, wxInt32 y
);
25 wxPoint2DInt( const wxPoint2DInt
&pt
);
26 wxPoint2DInt( const wxPoint
&pt
);
28 // noops for this class, just return the coords
29 void GetFloor( wxInt32
*x
, wxInt32
*y
) const;
30 void GetRounded( wxInt32
*x
, wxInt32
*y
) const;
32 wxDouble
GetVectorLength() const;
33 wxDouble
GetVectorAngle() const;
34 void SetVectorLength( wxDouble length
);
35 void SetVectorAngle( wxDouble degrees
);
36 void SetPolarCoordinates( wxInt32 angle
, wxInt32 length
);
37 // set the vector length to 1.0, preserving the angle
40 wxDouble
GetDistance( const wxPoint2DInt
&pt
) const;
41 wxDouble
GetDistanceSquare( const wxPoint2DInt
&pt
) const;
42 wxInt32
GetDotProduct( const wxPoint2DInt
&vec
) const;
43 wxInt32
GetCrossProduct( const wxPoint2DInt
&vec
) const;
45 // the reflection of this point
46 wxPoint2DInt
operator-();
48 wxPoint2DInt
& operator=(const wxPoint2DInt
& pt
);
49 wxPoint2DInt
& operator+=(const wxPoint2DInt
& pt
);
50 wxPoint2DInt
& operator-=(const wxPoint2DInt
& pt
);
51 wxPoint2DInt
& operator*=(const wxPoint2DInt
& pt
);
52 wxPoint2DInt
& operator*=(wxDouble n
);
53 wxPoint2DInt
& operator*=(wxInt32 n
);
54 wxPoint2DInt
& operator/=(const wxPoint2DInt
& pt
);
55 wxPoint2DInt
& operator/=(wxDouble n
);
56 wxPoint2DInt
& operator/=(wxInt32 n
);
57 operator wxPoint() const;
58 bool operator==(const wxPoint2DInt
& pt
) const;
59 bool operator!=(const wxPoint2DInt
& pt
) const;
65 wxPoint2DInt
operator+(const wxPoint2DInt
& pt1
, const wxPoint2DInt
& pt2
);
66 wxPoint2DInt
operator-(const wxPoint2DInt
& pt1
, const wxPoint2DInt
& pt2
);
67 wxPoint2DInt
operator*(const wxPoint2DInt
& pt1
, const wxPoint2DInt
& pt2
);
68 wxPoint2DInt
operator*(wxInt32 n
, const wxPoint2DInt
& pt
);
69 wxPoint2DInt
operator*(wxInt32 n
, const wxPoint2DInt
& pt
);
70 wxPoint2DInt
operator*(const wxPoint2DInt
& pt
, wxInt32 n
);
71 wxPoint2DInt
operator*(const wxPoint2DInt
& pt
, wxInt32 n
);
72 wxPoint2DInt
operator/(const wxPoint2DInt
& pt1
, const wxPoint2DInt
& pt2
);
73 wxPoint2DInt
operator/(const wxPoint2DInt
& pt
, wxInt32 n
);
74 wxPoint2DInt
operator/(const wxPoint2DInt
& pt
, wxInt32 n
);
77 // wxPoint2Ds represent a point or a vector in a 2d coordinate system
83 wxPoint2DDouble( wxDouble x
, wxDouble y
);
84 wxPoint2DDouble( const wxPoint2DDouble
&pt
);
85 wxPoint2DDouble( const wxPoint2DInt
&pt
);
86 wxPoint2DDouble( const wxPoint
&pt
);
88 // two different conversions to integers, floor and rounding
89 void GetFloor( wxInt32
*x
, wxInt32
*y
) const;
90 void GetRounded( wxInt32
*x
, wxInt32
*y
) const;
92 wxDouble
GetVectorLength() const;
93 wxDouble
GetVectorAngle() const ;
94 void SetVectorLength( wxDouble length
);
95 void SetVectorAngle( wxDouble degrees
);
96 void SetPolarCoordinates( wxDouble angle
, wxDouble length
);
97 // set the vector length to 1.0, preserving the angle
100 wxDouble
GetDistance( const wxPoint2DDouble
&pt
) const;
101 wxDouble
GetDistanceSquare( const wxPoint2DDouble
&pt
) const;
102 wxDouble
GetDotProduct( const wxPoint2DDouble
&vec
) const;
103 wxDouble
GetCrossProduct( const wxPoint2DDouble
&vec
) const;
105 // the reflection of this point
106 wxPoint2DDouble
operator-();
108 wxPoint2DDouble
& operator=(const wxPoint2DDouble
& pt
);
109 wxPoint2DDouble
& operator+=(const wxPoint2DDouble
& pt
);
110 wxPoint2DDouble
& operator-=(const wxPoint2DDouble
& pt
);
111 wxPoint2DDouble
& operator*=(const wxPoint2DDouble
& pt
);
112 wxPoint2DDouble
& operator*=(wxDouble n
);
113 wxPoint2DDouble
& operator*=(wxInt32 n
);
114 wxPoint2DDouble
& operator/=(const wxPoint2DDouble
& pt
);
115 wxPoint2DDouble
& operator/=(wxDouble n
);
116 wxPoint2DDouble
& operator/=(wxInt32 n
);
118 bool operator==(const wxPoint2DDouble
& pt
) const;
119 bool operator!=(const wxPoint2DDouble
& pt
) const;
125 wxPoint2DDouble
operator+(const wxPoint2DDouble
& pt1
, const wxPoint2DDouble
& pt2
);
126 wxPoint2DDouble
operator-(const wxPoint2DDouble
& pt1
, const wxPoint2DDouble
& pt2
);
127 wxPoint2DDouble
operator*(const wxPoint2DDouble
& pt1
, const wxPoint2DDouble
& pt2
);
128 wxPoint2DDouble
operator*(wxDouble n
, const wxPoint2DDouble
& pt
);
129 wxPoint2DDouble
operator*(wxInt32 n
, const wxPoint2DDouble
& pt
);
130 wxPoint2DDouble
operator*(const wxPoint2DDouble
& pt
, wxDouble n
);
131 wxPoint2DDouble
operator*(const wxPoint2DDouble
& pt
, wxInt32 n
);
132 wxPoint2DDouble
operator/(const wxPoint2DDouble
& pt1
, const wxPoint2DDouble
& pt2
);
133 wxPoint2DDouble
operator/(const wxPoint2DDouble
& pt
, wxDouble n
);
134 wxPoint2DDouble
operator/(const wxPoint2DDouble
& pt
, wxInt32 n
);
138 // 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
139 // top left and bottom right corner, or by the top left corner and size. A point is contained within the rectangle if
140 // left <= x < right and top <= m_y < bottom , thus it is a half open interval.
146 wxRect2DDouble(wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
148 // single attribute accessors
150 wxPoint2DDouble
GetPosition();
153 // for the edge and corner accessors there are two setters counterparts, the Set.. functions keep the other corners at their
154 // position whenever sensible, the Move.. functions keep the size of the rect and move the other corners appropriately
156 wxDouble
GetLeft() const;
157 void SetLeft( wxDouble n
);
158 void MoveLeftTo( wxDouble n
);
159 wxDouble
GetTop() const;
160 void SetTop( wxDouble n
);
161 void MoveTopTo( wxDouble n
);
162 wxDouble
GetBottom() const;
163 void SetBottom( wxDouble n
);
164 void MoveBottomTo( wxDouble n
);
165 wxDouble
GetRight() const;
166 void SetRight( wxDouble n
);
167 void MoveRightTo( wxDouble n
);
169 wxPoint2DDouble
GetLeftTop() const;
170 void SetLeftTop( const wxPoint2DDouble
&pt
);
171 void MoveLeftTopTo( const wxPoint2DDouble
&pt
);
172 wxPoint2DDouble
GetLeftBottom() const;
173 void SetLeftBottom( const wxPoint2DDouble
&pt
);
174 void MoveLeftBottomTo( const wxPoint2DDouble
&pt
);
175 wxPoint2DDouble
GetRightTop() const;
176 void SetRightTop( const wxPoint2DDouble
&pt
);
177 void MoveRightTopTo( const wxPoint2DDouble
&pt
);
178 wxPoint2DDouble
GetRightBottom() const;
179 void SetRightBottom( const wxPoint2DDouble
&pt
);
180 void MoveRightBottomTo( const wxPoint2DDouble
&pt
);
181 wxPoint2DDouble
GetCentre() const;
182 void SetCentre( const wxPoint2DDouble
&pt
);
183 void MoveCentreTo( const wxPoint2DDouble
&pt
);
184 wxOutCode
GetOutCode( const wxPoint2DDouble
&pt
) const;
185 wxOutCode
GetOutcode(const wxPoint2DDouble
&pt
) const;
186 bool Contains( const wxPoint2DDouble
&pt
) const;
187 bool Contains( const wxRect2DDouble
&rect
) const;
188 bool IsEmpty() const;
189 bool HaveEqualSize( const wxRect2DDouble
&rect
) const;
191 void Inset( wxDouble x
, wxDouble y
);
192 void Inset( wxDouble left
, wxDouble top
,wxDouble right
, wxDouble bottom
);
193 void Offset( const wxPoint2DDouble
&pt
);
195 void ConstrainTo( const wxRect2DDouble
&rect
);
197 wxPoint2DDouble
Interpolate( wxInt32 widthfactor
, wxInt32 heightfactor
);
199 static void Intersect( const wxRect2DDouble
&src1
, const wxRect2DDouble
&src2
, wxRect2DDouble
*dest
);
200 void Intersect( const wxRect2DDouble
&otherRect
);
201 wxRect2DDouble
CreateIntersection( const wxRect2DDouble
&otherRect
) const;
202 bool Intersects( const wxRect2DDouble
&rect
) const;
204 static void Union( const wxRect2DDouble
&src1
, const wxRect2DDouble
&src2
, wxRect2DDouble
*dest
);
205 void Union( const wxRect2DDouble
&otherRect
);
206 void Union( const wxPoint2DDouble
&pt
);
207 wxRect2DDouble
CreateUnion( const wxRect2DDouble
&otherRect
) const;
209 void Scale( wxDouble f
);
210 void Scale( wxInt32 num
, wxInt32 denum
);
212 wxRect2DDouble
& operator = (const wxRect2DDouble
& rect
);
213 bool operator == (const wxRect2DDouble
& rect
) const;
214 bool operator != (const wxRect2DDouble
& rect
) const;
225 // 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
226 // top left and bottom right corner, or by the top left corner and size. A point is contained within the rectangle if
227 // left <= x < right and top <= m_y < bottom , thus it is a half open interval.
233 wxRect2DInt( const wxRect
& r
);
234 wxRect2DInt(wxInt32 x
, wxInt32 y
, wxInt32 w
, wxInt32 h
);
235 wxRect2DInt(const wxPoint2DInt
& topLeft
, const wxPoint2DInt
& bottomRight
);
236 wxRect2DInt(const wxPoint2DInt
& pos
, const wxSize
& size
);
237 wxRect2DInt(const wxRect2DInt
& rect
);
239 // single attribute accessors
241 wxPoint2DInt
GetPosition();
244 // for the edge and corner accessors there are two setters counterparts, the Set.. functions keep the other corners at their
245 // position whenever sensible, the Move.. functions keep the size of the rect and move the other corners appropriately
247 wxInt32
GetLeft() const;
248 void SetLeft( wxInt32 n
);
249 void MoveLeftTo( wxInt32 n
);
250 wxInt32
GetTop() const;
251 void SetTop( wxInt32 n
);
252 void MoveTopTo( wxInt32 n
);
253 wxInt32
GetBottom() const;
254 void SetBottom( wxInt32 n
);
255 void MoveBottomTo( wxInt32 n
);
256 wxInt32
GetRight() const;
257 void SetRight( wxInt32 n
);
258 void MoveRightTo( wxInt32 n
);
260 wxPoint2DInt
GetLeftTop() const;
261 void SetLeftTop( const wxPoint2DInt
&pt
) ;
262 void MoveLeftTopTo( const wxPoint2DInt
&pt
) ;
263 wxPoint2DInt
GetLeftBottom() const ;
264 void SetLeftBottom( const wxPoint2DInt
&pt
) ;
265 void MoveLeftBottomTo( const wxPoint2DInt
&pt
) ;
266 wxPoint2DInt
GetRightTop() const ;
267 void SetRightTop( const wxPoint2DInt
&pt
) ;
268 void MoveRightTopTo( const wxPoint2DInt
&pt
) ;
269 wxPoint2DInt
GetRightBottom() const ;
270 void SetRightBottom( const wxPoint2DInt
&pt
) ;
271 void MoveRightBottomTo( const wxPoint2DInt
&pt
) ;
272 wxPoint2DInt
GetCentre() const ;
273 void SetCentre( const wxPoint2DInt
&pt
) ;
274 void MoveCentreTo( const wxPoint2DInt
&pt
) ;
275 wxOutCode
GetOutCode( const wxPoint2DInt
&pt
) const;
276 wxOutCode
GetOutcode( const wxPoint2DInt
&pt
) const;
277 bool Contains( const wxPoint2DInt
&pt
) const;
278 bool Contains( const wxRect2DInt
&rect
) const;
279 bool IsEmpty() const;
280 bool HaveEqualSize( const wxRect2DInt
&rect
) const;
282 void Inset( wxInt32 x
, wxInt32 y
);
283 void Inset( wxInt32 left
, wxInt32 top
,wxInt32 right
, wxInt32 bottom
);
284 void Offset( const wxPoint2DInt
&pt
);
285 void ConstrainTo( const wxRect2DInt
&rect
);
286 wxPoint2DInt
Interpolate( wxInt32 widthfactor
, wxInt32 heightfactor
);
288 static void Intersect( const wxRect2DInt
&src1
, const wxRect2DInt
&src2
, wxRect2DInt
*dest
);
289 void Intersect( const wxRect2DInt
&otherRect
);
290 wxRect2DInt
CreateIntersection( const wxRect2DInt
&otherRect
) const;
291 bool Intersects( const wxRect2DInt
&rect
) const;
293 static void Union( const wxRect2DInt
&src1
, const wxRect2DInt
&src2
, wxRect2DInt
*dest
);
294 void Union( const wxRect2DInt
&otherRect
);
295 void Union( const wxPoint2DInt
&pt
);
296 wxRect2DInt
CreateUnion( const wxRect2DInt
&otherRect
) const;
298 void Scale( wxInt32 f
);
299 void Scale( wxInt32 num
, wxInt32 denum
);
301 wxRect2DInt
& operator = (const wxRect2DInt
& rect
);
302 bool operator == (const wxRect2DInt
& rect
) const;
303 bool operator != (const wxRect2DInt
& rect
) const;
319 virtual ~wxTransform2D() { }
320 virtual void Transform( wxPoint2DInt
* pt
)const = 0;
321 virtual void Transform( wxRect2DInt
* r
) const;
322 virtual wxPoint2DInt
Transform( const wxPoint2DInt
&pt
) const;
323 virtual wxRect2DInt
Transform( const wxRect2DInt
&r
) const ;
325 virtual void InverseTransform( wxPoint2DInt
* pt
) const = 0;
326 virtual void InverseTransform( wxRect2DInt
* r
) const ;
327 virtual wxPoint2DInt
InverseTransform( const wxPoint2DInt
&pt
) const ;
328 virtual wxRect2DInt
InverseTransform( const wxRect2DInt
&r
) const ;