EdgeItem.cpp
1.12 KB
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
52
53
54
55
56
57
#include "stdafx.h"
#include "EdgeItem.h"
void EdgeItem::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
}
void EdgeItem::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
{
}
void EdgeItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
{
}
EdgeItem::EdgeItem(double x1, double y1, double x2, double y2, QColor color, int width,
QString from, QString to)
{
this->x1 = x1;
this->y1 = y1;
this->x2 = x2;
this->y2 = y2;
this->color = color;
this->width = width;
this->from = from;
this->to = to;
setZValue(0); //노드 앞 가리지 않도록 ZValue 설정
/*setFlags(ItemIsSelectable | ItemIsMovable);
setAcceptHoverEvents(true);*/
}
QRectF EdgeItem::boundingRect() const
{
return QRectF(0,0,0,0);
}
QPainterPath EdgeItem::shape() const
{
QPainterPath path;
return path;
}
void EdgeItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
{
Q_UNUSED(widget);
QPen oldPen = painter->pen();
QPen pen = oldPen;
pen.setWidth(width);
pen.setColor(color);
painter->setPen(pen);
painter->drawLine(QLineF(x1, y1, x2, y2));
//painter->drawText(QPoint((x1 + x2) / 2, (y1 + y2) / 2), "hi");
}