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
22QT_BEGIN_NAMESPACE
23
24class QLineSeries;
25class ChartPresenter;
26
27class Q_CHARTS_PRIVATE_EXPORT LineChartItem : public XYChart
28{
29 Q_OBJECT
30 Q_INTERFACES(QGraphicsItem)
31public:
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
42public Q_SLOTS:
43 void handleSeriesUpdated() override;
44
45protected:
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
55private:
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
80QT_END_NAMESPACE
81
82#endif
83

source code of qtcharts/src/charts/linechart/linechartitem_p.h