<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QMatrix Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QMatrix Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QMatrix class specifies 2D transformations of a coordinate system. <a href="#details">More...</a></p> <h3>Methods</h3><ul><li><div class="fn" /><b><a href="qmatrix.html#QMatrix">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmatrix.html#QMatrix-2">__init__</a></b> (<i>self</i>, float <i>m11</i>, float <i>m12</i>, float <i>m21</i>, float <i>m22</i>, float <i>dx</i>, float <i>dy</i>)</li><li><div class="fn" /><b><a href="qmatrix.html#QMatrix-3">__init__</a></b> (<i>self</i>, QMatrix <i>matrix</i>)</li><li><div class="fn" />float <b><a href="qmatrix.html#det">det</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qmatrix.html#determinant">determinant</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qmatrix.html#dx">dx</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qmatrix.html#dy">dy</a></b> (<i>self</i>)</li><li><div class="fn" />(QMatrix, bool <i>invertible</i>) <b><a href="qmatrix.html#inverted">inverted</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qmatrix.html#isIdentity">isIdentity</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qmatrix.html#isInvertible">isInvertible</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qmatrix.html#m11">m11</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qmatrix.html#m12">m12</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qmatrix.html#m21">m21</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qmatrix.html#m22">m22</a></b> (<i>self</i>)</li><li><div class="fn" />(int <i>tx</i>, int <i>ty</i>) <b><a href="qmatrix.html#map">map</a></b> (<i>self</i>, int <i>x</i>, int <i>y</i>)</li><li><div class="fn" />(float <i>tx</i>, float <i>ty</i>) <b><a href="qmatrix.html#map-2">map</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>)</li><li><div class="fn" />QPoint <b><a href="qmatrix.html#map-3">map</a></b> (<i>self</i>, QPoint <i>p</i>)</li><li><div class="fn" />QPointF <b><a href="qmatrix.html#map-4">map</a></b> (<i>self</i>, QPointF <i>p</i>)</li><li><div class="fn" />QLine <b><a href="qmatrix.html#map-5">map</a></b> (<i>self</i>, QLine <i>l</i>)</li><li><div class="fn" />QLineF <b><a href="qmatrix.html#map-6">map</a></b> (<i>self</i>, QLineF <i>l</i>)</li><li><div class="fn" />QPolygonF <b><a href="qmatrix.html#map-7">map</a></b> (<i>self</i>, QPolygonF <i>a</i>)</li><li><div class="fn" />QPolygon <b><a href="qmatrix.html#map-8">map</a></b> (<i>self</i>, QPolygon <i>a</i>)</li><li><div class="fn" />QRegion <b><a href="qmatrix.html#map-9">map</a></b> (<i>self</i>, QRegion <i>r</i>)</li><li><div class="fn" />QPainterPath <b><a href="qmatrix.html#map-10">map</a></b> (<i>self</i>, QPainterPath <i>p</i>)</li><li><div class="fn" />QRect <b><a href="qmatrix.html#mapRect">mapRect</a></b> (<i>self</i>, QRect)</li><li><div class="fn" />QRectF <b><a href="qmatrix.html#mapRect-2">mapRect</a></b> (<i>self</i>, QRectF)</li><li><div class="fn" />QPolygon <b><a href="qmatrix.html#mapToPolygon">mapToPolygon</a></b> (<i>self</i>, QRect <i>r</i>)</li><li><div class="fn" /><b><a href="qmatrix.html#reset">reset</a></b> (<i>self</i>)</li><li><div class="fn" />QMatrix <b><a href="qmatrix.html#rotate">rotate</a></b> (<i>self</i>, float <i>a</i>)</li><li><div class="fn" />QMatrix <b><a href="qmatrix.html#scale">scale</a></b> (<i>self</i>, float <i>sx</i>, float <i>sy</i>)</li><li><div class="fn" /><b><a href="qmatrix.html#setMatrix">setMatrix</a></b> (<i>self</i>, float <i>m11</i>, float <i>m12</i>, float <i>m21</i>, float <i>m22</i>, float <i>dx</i>, float <i>dy</i>)</li><li><div class="fn" />QMatrix <b><a href="qmatrix.html#shear">shear</a></b> (<i>self</i>, float <i>sh</i>, float <i>sv</i>)</li><li><div class="fn" />QMatrix <b><a href="qmatrix.html#translate">translate</a></b> (<i>self</i>, float <i>dx</i>, float <i>dy</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qmatrix.html#__eq__">__eq__</a></b> (<i>self</i>, QMatrix)</li><li><div class="fn" />QMatrix <b><a href="qmatrix.html#__imul__">__imul__</a></b> (<i>self</i>, QMatrix)</li><li><div class="fn" />QMatrix <b><a href="qmatrix.html#__mul__">__mul__</a></b> (<i>self</i>, QMatrix <i>o</i>)</li><li><div class="fn" />bool <b><a href="qmatrix.html#__ne__">__ne__</a></b> (<i>self</i>, QMatrix)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>This class can be pickled.</p><p>The QMatrix class specifies 2D transformations of a coordinate system.</p> <p>A matrix specifies how to translate, scale, shear or rotate the coordinate system, and is typically used when rendering graphics. QMatrix, in contrast to <a href="qtransform.html">QTransform</a>, does not allow perspective transformations. <a href="qtransform.html">QTransform</a> is the recommended transformation class in Qt.</p> <p>A QMatrix object can be built using the <a href="qmatrix.html#setMatrix">setMatrix</a>(), <a href="qmatrix.html#scale">scale</a>(), <a href="qmatrix.html#rotate">rotate</a>(), <a href="qmatrix.html#translate">translate</a>() and <a href="qmatrix.html#shear">shear</a>() functions. Alternatively, it can be built by applying <a href="#basic-matrix-operations">basic matrix operations</a>. The matrix can also be defined when constructed, and it can be reset to the identity matrix (the default) using the <a href="qmatrix.html#reset">reset</a>() function.</p> <p>The QMatrix class supports mapping of graphic primitives: A given point, line, polygon, region, or painter path can be mapped to the coordinate system defined by <i>this</i> matrix using the <a href="qmatrix.html#map">map</a>() function. In case of a rectangle, its coordinates can be transformed using the <a href="qmatrix.html#mapRect">mapRect</a>() function. A rectangle can also be transformed into a <i>polygon</i> (mapped to the coordinate system defined by <i>this</i> matrix), using the <a href="qmatrix.html#mapToPolygon">mapToPolygon</a>() function.</p> <p>QMatrix provides the <a href="qmatrix.html#isIdentity">isIdentity</a>() function which returns true if the matrix is the identity matrix, and the <a href="qmatrix.html#isInvertible">isInvertible</a>() function which returns true if the matrix is non-singular (i.e. AB = BA = I). The <a href="qmatrix.html#inverted">inverted</a>() function returns an inverted copy of <i>this</i> matrix if it is invertible (otherwise it returns the identity matrix). In addition, QMatrix provides the <a href="qmatrix.html#determinant">determinant</a>() function returning the matrix's determinant.</p> <p>Finally, the QMatrix class supports matrix multiplication, and objects of the class can be streamed as well as compared.</p> <a id="rendering-graphics" name="rendering-graphics" /> <h3>Rendering Graphics</h3> <p>When rendering graphics, the matrix defines the transformations but the actual transformation is performed by the drawing routines in <a href="qpainter.html">QPainter</a>.</p> <p>By default, <a href="qpainter.html">QPainter</a> operates on the associated device's own coordinate system. The standard coordinate system of a <a href="qpaintdevice.html">QPaintDevice</a> has its origin located at the top-left position. The <i>x</i> values increase to the right; <i>y</i> values increase downward. For a complete description, see the <a href="coordsys.html">coordinate system</a> documentation.</p> <p><a href="qpainter.html">QPainter</a> has functions to translate, scale, shear and rotate the coordinate system without using a QMatrix. For example:</p> <table class="generic" width="100%"> <tr class="odd" valign="top"> <td><img alt="" src="images/qmatrix-simpletransformation.png" /></td> <td> <pre class="cpp"> <span class="type">void</span> SimpleTransformation<span class="operator">.</span>paintEvent(<span class="type"><a href="qpaintevent.html">QPaintEvent</a></span> <span class="operator">*</span>) { <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>); painter<span class="operator">.</span>setPen(<span class="type"><a href="qpen.html">QPen</a></span>(<span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>blue<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>DashLine)); painter<span class="operator">.</span>drawRect(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">100</span><span class="operator">,</span> <span class="number">100</span>); painter<span class="operator">.</span>rotate(<span class="number">45</span>); painter<span class="operator">.</span>setFont(<span class="type"><a href="qfont.html">QFont</a></span>(<span class="string">"Helvetica"</span><span class="operator">,</span> <span class="number">24</span>)); painter<span class="operator">.</span>setPen(<span class="type"><a href="qpen.html">QPen</a></span>(<span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>black<span class="operator">,</span> <span class="number">1</span>)); painter<span class="operator">.</span>drawText(<span class="number">20</span><span class="operator">,</span> <span class="number">10</span><span class="operator">,</span> <span class="string">"QMatrix"</span>); } </pre></td> </tr> </table> <p>Although these functions are very convenient, it can be more efficient to build a QMatrix and call <a href="qpainter-obsolete.html#setMatrix">QPainter.setMatrix</a>() if you want to perform more than a single transform operation. For example:</p> <table class="generic" width="100%"> <tr class="odd" valign="top"> <td><img alt="" src="images/qmatrix-combinedtransformation.png" /></td> <td> <pre class="cpp"> <span class="type">void</span> CombinedTransformation<span class="operator">.</span>paintEvent(<span class="type"><a href="qpaintevent.html">QPaintEvent</a></span> <span class="operator">*</span>) { <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>); painter<span class="operator">.</span>setPen(<span class="type"><a href="qpen.html">QPen</a></span>(<span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>blue<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>DashLine)); painter<span class="operator">.</span>drawRect(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">100</span><span class="operator">,</span> <span class="number">100</span>); <span class="type">QMatrix</span> matrix; matrix<span class="operator">.</span>translate(<span class="number">50</span><span class="operator">,</span> <span class="number">50</span>); matrix<span class="operator">.</span>rotate(<span class="number">45</span>); matrix<span class="operator">.</span>scale(<span class="number">0.5</span><span class="operator">,</span> <span class="number">1.0</span>); painter<span class="operator">.</span>setMatrix(matrix); painter<span class="operator">.</span>setFont(<span class="type"><a href="qfont.html">QFont</a></span>(<span class="string">"Helvetica"</span><span class="operator">,</span> <span class="number">24</span>)); painter<span class="operator">.</span>setPen(<span class="type"><a href="qpen.html">QPen</a></span>(<span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>black<span class="operator">,</span> <span class="number">1</span>)); painter<span class="operator">.</span>drawText(<span class="number">20</span><span class="operator">,</span> <span class="number">10</span><span class="operator">,</span> <span class="string">"QMatrix"</span>); } </pre></td> </tr> </table> <a id="basic-matrix-operations" name="basic-matrix-operations" /> <h3>Basic Matrix Operations</h3> <p class="centerAlign"><img alt="" src="images/qmatrix-representation.png" /></p> <p>A QMatrix object contains a 3 x 3 matrix. The <tt>dx</tt> and <tt>dy</tt> elements specify horizontal and vertical translation. The <tt>m11</tt> and <tt>m22</tt> elements specify horizontal and vertical scaling. And finally, the <tt>m21</tt> and <tt>m12</tt> elements specify horizontal and vertical <i>shearing</i>.</p> <p>QMatrix transforms a point in the plane to another point using the following formulas:</p> <pre class="cpp"> x<span class="char">' = m11*x + m21*y + dx y'</span> <span class="operator">=</span> m22<span class="operator">*</span>y <span class="operator">+</span> m12<span class="operator">*</span>x <span class="operator">+</span> dy </pre> <p>The point <i>(x, y)</i> is the original point, and <i>(x', y')</i> is the transformed point. <i>(x', y')</i> can be transformed back to <i>(x, y)</i> by performing the same operation on the <a href="qmatrix.html#inverted">inverted</a>() matrix.</p> <p>The various matrix elements can be set when constructing the matrix, or by using the <a href="qmatrix.html#setMatrix">setMatrix</a>() function later on. They can also be manipulated using the <a href="qmatrix.html#translate">translate</a>(), <a href="qmatrix.html#rotate">rotate</a>(), <a href="qmatrix.html#scale">scale</a>() and <a href="qmatrix.html#shear">shear</a>() convenience functions, The currently set values can be retrieved using the <a href="qmatrix.html#m11">m11</a>(), <a href="qmatrix.html#m12">m12</a>(), <a href="qmatrix.html#m21">m21</a>(), <a href="qmatrix.html#m22">m22</a>(), <a href="qmatrix.html#dx">dx</a>() and <a href="qmatrix.html#dy">dy</a>() functions.</p> <p>Translation is the simplest transformation. Setting <tt>dx</tt> and <tt>dy</tt> will move the coordinate system <tt>dx</tt> units along the X axis and <tt>dy</tt> units along the Y axis. Scaling can be done by setting <tt>m11</tt> and <tt>m22</tt>. For example, setting <tt>m11</tt> to 2 and <tt>m22</tt> to 1.5 will double the height and increase the width by 50%. The identity matrix has <tt>m11</tt> and <tt>m22</tt> set to 1 (all others are set to 0) mapping a point to itself. Shearing is controlled by <tt>m12</tt> and <tt>m21</tt>. Setting these elements to values different from zero will twist the coordinate system. Rotation is achieved by carefully setting both the shearing factors and the scaling factors.</p> <p>Here's the combined transformations example using basic matrix operations:</p> <table class="generic" width="100%"> <tr class="odd" valign="top"> <td><img alt="" src="images/qmatrix-combinedtransformation.png" /></td> <td> <pre class="cpp"> <span class="type">void</span> BasicOperations<span class="operator">.</span>paintEvent(<span class="type"><a href="qpaintevent.html">QPaintEvent</a></span> <span class="operator">*</span>) { <span class="type">double</span> pi <span class="operator">=</span> <span class="number">3.14</span>; <span class="type">double</span> a <span class="operator">=</span> pi<span class="operator">/</span><span class="number">180</span> <span class="operator">*</span> <span class="number">45.0</span>; <span class="type">double</span> sina <span class="operator">=</span> sin(a); <span class="type">double</span> cosa <span class="operator">=</span> cos(a); <span class="type">QMatrix</span> translationMatrix(<span class="number">1</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">50.0</span><span class="operator">,</span> <span class="number">50.0</span>); <span class="type">QMatrix</span> rotationMatrix(cosa<span class="operator">,</span> sina<span class="operator">,</span> <span class="operator">-</span>sina<span class="operator">,</span> cosa<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>); <span class="type">QMatrix</span> scalingMatrix(<span class="number">0.5</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1.0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>); <span class="type">QMatrix</span> matrix; matrix <span class="operator">=</span> scalingMatrix <span class="operator">*</span> rotationMatrix <span class="operator">*</span> translationMatrix; <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>); painter<span class="operator">.</span>setPen(<span class="type"><a href="qpen.html">QPen</a></span>(<span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>blue<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>DashLine)); painter<span class="operator">.</span>drawRect(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">100</span><span class="operator">,</span> <span class="number">100</span>); painter<span class="operator">.</span>setMatrix(matrix); painter<span class="operator">.</span>setFont(<span class="type"><a href="qfont.html">QFont</a></span>(<span class="string">"Helvetica"</span><span class="operator">,</span> <span class="number">24</span>)); painter<span class="operator">.</span>setPen(<span class="type"><a href="qpen.html">QPen</a></span>(<span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>black<span class="operator">,</span> <span class="number">1</span>)); painter<span class="operator">.</span>drawText(<span class="number">20</span><span class="operator">,</span> <span class="number">10</span><span class="operator">,</span> <span class="string">"QMatrix"</span>); } </pre></td> </tr> </table> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QMatrix" />QMatrix.__init__ (<i>self</i>)</h3><p>Constructs an identity matrix.</p> <p>All elements are set to zero except <tt>m11</tt> and <tt>m22</tt> (specifying the scale), which are set to 1.</p> <p><b>See also</b> <a href="qmatrix.html#reset">reset</a>().</p> <h3 class="fn"><a name="QMatrix-2" />QMatrix.__init__ (<i>self</i>, float <i>m11</i>, float <i>m12</i>, float <i>m21</i>, float <i>m22</i>, float <i>dx</i>, float <i>dy</i>)</h3><h3 class="fn"><a name="QMatrix-3" />QMatrix.__init__ (<i>self</i>, <a href="qmatrix.html">QMatrix</a> <i>matrix</i>)</h3><p>Constructs a matrix with the elements, <i>m11</i>, <i>m12</i>, <i>m21</i>, <i>m22</i>, <i>dx</i> and <i>dy</i>.</p> <p><b>See also</b> <a href="qmatrix.html#setMatrix">setMatrix</a>().</p> <h3 class="fn"><a name="det" />float QMatrix.det (<i>self</i>)</h3><h3 class="fn"><a name="determinant" />float QMatrix.determinant (<i>self</i>)</h3><p>Returns the matrix's determinant.</p> <p>This function was introduced in Qt 4.6.</p> <h3 class="fn"><a name="dx" />float QMatrix.dx (<i>self</i>)</h3><p>Returns the horizontal translation factor.</p> <p><b>See also</b> <a href="qmatrix.html#translate">translate</a>() and <a class="obsolete" href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p> <h3 class="fn"><a name="dy" />float QMatrix.dy (<i>self</i>)</h3><p>Returns the vertical translation factor.</p> <p><b>See also</b> <a href="qmatrix.html#translate">translate</a>() and <a class="obsolete" href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p> <h3 class="fn"><a name="inverted" />(<a href="qmatrix.html">QMatrix</a>, bool <i>invertible</i>) QMatrix.inverted (<i>self</i>)</h3><p>Returns an inverted copy of this matrix.</p> <p>If the matrix is singular (not invertible), the returned matrix is the identity matrix. If <i>invertible</i> is valid (i.e. not 0), its value is set to true if the matrix is invertible, otherwise it is set to false.</p> <p><b>See also</b> <a href="qmatrix.html#isInvertible">isInvertible</a>().</p> <h3 class="fn"><a name="isIdentity" />bool QMatrix.isIdentity (<i>self</i>)</h3><p>Returns true if the matrix is the identity matrix, otherwise returns false.</p> <p><b>See also</b> <a href="qmatrix.html#reset">reset</a>().</p> <h3 class="fn"><a name="isInvertible" />bool QMatrix.isInvertible (<i>self</i>)</h3><p>Returns true if the matrix is invertible, otherwise returns false.</p> <p><b>See also</b> <a href="qmatrix.html#inverted">inverted</a>().</p> <h3 class="fn"><a name="m11" />float QMatrix.m11 (<i>self</i>)</h3><p>Returns the horizontal scaling factor.</p> <p><b>See also</b> <a href="qmatrix.html#scale">scale</a>() and <a class="obsolete" href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p> <h3 class="fn"><a name="m12" />float QMatrix.m12 (<i>self</i>)</h3><p>Returns the vertical shearing factor.</p> <p><b>See also</b> <a href="qmatrix.html#shear">shear</a>() and <a class="obsolete" href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p> <h3 class="fn"><a name="m21" />float QMatrix.m21 (<i>self</i>)</h3><p>Returns the horizontal shearing factor.</p> <p><b>See also</b> <a href="qmatrix.html#shear">shear</a>() and <a class="obsolete" href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p> <h3 class="fn"><a name="m22" />float QMatrix.m22 (<i>self</i>)</h3><p>Returns the vertical scaling factor.</p> <p><b>See also</b> <a href="qmatrix.html#scale">scale</a>() and <a class="obsolete" href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p> <h3 class="fn"><a name="map" />(int <i>tx</i>, int <i>ty</i>) QMatrix.map (<i>self</i>, int <i>x</i>, int <i>y</i>)</h3><p>Maps the given coordinates <i>x</i> and <i>y</i> into the coordinate system defined by this matrix. The resulting values are put in *<i>tx</i> and *<i>ty</i>, respectively.</p> <p>The coordinates are transformed using the following formulas:</p> <pre class="cpp"> x<span class="char">' = m11*x + m21*y + dx y'</span> <span class="operator">=</span> m22<span class="operator">*</span>y <span class="operator">+</span> m12<span class="operator">*</span>x <span class="operator">+</span> dy </pre> <p>The point (x, y) is the original point, and (x', y') is the transformed point.</p> <p><b>See also</b> <a class="obsolete" href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p> <h3 class="fn"><a name="map-2" />(float <i>tx</i>, float <i>ty</i>) QMatrix.map (<i>self</i>, float <i>x</i>, float <i>y</i>)</h3><h3 class="fn"><a name="map-3" /><a href="qpoint.html">QPoint</a> QMatrix.map (<i>self</i>, <a href="qpoint.html">QPoint</a> <i>p</i>)</h3><p>This is an overloaded function.</p> <p>Maps the given coordinates <i>x</i> and <i>y</i> into the coordinate system defined by this matrix. The resulting values are put in *<i>tx</i> and *<i>ty</i>, respectively. Note that the transformed coordinates are rounded to the nearest integer.</p> <h3 class="fn"><a name="map-4" /><a href="qpointf.html">QPointF</a> QMatrix.map (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>p</i>)</h3><p>This is an overloaded function.</p> <p>Creates and returns a <a href="qpointf.html">QPointF</a> object that is a copy of the given <i>point</i>, mapped into the coordinate system defined by this matrix.</p> <h3 class="fn"><a name="map-5" /><a href="qline.html">QLine</a> QMatrix.map (<i>self</i>, <a href="qline.html">QLine</a> <i>l</i>)</h3><p>This is an overloaded function.</p> <p>Creates and returns a <a href="qpoint.html">QPoint</a> object that is a copy of the given <i>point</i>, mapped into the coordinate system defined by this matrix. Note that the transformed coordinates are rounded to the nearest integer.</p> <h3 class="fn"><a name="map-6" /><a href="qlinef.html">QLineF</a> QMatrix.map (<i>self</i>, <a href="qlinef.html">QLineF</a> <i>l</i>)</h3><p>This is an overloaded function.</p> <p>Creates and returns a <a href="qlinef.html">QLineF</a> object that is a copy of the given <i>line</i>, mapped into the coordinate system defined by this matrix.</p> <h3 class="fn"><a name="map-7" /><a href="qpolygonf.html">QPolygonF</a> QMatrix.map (<i>self</i>, <a href="qpolygonf.html">QPolygonF</a> <i>a</i>)</h3><p>This is an overloaded function.</p> <p>Creates and returns a <a href="qline.html">QLine</a> object that is a copy of the given <i>line</i>, mapped into the coordinate system defined by this matrix. Note that the transformed coordinates are rounded to the nearest integer.</p> <h3 class="fn"><a name="map-8" /><a href="qpolygon.html">QPolygon</a> QMatrix.map (<i>self</i>, <a href="qpolygon.html">QPolygon</a> <i>a</i>)</h3><p>This is an overloaded function.</p> <p>Creates and returns a <a href="qpolygonf.html">QPolygonF</a> object that is a copy of the given <i>polygon</i>, mapped into the coordinate system defined by this matrix.</p> <h3 class="fn"><a name="map-9" /><a href="qregion.html">QRegion</a> QMatrix.map (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><p>This is an overloaded function.</p> <p>Creates and returns a <a href="qpolygon.html">QPolygon</a> object that is a copy of the given <i>polygon</i>, mapped into the coordinate system defined by this matrix. Note that the transformed coordinates are rounded to the nearest integer.</p> <h3 class="fn"><a name="map-10" /><a href="qpainterpath.html">QPainterPath</a> QMatrix.map (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>p</i>)</h3><p>This is an overloaded function.</p> <p>Creates and returns a <a href="qregion.html">QRegion</a> object that is a copy of the given <i>region</i>, mapped into the coordinate system defined by this matrix.</p> <p>Calling this method can be rather expensive if rotations or shearing are used.</p> <h3 class="fn"><a name="mapRect" /><a href="qrect.html">QRect</a> QMatrix.mapRect (<i>self</i>, <a href="qrect.html">QRect</a>)</h3><p>Creates and returns a <a href="qrectf.html">QRectF</a> object that is a copy of the given <i>rectangle</i>, mapped into the coordinate system defined by this matrix.</p> <p>The rectangle's coordinates are transformed using the following formulas:</p> <pre class="cpp"> x<span class="char">' = m11*x + m21*y + dx y'</span> <span class="operator">=</span> m22<span class="operator">*</span>y <span class="operator">+</span> m12<span class="operator">*</span>x <span class="operator">+</span> dy </pre> <p>If rotation or shearing has been specified, this function returns the <i>bounding</i> rectangle. To retrieve the exact region the given <i>rectangle</i> maps to, use the <a href="qmatrix.html#mapToPolygon">mapToPolygon</a>() function instead.</p> <p><b>See also</b> <a href="qmatrix.html#mapToPolygon">mapToPolygon</a>() and <a class="obsolete" href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p> <h3 class="fn"><a name="mapRect-2" /><a href="qrectf.html">QRectF</a> QMatrix.mapRect (<i>self</i>, <a href="qrectf.html">QRectF</a>)</h3><p>This is an overloaded function.</p> <p>Creates and returns a <a href="qrect.html">QRect</a> object that is a copy of the given <i>rectangle</i>, mapped into the coordinate system defined by this matrix. Note that the transformed coordinates are rounded to the nearest integer.</p> <h3 class="fn"><a name="mapToPolygon" /><a href="qpolygon.html">QPolygon</a> QMatrix.mapToPolygon (<i>self</i>, <a href="qrect.html">QRect</a> <i>r</i>)</h3><p>Creates and returns a <a href="qpolygon.html">QPolygon</a> representation of the given <i>rectangle</i>, mapped into the coordinate system defined by this matrix.</p> <p>The rectangle's coordinates are transformed using the following formulas:</p> <pre class="cpp"> x<span class="char">' = m11*x + m21*y + dx y'</span> <span class="operator">=</span> m22<span class="operator">*</span>y <span class="operator">+</span> m12<span class="operator">*</span>x <span class="operator">+</span> dy </pre> <p>Polygons and rectangles behave slightly differently when transformed (due to integer rounding), so <tt>matrix.map(QPolygon(rectangle))</tt> is not always the same as <tt>matrix.mapToPolygon(rectangle)</tt>.</p> <p><b>See also</b> <a href="qmatrix.html#mapRect">mapRect</a>() and <a class="obsolete" href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p> <h3 class="fn"><a name="reset" />QMatrix.reset (<i>self</i>)</h3><p>Resets the matrix to an identity matrix, i.e. all elements are set to zero, except <tt>m11</tt> and <tt>m22</tt> (specifying the scale) which are set to 1.</p> <p><b>See also</b> <a href="qmatrix.html#QMatrix">QMatrix</a>(), <a href="qmatrix.html#isIdentity">isIdentity</a>(), and <a class="obsolete" href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p> <h3 class="fn"><a name="rotate" /><a href="qmatrix.html">QMatrix</a> QMatrix.rotate (<i>self</i>, float <i>a</i>)</h3><p>Rotates the coordinate system the given <i>degrees</i> counterclockwise.</p> <p>Note that if you apply a <a class="obsolete" href="qmatrix.html">QMatrix</a> to a point defined in widget coordinates, the direction of the rotation will be clockwise because the y-axis points downwards.</p> <p>Returns a reference to the matrix.</p> <p><b>See also</b> <a href="qmatrix.html#setMatrix">setMatrix</a>().</p> <h3 class="fn"><a name="scale" /><a href="qmatrix.html">QMatrix</a> QMatrix.scale (<i>self</i>, float <i>sx</i>, float <i>sy</i>)</h3><p>Scales the coordinate system by <i>sx</i> horizontally and <i>sy</i> vertically, and returns a reference to the matrix.</p> <p><b>See also</b> <a href="qmatrix.html#setMatrix">setMatrix</a>().</p> <h3 class="fn"><a name="setMatrix" />QMatrix.setMatrix (<i>self</i>, float <i>m11</i>, float <i>m12</i>, float <i>m21</i>, float <i>m22</i>, float <i>dx</i>, float <i>dy</i>)</h3><p>Sets the matrix elements to the specified values, <i>m11</i>, <i>m12</i>, <i>m21</i>, <i>m22</i>, <i>dx</i> and <i>dy</i>.</p> <p>Note that this function replaces the previous values. <a class="obsolete" href="qmatrix.html">QMatrix</a> provide the <a href="qmatrix.html#translate">translate</a>(), <a href="qmatrix.html#rotate">rotate</a>(), <a href="qmatrix.html#scale">scale</a>() and <a href="qmatrix.html#shear">shear</a>() convenience functions to manipulate the various matrix elements based on the currently defined coordinate system.</p> <p><b>See also</b> <a href="qmatrix.html#QMatrix">QMatrix</a>().</p> <h3 class="fn"><a name="shear" /><a href="qmatrix.html">QMatrix</a> QMatrix.shear (<i>self</i>, float <i>sh</i>, float <i>sv</i>)</h3><p>Shears the coordinate system by <i>sh</i> horizontally and <i>sv</i> vertically, and returns a reference to the matrix.</p> <p><b>See also</b> <a href="qmatrix.html#setMatrix">setMatrix</a>().</p> <h3 class="fn"><a name="translate" /><a href="qmatrix.html">QMatrix</a> QMatrix.translate (<i>self</i>, float <i>dx</i>, float <i>dy</i>)</h3><p>Moves the coordinate system <i>dx</i> along the x axis and <i>dy</i> along the y axis, and returns a reference to the matrix.</p> <p><b>See also</b> <a href="qmatrix.html#setMatrix">setMatrix</a>().</p> <h3 class="fn"><a name="__eq__" />bool QMatrix.__eq__ (<i>self</i>, <a href="qmatrix.html">QMatrix</a>)</h3><h3 class="fn"><a name="__imul__" /><a href="qmatrix.html">QMatrix</a> QMatrix.__imul__ (<i>self</i>, <a href="qmatrix.html">QMatrix</a>)</h3><h3 class="fn"><a name="__mul__" /><a href="qmatrix.html">QMatrix</a> QMatrix.__mul__ (<i>self</i>, <a href="qmatrix.html">QMatrix</a> <i>o</i>)</h3><h3 class="fn"><a name="__ne__" />bool QMatrix.__ne__ (<i>self</i>, <a href="qmatrix.html">QMatrix</a>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>