| 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_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 hoverMoveEvent(QGraphicsSceneHoverEvent *event) override; | 
| 50 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; | 
| 51 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; | 
| 52 | void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; | 
| 53 | void suppressPoints() { m_pointsVisible = false; } | 
| 54 | void forceChartType(QChart::ChartType chartType) { m_chartType = chartType; } | 
| 55 | |
| 56 | private: | 
| 57 | QLineSeries *m_series; | 
| 58 | QPainterPath m_linePath; | 
| 59 | QPainterPath m_linePathPolarRight; | 
| 60 | QPainterPath m_linePathPolarLeft; | 
| 61 | QPainterPath m_fullPath; | 
| 62 | QPainterPath m_shapePath; | 
| 63 | |
| 64 | QList<QPointF> m_linePoints; | 
| 65 | QRectF m_rect; | 
| 66 | QPen m_linePen; | 
| 67 | bool m_pointsVisible; | 
| 68 | QChart::ChartType m_chartType; | 
| 69 | |
| 70 | bool m_pointLabelsVisible; | 
| 71 | qreal m_markerSize; | 
| 72 | QString m_pointLabelsFormat; | 
| 73 | QFont m_pointLabelsFont; | 
| 74 | QColor m_pointLabelsColor; | 
| 75 | bool m_pointLabelsClipping; | 
| 76 | |
| 77 | QPointF m_lastMousePos; | 
| 78 | QPointF m_lastHoveredMatchedPos; | 
| 79 | bool m_mousePressed; | 
| 80 | }; | 
| 81 | |
| 82 | QT_END_NAMESPACE | 
| 83 | |
| 84 | #endif | 
| 85 | 
