map2d_widget
point.h
Go to the documentation of this file.
1 
12 /*
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 */
27 #ifndef OPOINT_H
28 #define OPOINT_H
29 
30 
31 #include <QString>
32 
33 namespace core {
34  struct Size;
35  struct Point
36  {
37  friend uint qHash(Point const& point);
38  friend bool operator==(Point const& lhs,Point const& rhs);
39  friend bool operator!=(Point const& lhs,Point const& rhs);
40  public:
41 
42  Point();
43  Point(int x,int y);
44  Point(Size sz);
45  Point(int dw);
46  bool IsEmpty(){return empty;}
47  int X()const{return this->x;}
48  int Y()const{return this->y;}
49  void SetX(const int &value){x=value;empty=false;}
50  void SetY(const int &value){y=value;empty=false;}
51  QString ToString()const{return "{"+QString::number(x)+","+QString::number(y)+"}";}
52 
53  static Point Empty;
54  void Offset(const int &dx,const int &dy)
55  {
56  x += dx;
57  y += dy;
58  }
59  void Offset(Point p)
60  {
61  Offset(p.x, p.y);
62  }
63  static int HIWORD(int n);
64  static int LOWORD(int n);
65 
66  private:
67  int x;
68  int y;
69  bool empty;
70  };
71 }
72 #endif // POINT_H
QString ToString() const
Definition: point.h:51
friend uint qHash(Point const &point)
Definition: point.cpp:51
static int LOWORD(int n)
Definition: point.cpp:68
Definition: accessmode.h:35
Definition: size.h:35
friend bool operator==(Point const &lhs, Point const &rhs)
Definition: point.cpp:55
Definition: point.h:35
static Point Empty
Definition: point.h:53
void SetY(const int &value)
Definition: point.h:50
void Offset(Point p)
Definition: point.h:59
friend bool operator!=(Point const &lhs, Point const &rhs)
Definition: point.cpp:59
void SetX(const int &value)
Definition: point.h:49
static int HIWORD(int n)
Definition: point.cpp:63
Point()
Definition: point.cpp:49
int X() const
Definition: point.h:47
int Y() const
Definition: point.h:48
bool IsEmpty()
Definition: point.h:46
void Offset(const int &dx, const int &dy)
Definition: point.h:54