Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/painting/qmatrix.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5656    \brief The QMatrix class specifies 2D transformations of a
    5757    coordinate system.
    58 
    59     \ingroup multimedia
     58    \obsolete
     59
     60    \ingroup painting
    6061
    6162    A matrix specifies how to translate, scale, shear or rotate the
    6263    coordinate system, and is typically used when rendering graphics.
     64    QMatrix, in contrast to QTransform, does not allow perspective
     65    transformations. QTransform is the recommended transformation
     66    class in Qt.
    6367
    6468    A QMatrix object can be built using the setMatrix(), scale(),
     
    8286    I). The inverted() function returns an inverted copy of \e this
    8387    matrix if it is invertible (otherwise it returns the identity
    84     matrix). In addition, QMatrix provides the det() function
     88    matrix). In addition, QMatrix provides the determinant() function
    8589    returning the matrix's determinant.
    8690
     
    173177    \endtable
    174178
    175     \sa QPainter, {The Coordinate System}, {demos/affine}{Affine
    176     Transformations Demo}, {Transformations Example}
     179    \sa QPainter, QTransform, {The Coordinate System},
     180    {demos/affine}{Affine Transformations Demo}, {Transformations Example}
    177181*/
    178182
     
    198202  QMatrix member functions
    199203 *****************************************************************************/
     204/*!
     205    \fn QMatrix::QMatrix(Qt::Initialization)
     206    \internal
     207*/
    200208
    201209/*!
     
    209217
    210218QMatrix::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{
    214226}
    215227
     
    221233*/
    222234
    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;
     235QMatrix::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{
    229243}
    230244
     
    234248 */
    235249QMatrix::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{
    238257}
    239258
     
    250269*/
    251270
    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;
     271void 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;
    258279}
    259280
     
    939960
    940961/*!
     962    \obsolete
    941963    \fn qreal QMatrix::det() const
     964
     965    Returns the matrix's determinant.
     966
     967    \sa determinant()
     968*/
     969
     970/*!
     971    \since 4.6
     972    \fn qreal QMatrix::determinant() const
    942973
    943974    Returns the matrix's determinant.
     
    965996QMatrix QMatrix::inverted(bool *invertible) const
    966997{
    967     qreal determinant = det();
    968     if (determinant == 0.0) {
     998    qreal dtr = determinant();
     999    if (dtr == 0.0) {
    9691000        if (invertible)
    9701001            *invertible = false;                // singular matrix
    971         QMatrix defaultMatrix;
    972         return defaultMatrix;
     1002        return QMatrix(true);
    9731003    }
    9741004    else {                                        // invertible matrix
    9751005        if (invertible)
    9761006            *invertible = true;
    977         qreal dinv = 1.0/determinant;
    978         QMatrix imatrix((_m22*dinv),        (-_m12*dinv),
    979                           (-_m21*dinv), (_m11*dinv),
    980                           ((_m21*_dy - _m22*_dx)*dinv),
    981                           ((_m12*_dx - _m11*_dy)*dinv));
    982         return imatrix;
     1007        qreal dinv = 1.0/dtr;
     1008        return QMatrix((_m22*dinv),        (-_m12*dinv),
     1009                       (-_m21*dinv), (_m11*dinv),
     1010                       ((_m21*_dy - _m22*_dx)*dinv),
     1011                       ((_m12*_dx - _m11*_dy)*dinv),
     1012                       true);
    9831013    }
    9841014}
     
    10551085QMatrix QMatrix::operator *(const QMatrix &m) const
    10561086{
    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);
    10601095}
    10611096
     
    11621197                  << " dx=" << m.dx()
    11631198                  << " dy=" << m.dy()
    1164                   << ")";
     1199                  << ')';
    11651200    return dbg.space();
    11661201}
     
    11781213*/
    11791214
     1215
     1216/*!
     1217    \fn bool qFuzzyCompare(const QMatrix& m1, const QMatrix& m2)
     1218
     1219    \relates QMatrix
     1220    \since 4.6
     1221
     1222    \brief The qFuzzyCompare function is for comparing two matrices
     1223    using a fuzziness factor.
     1224   
     1225    Returns true if \a m1 and \a m2 are equal, allowing for a small
     1226    fuzziness factor for floating-point comparisons; false otherwise.
     1227*/
     1228
    11801229QT_END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.