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 <QtGraphs/qgraphsglobal.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_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) |
22 | Q_PROPERTY(QString textureFile READ textureFile WRITE setTextureFile NOTIFY textureFileChanged) |
23 | Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged) |
24 | Q_PROPERTY(bool positionAbsolute READ isPositionAbsolute WRITE setPositionAbsolute NOTIFY positionAbsoluteChanged) |
25 | Q_PROPERTY(QVector3D scaling READ scaling WRITE setScaling NOTIFY scalingChanged) |
26 | Q_PROPERTY(QQuaternion rotation READ rotation WRITE setRotation NOTIFY rotationChanged) |
27 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) |
28 | Q_PROPERTY(bool shadowCasting READ isShadowCasting WRITE setShadowCasting NOTIFY shadowCastingChanged) |
29 | Q_PROPERTY(bool scalingAbsolute READ isScalingAbsolute WRITE setScalingAbsolute NOTIFY scalingAbsoluteChanged) |
30 | |
31 | public: |
32 | explicit QCustom3DItem(QObject *parent = nullptr); |
33 | explicit QCustom3DItem(const QString &meshFile, const QVector3D &position, |
34 | const QVector3D &scaling, const QQuaternion &rotation, |
35 | const QImage &texture, QObject *parent = nullptr); |
36 | virtual ~QCustom3DItem(); |
37 | |
38 | void setMeshFile(const QString &meshFile); |
39 | QString meshFile() const; |
40 | |
41 | void setTextureFile(const QString &textureFile); |
42 | QString textureFile() const; |
43 | |
44 | void setPosition(const QVector3D &position); |
45 | QVector3D position() const; |
46 | |
47 | void setPositionAbsolute(bool positionAbsolute); |
48 | bool isPositionAbsolute() const; |
49 | |
50 | void setScaling(const QVector3D &scaling); |
51 | QVector3D scaling() const; |
52 | |
53 | void setScalingAbsolute(bool scalingAbsolute); |
54 | bool isScalingAbsolute() const; |
55 | |
56 | void setRotation(const QQuaternion &rotation); |
57 | QQuaternion rotation(); |
58 | |
59 | void setVisible(bool visible); |
60 | bool isVisible() const; |
61 | |
62 | void setShadowCasting(bool enabled); |
63 | bool isShadowCasting() const; |
64 | |
65 | Q_INVOKABLE void setRotationAxisAndAngle(const QVector3D &axis, float angle); |
66 | |
67 | void setTextureImage(const QImage &textureImage); |
68 | |
69 | Q_SIGNALS: |
70 | void meshFileChanged(const QString &meshFile); |
71 | void textureFileChanged(const QString &textureFile); |
72 | void positionChanged(const QVector3D &position); |
73 | void positionAbsoluteChanged(bool positionAbsolute); |
74 | void scalingChanged(const QVector3D &scaling); |
75 | void rotationChanged(const QQuaternion &rotation); |
76 | void visibleChanged(bool visible); |
77 | void shadowCastingChanged(bool shadowCasting); |
78 | void scalingAbsoluteChanged(bool scalingAbsolute); |
79 | void needUpdate(); |
80 | |
81 | protected: |
82 | QCustom3DItem(QCustom3DItemPrivate *d, QObject *parent = nullptr); |
83 | |
84 | QScopedPointer<QCustom3DItemPrivate> d_ptr; |
85 | |
86 | private: |
87 | Q_DISABLE_COPY(QCustom3DItem) |
88 | |
89 | friend class Abstract3DController; |
90 | friend class QQuickGraphsItem; |
91 | }; |
92 | |
93 | QT_END_NAMESPACE |
94 | |
95 | #endif |
96 | |