1 | // Copyright (C) 2023 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 <QtCore/qobject.h> |
8 | #include <QtGraphs/qgraphsglobal.h> |
9 | #include <QtGui/qimage.h> |
10 | #include <QtGui/qquaternion.h> |
11 | #include <QtGui/qvector3d.h> |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | class QCustom3DItemPrivate; |
16 | |
17 | class Q_GRAPHS_EXPORT QCustom3DItem : public QObject |
18 | { |
19 | Q_OBJECT |
20 | Q_DECLARE_PRIVATE(QCustom3DItem) |
21 | Q_PROPERTY(QString meshFile READ meshFile WRITE setMeshFile NOTIFY meshFileChanged FINAL) |
22 | Q_PROPERTY( |
23 | QString textureFile READ textureFile WRITE setTextureFile NOTIFY textureFileChanged FINAL) |
24 | Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged FINAL) |
25 | Q_PROPERTY(bool positionAbsolute READ isPositionAbsolute WRITE setPositionAbsolute NOTIFY |
26 | positionAbsoluteChanged FINAL) |
27 | Q_PROPERTY(QVector3D scaling READ scaling WRITE setScaling NOTIFY scalingChanged FINAL) |
28 | Q_PROPERTY(QQuaternion rotation READ rotation WRITE setRotation NOTIFY rotationChanged FINAL) |
29 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) |
30 | Q_PROPERTY(bool shadowCasting READ isShadowCasting WRITE setShadowCasting NOTIFY |
31 | shadowCastingChanged FINAL) |
32 | Q_PROPERTY(bool scalingAbsolute READ isScalingAbsolute WRITE setScalingAbsolute NOTIFY |
33 | scalingAbsoluteChanged FINAL) |
34 | |
35 | public: |
36 | explicit QCustom3DItem(QObject *parent = nullptr); |
37 | explicit QCustom3DItem(const QString &meshFile, |
38 | QVector3D position, |
39 | QVector3D scaling, |
40 | const QQuaternion &rotation, |
41 | const QImage &texture, |
42 | QObject *parent = nullptr); |
43 | ~QCustom3DItem() override; |
44 | |
45 | void setMeshFile(const QString &meshFile); |
46 | QString meshFile() const; |
47 | |
48 | void setTextureFile(const QString &textureFile); |
49 | QString textureFile() const; |
50 | |
51 | void setPosition(QVector3D position); |
52 | QVector3D position() const; |
53 | |
54 | void setPositionAbsolute(bool positionAbsolute); |
55 | bool isPositionAbsolute() const; |
56 | |
57 | void setScaling(QVector3D scaling); |
58 | QVector3D scaling() const; |
59 | |
60 | void setScalingAbsolute(bool scalingAbsolute); |
61 | bool isScalingAbsolute() const; |
62 | |
63 | void setRotation(const QQuaternion &rotation); |
64 | QQuaternion rotation(); |
65 | |
66 | void setVisible(bool visible); |
67 | bool isVisible() const; |
68 | |
69 | void setShadowCasting(bool enabled); |
70 | bool isShadowCasting() const; |
71 | |
72 | Q_INVOKABLE void setRotationAxisAndAngle(QVector3D axis, float angle); |
73 | |
74 | void setTextureImage(const QImage &textureImage); |
75 | |
76 | Q_SIGNALS: |
77 | void meshFileChanged(const QString &meshFile); |
78 | void textureFileChanged(const QString &textureFile); |
79 | void positionChanged(QVector3D position); |
80 | void positionAbsoluteChanged(bool positionAbsolute); |
81 | void scalingChanged(QVector3D scaling); |
82 | void rotationChanged(const QQuaternion &rotation); |
83 | void visibleChanged(bool visible); |
84 | void shadowCastingChanged(bool shadowCasting); |
85 | void scalingAbsoluteChanged(bool scalingAbsolute); |
86 | void needUpdate(); |
87 | |
88 | protected: |
89 | QCustom3DItem(QCustom3DItemPrivate &d, QObject *parent = nullptr); |
90 | |
91 | private: |
92 | Q_DISABLE_COPY(QCustom3DItem) |
93 | |
94 | friend class QQuickGraphsItem; |
95 | }; |
96 | |
97 | QT_END_NAMESPACE |
98 | |
99 | #endif |
100 | |