1 | // Copyright (C) 2023 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | // |
5 | // W A R N I N G |
6 | // ------------- |
7 | // |
8 | // This file is not part of the QtGraphs API. It exists purely as an |
9 | // implementation detail. This header file may change from version to |
10 | // version without notice, or even be removed. |
11 | // |
12 | // We mean it. |
13 | |
14 | #ifndef SCATTERINSTANCING_H |
15 | #define SCATTERINSTANCING_H |
16 | |
17 | #include <QtQuick3D/private/qquick3dinstancing_p.h> |
18 | |
19 | struct DataItemHolder { |
20 | QVector3D position; |
21 | QQuaternion rotation; |
22 | QVector3D scale; |
23 | bool hide = false; |
24 | }; |
25 | |
26 | class ScatterInstancing : public QQuick3DInstancing |
27 | { |
28 | Q_OBJECT |
29 | public: |
30 | ScatterInstancing(); |
31 | |
32 | const QList<DataItemHolder> &dataArray() const; |
33 | void setDataArray(const QList<DataItemHolder> &newDataArray); |
34 | void hideDataItem(int index); |
35 | void resetVisibilty(); |
36 | |
37 | QList<float> &customData(); |
38 | void setCustomData(const QList<float> &newCustomData); |
39 | |
40 | void markDataDirty(); |
41 | bool rangeGradient() const; |
42 | void setRangeGradient(bool newRangeGradient); |
43 | |
44 | // QQuick3DInstancing interface |
45 | |
46 | protected: |
47 | QByteArray getInstanceBuffer(int *instanceCount) override; |
48 | |
49 | private: |
50 | QByteArray m_instanceData; |
51 | QList<DataItemHolder> m_dataArray; |
52 | QList<float> m_customData; |
53 | int m_instanceCount = 0; |
54 | bool m_dirty = true; |
55 | bool m_rangeGradient = false; |
56 | }; |
57 | |
58 | #endif // SCATTERINSTANCING_H |
59 | |