forked from UIDO/UMapControl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GeoCircle.cpp
38 lines (33 loc) · 949 Bytes
/
GeoCircle.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
#include "GeoCircle.h"
GeoCircle::GeoCircle(QPointF world, int size, QColor pen, QColor brush) :
Geometry(UM::iGeoCircle, size*0.6, pen, brush)
{
list.append(world);
checkRect();
}
QRectF GeoCircle::boundingRect() const
{
return QRectF(-size/2, -size/2, size, size);
}
QPainterPath GeoCircle::shape() const
{
QPainterPath path;
path.addEllipse(-size/2, -size/2, size, size);
return path;
}
void GeoCircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
painter->setPen(pen);
painter->setBrush(brush);
painter->setRenderHint(QPainter::Antialiasing);
painter->drawEllipse(-size/2, -size/2, size, size);
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+5,label);
}
}