| 1 | // Copyright (C) 2021 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 XYCHART_H |
| 14 | #define XYCHART_H |
| 15 | |
| 16 | #include <QtCharts/QChartGlobal> |
| 17 | #include <private/chartitem_p.h> |
| 18 | #include <private/xyanimation_p.h> |
| 19 | #include <QtCharts/QValueAxis> |
| 20 | #include <QtCharts/QXYSeries> |
| 21 | #include <QtCharts/private/qchartglobal_p.h> |
| 22 | #include <QtGui/QPen> |
| 23 | |
| 24 | QT_BEGIN_NAMESPACE |
| 25 | |
| 26 | class ChartPresenter; |
| 27 | |
| 28 | class Q_CHARTS_EXPORT XYChart : public ChartItem |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | public: |
| 32 | explicit XYChart(QXYSeries *series,QGraphicsItem *item = 0); |
| 33 | ~XYChart() {} |
| 34 | |
| 35 | void setGeometryPoints(const QList<QPointF> &points); |
| 36 | QList<QPointF> geometryPoints() const { return m_points; } |
| 37 | |
| 38 | void setAnimation(XYAnimation *animation); |
| 39 | ChartAnimation *animation() const override { return m_animation; } |
| 40 | virtual void updateGeometry() = 0; |
| 41 | |
| 42 | bool isDirty() const { return m_dirty; } |
| 43 | void setDirty(bool dirty); |
| 44 | |
| 45 | void getSeriesRanges(qreal &minX, qreal &maxX, qreal &minY, qreal &maxY); |
| 46 | QList<bool> offGridStatusVector(); |
| 47 | |
| 48 | public Q_SLOTS: |
| 49 | void handlePointAdded(int index); |
| 50 | void handlePointRemoved(int index); |
| 51 | void handlePointsRemoved(int index, int count); |
| 52 | void handlePointReplaced(int index); |
| 53 | void handlePointsReplaced(); |
| 54 | void handleDomainUpdated() override; |
| 55 | |
| 56 | virtual void handleSeriesUpdated(); |
| 57 | |
| 58 | Q_SIGNALS: |
| 59 | void clicked(const QPointF &point); |
| 60 | void hovered(const QPointF &point, bool state); |
| 61 | void pressed(const QPointF &point); |
| 62 | void released(const QPointF &point); |
| 63 | void doubleClicked(const QPointF &point); |
| 64 | |
| 65 | protected: |
| 66 | virtual void updateChart(const QList<QPointF> &oldPoints, const QList<QPointF> &newPoints, |
| 67 | int index = -1); |
| 68 | virtual void updateGlChart(); |
| 69 | virtual void refreshGlChart(); |
| 70 | |
| 71 | QPointF matchForLightMarker(const QPointF &eventPos) const; |
| 72 | |
| 73 | private: |
| 74 | inline bool isEmpty(); |
| 75 | |
| 76 | protected: |
| 77 | QPointF hoverPoint(const QPointF &eventPos) const; |
| 78 | static bool fuzzyComparePointF(const QPointF &p1, const QPointF &p2); |
| 79 | |
| 80 | QXYSeries *m_series; |
| 81 | QList<QPointF> m_points; |
| 82 | QList<int> m_selectedPoints; |
| 83 | QColor m_selectedColor; |
| 84 | XYAnimation *m_animation; |
| 85 | bool m_dirty; |
| 86 | |
| 87 | QHash<int, QHash<QXYSeries::PointConfiguration, QVariant>> m_pointsConfiguration; |
| 88 | |
| 89 | friend class AreaChartItem; |
| 90 | }; |
| 91 | |
| 92 | QT_END_NAMESPACE |
| 93 | |
| 94 | #endif |
| 95 | |