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
20QT_BEGIN_NAMESPACE
21
22class SplineAnimation;
23
24class Q_CHARTS_EXPORT SplineChartItem : public XYChart
25{
26 Q_OBJECT
27 Q_INTERFACES(QGraphicsItem)
28public:
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
42public Q_SLOTS:
43 void handleSeriesUpdated() override;
44
45protected:
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 hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
53 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
54 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
55 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
56
57private:
58 QSplineSeries *m_series;
59 QPainterPath m_path;
60 QPainterPath m_pathPolarRight;
61 QPainterPath m_pathPolarLeft;
62 QPainterPath m_fullPath;
63 QRectF m_rect;
64 QPen m_linePen;
65 QPen m_pointPen;
66 bool m_pointsVisible;
67 QList<QPointF> m_controlPoints;
68 QList<QPointF> m_visiblePoints;
69 SplineAnimation *m_animation;
70
71 bool m_pointLabelsVisible;
72 qreal m_markerSize;
73 QString m_pointLabelsFormat;
74 QFont m_pointLabelsFont;
75 QColor m_pointLabelsColor;
76 bool m_pointLabelsClipping;
77
78 QPointF m_lastMousePos;
79 QPointF m_lastHoveredMatchedPos;
80 bool m_mousePressed;
81
82 friend class SplineAnimation;
83};
84
85QT_END_NAMESPACE
86
87#endif // SPLINECHARTITEM_P_H
88

source code of qtcharts/src/charts/splinechart/splinechartitem_p.h