-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroomlabel.cpp
51 lines (46 loc) · 1.45 KB
/
roomlabel.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
46
47
48
49
50
51
#include "roomlabel.h"
#include <QDebug>
#include <QPainter>
RoomLabel::RoomLabel(QRectF field, QVector <QPoint> &coordinates, QString name, QString brush_, QString info)
: QGraphicsObject(),
coordinates(coordinates),
field(field),
name(name),
brush_(brush_),
info(info)
{
QPolygon polygon;
foreach(QPoint point, coordinates){
polygon << point;
}
polyItem = new QGraphicsPolygonItem(QPolygonF(polygon));
QStringList br = brush_.split(" ");
polyItem->setBrush(QColor(br.at(0).toInt(),
br.at(1).toInt(),
br.at(2).toInt(),
br.at(3).toInt()));
//polyItem->setFlag(QGraphicsItem::ItemIsSelectable);
//polyItem->is
}
QRectF RoomLabel::boundingRect() const
{
return field;
// return QRectF(300, 300, 1000, 1000);
}
void RoomLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QPolygon polygon;
polygon << QPoint(200, 200);
QStringList br = brush_.split(" ");
painter->setBrush(QColor(br.at(0).toInt(),
br.at(1).toInt(),
br.at(2).toInt(),
br.at(3).toInt()));
painter->drawPolygon(polygon);
Q_UNUSED(option);
Q_UNUSED(widget);
}
void RoomLabel::mousePressEvent(QGraphicsSceneMouseEvent *event){
emit signal1();
QGraphicsItem::mousePressEvent(event);
}