1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QCUSTOM3DITEM_H |
5 | #define QCUSTOM3DITEM_H |
6 | |
7 | #include <QtDataVisualization/qdatavisualizationglobal.h> |
8 | #include <QtGui/QImage> |
9 | #include <QtGui/QVector3D> |
10 | #include <QtGui/QQuaternion> |
11 | #include <QtCore/QObject> |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | class QCustom3DItemPrivate; |
16 | |
17 | class Q_DATAVISUALIZATION_EXPORT QCustom3DItem : public QObject |
18 | { |
19 | Q_OBJECT |
20 | Q_PROPERTY(QString meshFile READ meshFile WRITE setMeshFile NOTIFY meshFileChanged) |
21 | Q_PROPERTY(QString textureFile READ textureFile WRITE setTextureFile NOTIFY textureFileChanged) |
22 | Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged) |
23 | Q_PROPERTY(bool positionAbsolute READ isPositionAbsolute WRITE setPositionAbsolute NOTIFY positionAbsoluteChanged) |
24 | Q_PROPERTY(QVector3D scaling READ scaling WRITE setScaling NOTIFY scalingChanged) |
25 | Q_PROPERTY(QQuaternion rotation READ rotation WRITE setRotation NOTIFY rotationChanged) |
26 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) |
27 | Q_PROPERTY(bool shadowCasting READ isShadowCasting WRITE setShadowCasting NOTIFY shadowCastingChanged) |
28 | Q_PROPERTY(bool scalingAbsolute READ isScalingAbsolute WRITE setScalingAbsolute NOTIFY scalingAbsoluteChanged REVISION(1, 2)) |
29 | |
30 | public: |
31 | explicit QCustom3DItem(QObject *parent = nullptr); |
32 | explicit QCustom3DItem(const QString &meshFile, const QVector3D &position, |
33 | const QVector3D &scaling, const QQuaternion &rotation, |
34 | const QImage &texture, QObject *parent = nullptr); |
35 | virtual ~QCustom3DItem(); |
36 | |
37 | void setMeshFile(const QString &meshFile); |
38 | QString meshFile() const; |
39 | |
40 | void setTextureFile(const QString &textureFile); |
41 | QString textureFile() const; |
42 | |
43 | void setPosition(const QVector3D &position); |
44 | QVector3D position() const; |
45 | |
46 | void setPositionAbsolute(bool positionAbsolute); |
47 | bool isPositionAbsolute() const; |
48 | |
49 | void setScaling(const QVector3D &scaling); |
50 | QVector3D scaling() const; |
51 | |
52 | void setScalingAbsolute(bool scalingAbsolute); |
53 | bool isScalingAbsolute() const; |
54 | |
55 | void setRotation(const QQuaternion &rotation); |
56 | QQuaternion rotation(); |
57 | |
58 | void setVisible(bool visible); |
59 | bool isVisible() const; |
60 | |
61 | void setShadowCasting(bool enabled); |
62 | bool isShadowCasting() const; |
63 | |
64 | Q_INVOKABLE void setRotationAxisAndAngle(const QVector3D &axis, float angle); |
65 | |
66 | void setTextureImage(const QImage &textureImage); |
67 | |
68 | Q_SIGNALS: |
69 | void meshFileChanged(const QString &meshFile); |
70 | void textureFileChanged(const QString &textureFile); |
71 | void positionChanged(const QVector3D &position); |
72 | void positionAbsoluteChanged(bool positionAbsolute); |
73 | void scalingChanged(const QVector3D &scaling); |
74 | void rotationChanged(const QQuaternion &rotation); |
75 | void visibleChanged(bool visible); |
76 | void shadowCastingChanged(bool shadowCasting); |
77 | Q_REVISION(1, 2) void scalingAbsoluteChanged(bool scalingAbsolute); |
78 | |
79 | protected: |
80 | QCustom3DItem(QCustom3DItemPrivate *d, QObject *parent = nullptr); |
81 | |
82 | QScopedPointer<QCustom3DItemPrivate> d_ptr; |
83 | |
84 | private: |
85 | Q_DISABLE_COPY(QCustom3DItem) |
86 | |
87 | friend class Abstract3DRenderer; |
88 | friend class Abstract3DController; |
89 | }; |
90 | |
91 | QT_END_NAMESPACE |
92 | |
93 | #endif |
94 | |