1 | /* |
2 | * This file is part of KQuickCharts |
3 | * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiemstra@heimr.nl> |
4 | * |
5 | * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
6 | */ |
7 | |
8 | #ifndef PIECHARTNODE_H |
9 | #define PIECHARTNODE_H |
10 | |
11 | #include <QColor> |
12 | #include <QSGGeometryNode> |
13 | |
14 | class QRectF; |
15 | class PieChartMaterial; |
16 | |
17 | /** |
18 | * @todo write docs |
19 | */ |
20 | class PieChartNode : public QSGGeometryNode |
21 | { |
22 | public: |
23 | PieChartNode(); |
24 | |
25 | /** |
26 | * Default constructor |
27 | */ |
28 | explicit PieChartNode(const QRectF &rect); |
29 | |
30 | /** |
31 | * Destructor |
32 | */ |
33 | ~PieChartNode(); |
34 | |
35 | void setRect(const QRectF &rect); |
36 | void setInnerRadius(qreal radius); |
37 | void setOuterRadius(qreal radius); |
38 | void setSections(const QList<qreal> §ions); |
39 | void setColors(const QList<QColor> &colors); |
40 | void setBackgroundColor(const QColor &color); |
41 | void setFromAngle(qreal angle); |
42 | void setToAngle(qreal angle); |
43 | void setSmoothEnds(bool smooth); |
44 | |
45 | private: |
46 | void updateSegments(); |
47 | |
48 | QRectF m_rect; |
49 | qreal m_innerRadius = 0.0; |
50 | qreal m_outerRadius = 0.0; |
51 | QColor m_backgroundColor; |
52 | qreal m_fromAngle = 0.0; |
53 | qreal m_toAngle = 360.0; |
54 | bool m_smoothEnds = false; |
55 | |
56 | QList<qreal> m_sections; |
57 | QList<QColor> m_colors; |
58 | |
59 | QSGGeometry *m_geometry = nullptr; |
60 | PieChartMaterial *m_material = nullptr; |
61 | }; |
62 | |
63 | #endif // PIECHARTNODE_H |
64 | |