QtBase  v6.3.1
qgraphicstransform.h
Go to the documentation of this file.
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 
52 
53 class QGraphicsItem;
55 
56 class Q_WIDGETS_EXPORT QGraphicsTransform : public QObject
57 {
58  Q_OBJECT
59 public:
60  QGraphicsTransform(QObject *parent = nullptr);
62 
63  virtual void applyTo(QMatrix4x4 *matrix) const = 0;
64 
65 protected Q_SLOTS:
66  void update();
67 
68 protected:
70 
71 private:
72  friend class QGraphicsItem;
73  friend class QGraphicsItemPrivate;
74  Q_DECLARE_PRIVATE(QGraphicsTransform)
75 };
76 
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:
110  void scaleChanged();
111 
112 private:
113  Q_DECLARE_PRIVATE(QGraphicsScale)
114 };
115 
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);
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:
143  void angleChanged();
144  void axisChanged();
145 
146 private:
147  Q_DECLARE_PRIVATE(QGraphicsRotation)
148 };
149 
151 
152 #endif // QFXTRANSFORM_H
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:83
The QGraphicsRotation class provides a rotation transformation around a given axis.
The QGraphicsScale class provides a scale transformation.
void yScaleChanged()
void zScaleChanged()
void xScaleChanged()
void originChanged()
The QGraphicsTransform class is an abstract base class for building advanced transformations on QGrap...
virtual void applyTo(QMatrix4x4 *matrix) const =0
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition: qmatrix4x4.h:61
The QObject class is the base class of all Qt objects.
Definition: qobject.h:125
The QVector3D class represents a vector or vertex in 3D space.
Definition: qvectornd.h:205
QT_END_INCLUDE_NAMESPACE typedef double qreal
Definition: qglobal.h:341
QT_REQUIRE_CONFIG(graphicsview)
GLfloat angle
GLuint GLenum matrix
Definition: qopenglext.h:11564
GLfloat GLfloat p
[1]
Definition: qopenglext.h:12698
#define Q_PROPERTY(...)
Definition: qtmetamacros.h:92
#define Q_OBJECT
Definition: qtmetamacros.h:158
#define Q_SLOTS
Definition: qtmetamacros.h:80
#define Q_SIGNALS
Definition: qtmetamacros.h:81
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent