home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qwmatrix.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  4KB  |  118 lines

  1. /****************************************************************************
  2. ** $Id:  qt/qwmatrix.h   3.0.0   edited Aug 14 10:49 $
  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. #endif // QT_H
  46.  
  47. #ifndef QT_NO_WMATRIX
  48.  
  49.  
  50. class Q_EXPORT QWMatrix                    // 2D transform matrix
  51. {
  52. public:
  53.     QWMatrix();
  54.     QWMatrix( double m11, double m12, double m21, double m22,
  55.           double dx, double dy );
  56.  
  57.     void    setMatrix( double m11, double m12, double m21, double m22,
  58.                double dx,  double dy );
  59.  
  60.     double    m11() const { return _m11; }
  61.     double    m12() const { return _m12; }
  62.     double    m21() const { return _m21; }
  63.     double    m22() const { return _m22; }
  64.     double    dx()  const { return _dx; }
  65.     double    dy()  const { return _dy; }
  66.  
  67.     void    map( int x, int y, int *tx, int *ty )          const;
  68.     void    map( double x, double y, double *tx, double *ty ) const;
  69.     QRect    mapRect( const QRect & )    const;
  70.  
  71.     QPoint    map( const QPoint &p )    const { return operator *( p ); }
  72.     QRect    map( const QRect &r )    const { return mapRect ( r ); }
  73.     QPointArray map( const QPointArray &a ) const { return operator * ( a ); }
  74.  
  75.     void    reset();
  76.     bool    isIdentity() const;
  77.  
  78.     QWMatrix   &translate( double dx, double dy );
  79.     QWMatrix   &scale( double sx, double sy );
  80.     QWMatrix   &shear( double sh, double sv );
  81.     QWMatrix   &rotate( double a );
  82.  
  83.     bool isInvertible() const { return (_m11*_m22 - _m12*_m21) != 0; }
  84.     QWMatrix    invert( bool * = 0 ) const;
  85.  
  86.     bool    operator==( const QWMatrix & ) const;
  87.     bool    operator!=( const QWMatrix & ) const;
  88.     QWMatrix   &operator*=( const QWMatrix & );
  89.  
  90.     /* we use matrix multiplication semantics here */
  91.     QPoint operator * (const QPoint & ) const;
  92.     QRegion operator * (const QRect & ) const;
  93.     QRegion operator * (const QRegion & ) const;
  94.     QPointArray operator *  ( const QPointArray &a ) const;
  95.     
  96. private:
  97.     QWMatrix   &bmul( const QWMatrix & );
  98.     double    _m11, _m12;
  99.     double    _m21, _m22;
  100.     double    _dx,  _dy;
  101. };
  102.  
  103.  
  104. Q_EXPORT QWMatrix operator*( const QWMatrix &, const QWMatrix & );
  105.  
  106.  
  107. /*****************************************************************************
  108.   QWMatrix stream functions
  109.  *****************************************************************************/
  110.  
  111. Q_EXPORT QDataStream &operator<<( QDataStream &, const QWMatrix & );
  112. Q_EXPORT QDataStream &operator>>( QDataStream &, QWMatrix & );
  113.  
  114.  
  115. #endif // QT_NO_WMATRIX
  116.  
  117. #endif // QWMATRIX_H
  118.