summaryrefslogtreecommitdiffstats
path: root/examples/datavisualization/qmlsurfacegallery/datasource.h
blob: bac5eeb235b841ce25fd4fc1fae7f40f8b3f2a46 (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
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#ifndef DATASOURCE_H
#define DATASOURCE_H

#include <QtDataVisualization/qsurface3dseries.h>
#include <QtQml/qqmlregistration.h>

//! [0]
//! [2]
class DataSource : public QObject
{
    Q_OBJECT
    //! [0]
    QML_ELEMENT
    //! [2]
public:
    explicit DataSource(QObject *parent = nullptr);
    virtual ~DataSource();

    //! [1]
    Q_INVOKABLE void generateData(int cacheCount, int rowCount, int columnCount,
                                  float xMin, float xMax,
                                  float yMin, float yMax,
                                  float zMin, float zMax);

    Q_INVOKABLE void update(QSurface3DSeries *series);
    //! [1]
private:
    void clearData();

    QList<QSurfaceDataArray> m_data;
    int m_index = -1;
    QSurfaceDataArray *m_resetArray = nullptr;
};

#endif