Changeset 561 for trunk/src/gui/painting/qmatrix.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/painting/qmatrix.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 56 56 \brief The QMatrix class specifies 2D transformations of a 57 57 coordinate system. 58 59 \ingroup multimedia 58 \obsolete 59 60 \ingroup painting 60 61 61 62 A matrix specifies how to translate, scale, shear or rotate the 62 63 coordinate system, and is typically used when rendering graphics. 64 65 66 63 67 64 68 A QMatrix object can be built using the setMatrix(), scale(), … … 82 86 I). The inverted() function returns an inverted copy of \e this 83 87 matrix if it is invertible (otherwise it returns the identity 84 matrix). In addition, QMatrix provides the det () function88 matrix). In addition, QMatrix provides the det() function 85 89 returning the matrix's determinant. 86 90 … … 173 177 \endtable 174 178 175 \sa QPainter, {The Coordinate System}, {demos/affine}{Affine176 Transformations Demo}, {Transformations Example}179 \sa QPainter, 180 Transformations Demo}, {Transformations Example} 177 181 */ 178 182 … … 198 202 QMatrix member functions 199 203 *****************************************************************************/ 204 205 206 207 200 208 201 209 /*! … … 209 217 210 218 QMatrix::QMatrix() 211 { 212 _m11 = _m22 = 1.0; 213 _m12 = _m21 = _dx = _dy = 0.0; 219 : _m11(1.) 220 , _m12(0.) 221 , _m21(0.) 222 , _m22(1.) 223 , _dx(0.) 224 , _dy(0.) 225 { 214 226 } 215 227 … … 221 233 */ 222 234 223 QMatrix::QMatrix(qreal m11, qreal m12, qreal m21, qreal m22, 224 qreal dx, qreal dy) 225 { 226 _m11 = m11; _m12 = m12; 227 _m21 = m21; _m22 = m22; 228 _dx = dx; _dy = dy; 235 QMatrix::QMatrix(qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy) 236 : _m11(m11) 237 , _m12(m12) 238 , _m21(m21) 239 , _m22(m22) 240 , _dx(dx) 241 , _dy(dy) 242 { 229 243 } 230 244 … … 234 248 */ 235 249 QMatrix::QMatrix(const QMatrix &matrix) 236 { 237 *this = matrix; 250 : _m11(matrix._m11) 251 , _m12(matrix._m12) 252 , _m21(matrix._m21) 253 , _m22(matrix._m22) 254 , _dx(matrix._dx) 255 , _dy(matrix._dy) 256 { 238 257 } 239 258 … … 250 269 */ 251 270 252 void QMatrix::setMatrix(qreal m11, qreal m12, qreal m21, qreal m22, 253 qreal dx, qreal dy) 254 { 255 _m11 = m11; _m12 = m12; 256 _m21 = m21; _m22 = m22; 257 _dx = dx; _dy = dy; 271 void QMatrix::setMatrix(qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy) 272 { 273 _m11 = m11; 274 _m12 = m12; 275 _m21 = m21; 276 _m22 = m22; 277 _dx = dx; 278 _dy = dy; 258 279 } 259 280 … … 939 960 940 961 /*! 962 941 963 \fn qreal QMatrix::det() const 964 965 966 967 968 969 970 971 972 942 973 943 974 Returns the matrix's determinant. … … 965 996 QMatrix QMatrix::inverted(bool *invertible) const 966 997 { 967 qreal d eterminant = det();968 if (d eterminant== 0.0) {998 qreal dt(); 999 if (d == 0.0) { 969 1000 if (invertible) 970 1001 *invertible = false; // singular matrix 971 QMatrix defaultMatrix; 972 return defaultMatrix; 1002 return QMatrix(true); 973 1003 } 974 1004 else { // invertible matrix 975 1005 if (invertible) 976 1006 *invertible = true; 977 qreal dinv = 1.0/d eterminant;978 QMatrix imatrix((_m22*dinv), (-_m12*dinv),979 980 981 ((_m12*_dx - _m11*_dy)*dinv));982 return imatrix;1007 qreal dinv = 1.0/d; 1008 atrix((_m22*dinv), (-_m12*dinv), 1009 (-_m21*dinv), (_m11*dinv), 1010 ((_m21*_dy - _m22*_dx)*dinv), 1011 1012 ; 983 1013 } 984 1014 } … … 1055 1085 QMatrix QMatrix::operator *(const QMatrix &m) const 1056 1086 { 1057 QMatrix result = *this; 1058 result *= m; 1059 return result; 1087 qreal tm11 = _m11*m._m11 + _m12*m._m21; 1088 qreal tm12 = _m11*m._m12 + _m12*m._m22; 1089 qreal tm21 = _m21*m._m11 + _m22*m._m21; 1090 qreal tm22 = _m21*m._m12 + _m22*m._m22; 1091 1092 qreal tdx = _dx*m._m11 + _dy*m._m21 + m._dx; 1093 qreal tdy = _dx*m._m12 + _dy*m._m22 + m._dy; 1094 return QMatrix(tm11, tm12, tm21, tm22, tdx, tdy, true); 1060 1095 } 1061 1096 … … 1162 1197 << " dx=" << m.dx() 1163 1198 << " dy=" << m.dy() 1164 << ")";1199 << ; 1165 1200 return dbg.space(); 1166 1201 } … … 1178 1213 */ 1179 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1180 1229 QT_END_NAMESPACE
Note:
See TracChangeset
for help on using the changeset viewer.