1 | // Copyright (C) 2024 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef PIERENDERER_H |
5 | #define PIERENDERER_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 <QQuickItem> |
18 | #include <QtGui/qpainterpath.h> |
19 | |
20 | QT_BEGIN_NAMESPACE |
21 | |
22 | class QGraphsView; |
23 | class QPieSeries; |
24 | class QPieSlice; |
25 | class QQuickShape; |
26 | class QAbstractSeries; |
27 | |
28 | class PieRenderer : public QQuickItem |
29 | { |
30 | Q_OBJECT |
31 | public: |
32 | PieRenderer(QGraphsView *graph); |
33 | ~PieRenderer() override; |
34 | |
35 | void handlePolish(QPieSeries *series); |
36 | void afterPolish(QList<QAbstractSeries *> &cleanupSeries); |
37 | void updateSeries(QPieSeries *series); |
38 | void afterUpdate(QList<QAbstractSeries *> &cleanupSeries); |
39 | void markedDeleted(QList<QPieSlice *> deleted); |
40 | |
41 | void setSize(QSizeF size); |
42 | |
43 | private: |
44 | struct SliceData |
45 | { |
46 | bool initialized; |
47 | }; |
48 | |
49 | QGraphsView *m_graph; |
50 | QQuickShape *m_shape; |
51 | QHash<QPieSlice *, SliceData> m_activeSlices; |
52 | |
53 | QPainterPath m_painterPath; |
54 | qsizetype m_colorIndex = -1; |
55 | }; |
56 | |
57 | QT_END_NAMESPACE |
58 | |
59 | #endif // QPIERENDERER_H |
60 |