[190] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qwmatrix.cpp:51 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>QWMatrix Class</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QWMatrix Class Reference</h1>
|
---|
| 33 |
|
---|
| 34 | <p>The QWMatrix class specifies 2D transformations of a
|
---|
| 35 | coordinate system.
|
---|
| 36 | <a href="#details">More...</a>
|
---|
| 37 | <p><tt>#include <<a href="qwmatrix-h.html">qwmatrix.h</a>></tt>
|
---|
| 38 | <p><a href="qwmatrix-members.html">List of all member functions.</a>
|
---|
| 39 | <h2>Public Members</h2>
|
---|
| 40 | <ul>
|
---|
| 41 | <li class=fn><a href="#QWMatrix"><b>QWMatrix</b></a> ()</li>
|
---|
| 42 | <li class=fn><a href="#QWMatrix-2"><b>QWMatrix</b></a> ( double m11, double m12, double m21, double m22, double dx, double dy )</li>
|
---|
| 43 | <li class=fn>void <a href="#setMatrix"><b>setMatrix</b></a> ( double m11, double m12, double m21, double m22, double dx, double dy )</li>
|
---|
| 44 | <li class=fn>double <a href="#m11"><b>m11</b></a> () const</li>
|
---|
| 45 | <li class=fn>double <a href="#m12"><b>m12</b></a> () const</li>
|
---|
| 46 | <li class=fn>double <a href="#m21"><b>m21</b></a> () const</li>
|
---|
| 47 | <li class=fn>double <a href="#m22"><b>m22</b></a> () const</li>
|
---|
| 48 | <li class=fn>double <a href="#dx"><b>dx</b></a> () const</li>
|
---|
| 49 | <li class=fn>double <a href="#dy"><b>dy</b></a> () const</li>
|
---|
| 50 | <li class=fn>void <a href="#map"><b>map</b></a> ( int x, int y, int * tx, int * ty ) const</li>
|
---|
| 51 | <li class=fn>void <a href="#map-2"><b>map</b></a> ( double x, double y, double * tx, double * ty ) const</li>
|
---|
| 52 | <li class=fn>QRect <a href="#mapRect"><b>mapRect</b></a> ( const QRect & rect ) const</li>
|
---|
| 53 | <li class=fn>QPoint <a href="#map-3"><b>map</b></a> ( const QPoint & p ) const</li>
|
---|
| 54 | <li class=fn>QRect map ( const QRect & r ) const <em>(obsolete)</em></li>
|
---|
| 55 | <li class=fn>QPointArray <a href="#map-5"><b>map</b></a> ( const QPointArray & a ) const</li>
|
---|
| 56 | <li class=fn>QRegion <a href="#map-6"><b>map</b></a> ( const QRegion & r ) const</li>
|
---|
| 57 | <li class=fn>QRegion <a href="#mapToRegion"><b>mapToRegion</b></a> ( const QRect & rect ) const</li>
|
---|
| 58 | <li class=fn>QPointArray <a href="#mapToPolygon"><b>mapToPolygon</b></a> ( const QRect & rect ) const</li>
|
---|
| 59 | <li class=fn>void <a href="#reset"><b>reset</b></a> ()</li>
|
---|
| 60 | <li class=fn>bool <a href="#isIdentity"><b>isIdentity</b></a> () const</li>
|
---|
| 61 | <li class=fn>QWMatrix & <a href="#translate"><b>translate</b></a> ( double dx, double dy )</li>
|
---|
| 62 | <li class=fn>QWMatrix & <a href="#scale"><b>scale</b></a> ( double sx, double sy )</li>
|
---|
| 63 | <li class=fn>QWMatrix & <a href="#shear"><b>shear</b></a> ( double sh, double sv )</li>
|
---|
| 64 | <li class=fn>QWMatrix & <a href="#rotate"><b>rotate</b></a> ( double a )</li>
|
---|
| 65 | <li class=fn>bool <a href="#isInvertible"><b>isInvertible</b></a> () const</li>
|
---|
| 66 | <li class=fn>double <a href="#det"><b>det</b></a> () const</li>
|
---|
| 67 | <li class=fn>QWMatrix <a href="#invert"><b>invert</b></a> ( bool * invertible = 0 ) const</li>
|
---|
| 68 | <li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const QWMatrix & m ) const</li>
|
---|
| 69 | <li class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const QWMatrix & m ) const</li>
|
---|
| 70 | <li class=fn>QWMatrix & <a href="#operator*-eq"><b>operator*=</b></a> ( const QWMatrix & m )</li>
|
---|
| 71 | <li class=fn>enum <a href="#TransformationMode-enum"><b>TransformationMode</b></a> { Points, Areas }</li>
|
---|
| 72 | </ul>
|
---|
| 73 | <h2>Static Public Members</h2>
|
---|
| 74 | <ul>
|
---|
| 75 | <li class=fn>void <a href="#setTransformationMode"><b>setTransformationMode</b></a> ( QWMatrix::TransformationMode m )</li>
|
---|
| 76 | <li class=fn>TransformationMode <a href="#transformationMode"><b>transformationMode</b></a> ()</li>
|
---|
| 77 | </ul>
|
---|
| 78 | <h2>Related Functions</h2>
|
---|
| 79 | <ul>
|
---|
| 80 | <li class=fn>QDataStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( QDataStream & s, const QWMatrix & m )</li>
|
---|
| 81 | <li class=fn>QDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( QDataStream & s, QWMatrix & m )</li>
|
---|
| 82 | </ul>
|
---|
| 83 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
| 84 |
|
---|
| 85 |
|
---|
| 86 | The QWMatrix class specifies 2D transformations of a
|
---|
| 87 | coordinate system.
|
---|
| 88 | <p>
|
---|
| 89 |
|
---|
| 90 | <p> The standard coordinate system of a <a href="qpaintdevice.html">paint
|
---|
| 91 | device</a> has the origin located at the top-left position. X
|
---|
| 92 | values increase to the right; Y values increase downward.
|
---|
| 93 | <p> This coordinate system is the default for the <a href="qpainter.html">QPainter</a>, which
|
---|
| 94 | renders graphics in a paint device. A user-defined coordinate
|
---|
| 95 | system can be specified by setting a QWMatrix for the painter.
|
---|
| 96 | <p> Example:
|
---|
| 97 | <pre>
|
---|
| 98 | MyWidget::paintEvent( <a href="qpaintevent.html">QPaintEvent</a> * )
|
---|
| 99 | {
|
---|
| 100 | <a href="qpainter.html">QPainter</a> p; // our painter
|
---|
| 101 | QWMatrix m; // our transformation matrix
|
---|
| 102 | m.<a href="#rotate">rotate</a>( 22.5 ); // rotated coordinate system
|
---|
| 103 | p.<a href="qpainter.html#begin">begin</a>( this ); // start painting
|
---|
| 104 | p.<a href="qpainter.html#setWorldMatrix">setWorldMatrix</a>( m ); // use rotated coordinate system
|
---|
| 105 | p.<a href="qpainter.html#drawText">drawText</a>( 30,20, "detator" ); // draw rotated text at 30,20
|
---|
| 106 | p.<a href="qpainter.html#end">end</a>(); // painting done
|
---|
| 107 | }
|
---|
| 108 | </pre>
|
---|
| 109 |
|
---|
| 110 | <p> A matrix specifies how to translate, scale, shear or rotate the
|
---|
| 111 | graphics; the actual transformation is performed by the drawing
|
---|
| 112 | routines in <a href="qpainter.html">QPainter</a> and by <a href="qpixmap.html#xForm">QPixmap::xForm</a>().
|
---|
| 113 | <p> The QWMatrix class contains a 3x3 matrix of the form:
|
---|
| 114 | <table align=center border=1 cellpadding=1 cellspacing=0>
|
---|
| 115 | <tr align=center><td>m11</td><td>m12</td><td> 0 </td></tr>
|
---|
| 116 | <tr align=center><td>m21</td><td>m22</td><td> 0 </td></tr>
|
---|
| 117 | <tr align=center><td>dx</td> <td>dy</td> <td> 1 </td></tr>
|
---|
| 118 | </table>
|
---|
| 119 | <p> A matrix transforms a point in the plane to another point:
|
---|
| 120 | <pre>
|
---|
| 121 | x' = m11*x + m21*y + dx
|
---|
| 122 | y' = m22*y + m12*x + dy
|
---|
| 123 | </pre>
|
---|
| 124 |
|
---|
| 125 | <p> The point <em>(x, y)</em> is the original point, and <em>(x', y')</em> is the
|
---|
| 126 | transformed point. <em>(x', y')</em> can be transformed back to <em>(x, y)</em> by performing the same operation on the <a href="#invert">inverted matrix</a>.
|
---|
| 127 | <p> The elements <em>dx</em> and <em>dy</em> specify horizontal and vertical
|
---|
| 128 | translation. The elements <em>m11</em> and <em>m22</em> specify horizontal and
|
---|
| 129 | vertical scaling. The elements <em>m12</em> and <em>m21</em> specify
|
---|
| 130 | horizontal and vertical shearing.
|
---|
| 131 | <p> The identity matrix has <em>m11</em> and <em>m22</em> set to 1; all others are
|
---|
| 132 | set to 0. This matrix maps a point to itself.
|
---|
| 133 | <p> Translation is the simplest transformation. Setting <em>dx</em> and <em>dy</em> will move the coordinate system <em>dx</em> units along the X axis
|
---|
| 134 | and <em>dy</em> units along the Y axis.
|
---|
| 135 | <p> Scaling can be done by setting <em>m11</em> and <em>m22</em>. For example,
|
---|
| 136 | setting <em>m11</em> to 2 and <em>m22</em> to 1.5 will double the height and
|
---|
| 137 | increase the width by 50%.
|
---|
| 138 | <p> Shearing is controlled by <em>m12</em> and <em>m21</em>. Setting these
|
---|
| 139 | elements to values different from zero will twist the coordinate
|
---|
| 140 | system.
|
---|
| 141 | <p> Rotation is achieved by carefully setting both the shearing
|
---|
| 142 | factors and the scaling factors. The QWMatrix also has a function
|
---|
| 143 | that sets <a href="#rotate">rotation</a> directly.
|
---|
| 144 | <p> QWMatrix lets you combine transformations like this:
|
---|
| 145 | <pre>
|
---|
| 146 | QWMatrix m; // identity matrix
|
---|
| 147 | m.<a href="#translate">translate</a>(10, -20); // first translate (10,-20)
|
---|
| 148 | m.<a href="#rotate">rotate</a>(25); // then rotate 25 degrees
|
---|
| 149 | m.<a href="#scale">scale</a>(1.2, 0.7); // finally scale it
|
---|
| 150 | </pre>
|
---|
| 151 |
|
---|
| 152 | <p> Here's the same example using basic matrix operations:
|
---|
| 153 | <pre>
|
---|
| 154 | double a = pi/180 * 25; // convert 25 to radians
|
---|
| 155 | double sina = sin(a);
|
---|
| 156 | double cosa = cos(a);
|
---|
| 157 | QWMatrix m1(1, 0, 0, 1, 10, -20); // translation matrix
|
---|
| 158 | QWMatrix m2( cosa, sina, // rotation matrix
|
---|
| 159 | -sina, cosa, 0, 0 );
|
---|
| 160 | QWMatrix m3(1.2, 0, 0, 0.7, 0, 0); // scaling matrix
|
---|
| 161 | QWMatrix m;
|
---|
| 162 | m = m3 * m2 * m1; // combine all transformations
|
---|
| 163 | </pre>
|
---|
| 164 |
|
---|
| 165 | <p> <a href="qpainter.html">QPainter</a> has functions to translate, scale, shear and rotate the
|
---|
| 166 | coordinate system without using a QWMatrix. Although these
|
---|
| 167 | functions are very convenient, it can be more efficient to build a
|
---|
| 168 | QWMatrix and call <a href="qpainter.html#setWorldMatrix">QPainter::setWorldMatrix</a>() if you want to perform
|
---|
| 169 | more than a single transform operation.
|
---|
| 170 | <p> <p>See also <a href="qpainter.html#setWorldMatrix">QPainter::setWorldMatrix</a>(), <a href="qpixmap.html#xForm">QPixmap::xForm</a>(), <a href="graphics.html">Graphics Classes</a>, and <a href="images.html">Image Processing Classes</a>.
|
---|
| 171 |
|
---|
| 172 | <hr><h2>Member Type Documentation</h2>
|
---|
| 173 | <h3 class=fn><a name="TransformationMode-enum"></a>QWMatrix::TransformationMode</h3>
|
---|
| 174 |
|
---|
| 175 | <p> <!-- index transformation matrix -->
|
---|
| 176 | <p> QWMatrix offers two transformation modes. Calculations can either
|
---|
| 177 | be done in terms of points (Points mode, the default), or in
|
---|
| 178 | terms of area (Area mode).
|
---|
| 179 | <p> In Points mode the transformation is applied to the points that
|
---|
| 180 | mark out the shape's bounding line. In Areas mode the
|
---|
| 181 | transformation is applied in such a way that the area of the
|
---|
| 182 | contained region is correctly transformed under the matrix.
|
---|
| 183 | <ul>
|
---|
| 184 | <li><tt>QWMatrix::Points</tt> - transformations are applied to the shape's points.
|
---|
| 185 | <li><tt>QWMatrix::Areas</tt> - transformations are applied (e.g. to the width and
|
---|
| 186 | height) so that the area is transformed.
|
---|
| 187 | </ul><p> Example:
|
---|
| 188 | <p> Suppose we have a rectangle,
|
---|
| 189 | <tt>QRect( 10, 20, 30, 40 )</tt> and a transformation matrix
|
---|
| 190 | <tt>QWMatrix( 2, 0, 0, 2, 0, 0 )</tt> to double the rectangle's size.
|
---|
| 191 | <p> In Points mode, the matrix will transform the top-left (10,20) and
|
---|
| 192 | the bottom-right (39,59) points producing a rectangle with its
|
---|
| 193 | top-left point at (20,40) and its bottom-right point at (78,118),
|
---|
| 194 | i.e. with a width of 59 and a height of 79.
|
---|
| 195 | <p> In Areas mode, the matrix will transform the top-left point in
|
---|
| 196 | the same way as in Points mode to (20/40), and double the width
|
---|
| 197 | and height, so the bottom-right will become (69,99), i.e. a width
|
---|
| 198 | of 60 and a height of 80.
|
---|
| 199 | <p> Because integer arithmetic is used (for speed), rounding
|
---|
| 200 | differences mean that the modes will produce slightly different
|
---|
| 201 | results given the same shape and the same transformation,
|
---|
| 202 | especially when scaling up. This also means that some operations
|
---|
| 203 | are not commutative.
|
---|
| 204 | <p> Under Points mode, <tt>matrix * ( region1 | region2 )</tt> is not equal to
|
---|
| 205 | <tt>matrix * region1 | matrix * region2</tt>. Under Area mode, <tt>matrix * (pointarray[i])</tt> is not neccesarily equal to
|
---|
| 206 | <tt>(matrix * pointarry)[i]</tt>.
|
---|
| 207 | <p> <center><img src="xform.png" alt="Comparison of Points and Areas TransformationModes"></center>
|
---|
| 208 | <hr><h2>Member Function Documentation</h2>
|
---|
| 209 | <h3 class=fn><a name="QWMatrix"></a>QWMatrix::QWMatrix ()
|
---|
| 210 | </h3>
|
---|
| 211 | Constructs an identity matrix. All elements are set to zero except
|
---|
| 212 | <em>m11</em> and <em>m22</em> (scaling), which are set to 1.
|
---|
| 213 |
|
---|
| 214 | <h3 class=fn><a name="QWMatrix-2"></a>QWMatrix::QWMatrix ( double m11, double m12, double m21, double m22, double dx, double dy )
|
---|
| 215 | </h3>
|
---|
| 216 | Constructs a matrix with the elements, <em>m11</em>, <em>m12</em>, <em>m21</em>, <em>m22</em>, <em>dx</em> and <em>dy</em>.
|
---|
| 217 |
|
---|
| 218 | <h3 class=fn>double <a name="det"></a>QWMatrix::det () const
|
---|
| 219 | </h3>
|
---|
| 220 |
|
---|
| 221 | <p> Returns the matrix's determinant.
|
---|
| 222 |
|
---|
| 223 | <h3 class=fn>double <a name="dx"></a>QWMatrix::dx () const
|
---|
| 224 | </h3>
|
---|
| 225 |
|
---|
| 226 | <p> Returns the horizontal translation.
|
---|
| 227 |
|
---|
| 228 | <h3 class=fn>double <a name="dy"></a>QWMatrix::dy () const
|
---|
| 229 | </h3>
|
---|
| 230 |
|
---|
| 231 | <p> Returns the vertical translation.
|
---|
| 232 |
|
---|
| 233 | <h3 class=fn><a href="qwmatrix.html">QWMatrix</a> <a name="invert"></a>QWMatrix::invert ( bool * invertible = 0 ) const
|
---|
| 234 | </h3>
|
---|
| 235 | Returns the inverted matrix.
|
---|
| 236 | <p> If the matrix is singular (not invertible), the identity matrix is
|
---|
| 237 | returned.
|
---|
| 238 | <p> If <em>invertible</em> is not 0: the value of <em>*invertible</em> is set
|
---|
| 239 | to TRUE if the matrix is invertible; otherwise <em>*invertible</em> is
|
---|
| 240 | set to FALSE.
|
---|
| 241 | <p> <p>See also <a href="#isInvertible">isInvertible</a>().
|
---|
| 242 |
|
---|
| 243 | <p>Example: <a href="tutorial1-14.html#x2433">t14/cannon.cpp</a>.
|
---|
| 244 | <h3 class=fn>bool <a name="isIdentity"></a>QWMatrix::isIdentity () const
|
---|
| 245 | </h3>
|
---|
| 246 | Returns TRUE if the matrix is the identity matrix; otherwise returns FALSE.
|
---|
| 247 | <p> <p>See also <a href="#reset">reset</a>().
|
---|
| 248 |
|
---|
| 249 | <h3 class=fn>bool <a name="isInvertible"></a>QWMatrix::isInvertible () const
|
---|
| 250 | </h3>
|
---|
| 251 |
|
---|
| 252 | <p> Returns TRUE if the matrix is invertible; otherwise returns FALSE.
|
---|
| 253 | <p> <p>See also <a href="#invert">invert</a>().
|
---|
| 254 |
|
---|
| 255 | <h3 class=fn>double <a name="m11"></a>QWMatrix::m11 () const
|
---|
| 256 | </h3>
|
---|
| 257 |
|
---|
| 258 | <p> Returns the X scaling factor.
|
---|
| 259 |
|
---|
| 260 | <h3 class=fn>double <a name="m12"></a>QWMatrix::m12 () const
|
---|
| 261 | </h3>
|
---|
| 262 |
|
---|
| 263 | <p> Returns the vertical shearing factor.
|
---|
| 264 |
|
---|
| 265 | <h3 class=fn>double <a name="m21"></a>QWMatrix::m21 () const
|
---|
| 266 | </h3>
|
---|
| 267 |
|
---|
| 268 | <p> Returns the horizontal shearing factor.
|
---|
| 269 |
|
---|
| 270 | <h3 class=fn>double <a name="m22"></a>QWMatrix::m22 () const
|
---|
| 271 | </h3>
|
---|
| 272 |
|
---|
| 273 | <p> Returns the Y scaling factor.
|
---|
| 274 |
|
---|
| 275 | <h3 class=fn>void <a name="map"></a>QWMatrix::map ( int x, int y, int * tx, int * ty ) const
|
---|
| 276 | </h3>
|
---|
| 277 | Transforms ( <em>x</em>, <em>y</em> ) to ( <em>*tx</em>, <em>*ty</em> ) using the formulae:
|
---|
| 278 | <p> <pre>
|
---|
| 279 | *tx = m11*x + m21*y + dx (rounded to the nearest integer)
|
---|
| 280 | *ty = m22*y + m12*x + dy (rounded to the nearest integer)
|
---|
| 281 | </pre>
|
---|
| 282 |
|
---|
| 283 |
|
---|
| 284 | <p>Examples: <a href="tutorial1-14.html#x2434">t14/cannon.cpp</a> and <a href="xform-example.html#x1278">xform/xform.cpp</a>.
|
---|
| 285 | <h3 class=fn>void <a name="map-2"></a>QWMatrix::map ( double x, double y, double * tx, double * ty ) const
|
---|
| 286 | </h3>
|
---|
| 287 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 288 | <p> Transforms ( <em>x</em>, <em>y</em> ) to ( <em>*tx</em>, <em>*ty</em> ) using the
|
---|
| 289 | following formulae:
|
---|
| 290 | <p> <pre>
|
---|
| 291 | *tx = m11*x + m21*y + dx
|
---|
| 292 | *ty = m22*y + m12*x + dy
|
---|
| 293 | </pre>
|
---|
| 294 |
|
---|
| 295 |
|
---|
| 296 | <h3 class=fn><a href="qpoint.html">QPoint</a> <a name="map-3"></a>QWMatrix::map ( const <a href="qpoint.html">QPoint</a> & p ) const
|
---|
| 297 | </h3>
|
---|
| 298 |
|
---|
| 299 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 300 | <p> Transforms <em>p</em> to using the formulae:
|
---|
| 301 | <p> <pre>
|
---|
| 302 | retx = m11*px + m21*py + dx (rounded to the nearest integer)
|
---|
| 303 | rety = m22*py + m12*px + dy (rounded to the nearest integer)
|
---|
| 304 | </pre>
|
---|
| 305 |
|
---|
| 306 |
|
---|
| 307 | <h3 class=fn><a href="qrect.html">QRect</a> <a name="map-4"></a>QWMatrix::map ( const <a href="qrect.html">QRect</a> & r ) const
|
---|
| 308 | </h3>
|
---|
| 309 |
|
---|
| 310 | <p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 311 | <p> Please use <a href="#mapRect">QWMatrix::mapRect</a>() instead.
|
---|
| 312 | <p> Note that this method does return the bounding rectangle of the <em>r</em>, when
|
---|
| 313 | shearing or rotations are used.
|
---|
| 314 |
|
---|
| 315 | <h3 class=fn><a href="qpointarray.html">QPointArray</a> <a name="map-5"></a>QWMatrix::map ( const <a href="qpointarray.html">QPointArray</a> & a ) const
|
---|
| 316 | </h3>
|
---|
| 317 |
|
---|
| 318 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 319 | <p> Returns the point array <em>a</em> transformed by calling map for each point.
|
---|
| 320 |
|
---|
| 321 | <h3 class=fn><a href="qregion.html">QRegion</a> <a name="map-6"></a>QWMatrix::map ( const <a href="qregion.html">QRegion</a> & r ) const
|
---|
| 322 | </h3>
|
---|
| 323 |
|
---|
| 324 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 325 | <p> Transforms the region <em>r</em>.
|
---|
| 326 | <p> Calling this method can be rather expensive, if rotations or
|
---|
| 327 | shearing are used.
|
---|
| 328 |
|
---|
| 329 | <h3 class=fn><a href="qrect.html">QRect</a> <a name="mapRect"></a>QWMatrix::mapRect ( const <a href="qrect.html">QRect</a> & rect ) const
|
---|
| 330 | </h3>
|
---|
| 331 | Returns the transformed rectangle <em>rect</em>.
|
---|
| 332 | <p> The bounding rectangle is returned if rotation or shearing has
|
---|
| 333 | been specified.
|
---|
| 334 | <p> If you need to know the exact region <em>rect</em> maps to use <a href="qsize.html#operator*-4">operator*</a>().
|
---|
| 335 | <p> <p>See also <a href="qsize.html#operator*-4">operator*</a>().
|
---|
| 336 |
|
---|
| 337 | <p>Example: <a href="xform-example.html#x1279">xform/xform.cpp</a>.
|
---|
| 338 | <h3 class=fn><a href="qpointarray.html">QPointArray</a> <a name="mapToPolygon"></a>QWMatrix::mapToPolygon ( const <a href="qrect.html">QRect</a> & rect ) const
|
---|
| 339 | </h3>
|
---|
| 340 | Returns the transformed rectangle <em>rect</em> as a polygon.
|
---|
| 341 | <p> Polygons and rectangles behave slightly differently
|
---|
| 342 | when transformed (due to integer rounding), so
|
---|
| 343 | <tt>matrix.map( QPointArray( rect ) )</tt> is not always the same as
|
---|
| 344 | <tt>matrix.mapToPolygon( rect )</tt>.
|
---|
| 345 |
|
---|
| 346 | <h3 class=fn><a href="qregion.html">QRegion</a> <a name="mapToRegion"></a>QWMatrix::mapToRegion ( const <a href="qrect.html">QRect</a> & rect ) const
|
---|
| 347 | </h3>
|
---|
| 348 |
|
---|
| 349 | <p> Returns the transformed rectangle <em>rect</em>.
|
---|
| 350 | <p> A rectangle which has been rotated or sheared may result in a
|
---|
| 351 | non-rectangular region being returned.
|
---|
| 352 | <p> Calling this method can be expensive, if rotations or shearing are
|
---|
| 353 | used. If you just need to know the bounding rectangle of the
|
---|
| 354 | returned region, use <a href="#mapRect">mapRect</a>() which is a lot faster than this
|
---|
| 355 | function.
|
---|
| 356 | <p> <p>See also <a href="#mapRect">QWMatrix::mapRect</a>().
|
---|
| 357 |
|
---|
| 358 | <h3 class=fn>bool <a name="operator!-eq"></a>QWMatrix::operator!= ( const <a href="qwmatrix.html">QWMatrix</a> & m ) const
|
---|
| 359 | </h3>
|
---|
| 360 | Returns TRUE if this matrix is not equal to <em>m</em>; otherwise returns FALSE.
|
---|
| 361 |
|
---|
| 362 | <h3 class=fn><a href="qwmatrix.html">QWMatrix</a> & <a name="operator*-eq"></a>QWMatrix::operator*= ( const <a href="qwmatrix.html">QWMatrix</a> & m )
|
---|
| 363 | </h3>
|
---|
| 364 | Returns the result of multiplying this matrix by matrix <em>m</em>.
|
---|
| 365 |
|
---|
| 366 | <h3 class=fn>bool <a name="operator-eq-eq"></a>QWMatrix::operator== ( const <a href="qwmatrix.html">QWMatrix</a> & m ) const
|
---|
| 367 | </h3>
|
---|
| 368 | Returns TRUE if this matrix is equal to <em>m</em>; otherwise returns FALSE.
|
---|
| 369 |
|
---|
| 370 | <h3 class=fn>void <a name="reset"></a>QWMatrix::reset ()
|
---|
| 371 | </h3>
|
---|
| 372 | Resets the matrix to an identity matrix.
|
---|
| 373 | <p> All elements are set to zero, except <em>m11</em> and <em>m22</em> (scaling)
|
---|
| 374 | which are set to 1.
|
---|
| 375 | <p> <p>See also <a href="#isIdentity">isIdentity</a>().
|
---|
| 376 |
|
---|
| 377 | <h3 class=fn><a href="qwmatrix.html">QWMatrix</a> & <a name="rotate"></a>QWMatrix::rotate ( double a )
|
---|
| 378 | </h3>
|
---|
| 379 | Rotates the coordinate system <em>a</em> degrees counterclockwise.
|
---|
| 380 | <p> Returns a reference to the matrix.
|
---|
| 381 | <p> <p>See also <a href="#translate">translate</a>(), <a href="#scale">scale</a>(), and <a href="#shear">shear</a>().
|
---|
| 382 |
|
---|
| 383 | <p>Examples: <a href="canvas-example.html#x2955">canvas/canvas.cpp</a>, <a href="desktop-example.html#x1764">desktop/desktop.cpp</a>, <a href="drawdemo-example.html#x1095">drawdemo/drawdemo.cpp</a>, <a href="tutorial1-14.html#x2435">t14/cannon.cpp</a>, and <a href="xform-example.html#x1280">xform/xform.cpp</a>.
|
---|
| 384 | <h3 class=fn><a href="qwmatrix.html">QWMatrix</a> & <a name="scale"></a>QWMatrix::scale ( double sx, double sy )
|
---|
| 385 | </h3>
|
---|
| 386 | Scales the coordinate system unit by <em>sx</em> horizontally and <em>sy</em>
|
---|
| 387 | vertically.
|
---|
| 388 | <p> Returns a reference to the matrix.
|
---|
| 389 | <p> <p>See also <a href="#translate">translate</a>(), <a href="#shear">shear</a>(), and <a href="#rotate">rotate</a>().
|
---|
| 390 |
|
---|
| 391 | <p>Examples: <a href="canvas-example.html#x2956">canvas/canvas.cpp</a>, <a href="fileiconview-example.html#x876">fileiconview/qfileiconview.cpp</a>, <a href="movies-example.html#x524">movies/main.cpp</a>, <a href="qmag-example.html#x1809">qmag/qmag.cpp</a>, <a href="showimg-example.html#x1357">showimg/showimg.cpp</a>, and <a href="xform-example.html#x1281">xform/xform.cpp</a>.
|
---|
| 392 | <h3 class=fn>void <a name="setMatrix"></a>QWMatrix::setMatrix ( double m11, double m12, double m21, double m22, double dx, double dy )
|
---|
| 393 | </h3>
|
---|
| 394 | Sets the matrix elements to the specified values, <em>m11</em>, <em>m12</em>,
|
---|
| 395 | <em>m21</em>, <em>m22</em>, <em>dx</em> and <em>dy</em>.
|
---|
| 396 |
|
---|
| 397 | <h3 class=fn>void <a name="setTransformationMode"></a>QWMatrix::setTransformationMode ( <a href="qwmatrix.html#TransformationMode-enum">QWMatrix::TransformationMode</a> m )<tt> [static]</tt>
|
---|
| 398 | </h3>
|
---|
| 399 | Sets the transformation mode that QWMatrix and painter
|
---|
| 400 | transformations use to <em>m</em>.
|
---|
| 401 | <p> <p>See also <a href="#TransformationMode-enum">QWMatrix::TransformationMode</a>.
|
---|
| 402 |
|
---|
| 403 | <h3 class=fn><a href="qwmatrix.html">QWMatrix</a> & <a name="shear"></a>QWMatrix::shear ( double sh, double sv )
|
---|
| 404 | </h3>
|
---|
| 405 | Shears the coordinate system by <em>sh</em> horizontally and <em>sv</em>
|
---|
| 406 | vertically.
|
---|
| 407 | <p> Returns a reference to the matrix.
|
---|
| 408 | <p> <p>See also <a href="#translate">translate</a>(), <a href="#scale">scale</a>(), and <a href="#rotate">rotate</a>().
|
---|
| 409 |
|
---|
| 410 | <p>Examples: <a href="drawdemo-example.html#x1096">drawdemo/drawdemo.cpp</a> and <a href="xform-example.html#x1282">xform/xform.cpp</a>.
|
---|
| 411 | <h3 class=fn><a href="qwmatrix.html#TransformationMode-enum">TransformationMode</a> <a name="transformationMode"></a>QWMatrix::transformationMode ()<tt> [static]</tt>
|
---|
| 412 | </h3>
|
---|
| 413 | Returns the current transformation mode.
|
---|
| 414 | <p> <p>See also <a href="#TransformationMode-enum">QWMatrix::TransformationMode</a>.
|
---|
| 415 |
|
---|
| 416 | <h3 class=fn><a href="qwmatrix.html">QWMatrix</a> & <a name="translate"></a>QWMatrix::translate ( double dx, double dy )
|
---|
| 417 | </h3>
|
---|
| 418 | Moves the coordinate system <em>dx</em> along the X-axis and <em>dy</em> along
|
---|
| 419 | the Y-axis.
|
---|
| 420 | <p> Returns a reference to the matrix.
|
---|
| 421 | <p> <p>See also <a href="#scale">scale</a>(), <a href="#shear">shear</a>(), and <a href="#rotate">rotate</a>().
|
---|
| 422 |
|
---|
| 423 | <p>Examples: <a href="canvas-example.html#x2957">canvas/canvas.cpp</a>, <a href="drawdemo-example.html#x1097">drawdemo/drawdemo.cpp</a>, <a href="tutorial1-14.html#x2436">t14/cannon.cpp</a>, and <a href="xform-example.html#x1283">xform/xform.cpp</a>.
|
---|
| 424 | <hr><h2>Related Functions</h2>
|
---|
| 425 | <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-lt-lt"></a>operator<< ( <a href="qdatastream.html">QDataStream</a> & s, const <a href="qwmatrix.html">QWMatrix</a> & m )
|
---|
| 426 | </h3>
|
---|
| 427 |
|
---|
| 428 | <p> Writes the matrix <em>m</em> to the stream <em>s</em> and returns a reference
|
---|
| 429 | to the stream.
|
---|
| 430 | <p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
|
---|
| 431 |
|
---|
| 432 | <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-gt-gt"></a>operator>> ( <a href="qdatastream.html">QDataStream</a> & s, <a href="qwmatrix.html">QWMatrix</a> & m )
|
---|
| 433 | </h3>
|
---|
| 434 |
|
---|
| 435 | <p> Reads the matrix <em>m</em> from the stream <em>s</em> and returns a reference
|
---|
| 436 | to the stream.
|
---|
| 437 | <p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
|
---|
| 438 |
|
---|
| 439 | <!-- eof -->
|
---|
| 440 | <hr><p>
|
---|
| 441 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 442 | Copyright © 1995-2007
|
---|
| 443 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
| 444 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 445 | <td>Copyright © 2007
|
---|
| 446 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 447 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 448 | </table></div></address></body>
|
---|
| 449 | </html>
|
---|