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 BARINSTANCING_H
15#define BARINSTANCING_H
16
17#include <QtQuick3D/private/qquick3dinstancing_p.h>
18
19struct BarItemHolder {
20 QVector3D position = {.0f, .0f, .0f};
21 QQuaternion rotation;
22 QVector3D eulerRotation = {.0f, .0f, .0f};
23 QVector3D scale = {.0f, .0f, .0f};
24 QPoint coord;
25 float heightValue = .0f;
26 bool selectedBar = false;
27 QColor color = {0, 0, 0};;
28};
29
30class BarInstancing : public QQuick3DInstancing
31{
32 Q_OBJECT
33public:
34 BarInstancing();
35 ~BarInstancing();
36
37 QList<BarItemHolder *> dataArray() const;
38 void setDataArray(const QList<BarItemHolder *> &newDataArray);
39
40 void markDataDirty();
41 bool rangeGradient() const;
42 void setRangeGradient(bool newRangeGradient);
43
44 void clearDataArray();
45
46protected:
47 QByteArray getInstanceBuffer(int *instanceCount) override;
48
49private:
50 QByteArray m_instanceData;
51 QList<BarItemHolder *> m_dataArray;
52 int m_instanceCount = 0;
53 bool m_dirty = true;
54 bool m_rangeGradient = false;
55};
56
57#endif // BARINSTANCING_H
58

source code of qtgraphs/src/graphs/engine/barinstancing_p.h