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
10 #ifndef AesalonArtisan_GViewport_Point_H
11 #define AesalonArtisan_GViewport_Point_H
18 /** A single point of data in two-dimensional space. */
21 /** The x-coordinate of this point. */
23 /** The y-coordinate of this point. */
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
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