1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the test suite of Qt for Python.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 
29 #ifndef POINT_H
30 #define POINT_H
31 
32 #include "complex.h"
33 #include <utility>
34 
35 #include "libsamplemacros.h"
36 
37 class LIBSAMPLE_API Point
38 {
39 public:
40     Point(int x = 0, int y = 0);
41     Point(double x, double y);
~Point()42     ~Point() {}
43 
x()44     inline double x() const { return m_x; }
y()45     inline double y() const { return m_y; }
46 
setX(double x)47     inline void setX(double x) { m_x = x; }
setY(double y)48     inline void setY(double y) { m_y = y; }
setXAsUint(unsigned int x)49     inline void setXAsUint(unsigned int x) { m_x = x; }
setYAsUint(unsigned int y)50     inline void setYAsUint(unsigned int y) { m_y = y; }
51 
52     // This method could simply return the midpoint,
53     // but the interesting part of the test is to set the
54     // result in the pointer argument.
55     void midpoint(const Point& other, Point* midpoint) const;
56 
57     Point* copy() const;
58 
getConstReferenceToSelf()59     inline const Point& getConstReferenceToSelf() const { return *this; }
getSelf()60     inline const Point* getSelf() const { return this; }
61 
62     // The != operator is not implemented for the purpose of testing
63     // for the absense of the __ne__ method in the Python binding.
64     bool operator==(const Point& other);
65 
66     Point operator+(const Point& other);
67     Point operator-(const Point& other);
68     Point operator/(int operand);
69 
70     friend LIBSAMPLE_API Point operator*(const Point& pt, double mult);
71     friend LIBSAMPLE_API Point operator*(const Point& pt, int mult);
72     friend LIBSAMPLE_API Point operator*(double mult, const Point& pt);
73     friend LIBSAMPLE_API Point operator*(int mult, const Point& pt);
74     friend LIBSAMPLE_API Point operator-(const Point& pt);
75     friend LIBSAMPLE_API bool operator!(const Point& pt);
76 
77     Point& operator+=(Point &other);
78     Point& operator-=(Point &other);
79 
80     void show();
81 
82 private:
83     double m_x;
84     double m_y;
85 };
86 
87 LIBSAMPLE_API Point operator*(const Point& pt, double mult);
88 LIBSAMPLE_API Point operator*(const Point& pt, int mult);
89 LIBSAMPLE_API Point operator*(double mult, const Point& pt);
90 LIBSAMPLE_API Point operator*(int mult, const Point& pt);
91 LIBSAMPLE_API Point operator-(const Point& pt);
92 LIBSAMPLE_API bool operator!(const Point& pt);
93 
94 LIBSAMPLE_API Complex transmutePointIntoComplex(const Point& point);
95 LIBSAMPLE_API Point transmuteComplexIntoPoint(const Complex& cpx);
96 
97 LIBSAMPLE_API Point operator*(const Point& pt, double multiplier);
98 
99 #endif // POINT_H
100