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 SPLINECHARTITEM_P_H |
14 | #define SPLINECHARTITEM_P_H |
15 | |
16 | #include <QtCharts/QSplineSeries> |
17 | #include <private/xychart_p.h> |
18 | #include <QtCharts/private/qchartglobal_p.h> |
19 | |
20 | QT_BEGIN_NAMESPACE |
21 | |
22 | class SplineAnimation; |
23 | |
24 | class Q_CHARTS_PRIVATE_EXPORT SplineChartItem : public XYChart |
25 | { |
26 | Q_OBJECT |
27 | Q_INTERFACES(QGraphicsItem) |
28 | public: |
29 | SplineChartItem(QSplineSeries *series, QGraphicsItem *item = 0); |
30 | |
31 | //from QGraphicsItem |
32 | QRectF boundingRect() const override; |
33 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; |
34 | QPainterPath shape() const override; |
35 | |
36 | void setControlGeometryPoints(const QList<QPointF> &points); |
37 | QList<QPointF> controlGeometryPoints() const; |
38 | |
39 | void setAnimation(SplineAnimation *animation); |
40 | ChartAnimation *animation() const override; |
41 | |
42 | public Q_SLOTS: |
43 | void handleSeriesUpdated() override; |
44 | |
45 | protected: |
46 | void updateGeometry() override; |
47 | QList<QPointF> calculateControlPoints(const QList<QPointF> &points); |
48 | QList<qreal> firstControlPoints(const QList<qreal> &list); |
49 | void updateChart(const QList<QPointF> &oldPoints, const QList<QPointF> &newPoints, int index) override; |
50 | void mousePressEvent(QGraphicsSceneMouseEvent *event) override; |
51 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; |
52 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; |
53 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; |
54 | void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; |
55 | |
56 | private: |
57 | QSplineSeries *m_series; |
58 | QPainterPath m_path; |
59 | QPainterPath m_pathPolarRight; |
60 | QPainterPath m_pathPolarLeft; |
61 | QPainterPath m_fullPath; |
62 | QRectF m_rect; |
63 | QPen m_linePen; |
64 | QPen m_pointPen; |
65 | bool m_pointsVisible; |
66 | QList<QPointF> m_controlPoints; |
67 | QList<QPointF> m_visiblePoints; |
68 | SplineAnimation *m_animation; |
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 | bool m_mousePressed; |
79 | |
80 | friend class SplineAnimation; |
81 | }; |
82 | |
83 | QT_END_NAMESPACE |
84 | |
85 | #endif // SPLINECHARTITEM_P_H |
86 |