C++SDK  1.0.0
annotationbasedefines.h
浏览该文件的文档.
1 #ifndef RT_AnnotationBaseDefines_H_
2 #define RT_AnnotationBaseDefines_H_
3 
4 
5 #include "list"
6 
7 namespace rtcimp {
8 
9  /* Ϣṹ.
10  */
11  typedef struct tagPoint {
12  int x;
13  int y;
14  tagPoint() :x(0), y(0) {}
15  tagPoint(int x, int y) :x(x), y(y) {}
16  }Point;
17 
18  typedef std::list<Point> PointArray;
19 
23  typedef struct tagRect {
24  int left;
25  int top;
26  int right;
27  int bottom;
28  tagRect() :left(0), top(0), right(0), bottom(0) {}
29  tagRect(int left, int top, int right, int bottom) :left(left), top(top), right(right), bottom(bottom) {}
30  bool isRectEmpty() const { return (left == right || top == bottom); }
31  int width() const { return right - left; }
32  int height() const { return bottom - top; }
33  bool pointIn(const Point& p) const { return pointIn(p.x, p.y); }
34  bool pointIn(int x, int y) const { return x >= left && right >= x && y >= top && bottom >= y; }
35  void moveY(int y) { int h = height(); top = y; bottom = top + h; }
36  void moveX(int x) { int w = width(); left = x; right = left + w; }
37  void moveXY(int x, int y) { moveX(x); moveY(y); }
38  bool operator ==(const tagRect& other) const { return left == other.left && right == other.right && top == other.top && bottom == other.bottom; }
39  bool operator !=(const tagRect& other) const { return !(*this == other); }
40  }Rect;
41  typedef struct tagColor {
42  unsigned long color;
43  tagColor() : tagColor(0, 0, 0, 0) {}
44  tagColor(unsigned long val) : color(val) {}
45  tagColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
46  :color(((r | ((unsigned long)g << 8)) | (((unsigned long)b) << 16)) | (((unsigned long)a) << 24)) {}
47  unsigned char r() const { return color & 0xFF; }
48  unsigned char g() const { return (color >> 8) & 0xFF; }
49  unsigned char b() const { return (color >> 16) & 0xFF; }
50  unsigned char a() const { return (color >> 24) & 0xFF; }
51  unsigned long rgb() const { return color & 0xFFFFFF; }
52  unsigned long argb() const { return ((b() | ((unsigned long)g() << 8)) | (((unsigned long)r()) << 16)) | (((unsigned long)a()) << 24); }
53  void setR(unsigned char r) { color = (color & 0xFFFFFF00) | ((unsigned long)r & 0xFF); }
54  void setG(unsigned char g) { color = (color & 0xFFFF00FF) | (((unsigned long)g & 0xFF) << 8); }
55  void setB(unsigned char b) { color = (color & 0xFF00FFFF) | (((unsigned long)b & 0xFF) << 16); }
56  void setA(unsigned char a) { color = (color & 0x00FFFFFF) | (((unsigned long)a & 0xFF) << 24); }
57  void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { setA(a); setR(r); setG(g); setB(b); }
58  }Color;
59 
60 }
61 #endif //RT_AnnotationBaseDefines_H_
tagPoint()
Definition: annotationbasedefines.h:14
tagColor()
Definition: annotationbasedefines.h:43
unsigned long argb() const
Definition: annotationbasedefines.h:52
Definition: annotationbasedefines.h:23
bool operator==(const tagRect &other) const
Definition: annotationbasedefines.h:38
int x
Definition: annotationbasedefines.h:12
tagPoint(int x, int y)
Definition: annotationbasedefines.h:15
void setA(unsigned char a)
Definition: annotationbasedefines.h:56
int height() const
Definition: annotationbasedefines.h:32
bool isRectEmpty() const
Definition: annotationbasedefines.h:30
int width() const
Definition: annotationbasedefines.h:31
struct rtcimp::tagColor Color
void moveY(int y)
Definition: annotationbasedefines.h:35
void moveX(int x)
Definition: annotationbasedefines.h:36
std::list< Point > PointArray
Definition: annotationbasedefines.h:18
int top
Definition: annotationbasedefines.h:25
bool pointIn(const Point &p) const
Definition: annotationbasedefines.h:33
void moveXY(int x, int y)
Definition: annotationbasedefines.h:37
unsigned long color
Definition: annotationbasedefines.h:42
int left
Definition: annotationbasedefines.h:24
int right
Definition: annotationbasedefines.h:26
tagRect(int left, int top, int right, int bottom)
Definition: annotationbasedefines.h:29
unsigned long rgb() const
Definition: annotationbasedefines.h:51
bool operator!=(const tagRect &other) const
Definition: annotationbasedefines.h:39
Definition: annotationbasedefines.h:41
Definition: annotationbasedefines.h:7
tagColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Definition: annotationbasedefines.h:45
bool pointIn(int x, int y) const
Definition: annotationbasedefines.h:34
tagColor(unsigned long val)
Definition: annotationbasedefines.h:44
struct rtcimp::tagRect Rect
void setG(unsigned char g)
Definition: annotationbasedefines.h:54
tagRect()
Definition: annotationbasedefines.h:28
unsigned char b() const
Definition: annotationbasedefines.h:49
unsigned char r() const
Definition: annotationbasedefines.h:47
int y
Definition: annotationbasedefines.h:13
void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Definition: annotationbasedefines.h:57
struct rtcimp::tagPoint Point
unsigned char a() const
Definition: annotationbasedefines.h:50
unsigned char g() const
Definition: annotationbasedefines.h:48
int bottom
Definition: annotationbasedefines.h:27
Definition: annotationbasedefines.h:11
void setB(unsigned char b)
Definition: annotationbasedefines.h:55
void setR(unsigned char r)
Definition: annotationbasedefines.h:53