fx_coordinates.h
Go to the documentation of this file.
1 
15 //<<<+++OPENSOURCE
16 //<<<+++OPENSOURCE_LICENSE
17 //<<<+++OPENSOURCE_BEGIN LIC==FOXIT||LIC==GOOGLE
18 
24 //<<<+++OPENSOURCE_MUST_BEGIN
25 #ifndef _FXCRT_COORDINATES_
26 #define _FXCRT_COORDINATES_
27 //<<<+++OPENSOURCE_MUST_END
28 
29 //internal classes
30 template<class baseType> class CFX_PSVTemplate;
31 template<class baseType> class CFX_VTemplate;
32 template<class baseType> class CFX_PRLTemplate;
33 template<class baseType> class CFX_RTemplate;
34 template<class baseType> class CFX_ETemplate;
35 template<class baseType> class CFX_ATemplate;
36 template<class baseType> class CFX_RRTemplate;
37 class CFX_Matrix;
38 
39 //*****************************************************************************
40 //* Point/Size
41 //*****************************************************************************
42 template<class BaseType>
43 class CFX_PSVTemplate : public CFX_Object
44 {
45  public:
46  typedef CFX_PSVTemplate<BaseType> FXT_PSV;
47 // typedef CFX_PSVTemplate<baseType> FXT_POINT;
48 // typedef CFX_PSVTemplate<baseType> FXT_SIZE;
49 
50  CFX_PSVTemplate() : x(0), y(0) {}
51  CFX_PSVTemplate(BaseType new_x, BaseType new_y) : x(new_x), y(new_y) {}
52  CFX_PSVTemplate(const CFX_PSVTemplate& other) : x(other.x), y(other.y) {}
53 
54  void Set(BaseType x, BaseType y) {FXT_PSV::x = x, FXT_PSV::y = y;}
55  void Set(const FXT_PSV &psv) {FXT_PSV::x = psv.x, FXT_PSV::y = psv.y;}
56  void Add(BaseType x, BaseType y) {FXT_PSV::x += x, FXT_PSV::y += y;}
57  void Subtract(BaseType x, BaseType y) {FXT_PSV::x -= x, FXT_PSV::y -= y;}
58  void Reset() {FXT_PSV::x = FXT_PSV::y = 0;}
59 
60  FXT_PSV& operator += (const FXT_PSV &obj) {x += obj.x; y += obj.y; return *this;}
61  FXT_PSV& operator -= (const FXT_PSV &obj) {x -= obj.x; y -= obj.y; return *this;}
62  FXT_PSV& operator *= (BaseType lamda) {x *= lamda; y *= lamda; return *this;}
63  FXT_PSV& operator /= (BaseType lamda) {x /= lamda; y /= lamda; return *this;}
64 
65  friend FX_BOOL operator == (const FXT_PSV &obj1, const FXT_PSV &obj2) {return obj1.x == obj2.x && obj1.y == obj2.y;}
66  friend FX_BOOL operator != (const FXT_PSV &obj1, const FXT_PSV &obj2) {return obj1.x != obj2.x || obj1.y != obj2.y;}
67  friend FXT_PSV operator + (const FXT_PSV &obj1, const FXT_PSV &obj2) {CFX_PSVTemplate obj; obj.x = obj1.x + obj2.x; obj.y = obj1.y + obj2.y; return obj;}
68  friend FXT_PSV operator - (const FXT_PSV &obj1, const FXT_PSV &obj2) {CFX_PSVTemplate obj; obj.x = obj1.x - obj2.x; obj.y = obj1.y - obj2.y; return obj;}
69  friend FXT_PSV operator * (const FXT_PSV &obj, BaseType lamda) {CFX_PSVTemplate t; t.x = obj.x * lamda; t.y = obj.y * lamda; return t;}
70  friend FXT_PSV operator * (BaseType lamda, const FXT_PSV &obj) {CFX_PSVTemplate t; t.x = lamda * obj.x; t.y = lamda * obj.y; return t;}
71  friend FXT_PSV operator / (const FXT_PSV &obj, BaseType lamda) {CFX_PSVTemplate t; t.x = obj.x / lamda; t.y = obj.y / lamda; return t;}
72 
73  BaseType x, y;
74 };
76 typedef CFX_PSVTemplate<FX_INT32> CFX_Point;
78 typedef CFX_PSVTemplate<FX_FLOAT> CFX_PointF;
80 typedef CFX_PSVTemplate<FX_INT32> CFX_Size;
82 typedef CFX_PSVTemplate<FX_FLOAT> CFX_SizeF;
88 typedef CFX_PSVTemplate<FX_INT32> * FX_LPPOINT;
90 typedef CFX_PSVTemplate<FX_FLOAT> * FX_LPPOINTF;
92 typedef CFX_PSVTemplate<FX_INT32> const * FX_LPCPOINT;
94 typedef CFX_PSVTemplate<FX_FLOAT> const * FX_LPCPOINTF;
95 
96 //Keep old symbol
97 #define CFX_FloatPoint CFX_PointF
98 
100 template<class baseType>
101 class CFX_VTemplate: public CFX_PSVTemplate<baseType>
102 {
103  public:
104  typedef CFX_PSVTemplate<baseType> FXT_PSV;
105  typedef CFX_PSVTemplate<baseType> FXT_POINT;
106  typedef CFX_PSVTemplate<baseType> FXT_SIZE;
107  typedef CFX_VTemplate<baseType> FXT_VECTOR;
108 
109  void Set(baseType x, baseType y) {FXT_PSV::x = x, FXT_PSV::y = y;}
110  void Set(const FXT_PSV &psv) {FXT_PSV::x = psv.x, FXT_PSV::y = psv.y;}
111  void Set(const FXT_POINT &p1, const FXT_POINT &p2) {FXT_PSV::x = p2.x - p1.x, FXT_PSV::y = p2.y - p1.y;}
112  void Reset() {FXT_PSV::x = FXT_PSV::y = 0;}
113 
114  baseType SquareLength() const {return FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y;}
115  baseType Length() const {return FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y);}
116  void Normalize()
117  {
118  FX_FLOAT fLen = FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y);
119  FXSYS_assert(fLen >= 0.0001f);
120  if (fLen < 0.0001f)
121  return;
122  FXT_PSV::x = ((baseType)FXT_PSV::x) / fLen;
123  FXT_PSV::y = ((baseType)FXT_PSV::y) / fLen;
124  }
125  baseType DotProduct(baseType x, baseType y) const {return FXT_PSV::x * x + FXT_PSV::y * y;}
126  baseType DotProduct(const FXT_VECTOR &v) const {return FXT_PSV::x * v.x + FXT_PSV::y * v.y;}
127  FX_BOOL IsParallel(baseType x, baseType y) const {baseType t = FXT_PSV::x * y - FXT_PSV::y * x; return FXSYS_fabs(t) < 0.0001f;}
128  FX_BOOL IsParallel(const FXT_VECTOR &v) const {return IsParallel(v.x, v.y);}
129  FX_BOOL IsPerpendicular(baseType x, baseType y) const {baseType t = DotProduct(x, y); return FXSYS_fabs(t) < 0.0001f;}
130  FX_BOOL IsPerpendicular(const FXT_VECTOR &v) const {return IsPerpendicular(v.x, v.y);}
131 
132  void Translate(baseType dx, baseType dy) {FXT_PSV::x += dx, FXT_PSV::y += dy;}
133  void Scale(baseType sx, baseType sy) {FXT_PSV::x *= sx, FXT_PSV::y *= sy;}
134  void Rotate(FX_FLOAT fRadian)
135  {
136  FX_FLOAT xx = (FX_FLOAT)FXT_PSV::x;
137  FX_FLOAT yy = (FX_FLOAT)FXT_PSV::y;
138  FX_FLOAT cosValue = FXSYS_cos(fRadian);
139  FX_FLOAT sinValue = FXSYS_sin(fRadian);
140  FXT_PSV::x = xx * cosValue - yy * sinValue;
141  FXT_PSV::y = xx * sinValue + yy * cosValue;
142  }
143 
144  friend FX_FLOAT Cosine(const FXT_VECTOR &v1, const FXT_VECTOR &v2)
145  {
146  FXSYS_assert(v1.SquareLength() != 0 && v2.SquareLength() != 0);
147  FX_FLOAT dotProduct = v1.DotProduct(v2);
148  return dotProduct / (FX_FLOAT)FXSYS_sqrt(v1.SquareLength() * v2.SquareLength());
149  }
150  friend FX_FLOAT ArcCosine(const FXT_VECTOR &v1, const FXT_VECTOR &v2)
151  {
152  return (FX_FLOAT)FXSYS_acos(Cosine(v1, v2));
153  }
154  friend FX_FLOAT SlopeAngle(const FXT_VECTOR &v)
155  {
156  CFX_VTemplate vx;
157  vx.Set(1, 0);
158  FX_FLOAT fSlope = ArcCosine(v, vx);
159  return v.y < 0 ? -fSlope : fSlope;
160  }
161 };
162 
167 
169 template<class baseType>
170 class CFX_PRLTemplate: public CFX_Object
171 {
172  public:
173  typedef CFX_PSVTemplate<baseType> FXT_POINT;
174  typedef CFX_PSVTemplate<baseType> FXT_SIZE;
175  typedef CFX_VTemplate<baseType> FXT_VECTOR;
176  typedef CFX_PRLTemplate<baseType> FXT_PARAL;
177 
178  void Set(baseType x, baseType y, baseType x1, baseType y1, baseType x2, baseType y2) {FXT_PARAL::x = x, FXT_PARAL::y = y, FXT_PARAL::x1 = x1, FXT_PARAL::y1 = y1, FXT_PARAL::x2 = x2, FXT_PARAL::y2 = y2;}
179  void Set(const FXT_POINT &p, const FXT_VECTOR &v1, const FXT_VECTOR &v2) {FXT_PARAL::P(p), FXT_PARAL::V1(v1), FXT_PARAL::V2(v2);}
180  void Reset() {FXT_PARAL::x = FXT_PARAL::y = FXT_PARAL::x1 = FXT_PARAL::y1 = FXT_PARAL::x2 = FXT_PARAL::y2 = 0;}
181 
182  CFX_PRLTemplate& operator += (const FXT_POINT &p) {x += p.x; y += p.y; return *this;}
183  CFX_PRLTemplate& operator -= (const FXT_POINT &p) {x -= p.x; y -= p.y; return *this;}
184 
185  FXT_POINT P() const {FXT_POINT p; p.x = x, p.y = y; return p;}
186  void P(FXT_POINT p) {x = p.x, y = p.y;}
187  FXT_VECTOR V1() const {FXT_VECTOR v; v.x = x1, v.y = y1; return v;}
188  void V1(FXT_VECTOR v) {x1 = v.x, y1 = v.y;}
189  FXT_VECTOR V2() const {FXT_VECTOR v; v.x = x2, v.y = y2; return v;}
190  void V2(FXT_VECTOR v) {x2 = v.x, y2 = v.y;}
191 
192  FX_BOOL IsEmpty() const {return V1().IsParallel(x2, y2);}
193  FX_BOOL IsRect() const {return V1().IsPerpendicular(x2, y2);}
194  FXT_SIZE Size() const {FXT_SIZE s; s.x = V1().Length(); s.y = V2().Length(); return s;}
195  FXT_POINT Center() const {return (V1() + V2()) / 2 + P();}
196  FXT_POINT P1() const {return P();}
197  FXT_POINT P2() const {return P() + V1();}
198  FXT_POINT P3() const {return P() + V1() + V2();}
199  FXT_POINT P4() const {return P() + V2();}
200 
201  baseType x, y;
202  baseType x1, y1;
203  baseType x2, y2;
204 };
205 
210 //<<<+++OPENSOURCE_MUST_END
211 
213 template<class baseType>
214 class CFX_RTemplate: public CFX_Object
215 {
216  public:
217  typedef CFX_PSVTemplate<baseType> FXT_POINT;
218  typedef CFX_PSVTemplate<baseType> FXT_SIZE;
219  typedef CFX_VTemplate<baseType> FXT_VECTOR;
220  typedef CFX_PRLTemplate<baseType> FXT_PARAL;
221  typedef CFX_RTemplate<baseType> FXT_RECT;
222 
223  void Set(baseType left, baseType top, baseType width, baseType height) {FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::width = width, FXT_RECT::height = height;}
224  void Set(baseType left, baseType top, const FXT_SIZE &size) {FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::Size(size);}
225  void Set(const FXT_POINT &p, baseType width, baseType height) {TopLeft(p), FXT_RECT::width = width, FXT_RECT::height = height;}
226  void Set(const FXT_POINT &p1, const FXT_POINT &p2) {TopLeft(p1), FXT_RECT::width = p2.x - p1.x, FXT_RECT::height = p2.y - p1.y, FXT_RECT::Normalize();}
227  void Set(const FXT_POINT &p, const FXT_VECTOR &v) {TopLeft(p), FXT_RECT::width = v.x, FXT_RECT::height = v.y, FXT_RECT::Normalize();}
228  void Reset() {FXT_RECT::left = FXT_RECT::top = FXT_RECT::width = FXT_RECT::height = 0;}
229 
230  FXT_RECT& operator += (const FXT_POINT &p) {left += p.x, top += p.y; return *this;}
231  FXT_RECT& operator -= (const FXT_POINT &p) {left -= p.x, top -= p.y; return *this;}
232 
233  baseType right() const {return left + width;}
234  baseType bottom() const {return top + height;}
235  void Normalize() {if (width < 0) {left += width; width = -width;} if (height < 0) {top += height; height = -height;}}
236  void Offset(baseType dx, baseType dy) {left += dx; top += dy;}
237  void Inflate(baseType x, baseType y) {left -= x; width += x * 2; top -= y; height += y * 2;}
238  void Inflate(const FXT_POINT &p) {Inflate(p.x, p.y);}
239  void Inflate(baseType left, baseType top, baseType right, baseType bottom) {FXT_RECT::left -= left; FXT_RECT::top -= top; FXT_RECT::width += left + right; FXT_RECT::height += top + bottom;}
240  void Inflate(const FXT_RECT &rt) {Inflate(rt.left, rt.top, rt.left + rt.width, rt.top + rt.height);}
241  void Deflate(baseType x, baseType y) {left += x; width -= x * 2; top += y; height -= y * 2;}
242  void Deflate(const FXT_POINT &p) {Deflate(p.x, p.y);}
243  void Deflate(baseType left, baseType top, baseType right, baseType bottom) {FXT_RECT::left += left; FXT_RECT::top += top; FXT_RECT::width -= left + right; FXT_RECT::height -= top + bottom;}
244  void Deflate(const FXT_RECT &rt) {Deflate(rt.left, rt.top, rt.top + rt.width, rt.top + rt.height);}
245  FX_BOOL IsEmpty() const {return width <= 0 || height <= 0;}
246  FX_BOOL IsEmpty(FX_FLOAT fEpsilon) const {return width <= fEpsilon || height <= fEpsilon;}
247  void Empty() {width = height = 0;}
248  FX_BOOL Contains(baseType x, baseType y) const {return x >= left && x < left + width && y >= top && y < top + height;}
249  FX_BOOL Contains(const FXT_POINT &p) const {return Contains(p.x, p.y);}
250  FX_BOOL Contains(const FXT_RECT &rt) const {return rt.left >= left && rt.right() <= right() && rt.top >= top && rt.bottom() <= bottom();}
251  baseType Width() const {return width;}
252  baseType Height() const {return height;}
253  FXT_SIZE Size() const {FXT_SIZE size; size.Set(width, height); return size;}
254  void Size(FXT_SIZE s) {width = s.x, height = s.y;}
255  FXT_POINT TopLeft() const {FXT_POINT p; p.x = left; p.y = top; return p;}
256  FXT_POINT TopRight() const {FXT_POINT p; p.x = left + width; p.y = top; return p;}
257  FXT_POINT BottomLeft() const {FXT_POINT p; p.x = left; p.y = top + height; return p;}
258  FXT_POINT BottomRight() const {FXT_POINT p; p.x = left + width; p.y = top + height; return p;}
259  void TopLeft(FXT_POINT tl) {left = tl.x; top = tl.y;}
260  void TopRight(FXT_POINT tr) {width = tr.x - left; top = tr.y;}
261  void BottomLeft(FXT_POINT bl) {left = bl.x; height = bl.y - top;}
262  void BottomRight(FXT_POINT br) {width = br.x - left; height = br.y - top;}
263  FXT_POINT Center() const {FXT_POINT p; p.x = left + width / 2; p.y = top + height / 2; return p;}
264 
265  void GetParallelogram(FXT_PARAL &pg) const {pg.x = left, pg.y = top; pg.x1 = width, pg.y1 = 0; pg.x2 = 0, pg.y2 = height;}
266 
267  void Union(baseType x, baseType y)
268  {
269  baseType r = right(), b = bottom();
270  if (left > x) left = x;
271  if (r < x) r = x;
272  if (top > y) top = y;
273  if (b < y) b = y;
274  width = r - left;
275  height = b - top;
276  }
277  void Union(const FXT_POINT &p) {Union(p.x, p.y);}
278  void Union(const FXT_RECT &rt)
279  {
280  baseType r = right(), b = bottom();
281  if (left > rt.left) left = rt.left;
282  if (r < rt.right()) r = rt.right();
283  if (top > rt.top) top = rt.top;
284  if (b < rt.bottom()) b = rt.bottom();
285  width = r - left;
286  height = b - top;
287  }
288  void Intersect(const FXT_RECT &rt)
289  {
290  baseType r = right(), b = bottom();
291  if (left < rt.left) left = rt.left;
292  if (r > rt.right()) r = rt.right();
293  if (top < rt.top) top = rt.top;
294  if (b > rt.bottom()) b = rt.bottom();
295  width = r - left;
296  height = b - top;
297  }
298  FX_BOOL IntersectWith(const FXT_RECT &rt) const
299  {
300  FXT_RECT rect = rt;
301  rect.Intersect(*this);
302  return !rect.IsEmpty();
303  }
304  FX_BOOL IntersectWith(const FXT_RECT &rt, FX_FLOAT fEpsilon) const
305  {
306  FXT_RECT rect = rt;
307  rect.Intersect(*this);
308  return !rect.IsEmpty(fEpsilon);
309  }
310 
311  friend FX_BOOL operator == (const FXT_RECT &rc1, const FXT_RECT &rc2) {return rc1.left == rc2.left && rc1.top == rc2.top && rc1.width == rc2.width && rc1.height == rc2.height;}
312  friend FX_BOOL operator != (const FXT_RECT &rc1, const FXT_RECT &rc2) {return rc1.left != rc2.left || rc1.top != rc2.top || rc1.width != rc2.width || rc1.height != rc2.height;}
313 
314  baseType left, top;
315  baseType width, height;
316 };
317 
332 
334 template<class baseType>
335 class CFX_ETemplate : public CFX_RTemplate<baseType>
336 {
337  public:
338  typedef CFX_PSVTemplate<baseType> FXT_POINT;
339  typedef CFX_PSVTemplate<baseType> FXT_SIZE;
340  typedef CFX_VTemplate<baseType> FXT_VECTOR;
341  typedef CFX_RTemplate<baseType> FXT_RECT;
342 
343  void Set(baseType left, baseType top, baseType width, baseType height) {FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::width = width, FXT_RECT::height = height;}
344  void Set(baseType left, baseType top, const FXT_SIZE &size) {FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::Size(size);}
345  void Set(const FXT_POINT &p, baseType width, baseType height) {FXT_RECT::TopLeft(p), FXT_RECT::width = width, FXT_RECT::height = height;}
346  void Set(const FXT_POINT &p1, const FXT_POINT &p2) {FXT_RECT::TopLeft(p1), FXT_RECT::width = p2.x - p1.x, FXT_RECT::height = p2.y - p1.y, FXT_RECT::Normalize();}
347  void Set(const FXT_POINT &p, const FXT_VECTOR &v) {FXT_RECT::TopLeft(p), FXT_RECT::width = v.x, FXT_RECT::height = v.y, FXT_RECT::Normalize();}
348  void SetRadius(const FXT_POINT &p, baseType xRadius, baseType yRadius) {FXT_RECT::left = p.x - xRadius, FXT_RECT::top = p.y - yRadius, FXT_RECT::width = xRadius * 2, FXT_RECT::height = yRadius * 2;}
349  void Reset() {FXT_RECT::left = FXT_RECT::top = FXT_RECT::width = FXT_RECT::height = 0;}
350 
351  FX_BOOL Contains(baseType x, baseType y) const
352  {
353  x -= FXT_RECT::left + FXT_RECT::width / 2;
354  y -= FXT_RECT::top + FXT_RECT::height / 2;
355  return ((FX_FLOAT)(x * x) / (FX_FLOAT)(FXT_RECT::width * FXT_RECT::width) + (FX_FLOAT)(y * y) / (FX_FLOAT)(FXT_RECT::height * FXT_RECT::height)) <= 0.25f;
356  }
357  FX_BOOL Contains(const FXT_POINT &p) const {return Contains(p.x, p.y);}
358  FX_BOOL Contains(const FXT_RECT &rt) const {return Contains(rt.TopLeft()) && Contains(rt.BottomRight());}
359 
360  baseType XRadius() const {return FXT_RECT::width / 2;}
361  baseType YRadius() const {return FXT_RECT::height / 2;}
362 
363  void GetPointF(FX_FLOAT fRadian, CFX_PointF &point) const
364  {
365  FX_FLOAT a = (FX_FLOAT)FXT_RECT::width / 2.0f;
366  FX_FLOAT b = (FX_FLOAT)FXT_RECT::height / 2.0f;
367  FX_FLOAT sinValue = (FX_FLOAT)FXSYS_sin(fRadian);
368  FX_FLOAT cosValue = (FX_FLOAT)FXSYS_cos(fRadian);
369  FX_FLOAT d = FXSYS_sqrt(b * b * cosValue * cosValue + a * a * sinValue * sinValue);
370  fRadian = a * b;
371  point.x = fRadian * cosValue / d + FXT_RECT::left + a;
372  point.y = fRadian * sinValue / d + FXT_RECT::top + b;
373  }
374  void GetPoint(FX_FLOAT fRadian, CFX_Point &point) const
375  {
376  CFX_PointF p;
377  GetPointF(fRadian, p);
378  point.x = FXSYS_round(p.x + 0.5f);
379  point.y = FXSYS_round(p.y + 0.5f);
380  }
381 };
382 
387 
389 template<class baseType>
390 class CFX_RRTemplate: public CFX_RTemplate<baseType>
391 {
392  public:
393  typedef CFX_PSVTemplate<baseType> FXT_POINT;
394  typedef CFX_VTemplate<baseType> FXT_VECTOR;
395  typedef CFX_RTemplate<baseType> FXT_RECT;
396  typedef CFX_RRTemplate<baseType> FXT_RRECT;
397 
398  void Set(baseType left, baseType top, baseType width, baseType height, baseType xRadius, baseType yRadius) {FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::width = width, FXT_RECT::height = height, FXT_RRECT::xRadius = xRadius, FXT_RRECT::yRadius = yRadius;}
399  void Set(const FXT_POINT &p1, const FXT_POINT &p2, baseType xRadius, baseType yRadius) {FXT_RECT::left = p1.x, FXT_RECT::top = p1.y, FXT_RECT::width = p2.x - p1.x, FXT_RECT::height = p2.y - p1.y, FXT_RRECT::xRadius = xRadius, FXT_RRECT::yRadius = yRadius, FXT_RECT::Normalize();}
400  void Set(const FXT_POINT &p, const FXT_VECTOR &v, baseType xRadius, baseType yRadius) {FXT_RECT::TopLeft(p), FXT_RECT::width = v.x, FXT_RECT::height = v.y, FXT_RRECT::xRadius = xRadius, FXT_RRECT::yRadius = yRadius, FXT_RECT::Normalize();}
401  void Set(const FXT_RECT &rt, baseType xRadius, baseType yRadius) {FXT_RECT::left = rt.left, FXT_RECT::top = rt.top, FXT_RECT::width = rt.width, FXT_RECT::height = rt.height, FXT_RRECT::xRadius = xRadius, FXT_RRECT::yRadius = yRadius;}
402  void Reset() {FXSYS_memset32((void*)this, 0, sizeof(FXT_RRECT));}
403 
405  baseType xRadius;
407  baseType yRadius;
408 };
409 
414 
416 template<class baseType>
417 class CFX_ATemplate: public CFX_ETemplate<baseType>
418 {
419  public:
420  typedef CFX_PSVTemplate<baseType> FXT_POINT;
421  typedef CFX_VTemplate<baseType> FXT_VECTOR;
422  typedef CFX_RTemplate<baseType> FXT_RECT;
423  typedef CFX_ETemplate<baseType> FXT_ELLIPSE;
424  typedef CFX_ATemplate<baseType> FXT_ARC;
425 
426  void Set(baseType left, baseType top, baseType width, baseType height, FX_FLOAT startAngle, FX_FLOAT sweepAngle) {FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::width = width, FXT_RECT::height = height, FXT_ARC::startAngle = startAngle, FXT_ARC::sweepAngle = sweepAngle;}
427  void Set(const FXT_POINT &p1, const FXT_POINT &p2, FX_FLOAT startAngle, FX_FLOAT sweepAngle) {FXT_RECT::left = p1.x, FXT_RECT::top = p1.y, FXT_RECT::width = p2.x - p1.x, FXT_RECT::height = p2.y - p1.y, FXT_ARC::startAngle = startAngle, FXT_ARC::sweepAngle = sweepAngle, FXT_RECT::Normalize();}
428  void Set(const FXT_POINT &p, const FXT_VECTOR &v, FX_FLOAT startAngle, FX_FLOAT sweepAngle) {FXT_RECT::TopLeft(p), FXT_RECT::width = v.x, FXT_RECT::height = v.y, FXT_ARC::startAngle = startAngle, FXT_ARC::sweepAngle = sweepAngle, FXT_RECT::Normalize();}
429  void Set(const FXT_POINT &p, baseType xRadius, baseType yRadius, FX_FLOAT startAngle, FX_FLOAT sweepAngle) {FXT_RECT::left = p.x - xRadius, FXT_RECT::top = p.y - yRadius, FXT_RECT::width = xRadius * 2, FXT_RECT::height = yRadius * 2, FXT_ARC::startAngle = startAngle, FXT_ARC::sweepAngle = sweepAngle;}
430  void Set(const FXT_RECT &rt, FX_FLOAT startAngle, FX_FLOAT sweepAngle) {FXT_RECT::left = rt.left, FXT_RECT::top = rt.top, FXT_RECT::width = rt.width, FXT_RECT::height = rt.height, FXT_ARC::startAngle = startAngle, FXT_ARC::sweepAngle = sweepAngle;}
431  void Set(const FXT_ELLIPSE &ellipse, FX_FLOAT startAngle, FX_FLOAT sweepAngle) {FXT_ELLIPSE::left = ellipse.left, FXT_RECT::top = ellipse.top, FXT_RECT::width = ellipse.width, FXT_RECT::height = ellipse.height, FXT_ARC::startAngle = startAngle, FXT_ARC::sweepAngle = sweepAngle;}
432  void Reset() {FXSYS_memset32((void*)this, 0, sizeof(FXT_ARC));}
433 
434  FX_FLOAT EndAngle() const {return startAngle + sweepAngle;}
435  void EndAngle(FX_FLOAT endAngle) {sweepAngle = endAngle - startAngle;}
436  void StartPointF(CFX_PointF &point) const {FXT_ELLIPSE::GetPointF(startAngle, point);}
437  void EndPointF(CFX_PointF &point) const {FXT_ELLIPSE::GetPointF(EndAngle(), point);}
438  void StartPoint(CFX_Point &point) const {FXT_ELLIPSE::GetPoint(startAngle, point);}
439  void EndPoint(CFX_Point &point) const {FXT_ELLIPSE::GetPoint(EndAngle(), point);}
440 
445 };
446 
451 //<<<+++OPENSOURCE_END
452 
458 struct FX_RECT
459 {
461  int left;
463  int top;
465  int right;
467  int bottom;
468 
473  left = 0;
474  top = 0;
475  right = 0;
476  bottom = 0;
477  }
478 
487  FX_RECT(int left1, int top1, int right1, int bottom1)
488  { left = left1; top = top1; right = right1; bottom = bottom1; }
489 
495  int Width() const { return right - left; }
496 
502  int Height() const { return bottom - top; }
503 
509  FX_BOOL IsEmpty() const { return right <= left || bottom <= top; }
510 
516  void Normalize();
517 
525  void Intersect(const FX_RECT& src);
526 
537  void Intersect(int left1, int top1, int right1, int bottom1) { Intersect(FX_RECT(left1, top1, right1, bottom1)); }
538 
546  void Union(const FX_RECT& other_rect);
547 
555  FX_BOOL operator == (const FX_RECT& src) const
556  { return left == src.left && right == src.right && top == src.top && bottom == src.bottom; }
557 
565  FX_BOOL operator != (const FX_RECT& src) const
566  { return left != src.left || right != src.right || top != src.top || bottom != src.bottom; }
567 
576  void Offset(int dx, int dy) { left += dx; right += dx; top += dy; bottom += dy; }
577 
586  FX_BOOL Contains(const FX_RECT& other_rect) const
587  {
588  // Assume both rects are normalized!
589  return other_rect.left >= left && other_rect.right <= right && other_rect.top >= top && other_rect.bottom <= bottom;
590  }
591 
601  FX_BOOL Contains(int x, int y) const
602  {
603  // Assume the rectangle is normalized!
604  return x >= left && x < right && y >= top && y < bottom;
605  }
606 };
607 
612 {
621 };
622 
627 class CFX_FloatRect : public CFX_Object
628 {
629  public:
633  CFX_FloatRect() { left = right = bottom = top = 0; }
634 
643  CFX_FloatRect(FX_FLOAT left1, FX_FLOAT bottom1, FX_FLOAT right1, FX_FLOAT top1)
644  { left = left1; bottom = bottom1; right = right1; top = top1; }
650  CFX_FloatRect(const FX_FLOAT* pArray)
651  { left = pArray[0]; bottom = pArray[1]; right = pArray[2]; top = pArray[3]; }
657  CFX_FloatRect(const FX_RECT& rect);
658 
664  FX_BOOL IsEmpty() const { return left >= right || bottom >= top; }
665 
671  void Normalize();
672 
681  { return FXSYS_fabs(left - src.left) < FLT_EPSILON && FXSYS_fabs(right - src.right) < FLT_EPSILON &&
682  FXSYS_fabs(top - src.top) < FLT_EPSILON && FXSYS_fabs(bottom - src.bottom) < FLT_EPSILON; }
683 
692  { return FXSYS_fabs(left - src.left) > FLT_EPSILON || FXSYS_fabs(right - src.right) > FLT_EPSILON ||
693  FXSYS_fabs(top - src.top) > FLT_EPSILON || FXSYS_fabs(bottom - src.bottom) > FLT_EPSILON; }
694 
700  void Reset() {left = right = bottom = top = 0;}
701 
710  FX_BOOL Contains(const CFX_FloatRect& other_rect) const;
711 
721  FX_BOOL Contains(FX_FLOAT x, FX_FLOAT y) const;
722 
730  void Transform(const CFX_Matrix* pMatrix);
731 
739  void Intersect(const CFX_FloatRect& other_rect);
740 
748  void Union(const CFX_FloatRect& other_rect);
749 
755  FX_RECT GetInnerRect() const;
756 
762  FX_RECT GetOutterRect() const;
763 
769  FX_RECT GetClosestRect() const;
779  int Substract4(CFX_FloatRect& substract_rect, CFX_FloatRect* pRects);
788  void InitRect(FX_FLOAT x, FX_FLOAT y) { left = right = x; bottom = top = y; }
789 
798  void UpdateRect(FX_FLOAT x, FX_FLOAT y);
799 
805  FX_FLOAT Width() const { return right - left; }
806 
812  FX_FLOAT Height() const { return top - bottom; }
813 
822  void Inflate(FX_FLOAT x, FX_FLOAT y) {Normalize(); left -= x; right += x; bottom -= y; top += y;}
823 
834  void Inflate(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top) {Normalize(); this->left -= left; this->bottom -= bottom; this->right += right; this->top += top;}
835 
843  void Inflate(const CFX_FloatRect &rt) {Inflate(rt.left, rt.bottom, rt.right, rt.top);}
844 
853  void Deflate(FX_FLOAT x, FX_FLOAT y) {Normalize(); left += x; right -= x; bottom += y; top -= y;}
854 
865  void Deflate(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top) {Normalize(); this->left += left; this->bottom += bottom; this->right -= right; this->top -= top;}
866 
874  void Deflate(const CFX_FloatRect &rt) {Deflate(rt.left, rt.bottom, rt.right, rt.top);}
875 
884  void Translate(FX_FLOAT e, FX_FLOAT f) {left += e; right += e; top += f; bottom += f;}
885 
894  static CFX_FloatRect GetBBox(const CFX_FloatPoint* pPoints, int nPoints);
895 
904 };
905 
914 class CFX_Matrix : public CFX_Object
915 {
916  public:
920  CFX_Matrix() {a = d = 1; b = c = e = f = 0;}
921 
933  {a = a1; b = b1; c = c1; d = d1; e = e1; f = f1;}
934 
942  FX_BOOL operator == (const CFX_Matrix& src) const
943  { return FXSYS_fabs(a - src.a) < FLT_EPSILON && FXSYS_fabs(b - src.b) < FLT_EPSILON &&
944  FXSYS_fabs(c - src.c) < FLT_EPSILON && FXSYS_fabs(d - src.d) < FLT_EPSILON &&
945  FXSYS_fabs(e - src.e) < FLT_EPSILON && FXSYS_fabs(f - src.f) < FLT_EPSILON; }
946 
954  FX_BOOL operator != (const CFX_Matrix& src) const
955  { return FXSYS_fabs(a - src.a) > FLT_EPSILON || FXSYS_fabs(b - src.b) > FLT_EPSILON ||
956  FXSYS_fabs(c - src.c) > FLT_EPSILON || FXSYS_fabs(d - src.d) > FLT_EPSILON ||
957  FXSYS_fabs(e - src.e) > FLT_EPSILON || FXSYS_fabs(f - src.f) > FLT_EPSILON; }
958 
972 
980  void Set(const FX_FLOAT n[6]);
981 
987  void SetIdentity() {a = d = 1; b = c = e = f = 0;}
988 
996  void SetReverse(const CFX_Matrix &m);
997 
1011  void Concat(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f, FX_BOOL bPrepended = FALSE);
1012 
1021  void Concat(const CFX_Matrix &m, FX_BOOL bPrepended = FALSE);
1022 
1031  void ConcatInverse(const CFX_Matrix& m, FX_BOOL bPrepended = FALSE);
1032 
1038  void Reset() {SetIdentity();}
1039 
1047  void Copy(const CFX_Matrix& m) {*this = m;}
1048 
1054  FX_BOOL IsIdentity() const {return a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0;}
1055 
1061  FX_BOOL IsInvertible() const;
1062 
1068  FX_BOOL Is90Rotated() const;
1069 
1075  FX_BOOL IsScaled() const;
1076 
1086  void Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = FALSE);
1087 
1097  void TranslateI(FX_INT32 x, FX_INT32 y, FX_BOOL bPrepended = FALSE) {Translate((FX_FLOAT)x, (FX_FLOAT)y, bPrepended);}
1107  void Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended = FALSE);
1116  void Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended = FALSE);
1117 
1128  void RotateAt(FX_FLOAT fRadian, FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = FALSE);
1129 
1139  void Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadian, FX_BOOL bPrepended = FALSE);
1140 
1149  void MatchRect(const CFX_FloatRect &dest, const CFX_FloatRect &src);
1150 
1156  FX_FLOAT GetXUnit() const;
1157 
1163  FX_FLOAT GetYUnit() const;
1164 
1165  void GetUnitParallelogram(CFX_ParallelogramF &pg) const;
1166  void GetUnitRect(CFX_RectF &rect) const;
1172  CFX_FloatRect GetUnitRect() const;
1178  FX_FLOAT GetUnitArea() const;
1179 
1180 #ifdef _FXGE_IMAGERENDER_SHORTCUT_
1181  const FX_INT32 GetRotation() const;
1182  const FX_BOOL NeedTransform() const;
1183 #endif
1184 
1185  FX_FLOAT TransformXDistance(FX_FLOAT dx) const;
1186  FX_INT32 TransformXDistance(FX_INT32 dx) const;
1187  FX_FLOAT TransformYDistance(FX_FLOAT dy) const;
1188  FX_INT32 TransformYDistance(FX_INT32 dy) const;
1189  FX_FLOAT TransformDistance(FX_FLOAT dx, FX_FLOAT dy) const;
1190  FX_INT32 TransformDistance(FX_INT32 dx, FX_INT32 dy) const;
1198  FX_FLOAT TransformDistance(FX_FLOAT distance) const;
1199 
1200  void TransformPoint(FX_FLOAT &x, FX_FLOAT &y) const;
1201  void TransformPoint(FX_INT32 &x, FX_INT32 &y) const;
1202  void TransformPoints(CFX_PointF *points, FX_INT32 iCount) const;
1203  void TransformPoints(CFX_Point *points, FX_INT32 iCount) const;
1204 
1213  void Transform(FX_FLOAT& x, FX_FLOAT& y) const {TransformPoint(x, y);}
1214 
1225  void Transform(FX_FLOAT x, FX_FLOAT y, FX_FLOAT& x1, FX_FLOAT& y1) const {x1 = x, y1 = y; TransformPoint(x1, y1);}
1226 
1227  void TransformVector(CFX_VectorF &v) const;
1228  void TransformVector(CFX_Vector &v) const;
1229 
1230  void TransformParallelogram(CFX_ParallelogramF &pg) const;
1231  void TransformParallelogram(CFX_Parallelogram &pg) const;
1232 
1233  void TransformRect(CFX_RectF &rect) const;
1234  void TransformRect(CFX_Rect &rect) const;
1235 
1246  void TransformRect(FX_FLOAT& left, FX_FLOAT& right, FX_FLOAT& top, FX_FLOAT& bottom) const;
1247 
1255  void TransformRect(CFX_FloatRect& rect) const {TransformRect(rect.left, rect.right, rect.top, rect.bottom);}
1263  void TransformRect(FX_RECT& rect) const {TransformRect((FX_FLOAT&)rect.left, (FX_FLOAT&) rect.right, (FX_FLOAT&) rect.top, (FX_FLOAT&) rect.bottom);}
1264 
1265  void TransformRoundRect(CFX_RoundRectF &rr) const;
1266  void TransformRoundRect(CFX_RoundRect &rr) const;
1267 
1273  FX_FLOAT GetA() const {return a;}
1274 
1280  FX_FLOAT GetB() const {return b;}
1281 
1287  FX_FLOAT GetC() const {return c;}
1288 
1294  FX_FLOAT GetD() const {return d;}
1295 
1301  FX_FLOAT GetE() const {return e;}
1302 
1308  FX_FLOAT GetF() const {return f;}
1309 
1310  public:
1323 };
1324 
1325 class CFX_Vector_3by1 : public CFX_Object
1326 {
1327  public:
1328 CFX_Vector_3by1():
1329  a(0.0f),
1330  b(0.0f),
1331  c(0.0f)
1332  {}
1333  CFX_Vector_3by1(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1):
1334  a(a1),
1335  b(b1),
1336  c(c1)
1337  {}
1338  FX_FLOAT a;
1339  FX_FLOAT b;
1340  FX_FLOAT c;
1341 };
1342 
1343 class CFX_Matrix_3by3 : public CFX_Object
1344 {
1345  public:
1346 CFX_Matrix_3by3():a(0.0f), b(0.0f), c(0.0f), d(0.0f), e(0.0f), f(0.0f), g(0.0f), h(0.0f), i(0.0f)
1347  {}
1348 
1349  CFX_Matrix_3by3(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1, FX_FLOAT d1, FX_FLOAT e1, FX_FLOAT f1, FX_FLOAT g1, FX_FLOAT h1, FX_FLOAT i1) :
1350  a(a1), b(b1), c(c1), d(d1), e(e1), f(f1), g(g1), h(h1), i(i1)
1351  {}
1352  CFX_Matrix_3by3 Inverse();
1353  CFX_Matrix_3by3 Multiply(const CFX_Matrix_3by3 &m);
1354  CFX_Vector_3by1 TransformVector(const CFX_Vector_3by1 &v);
1355  FX_FLOAT a;
1356  FX_FLOAT b;
1357  FX_FLOAT c;
1358  FX_FLOAT d;
1359  FX_FLOAT e;
1360  FX_FLOAT f;
1361  FX_FLOAT g;
1362  FX_FLOAT h;
1363  FX_FLOAT i;
1364 };
1365 
1366 //Keep old symbol
1367 #define CFX_AffineMatrix CFX_Matrix
1368 
1369 //<<<+++OPENSOURCE_MUST_BEGIN
1370 #endif //_FXCRT_COORDINATES_
1371 //<<<+++OPENSOURCE_MUST_END
1372 
1375 //<<<+++OPENSOURCE_END
int top
The top.
Definition: fx_coordinates.h:463
CFX_PRLTemplate< FX_INT32 > CFX_Parallelogram
Type definition for parallelogram class for integer.
Definition: fx_coordinates.h:207
static CFX_FloatRect GetBBox(const CFX_PointF *pPoints, int nPoints)
Get the bounding box of input points array.
FX_RECT GetOutterRect() const
Convert to an outer integer rectangle.
int bottom
The bottom.
Definition: fx_coordinates.h:467
void Normalize()
Normalize the rect. Make sure left <= right, top <= bottom.
int Width() const
Get the width of the rect.
Definition: fx_coordinates.h:495
void ConcatInverse(const CFX_Matrix &m, FX_BOOL bPrepended=FALSE)
Concatenate the inverse of another matrix.
void Intersect(int left1, int top1, int right1, int bottom1)
Intersect with a rect.
Definition: fx_coordinates.h:537
void TransformRect(CFX_FloatRect &rect) const
Transform a rectangle and return a bounding rectangle. The result rectangle is always normalized.
Definition: fx_coordinates.h:1255
void Concat(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f, FX_BOOL bPrepended=FALSE)
Concatenate with another matrix.
int Height() const
Get the height of the rect.
Definition: fx_coordinates.h:502
void Transform(FX_FLOAT x, FX_FLOAT y, FX_FLOAT &x1, FX_FLOAT &y1) const
Transform a point.
Definition: fx_coordinates.h:1225
FX_RECT GetClosestRect() const
Get a closest integer rectangle.
FX_BOOL Contains(const FX_RECT &other_rect) const
Check if current rectangle fully contains the other provided rectangle. That means to check if the ot...
Definition: fx_coordinates.h:586
CFX_ArrayTemplate< CFX_RectF > CFX_RectFArray
Type definition for rect array.
Definition: fx_coordinates.h:331
FX_RECT(int left1, int top1, int right1, int bottom1)
Construct a rect with left-top and right bottom corners.
Definition: fx_coordinates.h:487
int FXSYS_round(FX_FLOAT f)
Get nearest integer.
CFX_RTemplate< FX_FLOAT > * FX_LPRECTF
Type definition for pointer to float rectangle.
Definition: fx_coordinates.h:325
CFX_ArrayTemplate< CFX_PointF > CFX_PointsF
Type definition for float point array.
Definition: fx_coordinates.h:86
FX_FLOAT b
The coefficient b.
Definition: fx_coordinates.h:1314
void Reset()
Reset current matrix.
Definition: fx_coordinates.h:1038
void Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended=FALSE)
Rotate the matrix.
void Normalize()
Normalize the rect. Make sure left <= right, and bottom <= top.
CFX_RRTemplate< FX_FLOAT > CFX_RoundRectF
Type definition for round-corner rectangle class for float.
Definition: fx_coordinates.h:413
CFX_ArrayTemplate< CFX_Point > CFX_Points
Definition: fx_coordinates.h:84
void Union(const FX_RECT &other_rect)
Union with a rect.
void Inflate(const CFX_FloatRect &rt)
Increases the width and height of the rectangle.
Definition: fx_coordinates.h:843
FX_FLOAT sweepAngle
Sweep angle to draw arc. Positive is counterclockwise from starting angle, in radian.
Definition: fx_coordinates.h:444
#define FXSYS_sin
Calculate the sine of a floating-point number from a radian argument.
Definition: fx_system.h:1410
FX_BOOL IsScaled() const
Whether this matrix has scaling (or translating) only. No rotating.
CFX_PRLTemplate< FX_FLOAT > CFX_ParallelogramF
Type definition for parallelogram class for float.
Definition: fx_coordinates.h:209
int right
The right.
Definition: fx_coordinates.h:465
FX_FLOAT GetA() const
Get the coefficient a.
Definition: fx_coordinates.h:1273
CFX_ATemplate< FX_INT32 > CFX_Arc
Type definition for arc class for integer.
Definition: fx_coordinates.h:448
FX_BOOL operator!=(const FX_RECT &src) const
Compare(!=) operator overload. Compare two rectangles. Please make sure they are normalized first.
Definition: fx_coordinates.h:565
void SetIdentity()
Set the matrix to be an identity transformation matrix.
Definition: fx_coordinates.h:987
FX_RECT GetInnerRect() const
Convert to an inner integer rectangle.
void Inflate(FX_FLOAT x, FX_FLOAT y)
Increases the width and height of the rectangle.
Definition: fx_coordinates.h:822
void Transform(const CFX_Matrix *pMatrix)
Transform a rectangle. The result rectangle is always normalized.
CFX_PSVTemplate< FX_FLOAT > * FX_LPPOINTF
Type definition for pointer to float point.
Definition: fx_coordinates.h:90
void InitRect(FX_FLOAT x, FX_FLOAT y)
Initialize the rectangle to a single point.
Definition: fx_coordinates.h:788
CFX_FloatRect(FX_FLOAT left1, FX_FLOAT bottom1, FX_FLOAT right1, FX_FLOAT top1)
Construct a rectangle with left-bottom and right-top corners.
Definition: fx_coordinates.h:643
CFX_PSVTemplate< FX_INT32 > CFX_Point
Type definition for point class for integer.
Definition: fx_coordinates.h:76
CFX_FloatRect()
Construct an empty rectangle.
Definition: fx_coordinates.h:633
FX_SHORT Left
The left.
Definition: fx_coordinates.h:614
CFX_Matrix()
Construct a identity transformation matrix.
Definition: fx_coordinates.h:920
FX_FLOAT startAngle
Start angle to draw arc. Positive is counterclockwise, in radian.
Definition: fx_coordinates.h:442
baseType xRadius
x radius of round corner. This must not exceed the half width.
Definition: fx_coordinates.h:405
void Offset(int dx, int dy)
Shift the coordinates by delta value of x and y directions.
Definition: fx_coordinates.h:576
FX_FLOAT Width() const
Get the width of the rectangle.
Definition: fx_coordinates.h:805
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:662
FX_BOOL IsInvertible() const
Determine whether a matrix is invertible or not.
void * FXSYS_memset32(void *dst, FX_INT32 v, size_t size)
Set buffer data to specified value.
void Union(const CFX_FloatRect &other_rect)
Union with a rect.
CFX_RTemplate< FX_INT32 > * FX_LPRECT
Type definition for pointer to integer rectangle.
Definition: fx_coordinates.h:323
void Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended=FALSE)
Translate the matrix.
FX_FLOAT GetXUnit() const
Get the x-direction unit size.
bool operator==(const char *str1, const CFX_ByteString &str2)
Check if two byte strings are equal.
Definition: fs_basictypes.h:125
FX_SHORT Bottom
The bottom.
Definition: fx_coordinates.h:620
FX_FLOAT GetF() const
Get the coefficient f.
Definition: fx_coordinates.h:1308
int FX_BOOL
Boolean variable (should be TRUE or FALSE).
Definition: fx_system.h:666
FX_FLOAT GetYUnit() const
Get the y-direction unit size.
CFX_PSVTemplate< FX_FLOAT > const * FX_LPCPOINTF
Type definition for constant pointer to float point.
Definition: fx_coordinates.h:94
FX_FLOAT c
The coefficient c.
Definition: fx_coordinates.h:1316
CFX_PSVTemplate< FX_INT32 > const * FX_LPCPOINT
Type definition for constant pointer to integer point.
Definition: fx_coordinates.h:92
FX_FLOAT a
The coefficient a.
Definition: fx_coordinates.h:1312
int Substract4(CFX_FloatRect &substract_rect, CFX_FloatRect *pRects)
Subtract a rectangle area from this rectangle. The result might be up to 4 rectangles....
FX_BOOL IsEmpty() const
Verify whether the rect is empty.
Definition: fx_coordinates.h:664
CFX_ATemplate< FX_FLOAT > CFX_ArcF
Type definition for arc class for float.
Definition: fx_coordinates.h:450
CFX_RTemplate< FX_FLOAT > const * FX_LPCRECTF
Type definition for constant pointer to float rectangle.
Definition: fx_coordinates.h:329
FX_BOOL IsEmpty() const
Verify whether the rect is empty.
Definition: fx_coordinates.h:509
void RotateAt(FX_FLOAT fRadian, FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended=FALSE)
Rotate the matrix at a position.
FX_FLOAT GetD() const
Get the coefficient d.
Definition: fx_coordinates.h:1294
#define FXSYS_acos
Calculate the arccosine of a floating-point number, in radians.
Definition: fx_system.h:1405
short FX_SHORT
Short integer (16 bits).
Definition: fx_system.h:654
void Transform(FX_FLOAT &x, FX_FLOAT &y) const
Transform a point.
Definition: fx_coordinates.h:1213
void Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadian, FX_BOOL bPrepended=FALSE)
Shear the matrix.
#define FXSYS_fabs
Calculate the absolute. FXSYS_fabs(x) means |x|.
Definition: fx_system.h:1380
FX_FLOAT GetC() const
Get the coefficient c.
Definition: fx_coordinates.h:1287
#define FXSYS_cos
Calculate the cosine of a floating-point number from a radian argument.
Definition: fx_system.h:1400
void Deflate(FX_FLOAT x, FX_FLOAT y)
Decreases the width and height of the rectangle.
Definition: fx_coordinates.h:853
int left
The left.
Definition: fx_coordinates.h:461
Definition: fx_basic.h:1246
CFX_PSVTemplate< FX_FLOAT > CFX_SizeF
Type definition for size class for float.
Definition: fx_coordinates.h:82
void SetReverse(const CFX_Matrix &m)
Set the coefficients of the inverse of another matrix to this matrix.
CFX_ByteString operator+(FX_BSTR str1, FX_BSTR str2)
Concatenate a non-buffered byte string and a non-buffered byte string.
Definition: fx_string.h:982
FX_FLOAT Height() const
Get the height of the rectangle.
Definition: fx_coordinates.h:812
FX_BOOL Is90Rotated() const
Whether this matrix has rotating of 90, or -90 degrees.
CFX_ETemplate< FX_INT32 > CFX_Ellipse
Type definition for ellipse class for integer.
Definition: fx_coordinates.h:384
CFX_FloatRect GetUnitRect() const
Get a bounding rectangle of the parallelogram composing two unit vectors.
void TranslateI(FX_INT32 x, FX_INT32 y, FX_BOOL bPrepended=FALSE)
Translate the matrix. using integer value.
Definition: fx_coordinates.h:1097
float FX_FLOAT
32-bit floating-point number.
Definition: fx_system.h:664
void UpdateRect(FX_FLOAT x, FX_FLOAT y)
Update the rectangle to contain the specified point.
#define FXSYS_assert
Assertion.
Definition: fx_system.h:779
FX_BOOL operator!=(const CFX_FloatRect &src) const
Compare(!=) operator overload. Compare two rectangles. Please make sure they are normalized first.
Definition: fx_coordinates.h:691
CFX_PSVTemplate< FX_INT32 > * FX_LPPOINT
Type definition for pointer to integer point.
Definition: fx_coordinates.h:88
Definition: fx_coordinates.h:33
void Set(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f)
Change the coefficients in the matrix.
CFX_RTemplate< FX_INT32 > CFX_Rect
Type definition for rectangle class for integer.
Definition: fx_coordinates.h:319
Definition: fx_coordinates.h:458
FX_FLOAT GetUnitArea() const
Get area of the parallelogram composing two unit vectors.
void Inflate(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top)
Increases the width and height of the rectangle.
Definition: fx_coordinates.h:834
FX_BOOL Contains(int x, int y) const
Check if current rectangle contains the provided point. That means to check if the provided point is ...
Definition: fx_coordinates.h:601
void Deflate(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top)
Decreases the width and height of the rectangle.
Definition: fx_coordinates.h:865
FX_SHORT Top
The top.
Definition: fx_coordinates.h:616
CFX_RTemplate< FX_INT32 > const * FX_LPCRECT
Type definition for constant pointer to integer rectangle.
Definition: fx_coordinates.h:327
void Copy(const CFX_Matrix &m)
Copy coefficients from another matrix.
Definition: fx_coordinates.h:1047
CFX_VTemplate< FX_FLOAT > CFX_VectorF
Vector class for float.
Definition: fx_coordinates.h:166
FX_FLOAT GetB() const
Get the coefficient b.
Definition: fx_coordinates.h:1280
FX_FLOAT f
The coefficient f.
Definition: fx_coordinates.h:1322
FX_FLOAT right
The right.
Definition: fx_coordinates.h:899
FX_BOOL operator!=(const CFX_Matrix &src) const
Compare(!=) operator overload. Compare two matrixs.
Definition: fx_coordinates.h:954
void Intersect(const CFX_FloatRect &other_rect)
Intersect with a rect.
void MatchRect(const CFX_FloatRect &dest, const CFX_FloatRect &src)
Get a matrix that transforms a source rectangle to dest rectangle.
Definition: fx_coordinates.h:34
CFX_FloatRect(const FX_FLOAT *pArray)
Construct a rectangle with an array of left, bottom, right, top values.
Definition: fx_coordinates.h:650
CFX_PSVTemplate< FX_INT32 > CFX_Size
Type definition for size class for integer.
Definition: fx_coordinates.h:80
Definition: fx_coordinates.h:31
FX_FLOAT bottom
The bottom.
Definition: fx_coordinates.h:901
void Intersect(const FX_RECT &src)
Intersect with a rect.
Definition: fx_coordinates.h:32
FX_BOOL Contains(const CFX_FloatRect &other_rect) const
Check if current rectangle fully contains the other provided rectangle. That means to check if the ot...
#define FALSE
Keyword which value is 0.
Definition: fx_system.h:762
Definition: fx_coordinates.h:36
CFX_PSVTemplate< FX_FLOAT > CFX_PointF
Type definition for point class for float.
Definition: fx_coordinates.h:78
FX_FLOAT left
The left.
Definition: fx_coordinates.h:897
CFX_ETemplate< FX_FLOAT > CFX_EllipseF
Type definition for ellipse class for float.
Definition: fx_coordinates.h:386
Definition: fx_coordinates.h:35
void Reset()
Reset rectangle, set coordinates to 0.
Definition: fx_coordinates.h:700
void TransformRect(FX_RECT &rect) const
Transform a rectangle and return a bounding rectangle. The result rectangle is always normalized.
Definition: fx_coordinates.h:1263
bool operator!=(const char *str1, const CFX_ByteString &str2)
Check if two byte strings are not equal.
Definition: fs_basictypes.h:137
Definition: fx_coordinates.h:914
#define FXSYS_sqrt
Calculate the square root. FXSYS_sqrt(x) means sqrt(x).
Definition: fx_system.h:1375
FX_BOOL operator==(const CFX_FloatRect &src) const
Compare(==) operator overload. Compare two rectangles. Please make sure they are normalized first.
Definition: fx_coordinates.h:680
FX_BOOL operator==(const CFX_Matrix &src) const
Compare(==) operator overload. Compare two matrixs.
Definition: fx_coordinates.h:942
FX_FLOAT top
The top.
Definition: fx_coordinates.h:903
FX_RECT()
Construct a rect not initialized.
Definition: fx_coordinates.h:472
FX_FLOAT GetE() const
Get the coefficient e.
Definition: fx_coordinates.h:1301
CFX_RRTemplate< FX_INT32 > CFX_RoundRect
Type definition for round-corner rectangle class for integer.
Definition: fx_coordinates.h:411
void Translate(FX_FLOAT e, FX_FLOAT f)
Translate rectangle.
Definition: fx_coordinates.h:884
CFX_RTemplate< FX_FLOAT > CFX_RectF
Type definition for rectangle class for float.
Definition: fx_coordinates.h:321
baseType yRadius
y radius of round corner. This must not exceed the half height.
Definition: fx_coordinates.h:407
void Deflate(const CFX_FloatRect &rt)
Decreases the width and height of the rectangle.
Definition: fx_coordinates.h:874
CFX_Matrix(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1, FX_FLOAT d1, FX_FLOAT e1, FX_FLOAT f1)
Construct a matrix with six input coefficients.
Definition: fx_coordinates.h:932
Definition: fx_coordinates.h:627
void Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended=FALSE)
Scale the matrix.
FX_SHORT Right
The right.
Definition: fx_coordinates.h:618
FX_FLOAT d
The coefficient d.
Definition: fx_coordinates.h:1318
FX_BOOL IsIdentity() const
Determine whether a matrix is an identity transformation or not.
Definition: fx_coordinates.h:1054
FX_BOOL operator==(const FX_RECT &src) const
Compare(==) operator overload. Compare two rectangles. Please make sure they are normalized first.
Definition: fx_coordinates.h:555
Definition: fx_coordinates.h:611
FX_FLOAT e
The coefficient e.
Definition: fx_coordinates.h:1320
CFX_VTemplate< FX_INT32 > CFX_Vector
Vector class for integer.
Definition: fx_coordinates.h:164

Foxit Software Corporation Logo
@2018 Foxit Software Incorporated. All rights reserved.