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

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