forked from UIDO/UMapControl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GeoPie.cpp
45 lines (40 loc) · 1.13 KB
/
GeoPie.cpp
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
38
39
40
41
42
43
44
45
#include "GeoPie.h"
#include <math.h>
GeoPie::GeoPie(QPointF world, int size, int dir, QColor pen, QColor brush) :
Geometry(UM::iGeoPie, size, pen, brush)
{
list.append(world);
this->dir = dir;
checkRect();
}
QRectF GeoPie::boundingRect() const
{
return QRectF(-size/2, -size/2, size, size);
}
QPainterPath GeoPie::shape() const
{
QPainterPath path;
//path.addRect(-size/2, -size/2, size, size);
QPolygonF polygon;
polygon.append(QPointF(0,0));
polygon.append(QPointF(-size/6,-size/2));
polygon.append(QPointF(size/6,-size/2));
path.addPolygon(polygon);
return path;
}
void GeoPie::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
painter->setPen(pen);
painter->setBrush(brush);
painter->setRenderHint(QPainter::Antialiasing);
painter->drawPie(-size/2, -size/2, size, size-2,70*16, 40*16);
if(label.length())
{
QFont font = painter->font();
font.setFamily("Microsoft YaHei");
font.setBold(true);
painter->setFont(font);
painter->setPen(brush);
painter->drawText(-getLabelPixeSize()/2,-size/2-5,label);
}
}