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

source code of qtgraphs/src/graphs3d/data/qcustom3ditem.h