1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the QtWidgets 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 The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/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 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or (at your option) the GNU General 28 ** Public license version 3 or any later version approved by the KDE Free 29 ** Qt Foundation. The licenses are as published by the Free Software 30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 31 ** included in the packaging of this file. Please review the following 32 ** information to ensure the GNU General Public License requirements will 33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 34 ** https://www.gnu.org/licenses/gpl-3.0.html. 35 ** 36 ** $QT_END_LICENSE$ 37 ** 38 ****************************************************************************/ 39 40 #ifndef QGRAPHICSTRANSFORM_H 41 #define QGRAPHICSTRANSFORM_H 42 43 #include <QtWidgets/qtwidgetsglobal.h> 44 #include <QtCore/QObject> 45 #include <QtGui/QVector3D> 46 #include <QtGui/QTransform> 47 #include <QtGui/QMatrix4x4> 48 49 QT_REQUIRE_CONFIG(graphicsview); 50 51 QT_BEGIN_NAMESPACE 52 53 class QGraphicsItem; 54 class QGraphicsTransformPrivate; 55 56 class Q_WIDGETS_EXPORT QGraphicsTransform : public QObject 57 { 58 Q_OBJECT 59 public: 60 QGraphicsTransform(QObject *parent = nullptr); 61 ~QGraphicsTransform(); 62 63 virtual void applyTo(QMatrix4x4 *matrix) const = 0; 64 65 protected Q_SLOTS: 66 void update(); 67 68 protected: 69 QGraphicsTransform(QGraphicsTransformPrivate &p, QObject *parent); 70 71 private: 72 friend class QGraphicsItem; 73 friend class QGraphicsItemPrivate; 74 Q_DECLARE_PRIVATE(QGraphicsTransform) 75 }; 76 77 class QGraphicsScalePrivate; 78 79 class Q_WIDGETS_EXPORT QGraphicsScale : public QGraphicsTransform 80 { 81 Q_OBJECT 82 83 Q_PROPERTY(QVector3D origin READ origin WRITE setOrigin NOTIFY originChanged) 84 Q_PROPERTY(qreal xScale READ xScale WRITE setXScale NOTIFY xScaleChanged) 85 Q_PROPERTY(qreal yScale READ yScale WRITE setYScale NOTIFY yScaleChanged) 86 Q_PROPERTY(qreal zScale READ zScale WRITE setZScale NOTIFY zScaleChanged) 87 public: 88 QGraphicsScale(QObject *parent = nullptr); 89 ~QGraphicsScale(); 90 91 QVector3D origin() const; 92 void setOrigin(const QVector3D &point); 93 94 qreal xScale() const; 95 void setXScale(qreal); 96 97 qreal yScale() const; 98 void setYScale(qreal); 99 100 qreal zScale() const; 101 void setZScale(qreal); 102 103 void applyTo(QMatrix4x4 *matrix) const override; 104 105 Q_SIGNALS: 106 void originChanged(); 107 void xScaleChanged(); 108 void yScaleChanged(); 109 void zScaleChanged(); 110 void scaleChanged(); 111 112 private: 113 Q_DECLARE_PRIVATE(QGraphicsScale) 114 }; 115 116 class QGraphicsRotationPrivate; 117 118 class Q_WIDGETS_EXPORT QGraphicsRotation : public QGraphicsTransform 119 { 120 Q_OBJECT 121 122 Q_PROPERTY(QVector3D origin READ origin WRITE setOrigin NOTIFY originChanged) 123 Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged) 124 Q_PROPERTY(QVector3D axis READ axis WRITE setAxis NOTIFY axisChanged) 125 public: 126 QGraphicsRotation(QObject *parent = nullptr); 127 ~QGraphicsRotation(); 128 129 QVector3D origin() const; 130 void setOrigin(const QVector3D &point); 131 132 qreal angle() const; 133 void setAngle(qreal); 134 135 QVector3D axis() const; 136 void setAxis(const QVector3D &axis); 137 void setAxis(Qt::Axis axis); 138 139 void applyTo(QMatrix4x4 *matrix) const override; 140 141 Q_SIGNALS: 142 void originChanged(); 143 void angleChanged(); 144 void axisChanged(); 145 146 private: 147 Q_DECLARE_PRIVATE(QGraphicsRotation) 148 }; 149 150 QT_END_NAMESPACE 151 152 #endif // QFXTRANSFORM_H 153