1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef AREARENDERER_H
#define AREARENDERER_H
//
// W A R N I N G
// -------------
//
// This file is not part of the QtGraphs API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
#include <QPainterPath>
#include <QQuickItem>
#include <QtQuickShapes/private/qquickshape_p.h>
QT_BEGIN_NAMESPACE
class QGraphsView;
class QAreaSeries;
class AxisRenderer;
class QAbstractSeries;
class QQuickTapHandler;
class AreaRenderer : public QQuickItem
{
Q_OBJECT
public:
AreaRenderer(QGraphsView *graph, bool clipPlotArea);
~AreaRenderer() override;
void resetShapePathCount();
void handlePolish(QAreaSeries *series);
void afterPolish(QList<QAbstractSeries *> &cleanupSeries);
void afterUpdate(QList<QAbstractSeries *> &cleanupSeries);
void updateSeries(QAreaSeries *series);
bool handleHoverMove(QHoverEvent *event);
Q_SIGNALS:
private:
struct PointGroup
{
QAreaSeries *series = nullptr;
QQuickShapePath *shapePath = nullptr;
QPainterPath painterPath;
qsizetype colorIndex = -1;
qsizetype borderColorIndex = -1;
bool hover = false;
};
void onSingleTapped(QEventPoint eventPoint, Qt::MouseButton button);
void onDoubleTapped(QEventPoint eventPoint, Qt::MouseButton button);
void onPressedChanged();
QGraphsView *m_graph = nullptr;
QQuickShape m_shape;
QMap<QAreaSeries *, PointGroup *> m_groups;
qsizetype m_currentShapePathIndex = 0;
// Render area variables
qreal m_maxVertical = 0;
qreal m_maxHorizontal = 0;
qreal m_verticalOffset = 0;
qreal m_horizontalOffset = 0;
qreal m_areaWidth = 0;
qreal m_areaHeight = 0;
QQuickTapHandler *m_tapHandler = nullptr;
void calculateRenderCoordinates(qreal origX, qreal origY, qreal *renderX, qreal *renderY) const;
void calculateAxisCoordinates(
QAreaSeries *series, qreal origX, qreal origY, qreal *axisX, qreal *axisY) const;
bool pointInArea(QPoint pt, QAreaSeries *series) const;
};
QT_END_NAMESPACE
#endif // AREARENDERER_H
|