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

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of qtgraphs/src/graphs2d/qsgrenderer/arearenderer_p.h