Prepare 1.0 alpha3 release.
[tagua/yd.git] / src / point.h
blobe53c4f64993dd1ab740448be491e32a6d322dbed
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 <QPoint>
15 #include <iostream>
17 #include "export.h"
19 struct TAGUA_EXPORT Point {
20 static Point invalid() { return Point(-1, -1); }
21 bool valid() const { return x != -1 && y != -1; }
23 int x, y;
24 Point(int x, int y);
25 Point();
27 QString row(int ysize) const;
28 QString numcol(int xsize) const;
29 QString col() const;
30 QString alpharow() const;
32 explicit Point(const QString& str, int ysize);
33 explicit Point(const QPoint&);
35 QString toString(int ysize) const;
37 Point operator+(const Point& other) const;
38 Point operator+=(const Point& other);
39 Point operator-() const;
40 Point operator-(const Point& other) const;
41 Point operator*(int n) const;
42 Point operator/(int n) const;
43 Point div(int n) const;
44 bool operator==(const Point& other) const;
45 bool operator!=(const Point& other) const;
46 bool operator<(const Point& other) const;
47 bool operator<=(const Point& other) const;
49 // true if for each coordinate of other, either it
50 // is -1, or it is equal to the corresponding
51 // coordinate of this
52 bool resembles(const Point& other) const;
54 operator QPoint() const;
56 Point normalizeInfinity() const;
57 double norm() const;
59 private:
60 int normalizeInfinityHelper(int n) const;
63 TAGUA_EXPORT QDebug operator<<(QDebug dbg, const Point& c);
65 #endif // POINT_H