Kind-of worked on the R-Tree; not really enough time to do much.
[aesalon.git] / include / artisan / gviewport / Point.h
blob753cd052b8cae165241d4cc4b680b6986597532e
1 /** Aesalon, a tool to visualize program behaviour in real time.
2 Copyright (C) 2009-2011, Aesalon development team.
4 Aesalon is distributed under the terms of the GNU GPLv3. See
5 the included file LICENSE for more information.
7 @file include/artisan/gviewport/Point.h
8 */
10 #ifndef AesalonArtisan_GViewport_Point_H
11 #define AesalonArtisan_GViewport_Point_H
13 #include <QPoint>
15 namespace Artisan {
16 namespace GViewport {
18 /** A single point of data in two-dimensional space. */
19 class Point {
20 private:
21 /** The x-coordinate of this point. */
22 double m_x;
23 /** The y-coordinate of this point. */
24 double m_y;
25 public:
26 /** Default constructor; sets m_x = m_y = 0. */
27 Point() : m_x(0), m_y(0) {}
28 /** Simple constructor; sets the x/y coordinates as given. */
29 Point(double x, double y) : m_x(x), m_y(y) {}
30 /** QPoint "copy"-constructor; initializes this point to the value of a QPoint instance. */
31 Point(const QPoint &point) : m_x(point.x()), m_y(point.y()) {}
32 /** QPointF "copy"-constructor; initializes this point to the value of a QPointF instance. */
33 Point(const QPointF &point) : m_x(point.x()), m_y(point.y()) {}
35 /** Returns the x coordinate as a non-const reference for reading or modifying. */
36 double &x() { return m_x; }
37 /** Returns the x coordinate as a value reference for reading. */
38 double x() const { return m_x; }
39 /** Returns the y coordinate as a non-const reference for reading or modifying. */
40 double &y() { return m_y; }
41 /** Returns the y coordinate as a value reference for reading. */
42 double y() const { return m_y; }
44 /** Addition operator; adds the x/y coordinates of this point and another together and returns the result as a
45 new point.
46 @param other The second point.
47 @return The resulting point.
49 Point operator+(const Point &other) const {
50 return Point(m_x + other.m_x, m_y + other.m_y);
53 /** Converts this point to a QPointF instance. Useful for Qt integration. */
54 QPointF toQPoint() const {
55 return QPointF(m_x, m_y);
59 } // namespace GViewport
60 } // namespace Artisan
62 #endif