| 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 <QtGraphs/qgraphsglobal.h> |
| 18 | #include <private/qquick3dinstancing_p.h> |
| 19 | |
| 20 | struct DataItemHolder |
| 21 | { |
| 22 | QVector3D position; |
| 23 | QQuaternion rotation; |
| 24 | QVector3D scale; |
| 25 | bool hide = false; |
| 26 | }; |
| 27 | |
| 28 | class Q_GRAPHS_EXPORT ScatterInstancing : public QQuick3DInstancing |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | public: |
| 32 | ScatterInstancing(); |
| 33 | |
| 34 | const QList<DataItemHolder> &dataArray() const; |
| 35 | void setDataArray(const QList<DataItemHolder> &newDataArray); |
| 36 | void hideDataItem(qsizetype index); |
| 37 | void unhidePreviousDataItem(); |
| 38 | void resetVisibilty(); |
| 39 | |
| 40 | const QList<float> &customData() const; |
| 41 | void setCustomData(const QList<float> &newCustomData); |
| 42 | |
| 43 | void markDataDirty(); |
| 44 | bool rangeGradient() const; |
| 45 | void setRangeGradient(bool newRangeGradient); |
| 46 | |
| 47 | void setTransparency(bool transparency); |
| 48 | |
| 49 | bool isDirty() const { return m_dirty; } |
| 50 | |
| 51 | // QQuick3DInstancing interface |
| 52 | |
| 53 | protected: |
| 54 | QByteArray getInstanceBuffer(int *instanceCount) override; |
| 55 | |
| 56 | private: |
| 57 | QByteArray m_instanceData; |
| 58 | QList<DataItemHolder> m_dataArray; |
| 59 | QList<float> m_customData; |
| 60 | int m_instanceCount = 0; |
| 61 | bool m_dirty = true; |
| 62 | bool m_rangeGradient = false; |
| 63 | qsizetype m_previousHideIndex = -1; |
| 64 | }; |
| 65 | |
| 66 | #endif // SCATTERINSTANCING_H |
| 67 | |