openATV enigma2
openATV is an open source SetTopBox Graphical user interface.
epoint.h
Go to the documentation of this file.
1 #ifndef EPOINT_H
2 #define EPOINT_H
3 
4 #ifndef ABS
5 #define ABS(x) ( x>0 ? x : -x )
6 #endif
7 
8 class ePoint
9 {
10 public:
11  ePoint();
12  ePoint( int xpos, int ypos );
13  ePoint( float xpos, float ypos );
14  ePoint( float xpos, int ypos );
15  ePoint( int xpos, float ypos );
16 
17  bool isNull() const;
18 
19  int x() const;
20  int y() const;
21  void setX( int x );
22  void setY( int y );
23 
24  int manhattanLength() const;
25 
26  int &rx();
27  int &ry();
28 
29  ePoint &operator+=( const ePoint &p );
30  ePoint &operator-=( const ePoint &p );
31  ePoint &operator*=( int c );
32  ePoint &operator*=( double c );
33  ePoint &operator/=( int c );
34  ePoint &operator/=( double c );
35 
36  friend inline bool operator==( const ePoint &, const ePoint & );
37  friend inline bool operator!=( const ePoint &, const ePoint & );
38  friend inline ePoint operator+( const ePoint &, const ePoint & );
39  friend inline ePoint operator+( const ePoint &, const eSize & );
40  friend inline ePoint operator-( const ePoint &, const ePoint & );
41  friend inline ePoint operator-( const ePoint &, const eSize & );
42  friend inline ePoint operator*( const ePoint &, int );
43  friend inline ePoint operator*( int, const ePoint & );
44  friend inline ePoint operator*( const ePoint &, double );
45  friend inline ePoint operator*( double, const ePoint & );
46  friend inline ePoint operator-( const ePoint & );
47  friend inline ePoint operator/( const ePoint &, int );
48  friend inline ePoint operator/( const ePoint &, double );
49 private:
50  int xp;
51  int yp;
52 };
53 
54 
55 inline int ePoint::manhattanLength() const
56 {
57  return ABS(x())+ABS(y());
58 }
59 
60 
61 /*****************************************************************************
62  ePoint inline functions
63  *****************************************************************************/
64 
66 { xp=0; yp=0; }
67 
68 inline ePoint::ePoint( int xpos, int ypos )
69 { xp=(int)xpos; yp=(int)ypos; }
70 
71 inline ePoint::ePoint( float xpos, float ypos )
72 { xp=(int)xpos; yp=(int)ypos; }
73 
74 inline ePoint::ePoint( float xpos, int ypos )
75 { xp=(int)xpos; yp=(int)ypos; }
76 
77 inline ePoint::ePoint( int xpos, float ypos )
78 { xp=(int)xpos; yp=(int)ypos; }
79 
80 inline bool ePoint::isNull() const
81 { return xp == 0 && yp == 0; }
82 
83 inline int ePoint::x() const
84 { return xp; }
85 
86 inline int ePoint::y() const
87 { return yp; }
88 
89 inline void ePoint::setX( int x )
90 { xp = (int)x; }
91 
92 inline void ePoint::setY( int y )
93 { yp = (int)y; }
94 
95 inline int &ePoint::rx()
96 { return xp; }
97 
98 inline int &ePoint::ry()
99 { return yp; }
100 
102 { xp+=p.xp; yp+=p.yp; return *this; }
103 
105 { xp-=p.xp; yp-=p.yp; return *this; }
106 
107 inline ePoint &ePoint::operator*=( int c )
108 { xp*=(int)c; yp*=(int)c; return *this; }
109 
110 inline ePoint &ePoint::operator*=( double c )
111 { xp=(int)(xp*c); yp=(int)(yp*c); return *this; }
112 
113 inline bool operator==( const ePoint &p1, const ePoint &p2 )
114 { return p1.xp == p2.xp && p1.yp == p2.yp; }
115 
116 inline bool operator!=( const ePoint &p1, const ePoint &p2 )
117 { return p1.xp != p2.xp || p1.yp != p2.yp; }
118 
119 inline ePoint operator+( const ePoint &p1, const ePoint &p2 )
120 { return ePoint(p1.xp+p2.xp, p1.yp+p2.yp); }
121 
122 inline ePoint operator-( const ePoint &p1, const ePoint &p2 )
123 { return ePoint(p1.xp-p2.xp, p1.yp-p2.yp); }
124 
125 inline ePoint operator+( const ePoint &p1, const eSize &p2 )
126 { return ePoint(p1.xp+p2.width(), p1.yp+p2.height()); }
127 
128 inline ePoint operator-( const ePoint &p1, const eSize &p2 )
129 { return ePoint(p1.xp-p2.width(), p1.yp-p2.height()); }
130 
131 inline ePoint operator*( const ePoint &p, int c )
132 { return ePoint(p.xp*c, p.yp*c); }
133 
134 inline ePoint operator*( int c, const ePoint &p )
135 { return ePoint(p.xp*c, p.yp*c); }
136 
137 inline ePoint operator*( const ePoint &p, double c )
138 { return ePoint((int)(p.xp*c), (int)(p.yp*c)); }
139 
140 inline ePoint operator*( double c, const ePoint &p )
141 { return ePoint((int)(p.xp*c), (int)(p.yp*c)); }
142 
143 inline ePoint operator-( const ePoint &p )
144 { return ePoint(-p.xp, -p.yp); }
145 
146 inline ePoint &ePoint::operator/=( int c )
147 {
148  xp/=(int)c;
149  yp/=(int)c;
150  return *this;
151 }
152 
153 inline ePoint &ePoint::operator/=( double c )
154 {
155  xp=(int)(xp/c);
156  yp=(int)(yp/c);
157  return *this;
158 }
159 
160 inline ePoint operator/( const ePoint &p, int c )
161 {
162  return ePoint(p.xp/c, p.yp/c);
163 }
164 
165 inline ePoint operator/( const ePoint &p, double c )
166 {
167  return ePoint((int)(p.xp/c), (int)(p.yp/c));
168 }
169 
170 
171 #endif // EPOINT_H
Definition: epoint.h:9
int manhattanLength() const
Definition: epoint.h:55
bool isNull() const
Definition: epoint.h:80
friend ePoint operator-(const ePoint &, const ePoint &)
Definition: epoint.h:122
friend ePoint operator+(const ePoint &, const ePoint &)
Definition: epoint.h:119
int y() const
Definition: epoint.h:86
ePoint & operator/=(int c)
Definition: epoint.h:146
friend ePoint operator*(const ePoint &, int)
Definition: epoint.h:131
ePoint & operator+=(const ePoint &p)
Definition: epoint.h:101
void setY(int y)
Definition: epoint.h:92
int & rx()
Definition: epoint.h:95
ePoint & operator*=(int c)
Definition: epoint.h:107
friend bool operator==(const ePoint &, const ePoint &)
Definition: epoint.h:113
int x() const
Definition: epoint.h:83
ePoint & operator-=(const ePoint &p)
Definition: epoint.h:104
int & ry()
Definition: epoint.h:98
ePoint()
Definition: epoint.h:65
friend ePoint operator/(const ePoint &, int)
Definition: epoint.h:160
friend bool operator!=(const ePoint &, const ePoint &)
Definition: epoint.h:116
void setX(int x)
Definition: epoint.h:89
Definition: esize.h:8
int width() const
Definition: esize.h:72
int height() const
Definition: esize.h:75
ePoint operator+(const ePoint &p1, const ePoint &p2)
Definition: epoint.h:119
ePoint operator/(const ePoint &p, int c)
Definition: epoint.h:160
bool operator==(const ePoint &p1, const ePoint &p2)
Definition: epoint.h:113
ePoint operator*(const ePoint &p, int c)
Definition: epoint.h:131
#define ABS(x)
Definition: epoint.h:5
bool operator!=(const ePoint &p1, const ePoint &p2)
Definition: epoint.h:116
ePoint operator-(const ePoint &p1, const ePoint &p2)
Definition: epoint.h:122
p
Definition: upgrade.py:63
std::string int int y
Definition: picload.cpp:1503
std::string int x
Definition: picload.cpp:1503