File: qmatrix4x4.sip

package info (click to toggle)
python-qt4 4.11.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 39,748 kB
  • ctags: 6,146
  • sloc: python: 125,938; cpp: 12,612; xml: 292; makefile: 258; php: 27; sh: 27
file content (490 lines) | stat: -rw-r--r-- 14,155 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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
// qmatrix4x4.sip generated by MetaSIP on Thu Sep 11 18:36:31 2014
//
// This file is part of the QtGui Python extension module.
//
// Copyright (c) 2014 Riverbank Computing Limited <info@riverbankcomputing.com>
// 
// This file is part of PyQt.
// 
// This file may be used under the terms of the GNU General Public
// License versions 2.0 or 3.0 as published by the Free Software
// Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
// included in the packaging of this file.  Alternatively you may (at
// your option) use any later version of the GNU General Public
// License if such license has been publicly approved by Riverbank
// Computing Limited (or its successors, if any) and the KDE Free Qt
// Foundation. In addition, as a special exception, Riverbank gives you
// certain additional rights. These rights are described in the Riverbank
// GPL Exception version 1.1, which can be found in the file
// GPL_EXCEPTION.txt in this package.
// 
// If you are unsure which license is appropriate for your use, please
// contact the sales department at sales@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.


%If (Qt_4_6_0 -)
%ModuleCode
#include <qmatrix4x4.h>
%End
%End

%If (Qt_4_6_0 -)

class QMatrix4x4
{
%TypeHeaderCode
#include <qmatrix4x4.h>
%End

%PickleCode
    PYQT_FLOAT data[16];
    
    // We want the data in row-major order.
    sipCpp->copyDataTo(data);
    
    sipRes = Py_BuildValue((char *)"dddddddddddddddd",
            (double)data[0], (double)data[1], (double)data[2], (double)data[3],
            (double)data[4], (double)data[5], (double)data[6], (double)data[7],
            (double)data[8], (double)data[9], (double)data[10], (double)data[11],
            (double)data[12], (double)data[13], (double)data[14], (double)data[15]);
%End

public:
    QMatrix4x4();
%If (Qt_5_0_0 -)
    explicit QMatrix4x4(SIP_PYOBJECT values /DocType="sequence-of-float"/) [(const float *values)];
%MethodCode
        float values[16];
        
        if ((sipError = qtgui_matrixDataFromSequence(a0, 16, values)) == sipErrorNone)
            sipCpp = new QMatrix4x4(values);
%End

%End
%If (- Qt_5_0_0)
    explicit QMatrix4x4(SIP_PYOBJECT values /DocType="sequence-of-float"/) [(const qreal *values)];
%MethodCode
        qreal values[16];
        
        if ((sipError = qtgui_matrixDataFromSequence(a0, 16, values)) == sipErrorNone)
            sipCpp = new QMatrix4x4(values);
%End

%End
%If (Qt_5_0_0 -)
    QMatrix4x4(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44);
%End
%If (- Qt_5_0_0)
    QMatrix4x4(qreal m11, qreal m12, qreal m13, qreal m14, qreal m21, qreal m22, qreal m23, qreal m24, qreal m31, qreal m32, qreal m33, qreal m34, qreal m41, qreal m42, qreal m43, qreal m44);
%End
    QMatrix4x4(const QTransform &transform);
    QMatrix4x4(const QMatrix &matrix);
    SIP_PYOBJECT __repr__() const /DocType="str"/;
%MethodCode
        bool bad = false;
        int i;
        PyObject *m[16];
        PYQT_FLOAT data[16];
        
        // The raw data is in column-major order but we want row-major order.
        sipCpp->copyDataTo(data);
        
        for (i = 0; i < 16; ++i)
        {
            m[i] = PyFloat_FromDouble(data[i]);
        
            if (!m[i])
                bad = true;
        }
        
        if (!bad)
        {
        #if PY_MAJOR_VERSION >= 3
            sipRes = PyUnicode_FromFormat("PyQt4.QtGui.QMatrix4x4("
                    "%R, %R, %R, %R, "
                    "%R, %R, %R, %R, "
                    "%R, %R, %R, %R, "
                    "%R, %R, %R, %R)",
                    m[0], m[1], m[2], m[3],
                    m[4], m[5], m[6], m[7],
                    m[8], m[9], m[10], m[11],
                    m[12], m[13], m[14], m[15]);
        #else
            sipRes = PyString_FromString("PyQt4.QtGui.QMatrix4x4(");
        
            for (i = 0; i < 16; ++i)
            {
                if (i != 0)
                    PyString_ConcatAndDel(&sipRes, PyString_FromString(", "));
        
                PyString_ConcatAndDel(&sipRes, PyObject_Repr(m[i]));
            }
        
            PyString_ConcatAndDel(&sipRes, PyString_FromString(")"));
        #endif
        }
        
        for (i = 0; i < 16; ++i)
            Py_XDECREF(m[i]);
%End

%If (Qt_5_0_0 -)
    double determinant() const;
%End
%If (- Qt_5_0_0)
    qreal determinant() const;
%End
    QMatrix4x4 inverted(bool *invertible = 0) const;
    QMatrix4x4 transposed() const;
    QMatrix3x3 normalMatrix() const;
    void scale(const QVector3D &vector);
%If (Qt_5_0_0 -)
    void scale(float x, float y);
%End
%If (- Qt_5_0_0)
    void scale(qreal x, qreal y);
%End
%If (Qt_5_0_0 -)
    void scale(float x, float y, float z);
%End
%If (- Qt_5_0_0)
    void scale(qreal x, qreal y, qreal z);
%End
%If (Qt_5_0_0 -)
    void scale(float factor);
%End
%If (- Qt_5_0_0)
    void scale(qreal factor);
%End
    void translate(const QVector3D &vector);
%If (Qt_5_0_0 -)
    void translate(float x, float y);
%End
%If (- Qt_5_0_0)
    void translate(qreal x, qreal y);
%End
%If (Qt_5_0_0 -)
    void translate(float x, float y, float z);
%End
%If (- Qt_5_0_0)
    void translate(qreal x, qreal y, qreal z);
%End
%If (Qt_5_0_0 -)
    void rotate(float angle, const QVector3D &vector);
%End
%If (- Qt_5_0_0)
    void rotate(qreal angle, const QVector3D &vector);
%End
%If (Qt_5_0_0 -)
    void rotate(float angle, float x, float y, float z = 0.0f);
%End
%If (- Qt_5_0_0)
    void rotate(qreal angle, qreal x, qreal y, qreal z = 0.0);
%End
    void rotate(const QQuaternion &quaternion);
    void ortho(const QRect &rect);
    void ortho(const QRectF &rect);
%If (Qt_5_0_0 -)
    void ortho(float left, float right, float bottom, float top, float nearPlane, float farPlane);
%End
%If (- Qt_5_0_0)
    void ortho(qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane);
%End
%If (Qt_5_0_0 -)
    void frustum(float left, float right, float bottom, float top, float nearPlane, float farPlane);
%End
%If (- Qt_5_0_0)
    void frustum(qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane);
%End
%If (Qt_5_0_0 -)
    void perspective(float angle, float aspect, float nearPlane, float farPlane);
%End
%If (- Qt_5_0_0)
    void perspective(qreal angle, qreal aspect, qreal nearPlane, qreal farPlane);
%End
    void lookAt(const QVector3D &eye, const QVector3D &center, const QVector3D &up);
    void flipCoordinates();
%If (Qt_5_0_0 -)
    SIP_PYLIST copyDataTo() const /DocType="list-of-float"/;
%MethodCode
        float values[16];
        
        sipCpp->copyDataTo(values);
        sipError = qtgui_matrixDataAsList(16, values, &sipRes);
%End

%End
%If (- Qt_5_0_0)
    SIP_PYLIST copyDataTo() const /DocType="list-of-float"/;
%MethodCode
        qreal values[16];
        
        sipCpp->copyDataTo(values);
        sipError = qtgui_matrixDataAsList(16, values, &sipRes);
%End

%End
    QMatrix toAffine() const;
    QTransform toTransform() const;
%If (Qt_5_0_0 -)
    QTransform toTransform(float distanceToPlane) const;
%End
%If (- Qt_5_0_0)
    QTransform toTransform(qreal distanceToPlane) const;
%End
    QRect mapRect(const QRect &rect) const;
    QRectF mapRect(const QRectF &rect) const;
%If (Qt_5_0_0 -)
    SIP_PYLIST data() /DocType="list-of-float"/;
%MethodCode
        sipError = qtgui_matrixDataAsList(16, sipCpp->constData(), &sipRes);
%End

%End
%If (- Qt_5_0_0)
    SIP_PYLIST data() /DocType="list-of-float"/;
%MethodCode
        sipError = qtgui_matrixDataAsList(16, sipCpp->constData(), &sipRes);
%End

%End
    void optimize();
    SIP_PYOBJECT __getitem__(SIP_PYOBJECT) const;
%MethodCode
        int row, column;
        
        if ((sipError = qtgui_matrixParseIndex(a0, 4, 4, &row, &column)) == sipErrorNone)
        {
            sipRes = PyFloat_FromDouble(sipCpp->operator()(row, column));
        
            if (!sipRes)
                sipError = sipErrorFail;
        }
%End

    void __setitem__(SIP_PYOBJECT, qreal);
%MethodCode
        int row, column;
        
        if ((sipError = qtgui_matrixParseIndex(a0, 4, 4, &row, &column)) == sipErrorNone)
            sipCpp->operator()(row, column) = a1;
%End

    QVector4D column(int index) const;
    void setColumn(int index, const QVector4D &value);
    QVector4D row(int index) const;
    void setRow(int index, const QVector4D &value);
    bool isIdentity() const;
    void setToIdentity();
%If (Qt_5_0_0 -)
    void fill(float value);
%End
%If (- Qt_5_0_0)
    void fill(qreal value);
%End
    QMatrix4x4 &operator+=(const QMatrix4x4 &other);
    QMatrix4x4 &operator-=(const QMatrix4x4 &other);
    QMatrix4x4 &operator*=(const QMatrix4x4 &other);
%If (Qt_5_0_0 -)
    QMatrix4x4 &operator*=(float factor);
%End
%If (- Qt_5_0_0)
    QMatrix4x4 &operator*=(qreal factor);
%End
%If (Qt_5_0_0 -)
    QMatrix4x4 &operator/=(float divisor);
%End
%If (- Qt_5_0_0)
    QMatrix4x4 &operator/=(qreal divisor);
%End
    bool operator==(const QMatrix4x4 &other) const;
    bool operator!=(const QMatrix4x4 &other) const;
    QPoint map(const QPoint &point) const;
    QPointF map(const QPointF &point) const;
    QVector3D map(const QVector3D &point) const;
    QVector3D mapVector(const QVector3D &vector) const;
    QVector4D map(const QVector4D &point) const;
};

%End
%If (Qt_5_0_0 -)
QMatrix4x4 operator/(const QMatrix4x4 &matrix, float divisor);
%End
%If (Qt_4_6_0 - Qt_5_0_0)
QMatrix4x4 operator/(const QMatrix4x4 &matrix, qreal divisor);
%End
%If (Qt_4_6_0 -)
QMatrix4x4 operator+(const QMatrix4x4 &m1, const QMatrix4x4 &m2);
%End
%If (Qt_4_6_0 -)
QMatrix4x4 operator-(const QMatrix4x4 &m1, const QMatrix4x4 &m2);
%End
%If (Qt_4_6_0 -)
QMatrix4x4 operator*(const QMatrix4x4 &m1, const QMatrix4x4 &m2);
%End
%If (Qt_4_6_0 -)
QVector3D operator*(const QVector3D &vector, const QMatrix4x4 &matrix);
%End
%If (Qt_4_6_0 -)
QVector3D operator*(const QMatrix4x4 &matrix, const QVector3D &vector);
%End
%If (Qt_4_6_0 -)
QVector4D operator*(const QVector4D &vector, const QMatrix4x4 &matrix);
%End
%If (Qt_4_6_0 -)
QVector4D operator*(const QMatrix4x4 &matrix, const QVector4D &vector);
%End
%If (Qt_4_6_0 -)
QPoint operator*(const QPoint &point, const QMatrix4x4 &matrix);
%End
%If (Qt_4_6_0 -)
QPointF operator*(const QPointF &point, const QMatrix4x4 &matrix);
%End
%If (Qt_4_6_0 -)
QPoint operator*(const QMatrix4x4 &matrix, const QPoint &point);
%End
%If (Qt_4_6_0 -)
QPointF operator*(const QMatrix4x4 &matrix, const QPointF &point);
%End
%If (Qt_4_6_0 -)
QMatrix4x4 operator-(const QMatrix4x4 &matrix);
%End
%If (Qt_5_0_0 -)
QMatrix4x4 operator*(float factor, const QMatrix4x4 &matrix);
%End
%If (Qt_4_6_0 - Qt_5_0_0)
QMatrix4x4 operator*(qreal factor, const QMatrix4x4 &matrix);
%End
%If (Qt_5_0_0 -)
QMatrix4x4 operator*(const QMatrix4x4 &matrix, float factor);
%End
%If (Qt_4_6_0 - Qt_5_0_0)
QMatrix4x4 operator*(const QMatrix4x4 &matrix, qreal factor);
%End
%If (Qt_4_6_0 -)
bool qFuzzyCompare(const QMatrix4x4 &m1, const QMatrix4x4 &m2);
%End
%If (Qt_4_6_0 -)
QDataStream &operator<<(QDataStream &, const QMatrix4x4 & /Constrained/);
%End
%If (Qt_4_6_0 -)
QDataStream &operator>>(QDataStream &, QMatrix4x4 & /Constrained/);
%End

%ModuleHeaderCode
// Helpers for the matrix classes.
#if QT_VERSION >= 0x050000
typedef float PYQT_FLOAT;
#else
typedef qreal PYQT_FLOAT;
#endif

sipErrorState qtgui_matrixParseIndex(PyObject *tup, int nr_rows,
        int nr_columns, int *row, int *column);
sipErrorState qtgui_matrixDataFromSequence(PyObject *seq, int nr_values,
        PYQT_FLOAT *values);
sipErrorState qtgui_matrixDataAsList(int nr_values, const PYQT_FLOAT *values,
        PyObject **list);
%End

%ModuleCode
// Convert a Python object to a row and column.
sipErrorState qtgui_matrixParseIndex(PyObject *tup, int nr_rows,
        int nr_columns, int *row, int *column)
{
    sipErrorState es = sipErrorContinue;

#if PY_VERSION_HEX >= 0x02050000
    if (PyTuple_Check(tup) && PyArg_ParseTuple(tup, "ii", row, column))
#else
    if (PyTuple_Check(tup) && PyArg_ParseTuple(tup, const_cast<char *>("ii"), row, column))
#endif
        if (*row >= 0 && *row < nr_rows && *column >= 0 && *column < nr_columns)
            es = sipErrorNone;

    if (es == sipErrorContinue)
        PyErr_Format(PyExc_IndexError, "an index must be a row in the range 0 to %d and a column in the range 0 to %d", nr_rows - 1, nr_columns - 1);

    return es;
}


// Convert a Python object to an array of qreals.
sipErrorState qtgui_matrixDataFromSequence(PyObject *seq, int nr_values,
        PYQT_FLOAT *values)
{
    sipErrorState es;

    if (PySequence_Size(seq) == nr_values)
    {
        es = sipErrorNone;

        for (int i = 0; i < nr_values; ++i)
        {
            PyObject *value = PySequence_GetItem(seq, i);

            if (!value)
            {
                es = sipErrorFail;
                break;
            }

            PyErr_Clear();

            double d = PyFloat_AsDouble(value);

            if (PyErr_Occurred())
            {
                Py_DECREF(value);
                es = sipErrorContinue;
                break;
            }

            Py_DECREF(value);

            *values++ = d;
        }
    }
    else
    {
        es = sipErrorContinue;
    }

    if (es == sipErrorContinue)
        PyErr_Format(PyExc_TypeError, "a sequence of %d floats is expected",
                nr_values);

    return es;
}


// Convert an array of qreals to a Python list.
sipErrorState qtgui_matrixDataAsList(int nr_values, const PYQT_FLOAT *values,
        PyObject **list)
{
    PyObject *l = PyList_New(nr_values);

    if (!l)
        return sipErrorFail;

    for (int i = 0; i < nr_values; ++i)
    {
        PyObject *value = PyFloat_FromDouble(*values++);

        if (!value)
        {
            Py_DECREF(l);
            return sipErrorFail;
        }

        PyList_SET_ITEM(l, i, value);
    }

    *list = l;

    return sipErrorNone;
}
%End