Qt 4.8
qmatrix.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qdatastream.h"
43 #include "qdebug.h"
44 #include "qmatrix.h"
45 #include "qregion.h"
46 #include "qpainterpath.h"
47 #include "qvariant.h"
48 #include <qmath.h>
49 
50 #include <limits.h>
51 
53 
182 // some defines to inline some code
183 #define MAPDOUBLE(x, y, nx, ny) \
184 { \
185  qreal fx = x; \
186  qreal fy = y; \
187  nx = _m11*fx + _m21*fy + _dx; \
188  ny = _m12*fx + _m22*fy + _dy; \
189 }
190 
191 #define MAPINT(x, y, nx, ny) \
192 { \
193  qreal fx = x; \
194  qreal fy = y; \
195  nx = qRound(_m11*fx + _m21*fy + _dx); \
196  ny = qRound(_m12*fx + _m22*fy + _dy); \
197 }
198 
199 /*****************************************************************************
200  QMatrix member functions
201  *****************************************************************************/
217  : _m11(1.)
218  , _m12(0.)
219  , _m21(0.)
220  , _m22(1.)
221  , _dx(0.)
222  , _dy(0.)
223 {
224 }
225 
234  : _m11(m11)
235  , _m12(m12)
236  , _m21(m21)
237  , _m22(m22)
238  , _dx(dx)
239  , _dy(dy)
240 {
241 }
242 
243 
247 QMatrix::QMatrix(const QMatrix &matrix)
248  : _m11(matrix._m11)
249  , _m12(matrix._m12)
250  , _m21(matrix._m21)
251  , _m22(matrix._m22)
252  , _dx(matrix._dx)
253  , _dy(matrix._dy)
254 {
255 }
256 
270 {
271  _m11 = m11;
272  _m12 = m12;
273  _m21 = m21;
274  _m22 = m22;
275  _dx = dx;
276  _dy = dy;
277 }
278 
279 
368 void QMatrix::map(qreal x, qreal y, qreal *tx, qreal *ty) const
369 {
370  MAPDOUBLE(x, y, *tx, *ty);
371 }
372 
373 
374 
384 void QMatrix::map(int x, int y, int *tx, int *ty) const
385 {
386  MAPINT(x, y, *tx, *ty);
387 }
388 
389 QRect QMatrix::mapRect(const QRect &rect) const
390 {
391  QRect result;
392  if (_m12 == 0.0F && _m21 == 0.0F) {
393  int x = qRound(_m11*rect.x() + _dx);
394  int y = qRound(_m22*rect.y() + _dy);
395  int w = qRound(_m11*rect.width());
396  int h = qRound(_m22*rect.height());
397  if (w < 0) {
398  w = -w;
399  x -= w;
400  }
401  if (h < 0) {
402  h = -h;
403  y -= h;
404  }
405  result = QRect(x, y, w, h);
406  } else {
407  // see mapToPolygon for explanations of the algorithm.
408  qreal x0, y0;
409  qreal x, y;
410  MAPDOUBLE(rect.left(), rect.top(), x0, y0);
411  qreal xmin = x0;
412  qreal ymin = y0;
413  qreal xmax = x0;
414  qreal ymax = y0;
415  MAPDOUBLE(rect.right() + 1, rect.top(), x, y);
416  xmin = qMin(xmin, x);
417  ymin = qMin(ymin, y);
418  xmax = qMax(xmax, x);
419  ymax = qMax(ymax, y);
420  MAPDOUBLE(rect.right() + 1, rect.bottom() + 1, x, y);
421  xmin = qMin(xmin, x);
422  ymin = qMin(ymin, y);
423  xmax = qMax(xmax, x);
424  ymax = qMax(ymax, y);
425  MAPDOUBLE(rect.left(), rect.bottom() + 1, x, y);
426  xmin = qMin(xmin, x);
427  ymin = qMin(ymin, y);
428  xmax = qMax(xmax, x);
429  ymax = qMax(ymax, y);
430  result = QRect(qRound(xmin), qRound(ymin), qRound(xmax)-qRound(xmin), qRound(ymax)-qRound(ymin));
431  }
432  return result;
433 }
434 
457 QRectF QMatrix::mapRect(const QRectF &rect) const
458 {
459  QRectF result;
460  if (_m12 == 0.0F && _m21 == 0.0F) {
461  qreal x = _m11*rect.x() + _dx;
462  qreal y = _m22*rect.y() + _dy;
463  qreal w = _m11*rect.width();
464  qreal h = _m22*rect.height();
465  if (w < 0) {
466  w = -w;
467  x -= w;
468  }
469  if (h < 0) {
470  h = -h;
471  y -= h;
472  }
473  result = QRectF(x, y, w, h);
474  } else {
475  qreal x0, y0;
476  qreal x, y;
477  MAPDOUBLE(rect.x(), rect.y(), x0, y0);
478  qreal xmin = x0;
479  qreal ymin = y0;
480  qreal xmax = x0;
481  qreal ymax = y0;
482  MAPDOUBLE(rect.x() + rect.width(), rect.y(), x, y);
483  xmin = qMin(xmin, x);
484  ymin = qMin(ymin, y);
485  xmax = qMax(xmax, x);
486  ymax = qMax(ymax, y);
487  MAPDOUBLE(rect.x() + rect.width(), rect.y() + rect.height(), x, y);
488  xmin = qMin(xmin, x);
489  ymin = qMin(ymin, y);
490  xmax = qMax(xmax, x);
491  ymax = qMax(ymax, y);
492  MAPDOUBLE(rect.x(), rect.y() + rect.height(), x, y);
493  xmin = qMin(xmin, x);
494  ymin = qMin(ymin, y);
495  xmax = qMax(xmax, x);
496  ymax = qMax(ymax, y);
497  result = QRectF(xmin, ymin, xmax-xmin, ymax - ymin);
498  }
499  return result;
500 }
501 
525 QPoint QMatrix::map(const QPoint &p) const
526 {
527  qreal fx = p.x();
528  qreal fy = p.y();
529  return QPoint(qRound(_m11*fx + _m21*fy + _dx),
530  qRound(_m12*fx + _m22*fy + _dy));
531 }
532 
552 QPointF QMatrix::map(const QPointF &point) const
553 {
554  qreal fx = point.x();
555  qreal fy = point.y();
556  return QPointF(_m11*fx + _m21*fy + _dx, _m12*fx + _m22*fy + _dy);
557 }
558 
599 QLineF QMatrix::map(const QLineF &line) const
600 {
601  return QLineF(map(line.p1()), map(line.p2()));
602 }
603 
615 QLine QMatrix::map(const QLine &line) const
616 {
617  return QLine(map(line.p1()), map(line.p2()));
618 }
619 
639 {
640  int size = a.size();
641  int i;
642  QPolygon p(size);
643  const QPoint *da = a.constData();
644  QPoint *dp = p.data();
645  for(i = 0; i < size; i++) {
646  MAPINT(da[i].x(), da[i].y(), dp[i].rx(), dp[i].ry());
647  }
648  return p;
649 }
650 
663 {
664  int size = a.size();
665  int i;
666  QPolygonF p(size);
667  const QPointF *da = a.constData();
668  QPointF *dp = p.data();
669  for(i = 0; i < size; i++) {
670  MAPDOUBLE(da[i].xp, da[i].yp, dp[i].xp, dp[i].yp);
671  }
672  return p;
673 }
674 
698 
712 QRegion QMatrix::map(const QRegion &r) const
713 {
714  if (_m11 == 1.0 && _m22 == 1.0 && _m12 == 0.0 && _m21 == 0.0) { // translate or identity
715  if (_dx == 0.0 && _dy == 0.0) // Identity
716  return r;
717  QRegion copy(r);
718  copy.translate(qRound(_dx), qRound(_dy));
719  return copy;
720  }
721 
723  return p.toFillPolygon().toPolygon();
724 }
725 
746 {
747  if (path.isEmpty())
748  return QPainterPath();
749 
750  QPainterPath copy = path;
751 
752  // Translate or identity
753  if (_m11 == 1.0 && _m22 == 1.0 && _m12 == 0.0 && _m21 == 0.0) {
754 
755  // Translate
756  if (_dx != 0.0 || _dy != 0.0) {
757  copy.detach();
758  for (int i=0; i<path.elementCount(); ++i) {
759  QPainterPath::Element &e = copy.d_ptr->elements[i];
760  e.x += _dx;
761  e.y += _dy;
762  }
763  }
764 
765  // Full xform
766  } else {
767  copy.detach();
768  for (int i=0; i<path.elementCount(); ++i) {
769  QPainterPath::Element &e = copy.d_ptr->elements[i];
770  qreal fx = e.x, fy = e.y;
771  e.x = _m11*fx + _m21*fy + _dx;
772  e.y = _m12*fx + _m22*fy + _dy;
773  }
774  }
775 
776  return copy;
777 }
778 
791 #ifdef QT3_SUPPORT
792 QRegion QMatrix::mapToRegion(const QRect &rect) const
793 {
794  QRegion result;
795  if (isIdentity()) {
796  result = rect;
797  } else if (m12() == 0.0F && m21() == 0.0F) {
798  int x = qRound(m11()*rect.x() + dx());
799  int y = qRound(m22()*rect.y() + dy());
800  int w = qRound(m11()*rect.width());
801  int h = qRound(m22()*rect.height());
802  if (w < 0) {
803  w = -w;
804  x -= w - 1;
805  }
806  if (h < 0) {
807  h = -h;
808  y -= h - 1;
809  }
810  result = QRect(x, y, w, h);
811  } else {
812  result = QRegion(mapToPolygon(rect));
813  }
814  return result;
815 
816 }
817 #endif
818 
842 {
843  QPolygon a(4);
844  qreal x[4], y[4];
845  if (_m12 == 0.0F && _m21 == 0.0F) {
846  x[0] = _m11*rect.x() + _dx;
847  y[0] = _m22*rect.y() + _dy;
848  qreal w = _m11*rect.width();
849  qreal h = _m22*rect.height();
850  if (w < 0) {
851  w = -w;
852  x[0] -= w;
853  }
854  if (h < 0) {
855  h = -h;
856  y[0] -= h;
857  }
858  x[1] = x[0]+w;
859  x[2] = x[1];
860  x[3] = x[0];
861  y[1] = y[0];
862  y[2] = y[0]+h;
863  y[3] = y[2];
864  } else {
865  qreal right = rect.x() + rect.width();
866  qreal bottom = rect.y() + rect.height();
867  MAPDOUBLE(rect.x(), rect.y(), x[0], y[0]);
868  MAPDOUBLE(right, rect.y(), x[1], y[1]);
869  MAPDOUBLE(right, bottom, x[2], y[2]);
870  MAPDOUBLE(rect.x(), bottom, x[3], y[3]);
871  }
872 #if 0
873  int i;
874  for(i = 0; i< 4; i++)
875  qDebug("coords(%d) = (%f/%f) (%d/%d)", i, x[i], y[i], qRound(x[i]), qRound(y[i]));
876  qDebug("width=%f, height=%f", qSqrt((x[1]-x[0])*(x[1]-x[0]) + (y[1]-y[0])*(y[1]-y[0])),
877  qSqrt((x[0]-x[3])*(x[0]-x[3]) + (y[0]-y[3])*(y[0]-y[3])));
878 #endif
879  // all coordinates are correctly, tranform to a pointarray
880  // (rounding to the next integer)
881  a.setPoints(4, qRound(x[0]), qRound(y[0]),
882  qRound(x[1]), qRound(y[1]),
883  qRound(x[2]), qRound(y[2]),
884  qRound(x[3]), qRound(y[3]));
885  return a;
886 }
887 
898 {
899  _m11 = _m22 = 1.0;
900  _m12 = _m21 = _dx = _dy = 0.0;
901 }
902 
923 {
924  _dx += dx*_m11 + dy*_m21;
925  _dy += dy*_m22 + dx*_m12;
926  return *this;
927 }
928 
942 {
943  _m11 *= sx;
944  _m12 *= sx;
945  _m21 *= sy;
946  _m22 *= sy;
947  return *this;
948 }
949 
958 {
959  qreal tm11 = sv*_m21;
960  qreal tm12 = sv*_m22;
961  qreal tm21 = sh*_m11;
962  qreal tm22 = sh*_m12;
963  _m11 += tm11;
964  _m12 += tm12;
965  _m21 += tm21;
966  _m22 += tm22;
967  return *this;
968 }
969 
970 const qreal deg2rad = qreal(0.017453292519943295769); // pi/180
971 
991 {
992  qreal sina = 0;
993  qreal cosa = 0;
994  if (a == 90. || a == -270.)
995  sina = 1.;
996  else if (a == 270. || a == -90.)
997  sina = -1.;
998  else if (a == 180.)
999  cosa = -1.;
1000  else{
1001  qreal b = deg2rad*a; // convert to radians
1002  sina = qSin(b); // fast and convenient
1003  cosa = qCos(b);
1004  }
1005  qreal tm11 = cosa*_m11 + sina*_m21;
1006  qreal tm12 = cosa*_m12 + sina*_m22;
1007  qreal tm21 = -sina*_m11 + cosa*_m21;
1008  qreal tm22 = -sina*_m12 + cosa*_m22;
1009  _m11 = tm11; _m12 = tm12;
1010  _m21 = tm21; _m22 = tm22;
1011  return *this;
1012 }
1013 
1066 QMatrix QMatrix::inverted(bool *invertible) const
1067 {
1068  qreal dtr = determinant();
1069  if (dtr == 0.0) {
1070  if (invertible)
1071  *invertible = false; // singular matrix
1072  return QMatrix(true);
1073  }
1074  else { // invertible matrix
1075  if (invertible)
1076  *invertible = true;
1077  qreal dinv = 1.0/dtr;
1078  return QMatrix((_m22*dinv), (-_m12*dinv),
1079  (-_m21*dinv), (_m11*dinv),
1080  ((_m21*_dy - _m22*_dx)*dinv),
1081  ((_m12*_dx - _m11*_dy)*dinv),
1082  true);
1083  }
1084 }
1085 
1086 
1097 bool QMatrix::operator==(const QMatrix &m) const
1098 {
1099  return _m11 == m._m11 &&
1100  _m12 == m._m12 &&
1101  _m21 == m._m21 &&
1102  _m22 == m._m22 &&
1103  _dx == m._dx &&
1104  _dy == m._dy;
1105 }
1106 
1117 bool QMatrix::operator!=(const QMatrix &m) const
1118 {
1119  return _m11 != m._m11 ||
1120  _m12 != m._m12 ||
1121  _m21 != m._m21 ||
1122  _m22 != m._m22 ||
1123  _dx != m._dx ||
1124  _dy != m._dy;
1125 }
1126 
1136 {
1137  qreal tm11 = _m11*m._m11 + _m12*m._m21;
1138  qreal tm12 = _m11*m._m12 + _m12*m._m22;
1139  qreal tm21 = _m21*m._m11 + _m22*m._m21;
1140  qreal tm22 = _m21*m._m12 + _m22*m._m22;
1141 
1142  qreal tdx = _dx*m._m11 + _dy*m._m21 + m._dx;
1143  qreal tdy = _dx*m._m12 + _dy*m._m22 + m._dy;
1144 
1145  _m11 = tm11; _m12 = tm12;
1146  _m21 = tm21; _m22 = tm22;
1147  _dx = tdx; _dy = tdy;
1148  return *this;
1149 }
1150 
1162 {
1163  qreal tm11 = _m11*m._m11 + _m12*m._m21;
1164  qreal tm12 = _m11*m._m12 + _m12*m._m22;
1165  qreal tm21 = _m21*m._m11 + _m22*m._m21;
1166  qreal tm22 = _m21*m._m12 + _m22*m._m22;
1167 
1168  qreal tdx = _dx*m._m11 + _dy*m._m21 + m._dx;
1169  qreal tdy = _dx*m._m12 + _dy*m._m22 + m._dy;
1170  return QMatrix(tm11, tm12, tm21, tm22, tdx, tdy, true);
1171 }
1172 
1177 {
1178  _m11 = matrix._m11;
1179  _m12 = matrix._m12;
1180  _m21 = matrix._m21;
1181  _m22 = matrix._m22;
1182  _dx = matrix._dx;
1183  _dy = matrix._dy;
1184  return *this;
1185 }
1186 
1195 QMatrix::operator QVariant() const
1196 {
1197  return QVariant(QVariant::Matrix, this);
1198 }
1199 
1201 {
1202  return m.map(p);
1203 }
1204 
1205 
1206 /*****************************************************************************
1207  QMatrix stream functions
1208  *****************************************************************************/
1209 #ifndef QT_NO_DATASTREAM
1210 
1224 {
1225  if (s.version() == 1) {
1226  s << (float)m.m11() << (float)m.m12() << (float)m.m21()
1227  << (float)m.m22() << (float)m.dx() << (float)m.dy();
1228  } else {
1229  s << double(m.m11())
1230  << double(m.m12())
1231  << double(m.m21())
1232  << double(m.m22())
1233  << double(m.dx())
1234  << double(m.dy());
1235  }
1236  return s;
1237 }
1238 
1253 {
1254  if (s.version() == 1) {
1255  float m11, m12, m21, m22, dx, dy;
1256  s >> m11; s >> m12; s >> m21; s >> m22;
1257  s >> dx; s >> dy;
1258  m.setMatrix(m11, m12, m21, m22, dx, dy);
1259  }
1260  else {
1261  double m11, m12, m21, m22, dx, dy;
1262  s >> m11;
1263  s >> m12;
1264  s >> m21;
1265  s >> m22;
1266  s >> dx;
1267  s >> dy;
1268  m.setMatrix(m11, m12, m21, m22, dx, dy);
1269  }
1270  return s;
1271 }
1272 #endif // QT_NO_DATASTREAM
1273 
1274 #ifndef QT_NO_DEBUG_STREAM
1276 {
1277  dbg.nospace() << "QMatrix("
1278  << "11=" << m.m11()
1279  << " 12=" << m.m12()
1280  << " 21=" << m.m21()
1281  << " 22=" << m.m22()
1282  << " dx=" << m.dx()
1283  << " dy=" << m.dy()
1284  << ')';
1285  return dbg.space();
1286 }
1287 #endif
1288 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:62
The QPainterPath::Element class specifies the position and type of a subpath.
Definition: qpainterpath.h:77
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
Definition: qpainterpath.h:392
QMatrix()
Constructs an identity matrix.
Definition: qmatrix.cpp:216
Q_AUTOTEST_EXPORT QPainterPath qt_regionToPath(const QRegion &region)
Definition: qregion.cpp:1160
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QLine class provides a two-dimensional vector using integer precision.
Definition: qline.h:57
The QMatrix class specifies 2D transformations of a coordinate system.
Definition: qmatrix.h:61
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QPoint p1() const
Returns the line&#39;s start point.
Definition: qline.h:132
QDebug & nospace()
Clears the stream&#39;s internal flag that records whether the last character was a space and returns a r...
Definition: qdebug.h:92
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
QPointF p1() const
Returns the line&#39;s start point.
Definition: qline.h:314
QPoint p2() const
Returns the line&#39;s end point.
Definition: qline.h:137
qreal dx() const
Returns the horizontal translation factor.
Definition: qmatrix.h:77
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define MAPDOUBLE(x, y, nx, ny)
Definition: qmatrix.cpp:183
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void reset()
Resets the matrix to an identity matrix, i.e.
Definition: qmatrix.cpp:897
long ASN1_INTEGER_get ASN1_INTEGER * a
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
qreal m12() const
Returns the vertical shearing factor.
Definition: qmatrix.h:74
qreal y
the y coordinate of the element&#39;s position.
Definition: qpainterpath.h:80
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
qreal _m22
Definition: qmatrix.h:144
#define MAPINT(x, y, nx, ny)
Definition: qmatrix.cpp:191
QMatrix & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
Definition: qmatrix.cpp:922
qreal determinant() const
Returns the matrix&#39;s determinant.
Definition: qmatrix.h:104
QPolygon toPolygon() const
Creates and returns a QPolygon by converting each QPointF to a QPoint.
Definition: qpolygon.cpp:772
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
qreal m11() const
Returns the horizontal scaling factor.
Definition: qmatrix.h:73
QPolygon mapToPolygon(const QRect &r) const
Creates and returns a QPolygon representation of the given rectangle, mapped into the coordinate syst...
Definition: qmatrix.cpp:841
Q_CORE_EXPORT void qDebug(const char *,...)
QMatrix & operator*=(const QMatrix &)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qmatrix.cpp:1135
qreal m21() const
Returns the horizontal shearing factor.
Definition: qmatrix.h:75
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QMatrix & rotate(qreal a)
Rotates the coordinate system the given degrees counterclockwise.
Definition: qmatrix.cpp:990
QPolygonF toFillPolygon(const QMatrix &matrix=QMatrix()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
qreal qSin(qreal v)
Definition: qmath.h:93
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
The QPolygonF class provides a vector of points using floating point precision.
Definition: qpolygon.h:134
QMatrix & operator=(const QMatrix &)
Assigns the given matrix&#39;s values to this matrix.
Definition: qmatrix.cpp:1176
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QMatrix & shear(qreal sh, qreal sv)
Shears the coordinate system by sh horizontally and sv vertically, and returns a reference to the mat...
Definition: qmatrix.cpp:957
void setMatrix(qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy)
Sets the matrix elements to the specified values, m11, m12, m21, m22, dx and dy.
Definition: qmatrix.cpp:269
QDataStream & operator<<(QDataStream &stream, const QMatrix &matrix)
Writes the given matrix to the given stream and returns a reference to the stream.
Definition: qmatrix.cpp:1223
int version() const
Returns the version number of the data serialization format.
Definition: qdatastream.h:212
qreal _m12
Definition: qmatrix.h:143
const qreal deg2rad
Definition: qmatrix.cpp:970
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
qreal _dx
Definition: qmatrix.h:145
QDataStream & operator>>(QDataStream &stream, QMatrix &matrix)
Reads the given matrix from the given stream and returns a reference to the stream.
Definition: qmatrix.cpp:1252
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
void map(int x, int y, int *tx, int *ty) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qmatrix.cpp:384
QMatrix operator*(const QMatrix &o) const
Returns the result of multiplying this matrix by the given matrix.
Definition: qmatrix.cpp:1161
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
qreal dy() const
Returns the vertical translation factor.
Definition: qmatrix.h:78
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
qreal _dy
Definition: qmatrix.h:145
QPointF p2() const
Returns the line&#39;s end point.
Definition: qline.h:319
QVector< QPainterPath::Element > elements
Definition: qpainterpath.h:254
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
bool operator==(const QMatrix &) const
Returns true if this matrix is equal to the given matrix, otherwise returns false.
Definition: qmatrix.cpp:1097
qreal x
the x coordinate of the element&#39;s position.
Definition: qpainterpath.h:79
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
qreal _m21
Definition: qmatrix.h:144
bool operator!=(const QMatrix &) const
Returns true if this matrix is not equal to the given matrix, otherwise returns false.
Definition: qmatrix.cpp:1117
qreal _m11
Definition: qmatrix.h:143
void translate(int dx, int dy)
Translates (moves) the region dx along the X axis and dy along the Y axis.
Definition: qregion.cpp:4116
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
void setPoints(int nPoints, const int *points)
Resizes the polygon to nPoints and populates it with the given points.
Definition: qpolygon.cpp:350
bool isIdentity() const
Returns true if the matrix is the identity matrix, otherwise returns false.
Definition: qmatrix.h:166
int elementCount() const
Returns the number of path elements in the painter path.
Definition: qpainterpath.h:397
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QMatrix & scale(qreal sx, qreal sy)
Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the mat...
Definition: qmatrix.cpp:941
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
Definition: qdebug.h:91
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
Definition: qmatrix.cpp:389
qreal qCos(qreal v)
Definition: qmath.h:109
qreal qSqrt(qreal v)
Definition: qmath.h:205
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
qreal m22() const
Returns the vertical scaling factor.
Definition: qmatrix.h:76
QMatrix inverted(bool *invertible=0) const
Returns an inverted copy of this matrix.
Definition: qmatrix.cpp:1066
QScopedPointer< QPainterPathPrivate, QPainterPathPrivateDeleter > d_ptr
Definition: qpainterpath.h:211