61 class QVariant; |
61 class QVariant; |
62 |
62 |
63 class Q_GUI_EXPORT QMatrix4x4 |
63 class Q_GUI_EXPORT QMatrix4x4 |
64 { |
64 { |
65 public: |
65 public: |
66 inline QMatrix4x4() { setIdentity(); } |
66 inline QMatrix4x4() { setToIdentity(); } |
67 explicit QMatrix4x4(const qreal *values); |
67 explicit QMatrix4x4(const qreal *values); |
68 inline QMatrix4x4(qreal m11, qreal m12, qreal m13, qreal m14, |
68 inline QMatrix4x4(qreal m11, qreal m12, qreal m13, qreal m14, |
69 qreal m21, qreal m22, qreal m23, qreal m24, |
69 qreal m21, qreal m22, qreal m23, qreal m24, |
70 qreal m31, qreal m32, qreal m33, qreal m34, |
70 qreal m31, qreal m32, qreal m33, qreal m34, |
71 qreal m41, qreal m42, qreal m43, qreal m44); |
71 qreal m41, qreal m42, qreal m43, qreal m44); |
125 friend Q_GUI_EXPORT QMatrix4x4 operator/(const QMatrix4x4& matrix, qreal divisor); |
125 friend Q_GUI_EXPORT QMatrix4x4 operator/(const QMatrix4x4& matrix, qreal divisor); |
126 |
126 |
127 friend inline bool qFuzzyCompare(const QMatrix4x4& m1, const QMatrix4x4& m2); |
127 friend inline bool qFuzzyCompare(const QMatrix4x4& m1, const QMatrix4x4& m2); |
128 |
128 |
129 #ifndef QT_NO_VECTOR3D |
129 #ifndef QT_NO_VECTOR3D |
130 QMatrix4x4& scale(const QVector3D& vector); |
130 void scale(const QVector3D& vector); |
131 QMatrix4x4& translate(const QVector3D& vector); |
131 void translate(const QVector3D& vector); |
132 QMatrix4x4& rotate(qreal angle, const QVector3D& vector); |
132 void rotate(qreal angle, const QVector3D& vector); |
133 #endif |
133 #endif |
134 QMatrix4x4& scale(qreal x, qreal y); |
134 void scale(qreal x, qreal y); |
135 QMatrix4x4& scale(qreal x, qreal y, qreal z); |
135 void scale(qreal x, qreal y, qreal z); |
136 QMatrix4x4& scale(qreal factor); |
136 void scale(qreal factor); |
137 QMatrix4x4& translate(qreal x, qreal y); |
137 void translate(qreal x, qreal y); |
138 QMatrix4x4& translate(qreal x, qreal y, qreal z); |
138 void translate(qreal x, qreal y, qreal z); |
139 QMatrix4x4& rotate(qreal angle, qreal x, qreal y, qreal z = 0.0f); |
139 void rotate(qreal angle, qreal x, qreal y, qreal z = 0.0f); |
140 #ifndef QT_NO_QUATERNION |
140 #ifndef QT_NO_QUATERNION |
141 QMatrix4x4& rotate(const QQuaternion& quaternion); |
141 void rotate(const QQuaternion& quaternion); |
142 #endif |
142 #endif |
143 |
143 |
|
144 void ortho(const QRect& rect); |
|
145 void ortho(const QRectF& rect); |
|
146 void ortho(qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane); |
|
147 void frustum(qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane); |
|
148 void perspective(qreal angle, qreal aspect, qreal nearPlane, qreal farPlane); |
144 #ifndef QT_NO_VECTOR3D |
149 #ifndef QT_NO_VECTOR3D |
145 void extractAxisRotation(qreal &angle, QVector3D &axis) const; |
150 void lookAt(const QVector3D& eye, const QVector3D& center, const QVector3D& up); |
146 QVector3D extractTranslation() const; |
151 #endif |
147 #endif |
152 void flipCoordinates(); |
148 |
153 |
149 QMatrix4x4& ortho(const QRect& rect); |
154 void copyDataTo(qreal *values) const; |
150 QMatrix4x4& ortho(const QRectF& rect); |
|
151 QMatrix4x4& ortho(qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane); |
|
152 QMatrix4x4& frustum(qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane); |
|
153 QMatrix4x4& perspective(qreal angle, qreal aspect, qreal nearPlane, qreal farPlane); |
|
154 #ifndef QT_NO_VECTOR3D |
|
155 QMatrix4x4& lookAt(const QVector3D& eye, const QVector3D& center, const QVector3D& up); |
|
156 #endif |
|
157 QMatrix4x4& flipCoordinates(); |
|
158 |
|
159 void toValueArray(qreal *values) const; |
|
160 |
155 |
161 QMatrix toAffine() const; |
156 QMatrix toAffine() const; |
162 QTransform toTransform(qreal distanceToPlane = 1024.0f) const; |
157 QTransform toTransform() const; |
|
158 QTransform toTransform(qreal distanceToPlane) const; |
163 |
159 |
164 QPoint map(const QPoint& point) const; |
160 QPoint map(const QPoint& point) const; |
165 QPointF map(const QPointF& point) const; |
161 QPointF map(const QPointF& point) const; |
166 #ifndef QT_NO_VECTOR3D |
162 #ifndef QT_NO_VECTOR3D |
167 QVector3D map(const QVector3D& point) const; |
163 QVector3D map(const QVector3D& point) const; |
204 |
200 |
205 // Construct without initializing identity matrix. |
201 // Construct without initializing identity matrix. |
206 QMatrix4x4(int) { flagBits = General; } |
202 QMatrix4x4(int) { flagBits = General; } |
207 |
203 |
208 QMatrix4x4 orthonormalInverse() const; |
204 QMatrix4x4 orthonormalInverse() const; |
|
205 |
|
206 void projectedRotate(qreal angle, qreal x, qreal y, qreal z); |
|
207 |
|
208 friend class QGraphicsRotation; |
209 }; |
209 }; |
210 |
210 |
211 inline QMatrix4x4::QMatrix4x4 |
211 inline QMatrix4x4::QMatrix4x4 |
212 (qreal m11, qreal m12, qreal m13, qreal m14, |
212 (qreal m11, qreal m12, qreal m13, qreal m14, |
213 qreal m21, qreal m22, qreal m23, qreal m24, |
213 qreal m21, qreal m22, qreal m23, qreal m24, |