1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QGRAPHICSTRANSFORM_H
5#define QGRAPHICSTRANSFORM_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtCore/QObject>
9#include <QtGui/QVector3D>
10#include <QtGui/QTransform>
11#include <QtGui/QMatrix4x4>
12
13QT_REQUIRE_CONFIG(graphicsview);
14
15QT_BEGIN_NAMESPACE
16
17class QGraphicsItem;
18class QGraphicsTransformPrivate;
19
20class Q_WIDGETS_EXPORT QGraphicsTransform : public QObject
21{
22 Q_OBJECT
23public:
24 QGraphicsTransform(QObject *parent = nullptr);
25 ~QGraphicsTransform();
26
27 virtual void applyTo(QMatrix4x4 *matrix) const = 0;
28
29protected Q_SLOTS:
30 void update();
31
32protected:
33 QGraphicsTransform(QGraphicsTransformPrivate &p, QObject *parent);
34
35private:
36 friend class QGraphicsItem;
37 friend class QGraphicsItemPrivate;
38 Q_DECLARE_PRIVATE(QGraphicsTransform)
39};
40
41class QGraphicsScalePrivate;
42
43class Q_WIDGETS_EXPORT QGraphicsScale : public QGraphicsTransform
44{
45 Q_OBJECT
46
47 Q_PROPERTY(QVector3D origin READ origin WRITE setOrigin NOTIFY originChanged)
48 Q_PROPERTY(qreal xScale READ xScale WRITE setXScale NOTIFY xScaleChanged)
49 Q_PROPERTY(qreal yScale READ yScale WRITE setYScale NOTIFY yScaleChanged)
50 Q_PROPERTY(qreal zScale READ zScale WRITE setZScale NOTIFY zScaleChanged)
51public:
52 QGraphicsScale(QObject *parent = nullptr);
53 ~QGraphicsScale();
54
55 QVector3D origin() const;
56 void setOrigin(const QVector3D &point);
57
58 qreal xScale() const;
59 void setXScale(qreal);
60
61 qreal yScale() const;
62 void setYScale(qreal);
63
64 qreal zScale() const;
65 void setZScale(qreal);
66
67 void applyTo(QMatrix4x4 *matrix) const override;
68
69Q_SIGNALS:
70 void originChanged();
71 void xScaleChanged();
72 void yScaleChanged();
73 void zScaleChanged();
74 void scaleChanged();
75
76private:
77 Q_DECLARE_PRIVATE(QGraphicsScale)
78};
79
80class QGraphicsRotationPrivate;
81
82class Q_WIDGETS_EXPORT QGraphicsRotation : public QGraphicsTransform
83{
84 Q_OBJECT
85
86 Q_PROPERTY(QVector3D origin READ origin WRITE setOrigin NOTIFY originChanged)
87 Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged)
88 Q_PROPERTY(QVector3D axis READ axis WRITE setAxis NOTIFY axisChanged)
89public:
90 QGraphicsRotation(QObject *parent = nullptr);
91 ~QGraphicsRotation();
92
93 QVector3D origin() const;
94 void setOrigin(const QVector3D &point);
95
96 qreal angle() const;
97 void setAngle(qreal);
98
99 QVector3D axis() const;
100 void setAxis(const QVector3D &axis);
101 void setAxis(Qt::Axis axis);
102
103 void applyTo(QMatrix4x4 *matrix) const override;
104
105Q_SIGNALS:
106 void originChanged();
107 void angleChanged();
108 void axisChanged();
109
110private:
111 Q_DECLARE_PRIVATE(QGraphicsRotation)
112};
113
114QT_END_NAMESPACE
115
116#endif // QFXTRANSFORM_H
117

source code of qtbase/src/widgets/graphicsview/qgraphicstransform.h