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
24QT_BEGIN_NAMESPACE
25
26class ChartPresenter;
27
28class Q_CHARTS_PRIVATE_EXPORT XYChart : public ChartItem
29{
30 Q_OBJECT
31public:
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
48public 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
58Q_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
65protected:
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);
72
73private:
74 inline bool isEmpty();
75
76protected:
77 QXYSeries *m_series;
78 QList<QPointF> m_points;
79 QList<int> m_selectedPoints;
80 QColor m_selectedColor;
81 XYAnimation *m_animation;
82 bool m_dirty;
83
84 QHash<int, QHash<QXYSeries::PointConfiguration, QVariant>> m_pointsConfiguration;
85
86 friend class AreaChartItem;
87};
88
89QT_END_NAMESPACE
90
91#endif
92

source code of qtcharts/src/charts/xychart/xychart_p.h