22 enum TransformationType {
31 inline explicit QTransform(Qt::Initialization) {}
33 : m_matrix{ {1, 0, 0}, {0, 1, 0}, {0, 0, 1} }
36 QTransform(qreal h11, qreal h12, qreal h13,
37 qreal h21, qreal h22, qreal h23,
38 qreal h31, qreal h32, qreal h33)
39 : m_matrix{ {h11, h12, h13}, {h21, h22, h23}, {h31, h32, h33} }
41 , m_dirty(TxProject) {}
42 QTransform(qreal h11, qreal h12, qreal h21,
43 qreal h22, qreal dx, qreal dy)
44 : m_matrix{ {h11, h12, 0}, {h21, h22, 0}, {dx, dy, 1} }
48 QTransform &operator=(QTransform &&other)
noexcept =
default;
49 QTransform &operator=(
const QTransform &)
noexcept =
default;
50 QTransform(QTransform &&other)
noexcept =
default;
51 QTransform(
const QTransform &other)
noexcept =
default;
53 bool isAffine()
const;
54 bool isIdentity()
const;
55 bool isInvertible()
const;
56 bool isScaling()
const;
57 bool isRotating()
const;
58 bool isTranslating()
const;
60 TransformationType type()
const;
62 inline qreal determinant()
const;
76 void setMatrix(qreal m11, qreal m12, qreal m13,
77 qreal m21, qreal m22, qreal m23,
78 qreal m31, qreal m32, qreal m33);
80 [[nodiscard]] QTransform inverted(
bool *invertible =
nullptr)
const;
81 [[nodiscard]] QTransform adjoint()
const;
82 [[nodiscard]] QTransform transposed()
const;
84 QTransform &translate(qreal dx, qreal dy);
85 QTransform &scale(qreal sx, qreal sy);
86 QTransform &shear(qreal sh, qreal sv);
87#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
88 QTransform &rotate(qreal a, Qt::Axis axis, qreal distanceToPlane);
90 QTransform &rotate(qreal a, Qt::Axis axis = Qt::ZAxis);
91 QTransform &rotateRadians(qreal a, Qt::Axis axis, qreal distanceToPlane);
93 QTransform &rotateRadians(qreal a, Qt::Axis axis = Qt::ZAxis);
95 QTransform &rotate(qreal a, Qt::Axis axis = Qt::ZAxis, qreal distanceToPlane = 1024.0f);
96 QTransform &rotateRadians(qreal a, Qt::Axis axis = Qt::ZAxis, qreal distanceToPlane = 1024.0f);
99 static bool squareToQuad(
const QPolygonF &square, QTransform &result);
100 static bool quadToSquare(
const QPolygonF &quad, QTransform &result);
101 static bool quadToQuad(
const QPolygonF &one,
102 const QPolygonF &two,
105 bool operator==(
const QTransform &)
const;
106 bool operator!=(
const QTransform &)
const;
108 QTransform &operator*=(
const QTransform &);
109 QTransform operator*(
const QTransform &o)
const;
111 operator QVariant()
const;
114 QPoint map(
const QPoint &p)
const;
115 QPointF map(
const QPointF &p)
const;
116 QLine map(
const QLine &l)
const;
117 QLineF map(
const QLineF &l)
const;
118 QPolygonF map(
const QPolygonF &a)
const;
119 QPolygon map(
const QPolygon &a)
const;
120 QRegion map(
const QRegion &r)
const;
121 QPainterPath map(
const QPainterPath &p)
const;
122 QPolygon mapToPolygon(
const QRect &r)
const;
123 QRect mapRect(
const QRect &)
const;
124 QRectF mapRect(
const QRectF &)
const;
125 void map(
int x,
int y,
int *tx,
int *ty)
const;
126 void map(qreal x, qreal y, qreal *tx, qreal *ty)
const;
128 QTransform &operator*=(qreal div);
129 QTransform &operator/=(qreal div);
130 QTransform &operator+=(qreal div);
131 QTransform &operator-=(qreal div);
133 static QTransform fromTranslate(qreal dx, qreal dy);
134 static QTransform fromScale(qreal dx, qreal dy);
138 qreal (& m_matrix)[3][3];
142 auto asAffineMatrix() {
return Affine { m_matrix }; }
143 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &s, Affine &m);
144 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s,
const Affine &m);
147 inline TransformationType inline_type()
const;
148 void do_map(qreal x, qreal y, qreal &nx, qreal &ny)
const;
149 qreal m_matrix[3][3];
151 mutable uint m_type : 5;
152 mutable uint m_dirty : 5;
307inline bool qFuzzyCompare(
const QTransform& t1,
const QTransform& t2)
noexcept
309 return qFuzzyCompare(t1.m11(), t2.m11())
310 && qFuzzyCompare(t1.m12(), t2.m12())
311 && qFuzzyCompare(t1.m13(), t2.m13())
312 && qFuzzyCompare(t1.m21(), t2.m21())
313 && qFuzzyCompare(t1.m22(), t2.m22())
314 && qFuzzyCompare(t1.m23(), t2.m23())
315 && qFuzzyCompare(t1.m31(), t2.m31())
316 && qFuzzyCompare(t1.m32(), t2.m32())
317 && qFuzzyCompare(t1.m33(), t2.m33());