From d24f813f3f2a05c112e803e4256b53535895fc98 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Wed, 14 Jul 2021 11:49:10 +1200 Subject: Initial mirror commit --- src/charts/PieRound.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/charts/PieRound.h (limited to 'src/charts/PieRound.h') diff --git a/src/charts/PieRound.h b/src/charts/PieRound.h new file mode 100644 index 0000000..1963f26 --- /dev/null +++ b/src/charts/PieRound.h @@ -0,0 +1,37 @@ +#ifndef PIE_ROUND_H +#define PIE_ROUND_H + +#include + +#include "DataPoint.h" + +class PieChartScene; + +class PieRound: public QGraphicsItem +{ +public: + static const int Margin = 20; + static const int Radius = 80; + static const int LabelRadius = 50; + +public: + PieRound(const QPointF& center, const PieChartScene* scene); + QRectF boundingRect() const; + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* = 0) {} + +private: + void calculateSum(); + void addSectors(); + void addSector(int index, qreal startAngle, qreal sweep); + QPainterPath createSectorPath(qreal startAngle, qreal sweep); + void addSectorItem(const QPainterPath& path, QColor color); + void addSectorLabel(int index, qreal startAngle, qreal sweep); + QPointF getLabelPos(qreal startAngle, qreal sweep, + QGraphicsSimpleTextItem* labelItem); + +private: + int sum; + const PieChartScene* scene; +}; + +#endif -- cgit