summaryrefslogtreecommitdiffstats
path: root/src/graphs3d/engine/barinstancing_p.h
blob: 53539f08a4fc9e9467cf1d860d581d466416cd75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

//
//  W A R N I N G
//  -------------
//
// This file is not part of the QtGraphs API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.

#ifndef BARINSTANCING_H
#define BARINSTANCING_H
#include <QtGraphs/qgraphsglobal.h>
#include <private/qquick3dinstancing_p.h>

struct BarItemHolder
{
    QVector3D position = {.0f, .0f, .0f};
    QQuaternion rotation = {1.f, .0f, .0f, .0f};
    QVector3D scale = {.0f, .0f, .0f};
    QPoint coord;
    float heightValue = .0f;
    bool selectedBar = false;
    QColor color = {0, 0, 0};
    ;
};

class Q_GRAPHS_EXPORT BarInstancing : public QQuick3DInstancing
{
    Q_OBJECT
public:
    BarInstancing();
    ~BarInstancing();

    QList<BarItemHolder *> dataArray() const;
    void setDataArray(const QList<BarItemHolder *> &newDataArray);

    void markDataDirty();
    bool transparency() const;
    void setTransparency(bool newTransparencyValue);

    void clearDataArray();

protected:
    QByteArray getInstanceBuffer(int *instanceCount) override;

private:
    QByteArray m_instanceData;
    QList<BarItemHolder *> m_dataArray;
    int m_instanceCount = 0;
    bool m_dirty = true;
    bool m_transparency = false;
};

#endif // BARINSTANCING_H