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/PieLegend.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/charts/PieLegend.h (limited to 'src/charts/PieLegend.h') diff --git a/src/charts/PieLegend.h b/src/charts/PieLegend.h new file mode 100644 index 0000000..d8e83e5 --- /dev/null +++ b/src/charts/PieLegend.h @@ -0,0 +1,34 @@ +#ifndef PIE_LEGEND_H +#define PIE_LEGEND_H + +#include + +#include "DataPoint.h" + +class PieChartScene; + +class PieLegend: public QGraphicsItem +{ +public: + static const int Width = 150; + static const int SquareSide = 20; + static const int LabelSpacing = 10; + static const int LabelTextSpacing = 10; + +public: + PieLegend(const QPointF& pos, const PieChartScene* scene); + QRectF boundingRect() const; + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* = 0) {} + +private: + void addLabels(); + QPointF getLabelPos(int index) const; + void addLabel(int index, const QPointF& pos); + QPointF getTextPos(const QPointF& squarePos, + const QGraphicsSimpleTextItem* textItem) const; + +private: + const PieChartScene* scene; +}; + +#endif -- cgit