| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | // W A R N I N G |
| 5 | // ------------- |
| 6 | // |
| 7 | // This file is not part of the Qt Chart API. It exists purely as an |
| 8 | // implementation detail. This header file may change from version to |
| 9 | // version without notice, or even be removed. |
| 10 | // |
| 11 | // We mean it. |
| 12 | |
| 13 | #ifndef GLXYSERIESDATA_H |
| 14 | #define GLXYSERIESDATA_H |
| 15 | |
| 16 | #include <QtCore/QMap> |
| 17 | #include <QtCharts/QAbstractSeries> |
| 18 | #include <QtCharts/QXYSeries> |
| 19 | #include <QtCharts/private/qchartglobal_p.h> |
| 20 | #include <QtGui/QVector3D> |
| 21 | #include <QtGui/QVector2D> |
| 22 | #include <QtGui/QMatrix4x4> |
| 23 | |
| 24 | QT_BEGIN_NAMESPACE |
| 25 | |
| 26 | class AbstractDomain; |
| 27 | |
| 28 | struct GLXYSeriesData { |
| 29 | QList<float> array; |
| 30 | bool dirty; |
| 31 | QVector3D color; |
| 32 | float width; |
| 33 | QAbstractSeries::SeriesType type; |
| 34 | QVector2D min; |
| 35 | QVector2D delta; |
| 36 | bool visible; |
| 37 | QMatrix4x4 matrix; |
| 38 | public: |
| 39 | GLXYSeriesData &operator=(const GLXYSeriesData &data) { |
| 40 | array = data.array; |
| 41 | dirty = data.dirty; |
| 42 | color = data.color; |
| 43 | width = data.width; |
| 44 | type = data.type; |
| 45 | min = data.min; |
| 46 | delta = data.delta; |
| 47 | visible = data.visible; |
| 48 | matrix = data.matrix; |
| 49 | return *this; |
| 50 | } |
| 51 | }; |
| 52 | |
| 53 | typedef QMap<const QXYSeries *, GLXYSeriesData *> GLXYDataMap; |
| 54 | |
| 55 | class Q_CHARTS_EXPORT GLXYSeriesDataManager : public QObject |
| 56 | { |
| 57 | Q_OBJECT |
| 58 | |
| 59 | public: |
| 60 | GLXYSeriesDataManager(QObject *parent = 0); |
| 61 | ~GLXYSeriesDataManager(); |
| 62 | |
| 63 | void setPoints(QXYSeries *series, const AbstractDomain *domain); |
| 64 | |
| 65 | void removeSeries(const QXYSeries *series); |
| 66 | |
| 67 | GLXYDataMap &dataMap() { return m_seriesDataMap; } |
| 68 | |
| 69 | // These functions are needed by qml side, so they must be inline |
| 70 | bool mapDirty() const { return m_mapDirty; } |
| 71 | void clearAllDirty() { |
| 72 | m_mapDirty = false; |
| 73 | for (GLXYSeriesData *data : m_seriesDataMap) |
| 74 | data->dirty = false; |
| 75 | } |
| 76 | void handleAxisReverseChanged(const QList<QAbstractSeries *> &seriesList); |
| 77 | |
| 78 | public Q_SLOTS: |
| 79 | void cleanup(); |
| 80 | void handleSeriesPenChange(); |
| 81 | void handleSeriesOpenGLChange(); |
| 82 | void handleSeriesVisibilityChange(); |
| 83 | #if QT_CONFIG(charts_scatter_chart) |
| 84 | void handleScatterColorChange(); |
| 85 | void handleScatterMarkerSizeChange(); |
| 86 | #endif |
| 87 | |
| 88 | Q_SIGNALS: |
| 89 | void seriesRemoved(const QXYSeries *series); |
| 90 | |
| 91 | private: |
| 92 | GLXYDataMap m_seriesDataMap; |
| 93 | bool m_mapDirty; |
| 94 | }; |
| 95 | |
| 96 | QT_END_NAMESPACE |
| 97 | |
| 98 | #endif |
| 99 |
