qpolygon.sip 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. // qpolygon.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtGui Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  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. class QPolygon
  22. {
  23. %TypeHeaderCode
  24. #include <qpolygon.h>
  25. %End
  26. %PickleCode
  27. PyObject *pl = PyList_New(sipCpp->count() * 2);
  28. for (int p = 0, i = 0; i < sipCpp->count(); ++i, p += 2)
  29. {
  30. int x, y;
  31. sipCpp->point(i, &x, &y);
  32. PyList_SetItem(pl, p, PyLong_FromLong(x));
  33. PyList_SetItem(pl, p + 1, PyLong_FromLong(y));
  34. }
  35. sipRes = Py_BuildValue("(N)", pl);
  36. %End
  37. public:
  38. QPolygon();
  39. QPolygon(const QRect &r, bool closed = false);
  40. QPolygon(const QList<QPoint> &v);
  41. QPolygon(const QVariant &variant /GetWrapper/) /NoDerived/;
  42. %MethodCode
  43. if (a0->canConvert<QPolygon>())
  44. sipCpp = new QPolygon(a0->value<QPolygon>());
  45. else
  46. sipError = sipBadCallableArg(0, a0Wrapper);
  47. %End
  48. void swap(QPolygon &other /Constrained/);
  49. void translate(int dx, int dy);
  50. void translate(const QPoint &offset);
  51. QPolygon translated(int dx, int dy) const;
  52. QPolygon translated(const QPoint &offset) const;
  53. QRect boundingRect() const;
  54. QPoint point(int i) const;
  55. void setPoint(int index, int x, int y);
  56. void setPoint(int index, const QPoint &p);
  57. void setPoints(int firstx, int firsty, ... /TypeHint="int"/);
  58. %MethodCode
  59. // Accept at least one pair of integer coordinates.
  60. int nPoints = 1 + ((PyTuple_Size(a2) + 1) >> 1);
  61. int *points = new int[nPoints * 2];
  62. points[0] = a0;
  63. points[1] = a1;
  64. for (Py_ssize_t i = 0; i < PyTuple_Size(a2); ++i)
  65. points[2 + i] = PyLong_AsLong(PyTuple_GetItem(a2, i));
  66. sipCpp->setPoints(nPoints, points);
  67. delete[] points;
  68. %End
  69. void putPoints(int index, int firstx, int firsty, ... /TypeHint="int"/);
  70. %MethodCode
  71. // Accept at least one pair of integer coordinates.
  72. int nPoints = 1 + ((PyTuple_Size(a3) + 1) >> 1);
  73. int *points = new int[nPoints * 2];
  74. points[0] = a1;
  75. points[1] = a2;
  76. for (Py_ssize_t i = 0; i < PyTuple_Size(a3); ++i)
  77. points[2 + i] = PyLong_AsLong(PyTuple_GetItem(a3, i));
  78. sipCpp->putPoints(a0, nPoints, points);
  79. delete[] points;
  80. %End
  81. void putPoints(int index, int nPoints, const QPolygon &fromPolygon, int from = 0);
  82. bool containsPoint(const QPoint &pt, Qt::FillRule fillRule) const;
  83. QPolygon united(const QPolygon &r) const;
  84. QPolygon intersected(const QPolygon &r) const;
  85. QPolygon subtracted(const QPolygon &r) const;
  86. bool intersects(const QPolygon &r) const;
  87. // Methods inherited from QList<QPoint> and Python special methods.
  88. // Keep in sync with QPolygonF and QXmlStreamAttributes.
  89. void append(const QPoint &value);
  90. const QPoint &at(int i) const;
  91. void clear();
  92. bool contains(const QPoint &value) const;
  93. int count(const QPoint &value) const;
  94. int count() const /__len__/;
  95. void *data();
  96. // Note the Qt return value is discarded as it would require handwritten code
  97. // and seems pretty useless.
  98. void fill(const QPoint &value, int size = -1);
  99. QPoint &first();
  100. int indexOf(const QPoint &value, int from = 0) const;
  101. void insert(int i, const QPoint &value);
  102. bool isEmpty() const;
  103. QPoint &last();
  104. int lastIndexOf(const QPoint &value, int from = -1) const;
  105. // Note the Qt return type is QList<QPoint>.
  106. QPolygon mid(int pos, int length = -1) const;
  107. void prepend(const QPoint &value);
  108. void remove(int i);
  109. void remove(int i, int count);
  110. void replace(int i, const QPoint &value);
  111. void resize(qsizetype size);
  112. int size() const;
  113. QPoint value(int i) const;
  114. QPoint value(int i, const QPoint &defaultValue) const;
  115. bool operator!=(const QPolygon &other) const;
  116. // Note the Qt return type is QList<QPoint>.
  117. QPolygon operator+(const QPolygon &other) const;
  118. QPolygon &operator+=(const QPolygon &other);
  119. QPolygon &operator+=(const QPoint &value);
  120. bool operator==(const QPolygon &other) const;
  121. SIP_PYOBJECT operator<<(const QPoint &value);
  122. %MethodCode
  123. *a0 << *a1;
  124. sipRes = sipArg0;
  125. Py_INCREF(sipRes);
  126. %End
  127. QPoint &operator[](int i);
  128. %MethodCode
  129. Py_ssize_t idx = sipConvertFromSequenceIndex(a0, sipCpp->count());
  130. if (idx < 0)
  131. sipIsErr = 1;
  132. else
  133. sipRes = &sipCpp->operator[]((int)idx);
  134. %End
  135. // Some additional Python special methods.
  136. void __setitem__(int i, const QPoint &value);
  137. %MethodCode
  138. int len;
  139. len = sipCpp->count();
  140. if ((a0 = (int)sipConvertFromSequenceIndex(a0, len)) < 0)
  141. sipIsErr = 1;
  142. else
  143. (*sipCpp)[a0] = *a1;
  144. %End
  145. void __setitem__(SIP_PYSLICE slice, const QPolygon &list);
  146. %MethodCode
  147. Py_ssize_t start, stop, step, slicelength;
  148. if (sipConvertFromSliceObject(a0, sipCpp->count(), &start, &stop, &step, &slicelength) < 0)
  149. {
  150. sipIsErr = 1;
  151. }
  152. else
  153. {
  154. int vlen = a1->count();
  155. if (vlen != slicelength)
  156. {
  157. sipBadLengthForSlice(vlen, slicelength);
  158. sipIsErr = 1;
  159. }
  160. else
  161. {
  162. QList<QPoint>::const_iterator it = a1->begin();
  163. for (Py_ssize_t i = 0; i < slicelength; ++i)
  164. {
  165. (*sipCpp)[start] = *it;
  166. start += step;
  167. ++it;
  168. }
  169. }
  170. }
  171. %End
  172. void __delitem__(int i);
  173. %MethodCode
  174. if ((a0 = (int)sipConvertFromSequenceIndex(a0, sipCpp->count())) < 0)
  175. sipIsErr = 1;
  176. else
  177. sipCpp->remove(a0);
  178. %End
  179. void __delitem__(SIP_PYSLICE slice);
  180. %MethodCode
  181. Py_ssize_t start, stop, step, slicelength;
  182. if (sipConvertFromSliceObject(a0, sipCpp->count(), &start, &stop, &step, &slicelength) < 0)
  183. {
  184. sipIsErr = 1;
  185. }
  186. else
  187. {
  188. for (Py_ssize_t i = 0; i < slicelength; ++i)
  189. {
  190. sipCpp->remove(start);
  191. start += step - 1;
  192. }
  193. }
  194. %End
  195. QPolygon operator[](SIP_PYSLICE slice);
  196. %MethodCode
  197. Py_ssize_t start, stop, step, slicelength;
  198. if (sipConvertFromSliceObject(a0, sipCpp->count(), &start, &stop, &step, &slicelength) < 0)
  199. {
  200. sipIsErr = 1;
  201. }
  202. else
  203. {
  204. sipRes = new QPolygon();
  205. for (Py_ssize_t i = 0; i < slicelength; ++i)
  206. {
  207. (*sipRes) += (*sipCpp)[start];
  208. start += step;
  209. }
  210. }
  211. %End
  212. int __contains__(const QPoint &value);
  213. %MethodCode
  214. sipRes = bool(sipCpp->contains(*a0));
  215. %End
  216. %If (Qt_6_4_0 -)
  217. QPolygonF toPolygonF() const;
  218. %End
  219. };
  220. QDataStream &operator<<(QDataStream &stream, const QPolygon &polygon) /ReleaseGIL/;
  221. QDataStream &operator>>(QDataStream &stream, QPolygon &polygon /Constrained/) /ReleaseGIL/;
  222. class QPolygonF
  223. {
  224. %TypeHeaderCode
  225. #include <qpolygon.h>
  226. %End
  227. public:
  228. QPolygonF();
  229. QPolygonF(const QList<QPointF> &v);
  230. QPolygonF(const QRectF &r);
  231. QPolygonF(const QPolygon &a);
  232. QPolygonF(const QVariant &variant /GetWrapper/) /NoDerived/;
  233. %MethodCode
  234. if (a0->canConvert<QPolygonF>())
  235. sipCpp = new QPolygonF(a0->value<QPolygonF>());
  236. else
  237. sipError = sipBadCallableArg(0, a0Wrapper);
  238. %End
  239. void swap(QPolygonF &other /Constrained/);
  240. void translate(qreal dx, qreal dy);
  241. void translate(const QPointF &offset);
  242. QPolygonF translated(qreal dx, qreal dy) const;
  243. QPolygonF translated(const QPointF &offset) const;
  244. QPolygon toPolygon() const;
  245. bool isClosed() const;
  246. QRectF boundingRect() const;
  247. bool containsPoint(const QPointF &pt, Qt::FillRule fillRule) const;
  248. QPolygonF united(const QPolygonF &r) const;
  249. QPolygonF intersected(const QPolygonF &r) const;
  250. QPolygonF subtracted(const QPolygonF &r) const;
  251. bool intersects(const QPolygonF &r) const;
  252. // Methods inherited from QList<QPointF> and Python special methods.
  253. // Keep in sync with QPolygon and QXmlStreamAttributes.
  254. void append(const QPointF &value);
  255. const QPointF &at(int i) const;
  256. void clear();
  257. bool contains(const QPointF &value) const;
  258. int count(const QPointF &value) const;
  259. int count() const /__len__/;
  260. void *data();
  261. // Note the Qt return value is discarded as it would require handwritten code
  262. // and seems pretty useless.
  263. void fill(const QPointF &value, int size = -1);
  264. QPointF &first();
  265. int indexOf(const QPointF &value, int from = 0) const;
  266. void insert(int i, const QPointF &value);
  267. bool isEmpty() const;
  268. QPointF &last();
  269. int lastIndexOf(const QPointF &value, int from = -1) const;
  270. // Note the Qt return type is QList<QPointF>.
  271. QPolygonF mid(int pos, int length = -1) const;
  272. void prepend(const QPointF &value);
  273. void remove(int i);
  274. void remove(int i, int count);
  275. void replace(int i, const QPointF &value);
  276. void resize(qsizetype size);
  277. int size() const;
  278. QPointF value(int i) const;
  279. QPointF value(int i, const QPointF &defaultValue) const;
  280. bool operator!=(const QPolygonF &other) const;
  281. // Note the Qt return type is QList<QPointF>.
  282. QPolygonF operator+(const QPolygonF &other) const;
  283. QPolygonF &operator+=(const QPolygonF &other);
  284. QPolygonF &operator+=(const QPointF &value);
  285. bool operator==(const QPolygonF &other) const;
  286. SIP_PYOBJECT operator<<(const QPointF &value);
  287. %MethodCode
  288. *a0 << *a1;
  289. sipRes = sipArg0;
  290. Py_INCREF(sipRes);
  291. %End
  292. QPointF &operator[](int i);
  293. %MethodCode
  294. Py_ssize_t idx = sipConvertFromSequenceIndex(a0, sipCpp->count());
  295. if (idx < 0)
  296. sipIsErr = 1;
  297. else
  298. sipRes = &sipCpp->operator[]((int)idx);
  299. %End
  300. // Some additional Python special methods.
  301. void __setitem__(int i, const QPointF &value);
  302. %MethodCode
  303. int len;
  304. len = sipCpp->count();
  305. if ((a0 = (int)sipConvertFromSequenceIndex(a0, len)) < 0)
  306. sipIsErr = 1;
  307. else
  308. (*sipCpp)[a0] = *a1;
  309. %End
  310. void __setitem__(SIP_PYSLICE slice, const QPolygonF &list);
  311. %MethodCode
  312. Py_ssize_t start, stop, step, slicelength;
  313. if (sipConvertFromSliceObject(a0, sipCpp->count(), &start, &stop, &step, &slicelength) < 0)
  314. {
  315. sipIsErr = 1;
  316. }
  317. else
  318. {
  319. int vlen = a1->count();
  320. if (vlen != slicelength)
  321. {
  322. sipBadLengthForSlice(vlen, slicelength);
  323. sipIsErr = 1;
  324. }
  325. else
  326. {
  327. QList<QPointF>::const_iterator it = a1->begin();
  328. for (Py_ssize_t i = 0; i < slicelength; ++i)
  329. {
  330. (*sipCpp)[start] = *it;
  331. start += step;
  332. ++it;
  333. }
  334. }
  335. }
  336. %End
  337. void __delitem__(int i);
  338. %MethodCode
  339. if ((a0 = (int)sipConvertFromSequenceIndex(a0, sipCpp->count())) < 0)
  340. sipIsErr = 1;
  341. else
  342. sipCpp->remove(a0);
  343. %End
  344. void __delitem__(SIP_PYSLICE slice);
  345. %MethodCode
  346. Py_ssize_t start, stop, step, slicelength;
  347. if (sipConvertFromSliceObject(a0, sipCpp->count(), &start, &stop, &step, &slicelength) < 0)
  348. {
  349. sipIsErr = 1;
  350. }
  351. else
  352. {
  353. for (Py_ssize_t i = 0; i < slicelength; ++i)
  354. {
  355. sipCpp->remove(start);
  356. start += step - 1;
  357. }
  358. }
  359. %End
  360. QPolygonF operator[](SIP_PYSLICE slice);
  361. %MethodCode
  362. Py_ssize_t start, stop, step, slicelength;
  363. if (sipConvertFromSliceObject(a0, sipCpp->count(), &start, &stop, &step, &slicelength) < 0)
  364. {
  365. sipIsErr = 1;
  366. }
  367. else
  368. {
  369. sipRes = new QPolygonF();
  370. for (Py_ssize_t i = 0; i < slicelength; ++i)
  371. {
  372. (*sipRes) += (*sipCpp)[start];
  373. start += step;
  374. }
  375. }
  376. %End
  377. int __contains__(const QPointF &value);
  378. %MethodCode
  379. sipRes = bool(sipCpp->contains(*a0));
  380. %End
  381. };
  382. QDataStream &operator<<(QDataStream &stream, const QPolygonF &array) /ReleaseGIL/;
  383. QDataStream &operator>>(QDataStream &stream, QPolygonF &array /Constrained/) /ReleaseGIL/;