Merge branch 'pool_rebirth'
[tagua/yd.git] / src / point.h
blob6095d793fc9e371f72383ee0400bbbd6f4c38b38
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef POINT_H
12 #define POINT_H
14 #include <QPoint>
15 #include <iostream>
17 struct Point {
18 static Point invalid() { return Point(-1, -1); }
19 bool valid() const { return x != -1 && y != -1; }
21 int x, y;
22 Point(int x, int y);
23 Point();
25 QString row(int ysize) const;
26 QString col() const;
28 explicit Point(const QString& str, int ysize);
29 explicit Point(const QPoint&);
31 QString toString(int ysize) const;
33 Point operator+(const Point& other) const;
34 Point operator+=(const Point& other);
35 Point operator-() const;
36 Point operator-(const Point& other) const;
37 Point operator*(int n) const;
38 Point operator/(int n) const;
39 Point div(int n) const;
40 bool operator==(const Point& other) const;
41 bool operator!=(const Point& other) const;
42 bool operator<(const Point& other) const;
43 bool operator<=(const Point& other) const;
45 // true if for each coordinate of other, either it
46 // is -1, or it is equal to the corresponding
47 // coordinate of this
48 bool resembles(const Point& other) const;
50 operator QPoint() const;
52 Point normalizeInfinity() const;
53 double norm() const;
55 private:
56 int normalizeInfinityHelper(int n) const;
59 std::ostream& operator<<(std::ostream&, const Point&);
61 #endif // POINT_H