| 1 | /****************************************************************************
|
|---|
| 2 | ** $Id: qwmatrix.h 2 2005-11-16 15:49:26Z dmik $
|
|---|
| 3 | **
|
|---|
| 4 | ** Definition of QWMatrix class
|
|---|
| 5 | **
|
|---|
| 6 | ** Created : 941020
|
|---|
| 7 | **
|
|---|
| 8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
|---|
| 9 | **
|
|---|
| 10 | ** This file is part of the kernel module of the Qt GUI Toolkit.
|
|---|
| 11 | **
|
|---|
| 12 | ** This file may be distributed under the terms of the Q Public License
|
|---|
| 13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
|---|
| 14 | ** LICENSE.QPL included in the packaging of this file.
|
|---|
| 15 | **
|
|---|
| 16 | ** This file may be distributed and/or modified under the terms of the
|
|---|
| 17 | ** GNU General Public License version 2 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 19 | ** packaging of this file.
|
|---|
| 20 | **
|
|---|
| 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
|---|
| 22 | ** licenses may use this file in accordance with the Qt Commercial License
|
|---|
| 23 | ** Agreement provided with the Software.
|
|---|
| 24 | **
|
|---|
| 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|---|
| 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|---|
| 27 | **
|
|---|
| 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
|---|
| 29 | ** information about Qt Commercial License Agreements.
|
|---|
| 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
|---|
| 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
|---|
| 32 | **
|
|---|
| 33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
|---|
| 34 | ** not clear to you.
|
|---|
| 35 | **
|
|---|
| 36 | **********************************************************************/
|
|---|
| 37 |
|
|---|
| 38 | #ifndef QWMATRIX_H
|
|---|
| 39 | #define QWMATRIX_H
|
|---|
| 40 |
|
|---|
| 41 | #ifndef QT_H
|
|---|
| 42 | #include "qwindowdefs.h"
|
|---|
| 43 | #include "qpointarray.h"
|
|---|
| 44 | #include "qrect.h"
|
|---|
| 45 | #include "qregion.h"
|
|---|
| 46 | #endif // QT_H
|
|---|
| 47 |
|
|---|
| 48 | #ifndef QT_NO_WMATRIX
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 | class Q_EXPORT QWMatrix // 2D transform matrix
|
|---|
| 52 | {
|
|---|
| 53 | public:
|
|---|
| 54 | QWMatrix();
|
|---|
| 55 | QWMatrix( double m11, double m12, double m21, double m22,
|
|---|
| 56 | double dx, double dy );
|
|---|
| 57 |
|
|---|
| 58 | void setMatrix( double m11, double m12, double m21, double m22,
|
|---|
| 59 | double dx, double dy );
|
|---|
| 60 |
|
|---|
| 61 | double m11() const { return _m11; }
|
|---|
| 62 | double m12() const { return _m12; }
|
|---|
| 63 | double m21() const { return _m21; }
|
|---|
| 64 | double m22() const { return _m22; }
|
|---|
| 65 | double dx() const { return _dx; }
|
|---|
| 66 | double dy() const { return _dy; }
|
|---|
| 67 |
|
|---|
| 68 | void map( int x, int y, int *tx, int *ty ) const;
|
|---|
| 69 | void map( double x, double y, double *tx, double *ty ) const;
|
|---|
| 70 | QRect mapRect( const QRect & ) const;
|
|---|
| 71 |
|
|---|
| 72 | QPoint map( const QPoint &p ) const { return operator *( p ); }
|
|---|
| 73 | QRect map( const QRect &r ) const { return mapRect ( r ); }
|
|---|
| 74 | QPointArray map( const QPointArray &a ) const { return operator * ( a ); }
|
|---|
| 75 | QRegion map( const QRegion &r ) const { return operator *( r ); }
|
|---|
| 76 | QRegion mapToRegion( const QRect &r ) const { return operator *( r ); }
|
|---|
| 77 | QPointArray mapToPolygon( const QRect &r ) const;
|
|---|
| 78 |
|
|---|
| 79 | void reset();
|
|---|
| 80 | bool isIdentity() const;
|
|---|
| 81 |
|
|---|
| 82 | QWMatrix &translate( double dx, double dy );
|
|---|
| 83 | QWMatrix &scale( double sx, double sy );
|
|---|
| 84 | QWMatrix &shear( double sh, double sv );
|
|---|
| 85 | QWMatrix &rotate( double a );
|
|---|
| 86 |
|
|---|
| 87 | bool isInvertible() const { return (_m11*_m22 - _m12*_m21) != 0; }
|
|---|
| 88 | double det() const { return _m11*_m22 - _m12*_m21; }
|
|---|
| 89 |
|
|---|
| 90 | QWMatrix invert( bool * = 0 ) const;
|
|---|
| 91 |
|
|---|
| 92 | bool operator==( const QWMatrix & ) const;
|
|---|
| 93 | bool operator!=( const QWMatrix & ) const;
|
|---|
| 94 | QWMatrix &operator*=( const QWMatrix & );
|
|---|
| 95 |
|
|---|
| 96 | /* we use matrix multiplication semantics here */
|
|---|
| 97 | QPoint operator * (const QPoint & ) const;
|
|---|
| 98 | QRegion operator * (const QRect & ) const;
|
|---|
| 99 | QRegion operator * (const QRegion & ) const;
|
|---|
| 100 | QPointArray operator * ( const QPointArray &a ) const;
|
|---|
| 101 |
|
|---|
| 102 | enum TransformationMode {
|
|---|
| 103 | Points, Areas
|
|---|
| 104 | };
|
|---|
| 105 | static void setTransformationMode( QWMatrix::TransformationMode m );
|
|---|
| 106 | static TransformationMode transformationMode();
|
|---|
| 107 | private:
|
|---|
| 108 | double _m11, _m12;
|
|---|
| 109 | double _m21, _m22;
|
|---|
| 110 | double _dx, _dy;
|
|---|
| 111 | };
|
|---|
| 112 |
|
|---|
| 113 | Q_EXPORT QWMatrix operator*( const QWMatrix &, const QWMatrix & );
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 | /*****************************************************************************
|
|---|
| 117 | QWMatrix stream functions
|
|---|
| 118 | *****************************************************************************/
|
|---|
| 119 |
|
|---|
| 120 | Q_EXPORT QDataStream &operator<<( QDataStream &, const QWMatrix & );
|
|---|
| 121 | Q_EXPORT QDataStream &operator>>( QDataStream &, QWMatrix & );
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 | #endif // QT_NO_WMATRIX
|
|---|
| 125 |
|
|---|
| 126 | #endif // QWMATRIX_H
|
|---|