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