1// qpoint.sip generated by MetaSIP 2// 3// This file is part of the QtCore 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 23class QPoint 24{ 25%TypeHeaderCode 26#include <qpoint.h> 27%End 28 29%PickleCode 30 sipRes = Py_BuildValue((char *)"ii", sipCpp->x(), sipCpp->y()); 31%End 32 33public: 34 int manhattanLength() const; 35 QPoint(); 36 QPoint(int xpos, int ypos); 37 SIP_PYOBJECT __repr__() const /TypeHint="str"/; 38%MethodCode 39 if (sipCpp->isNull()) 40 { 41 #if PY_MAJOR_VERSION >= 3 42 sipRes = PyUnicode_FromString("PyQt5.QtCore.QPoint()"); 43 #else 44 sipRes = PyString_FromString("PyQt5.QtCore.QPoint()"); 45 #endif 46 } 47 else 48 { 49 sipRes = 50 #if PY_MAJOR_VERSION >= 3 51 PyUnicode_FromFormat 52 #else 53 PyString_FromFormat 54 #endif 55 ("PyQt5.QtCore.QPoint(%i, %i)", sipCpp->x(), sipCpp->y()); 56 } 57%End 58 59 bool isNull() const; 60 int __bool__() const; 61%MethodCode 62 sipRes = !sipCpp->isNull(); 63%End 64 65 int x() const; 66 int y() const; 67 void setX(int xpos); 68 void setY(int ypos); 69 QPoint &operator+=(const QPoint &p); 70 QPoint &operator-=(const QPoint &p); 71 QPoint &operator*=(int c /Constrained/); 72 QPoint &operator*=(double c); 73 QPoint &operator/=(qreal c); 74%If (Qt_5_1_0 -) 75 static int dotProduct(const QPoint &p1, const QPoint &p2); 76%End 77%If (Qt_5_14_0 -) 78 QPoint transposed() const; 79%End 80}; 81 82QDataStream &operator<<(QDataStream &, const QPoint & /Constrained/) /ReleaseGIL/; 83QDataStream &operator>>(QDataStream &, QPoint & /Constrained/) /ReleaseGIL/; 84bool operator==(const QPoint &p1, const QPoint &p2); 85bool operator!=(const QPoint &p1, const QPoint &p2); 86const QPoint operator+(const QPoint &p1, const QPoint &p2); 87const QPoint operator-(const QPoint &p1, const QPoint &p2); 88const QPoint operator*(const QPoint &p, int c /Constrained/); 89const QPoint operator*(int c /Constrained/, const QPoint &p); 90const QPoint operator*(const QPoint &p, double c); 91const QPoint operator*(double c, const QPoint &p); 92const QPoint operator-(const QPoint &p); 93const QPoint operator/(const QPoint &p, qreal c); 94 95class QPointF /TypeHintIn="Union[QPointF, QPoint]"/ 96{ 97%TypeHeaderCode 98#include <qpoint.h> 99%End 100 101%ConvertToTypeCode 102// Allow a QPoint whenever a QPointF is expected. This is mainly to help source 103// compatibility for Qt5. 104 105if (sipIsErr == NULL) 106 return (sipCanConvertToType(sipPy, sipType_QPointF, SIP_NO_CONVERTORS) || 107 sipCanConvertToType(sipPy, sipType_QPoint, 0)); 108 109if (sipCanConvertToType(sipPy, sipType_QPointF, SIP_NO_CONVERTORS)) 110{ 111 *sipCppPtr = reinterpret_cast<QPointF *>(sipConvertToType(sipPy, sipType_QPointF, sipTransferObj, SIP_NO_CONVERTORS, 0, sipIsErr)); 112 113 return 0; 114} 115 116int state; 117 118QPoint *pt = reinterpret_cast<QPoint *>(sipConvertToType(sipPy, sipType_QPoint, 0, 0, &state, sipIsErr)); 119 120if (*sipIsErr) 121{ 122 sipReleaseType(pt, sipType_QPoint, state); 123 return 0; 124} 125 126*sipCppPtr = new QPointF(*pt); 127 128sipReleaseType(pt, sipType_QPoint, state); 129 130return sipGetState(sipTransferObj); 131%End 132 133%PickleCode 134 sipRes = Py_BuildValue((char *)"dd", sipCpp->x(), sipCpp->y()); 135%End 136 137public: 138 QPointF(); 139 QPointF(qreal xpos, qreal ypos); 140 QPointF(const QPoint &p); 141 SIP_PYOBJECT __repr__() const /TypeHint="str"/; 142%MethodCode 143 if (sipCpp->isNull()) 144 { 145 #if PY_MAJOR_VERSION >= 3 146 sipRes = PyUnicode_FromString("PyQt5.QtCore.QPointF()"); 147 #else 148 sipRes = PyString_FromString("PyQt5.QtCore.QPointF()"); 149 #endif 150 } 151 else 152 { 153 PyObject *x = PyFloat_FromDouble(sipCpp->x()); 154 PyObject *y = PyFloat_FromDouble(sipCpp->y()); 155 156 if (x && y) 157 { 158 #if PY_MAJOR_VERSION >= 3 159 sipRes = PyUnicode_FromFormat("PyQt5.QtCore.QPointF(%R, %R)", x, y); 160 #else 161 sipRes = PyString_FromString("PyQt5.QtCore.QPointF("); 162 PyString_ConcatAndDel(&sipRes, PyObject_Repr(x)); 163 PyString_ConcatAndDel(&sipRes, PyString_FromString(", ")); 164 PyString_ConcatAndDel(&sipRes, PyObject_Repr(y)); 165 PyString_ConcatAndDel(&sipRes, PyString_FromString(")")); 166 #endif 167 } 168 169 Py_XDECREF(x); 170 Py_XDECREF(y); 171 } 172%End 173 174 bool isNull() const; 175 int __bool__() const; 176%MethodCode 177 sipRes = !sipCpp->isNull(); 178%End 179 180 qreal x() const; 181 qreal y() const; 182 void setX(qreal xpos); 183 void setY(qreal ypos); 184 QPointF &operator+=(const QPointF &p); 185 QPointF &operator-=(const QPointF &p); 186 QPointF &operator*=(qreal c); 187 QPointF &operator/=(qreal c); 188 QPoint toPoint() const; 189 qreal manhattanLength() const; 190%If (Qt_5_1_0 -) 191 static qreal dotProduct(const QPointF &p1, const QPointF &p2); 192%End 193%If (Qt_5_14_0 -) 194 QPointF transposed() const; 195%End 196}; 197 198QDataStream &operator<<(QDataStream &, const QPointF & /Constrained/) /ReleaseGIL/; 199QDataStream &operator>>(QDataStream &, QPointF & /Constrained/) /ReleaseGIL/; 200bool operator==(const QPointF &p1, const QPointF &p2); 201bool operator!=(const QPointF &p1, const QPointF &p2); 202const QPointF operator+(const QPointF &p1, const QPointF &p2); 203const QPointF operator-(const QPointF &p1, const QPointF &p2); 204const QPointF operator*(const QPointF &p, qreal c); 205const QPointF operator*(qreal c, const QPointF &p); 206const QPointF operator-(const QPointF &p); 207const QPointF operator/(const QPointF &p, qreal c); 208const QPoint operator+(const QPoint &p); 209const QPointF operator+(const QPointF &p); 210