File: qsggeometry.sip

package info (click to toggle)
pyqt5 5.11.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 15,956 kB
  • sloc: python: 93,806; cpp: 21,390; xml: 285; makefile: 266; sh: 31
file content (392 lines) | stat: -rw-r--r-- 12,143 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
// qsggeometry.sip generated by MetaSIP
//
// This file is part of the QtQuick Python extension module.
//
// Copyright (c) 2018 Riverbank Computing Limited <info@riverbankcomputing.com>
// 
// This file is part of PyQt5.
// 
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file.  Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
// 
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license.  For more information contact
// info@riverbankcomputing.com.
// 
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.


class QSGGeometry /Supertype=sip.wrapper/
{
%TypeHeaderCode
#include <qsggeometry.h>
%End

public:
// Convenient primitives and drawing modes.
enum /NoScope/
{
    GL_BYTE,
%If (PyQt_Desktop_OpenGL)
    GL_DOUBLE,
%End
    GL_FLOAT,
    GL_INT
};

enum /NoScope/
{
    GL_POINTS,
    GL_LINES,
    GL_LINE_LOOP,
    GL_LINE_STRIP,
    GL_TRIANGLES,
    GL_TRIANGLE_STRIP,
    GL_TRIANGLE_FAN
};

    struct Attribute
    {
%TypeHeaderCode
#include <qsggeometry.h>
%End

        int position;
        int tupleSize;
        int type;
        uint isVertexCoordinate;
%If (Qt_5_8_0 -)
        QSGGeometry::AttributeType attributeType;
%End
        static QSGGeometry::Attribute create(int pos, int tupleSize, int primitiveType, bool isPosition = false) /Factory/;
%If (Qt_5_8_0 -)
        static QSGGeometry::Attribute createWithAttributeType(int pos, int tupleSize, int primitiveType, QSGGeometry::AttributeType attributeType) /Factory/;
%End
    };

    struct AttributeSet /NoDefaultCtors/
    {
%TypeHeaderCode
#include <qsggeometry.h>
#include <QVector>
%End

        AttributeSet(SIP_PYOBJECT attributes /TypeHint="Iterable[QSGGeometry.Attribute]"/, int stride = 0);
%MethodCode
            PyObject *iter = PyObject_GetIter(a0);
            
            if (!iter
            #if PY_MAJOR_VERSION < 3
                || PyString_Check(a0)
            #endif
                || PyUnicode_Check(a0))
            {
                Py_XDECREF(iter);
                PyErr_SetString(PyExc_TypeError, "iterable object expected");
                sipError = sipErrorContinue;
            }
            else
            {
                QVector<QSGGeometry::Attribute> attrs;
                int stride = 0;
            
                for (Py_ssize_t i = 0; ; ++i)
                {
                    PyErr_Clear();
                    PyObject *itm = PyIter_Next(iter);
            
                    if (!itm)
                    {
                        if (PyErr_Occurred())
                            sipError = sipErrorFail;
            
                        break;
                    }
            
                    int state, is_err = 0;
                    QSGGeometry::Attribute *attr;
            
                    attr = reinterpret_cast<QSGGeometry::Attribute *>(
                            sipForceConvertToType(itm, sipType_QSGGeometry_Attribute, 0,
                            SIP_NOT_NONE, &state, &is_err));
            
                    if (is_err)
                    {
                        PyErr_Format(PyExc_TypeError,
                                "index %zd has type '%s' but 'QSGGeometry.Attribute' is expected",
                                i, sipPyTypeName(Py_TYPE(itm)));
            
                        Py_DECREF(itm);
                        sipError = sipErrorFail;
            
                        break;
                    }
            
                    // Calculate the stride if there no explicit one.
                    if (a1 <= 0)
                    {
                        int size;
            
                        switch (attr->type)
                        {
                        case GL_BYTE:
                            size = sizeof (qint8);
                            break;
            
            #if defined(SIPFeature_PyQt_Desktop_OpenGL)
            #if GL_DOUBLE != GL_FLOAT
                        case GL_DOUBLE:
                            size = sizeof (double);
                            break;
            #endif
            #endif
            
                        case GL_FLOAT:
                            size = sizeof (float);
                            break;
            
                        case GL_INT:
                            size = sizeof (qint32);
                            break;
            
                        default:
                            size = 0;
                        }
            
                        if (!size)
                        {
                            PyErr_Format(PyExc_TypeError,
                                    "index %zd has an unsupported primitive type",
                                    i);
            
                            sipReleaseType(attr, sipType_QSGGeometry_Attribute, state);
                            Py_DECREF(itm);
                            sipError = sipErrorFail;
            
                            break;
                        }
            
                        stride += attr->tupleSize * size;
                    }
            
                    attrs.append(*attr);
            
                    sipReleaseType(attr, sipType_QSGGeometry_Attribute, state);
                    Py_DECREF(itm);
                }
            
                Py_DECREF(iter);
            
                if (sipError == sipErrorNone)
                {
                    if (attrs.isEmpty())
                    {
                        PyErr_SetString(PyExc_TypeError, "no attributes defined");
                        sipError = sipErrorFail;
                    }
                    else
                    {
                        PyObject *bytes = SIPBytes_FromStringAndSize(
                                reinterpret_cast<char *>(attrs.data()),
                                sizeof (QSGGeometry::Attribute) * attrs.size());
            
                        if (!bytes)
                        {
                            sipError = sipErrorFail;
                        }
                        else
                        {
                            sipCpp = new QSGGeometry::AttributeSet;
            
                            sipCpp->count = attrs.size();
                            sipCpp->stride = (a1 > 0 ? a1 : stride);
                            sipCpp->attributes = reinterpret_cast<QSGGeometry::Attribute *>(
                                    SIPBytes_AsString(bytes));
            
                            sipSetUserObject(sipSelf, bytes);
                        }
                    }
                }
            }
%End

        int count;
        int stride;
        const QSGGeometry::Attribute *attributes /TypeHint="sip.array[QSGGeometry.Attribute]"/ {
%GetCode
            sipPy = sipConvertToTypedArray((void *)sipCpp->attributes,
                    sipType_QSGGeometry_Attribute, "iiiI", sizeof (QSGGeometry::Attribute),
                    sipCpp->count, SIP_READ_ONLY);
%End

%SetCode
            sipErr = 1;
            PyErr_SetString(PyExc_ValueError, "array is read-only");
%End

        };
    };

    struct Point2D
    {
%TypeHeaderCode
#include <qsggeometry.h>
%End

        float x;
        float y;
        void set(float nx, float ny);
    };

    struct TexturedPoint2D
    {
%TypeHeaderCode
#include <qsggeometry.h>
%End

        float x;
        float y;
        float tx;
        float ty;
        void set(float nx, float ny, float ntx, float nty);
    };

    struct ColoredPoint2D
    {
%TypeHeaderCode
#include <qsggeometry.h>
%End

        float x;
        float y;
        unsigned char r /PyInt/;
        unsigned char g /PyInt/;
        unsigned char b /PyInt/;
        unsigned char a /PyInt/;
        void set(float nx, float ny, uchar nr /PyInt/, uchar ng /PyInt/, uchar nb /PyInt/, uchar na /PyInt/);
    };

    static const QSGGeometry::AttributeSet &defaultAttributes_Point2D() /NoCopy/;
    static const QSGGeometry::AttributeSet &defaultAttributes_TexturedPoint2D() /NoCopy/;
    static const QSGGeometry::AttributeSet &defaultAttributes_ColoredPoint2D() /NoCopy/;

    enum DataPattern
    {
        AlwaysUploadPattern,
        StreamPattern,
        DynamicPattern,
        StaticPattern,
    };

    QSGGeometry(const QSGGeometry::AttributeSet &attribs /KeepReference/, int vertexCount, int indexCount = 0, int indexType = GL_UNSIGNED_SHORT);
    virtual ~QSGGeometry();
    void setDrawingMode(GLenum mode);
    GLenum drawingMode() const;
    void allocate(int vertexCount, int indexCount = 0);
    int vertexCount() const;
    void *vertexData();
    int indexType() const;
    int indexCount() const;
    void *indexData();
    int attributeCount() const;
    SIP_PYOBJECT attributes() const /TypeHint="sip.array[QSGGeometry.Attribute]"/;
%MethodCode
        sipRes = sipConvertToTypedArray((void *)sipCpp->attributes(),
                sipType_QSGGeometry_Attribute, "iiiI", sizeof (QSGGeometry::Attribute),
                sipCpp->attributeCount(), SIP_READ_ONLY);
%End

    int sizeOfVertex() const;
    static void updateRectGeometry(QSGGeometry *g, const QRectF &rect);
    static void updateTexturedRectGeometry(QSGGeometry *g, const QRectF &rect, const QRectF &sourceRect);
    void setIndexDataPattern(QSGGeometry::DataPattern p);
    QSGGeometry::DataPattern indexDataPattern() const;
    void setVertexDataPattern(QSGGeometry::DataPattern p);
    QSGGeometry::DataPattern vertexDataPattern() const;
    void markIndexDataDirty();
    void markVertexDataDirty();
    float lineWidth() const;
    void setLineWidth(float w);
    SIP_PYOBJECT indexDataAsUInt() /TypeHint="sip.array[int]"/;
%MethodCode
        sipRes = sipConvertToArray(sipCpp->indexDataAsUInt(), "I",
                sipCpp->indexCount(), 0);
%End

    SIP_PYOBJECT indexDataAsUShort() /TypeHint="sip.array[int]"/;
%MethodCode
        sipRes = sipConvertToArray(sipCpp->indexDataAsUShort(), "H",
                sipCpp->indexCount(), 0);
%End

    SIP_PYOBJECT vertexDataAsPoint2D() /TypeHint="sip.array[QSGGeometry.Point2D]"/;
%MethodCode
        sipRes = sipConvertToTypedArray(sipCpp->vertexDataAsPoint2D(),
                sipType_QSGGeometry_Point2D, "ff", sizeof (QSGGeometry::Point2D),
                sipCpp->vertexCount(), 0);
%End

    SIP_PYOBJECT vertexDataAsTexturedPoint2D() /TypeHint="sip.array[QSGGeometry.TexturedPoint2D]"/;
%MethodCode
        sipRes = sipConvertToTypedArray(sipCpp->vertexDataAsTexturedPoint2D(),
                sipType_QSGGeometry_TexturedPoint2D, "ffff",
                sizeof (QSGGeometry::TexturedPoint2D), sipCpp->vertexCount(), 0);
%End

    SIP_PYOBJECT vertexDataAsColoredPoint2D() /TypeHint="sip.array[QSGGeometry.ColoredPoint2D]"/;
%MethodCode
        sipRes = sipConvertToTypedArray(sipCpp->vertexDataAsColoredPoint2D(),
                sipType_QSGGeometry_ColoredPoint2D, "ffbbbb",
                sizeof (QSGGeometry::ColoredPoint2D), sipCpp->vertexCount(), 0);
%End

    int sizeOfIndex() const;
%If (Qt_5_8_0 -)

    enum AttributeType
    {
        UnknownAttribute,
        PositionAttribute,
        ColorAttribute,
        TexCoordAttribute,
        TexCoord1Attribute,
        TexCoord2Attribute,
    };

%End
%If (Qt_5_8_0 -)

    enum DrawingMode
    {
        DrawPoints,
        DrawLines,
        DrawLineLoop,
        DrawLineStrip,
        DrawTriangles,
        DrawTriangleStrip,
        DrawTriangleFan,
    };

%End
%If (Qt_5_8_0 -)

    enum Type
    {
        ByteType,
        UnsignedByteType,
        ShortType,
        UnsignedShortType,
        IntType,
        UnsignedIntType,
        FloatType,
    };

%End
%If (Qt_5_8_0 -)
    static void updateColoredRectGeometry(QSGGeometry *g, const QRectF &rect);
%End
};