push c6c9a0f557d256d471fa4608ad1fd3b70424bdfb
[tagua/yd.git] / src / core / point.h
blob8fe209e0aa7d3ab330bc8a8b64f13a29b74b811d
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
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 <QDebug>
15 #include <QMetaType>
16 #include <QPoint>
18 #include "export.h"
20 struct TAGUA_EXPORT Point {
21 static Point invalid() { return Point(-1, -1); }
22 bool valid() const { return x != -1 && y != -1; }
24 int x, y;
25 Point(int x, int y);
26 Point();
28 QString row(int ysize) const;
29 QString numcol(int xsize) const;
30 QString col() const;
31 QString alpharow() const;
33 explicit Point(const QString& str, int ysize);
34 explicit Point(const QPoint&);
36 QString toString(int ysize) const;
38 Point operator+(const Point& other) const;
39 Point operator+=(const Point& other);
40 Point operator-() const;
41 Point operator-(const Point& other) const;
42 Point operator*(int n) const;
43 Point operator/(int n) const;
44 Point div(int n) const;
45 bool operator==(const Point& other) const;
46 bool operator!=(const Point& other) const;
47 bool operator<(const Point& other) const;
48 bool operator<=(const Point& other) const;
50 // true if for each coordinate of other, either it
51 // is -1, or it is equal to the corresponding
52 // coordinate of this
53 bool resembles(const Point& other) const;
55 operator QPoint() const;
57 Point normalizeInfinity() const;
58 double norm() const;
60 private:
61 int normalizeInfinityHelper(int n) const;
64 Q_DECLARE_METATYPE(Point)
66 TAGUA_EXPORT QDebug operator<<(QDebug, const Point&);
69 #endif // POINT_H