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 LINECHARTITEM_H |
14 | #define LINECHARTITEM_H |
15 | |
16 | #include <QtCharts/QChartGlobal> |
17 | #include <private/xychart_p.h> |
18 | #include <QtCharts/QChart> |
19 | #include <QtGui/QPen> |
20 | #include <QtCharts/private/qchartglobal_p.h> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | class QLineSeries; |
25 | class ChartPresenter; |
26 | |
27 | class Q_CHARTS_PRIVATE_EXPORT LineChartItem : public XYChart |
28 | { |
29 | Q_OBJECT |
30 | Q_INTERFACES(QGraphicsItem) |
31 | public: |
32 | explicit LineChartItem(QLineSeries *series, QGraphicsItem *item = 0); |
33 | ~LineChartItem() {} |
34 | |
35 | //from QGraphicsItem |
36 | QRectF boundingRect() const override; |
37 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; |
38 | QPainterPath shape() const override; |
39 | |
40 | QPainterPath path() const { return m_fullPath; } |
41 | |
42 | public Q_SLOTS: |
43 | void handleSeriesUpdated() override; |
44 | |
45 | protected: |
46 | void updateGeometry() override; |
47 | void mousePressEvent(QGraphicsSceneMouseEvent *event) override; |
48 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; |
49 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; |
50 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; |
51 | void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; |
52 | void suppressPoints() { m_pointsVisible = false; } |
53 | void forceChartType(QChart::ChartType chartType) { m_chartType = chartType; } |
54 | |
55 | private: |
56 | QLineSeries *m_series; |
57 | QPainterPath m_linePath; |
58 | QPainterPath m_linePathPolarRight; |
59 | QPainterPath m_linePathPolarLeft; |
60 | QPainterPath m_fullPath; |
61 | QPainterPath m_shapePath; |
62 | |
63 | QList<QPointF> m_linePoints; |
64 | QRectF m_rect; |
65 | QPen m_linePen; |
66 | bool m_pointsVisible; |
67 | QChart::ChartType m_chartType; |
68 | |
69 | bool m_pointLabelsVisible; |
70 | qreal m_markerSize; |
71 | QString m_pointLabelsFormat; |
72 | QFont m_pointLabelsFont; |
73 | QColor m_pointLabelsColor; |
74 | bool m_pointLabelsClipping; |
75 | |
76 | QPointF m_lastMousePos; |
77 | bool m_mousePressed; |
78 | }; |
79 | |
80 | QT_END_NAMESPACE |
81 | |
82 | #endif |
83 |