blob: 1963f260f7c194b7441235414e130f16193826ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#ifndef PIE_ROUND_H
#define PIE_ROUND_H
#include <QtWidgets>
#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
|