SCV  4.2.1
Simple Components for Visual
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Point.h
Go to the documentation of this file.
1 #ifndef __SCV_POINT_H__
2 #define __SCV_POINT_H__
3 
4 #include "stdafx.h"
5 
6 namespace scv {
7 
8 class Point {
9 public:
10  Point();
11  Point(int x, int y);
12  //[<number>,<number>]
13  Point(const std::string &str);
14 
15  inline Point operator*(int w) const;
16  inline Point operator/(int w) const;
17  inline Point operator+(int w) const;
18  inline Point operator-(int w) const;
19 
20  inline Point operator+(const Point& rhs) const;
21  inline Point operator-(const Point& rhs) const;
22 
23  inline void operator+=(int w);
24  inline void operator-=(int w);
25 
26  inline void operator+=(const Point& rhs);
27  inline void operator-=(const Point& rhs);
28  inline bool operator!=(const Point& rhs) const;
29  inline bool operator==(const Point& rhs) const;
30  inline bool operator>=(const Point& rhs) const;
31  inline bool operator<=(const Point& rhs) const;
32  inline bool operator>(const Point& rhs) const;
33  inline bool operator<(const Point& rhs) const;
34 
35  friend std::ostream& operator<<(std::ostream& lhs, const Point& rhs);
36 
37  inline Point & translateX(int w);
38  inline Point & translateY(int w);
39 
40  const Point inverse(void) const;
41 
42  int x, y;
43 };
44 
45 
46 
47 Point Point::operator*(int w) const {
48  return Point(x * w, y * w);
49 }
50 
51 Point Point::operator/(int w) const {
52  return Point(x / w, y / w);
53 }
54 
55 Point Point::operator+(int w) const {
56  return Point(x + w, y + w);
57 }
58 
59 Point Point::operator+(const Point& rhs) const {
60  return Point(x + rhs.x, y + rhs.y);
61 }
62 
63 Point Point::operator-(int w) const {
64  return Point(x - w, y - w);
65 }
66 
67 
68 Point Point::operator-(const Point &rhs) const {
69  return Point(x - rhs.x, y - rhs.y);
70 }
71 
72 void Point::operator+=(int w) {
73  x += w;
74  y += w;
75 }
76 
77 void Point::operator+=(const Point &rhs) {
78  x += rhs.x;
79  y += rhs.y;
80 }
81 
82 void Point::operator-=(int w) {
83  x -= w;
84  y -= w;
85 }
86 
87 void Point::operator-=(const Point &rhs) {
88  x -= rhs.x;
89  y -= rhs.y;
90 }
91 
92 bool Point::operator!=(const Point &rhs) const {
93  return (x != rhs.x || y != rhs.y);
94 }
95 
96 bool Point::operator==(const Point &rhs) const {
97  return (x == rhs.x && y == rhs.y);
98 }
99 
100 bool Point::operator>=(const Point &rhs) const {
101  return (x >= rhs.x && y >= rhs.y);
102 }
103 
104 bool Point::operator<=(const Point &rhs) const {
105  return (x <= rhs.x && y <= rhs.y);
106 }
107 
108 bool Point::operator>(const Point &rhs) const {
109  return (x > rhs.x && y > rhs.y);
110 }
111 
112 bool Point::operator<(const Point &rhs) const {
113  return (x < rhs.x && y < rhs.y);
114 }
115 
117  x += w;
118  return *this;
119 }
120 
122  y += w;
123  return *this;
124 }
125 
126 } // namespace scv
127 
128 
129 #endif // __SCV_POINT_H__