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