1// qvector2d.sip generated by MetaSIP
2//
3// This file is part of the QtGui Python extension module.
4//
5// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com>
6//
7// This file is part of PyQt5.
8//
9// This file may be used under the terms of the GNU General Public License
10// version 3.0 as published by the Free Software Foundation and appearing in
11// the file LICENSE included in the packaging of this file.  Please review the
12// following information to ensure the GNU General Public License version 3.0
13// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
14//
15// If you do not wish to use this file under the terms of the GPL version 3.0
16// then you may purchase a commercial license.  For more information contact
17// info@riverbankcomputing.com.
18//
19// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21
22
23%ModuleCode
24#include <qvector2d.h>
25%End
26
27class QVector2D
28{
29%TypeHeaderCode
30#include <qvector2d.h>
31%End
32
33%PickleCode
34    sipRes = Py_BuildValue((char *)"dd", (double)sipCpp->x(), (double)sipCpp->y());
35%End
36
37public:
38    QVector2D();
39    QVector2D(float xpos, float ypos);
40    explicit QVector2D(const QPoint &point);
41    explicit QVector2D(const QPointF &point);
42    explicit QVector2D(const QVector3D &vector);
43    explicit QVector2D(const QVector4D &vector);
44    SIP_PYOBJECT __repr__() const /TypeHint="str"/;
45%MethodCode
46        PyObject *x = PyFloat_FromDouble(sipCpp->x());
47        PyObject *y = PyFloat_FromDouble(sipCpp->y());
48
49        if (x && y)
50        {
51        #if PY_MAJOR_VERSION >= 3
52            sipRes = PyUnicode_FromFormat("PyQt5.QtGui.QVector2D(%R, %R)", x, y);
53        #else
54            sipRes = PyString_FromString("PyQt5.QtGui.QVector2D(");
55            PyString_ConcatAndDel(&sipRes, PyObject_Repr(x));
56            PyString_ConcatAndDel(&sipRes, PyString_FromString(", "));
57            PyString_ConcatAndDel(&sipRes, PyObject_Repr(y));
58            PyString_ConcatAndDel(&sipRes, PyString_FromString(")"));
59        #endif
60        }
61
62        Py_XDECREF(x);
63        Py_XDECREF(y);
64%End
65
66    float length() const;
67    float lengthSquared() const;
68    QVector2D normalized() const;
69    void normalize();
70    static float dotProduct(const QVector2D &v1, const QVector2D &v2);
71    QVector3D toVector3D() const;
72    QVector4D toVector4D() const;
73    bool isNull() const;
74    float x() const;
75    float y() const;
76    void setX(float aX);
77    void setY(float aY);
78    QVector2D &operator+=(const QVector2D &vector);
79    QVector2D &operator-=(const QVector2D &vector);
80    QVector2D &operator*=(float factor);
81    QVector2D &operator*=(const QVector2D &vector);
82    QVector2D &operator/=(float divisor);
83%If (Qt_5_5_0 -)
84    QVector2D &operator/=(const QVector2D &vector);
85%End
86    QPoint toPoint() const;
87    QPointF toPointF() const;
88%If (Qt_5_1_0 -)
89    float distanceToPoint(const QVector2D &point) const;
90%End
91%If (Qt_5_1_0 -)
92    float distanceToLine(const QVector2D &point, const QVector2D &direction) const;
93%End
94%If (Qt_5_2_0 -)
95    float operator[](int i) const;
96%End
97};
98
99bool operator==(const QVector2D &v1, const QVector2D &v2);
100bool operator!=(const QVector2D &v1, const QVector2D &v2);
101const QVector2D operator+(const QVector2D &v1, const QVector2D &v2);
102const QVector2D operator-(const QVector2D &v1, const QVector2D &v2);
103const QVector2D operator*(float factor, const QVector2D &vector);
104const QVector2D operator*(const QVector2D &vector, float factor);
105const QVector2D operator*(const QVector2D &v1, const QVector2D &v2);
106const QVector2D operator-(const QVector2D &vector);
107const QVector2D operator/(const QVector2D &vector, float divisor);
108%If (Qt_5_5_0 -)
109const QVector2D operator/(const QVector2D &vector, const QVector2D &divisor);
110%End
111bool qFuzzyCompare(const QVector2D &v1, const QVector2D &v2);
112QDataStream &operator<<(QDataStream &, const QVector2D & /Constrained/) /ReleaseGIL/;
113QDataStream &operator>>(QDataStream &, QVector2D & /Constrained/) /ReleaseGIL/;
114