-
Notifications
You must be signed in to change notification settings - Fork 0
/
GraphicsSocket.cpp
34 lines (28 loc) · 963 Bytes
/
GraphicsSocket.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
#include "GraphicsSocket.h"
#include "GraphicsNode.h"
GraphicsSocket::GraphicsSocket(GraphicsNode *p) : QGraphicsItem(p), parent(p)
{
radius = 5;
outlineWidth = 2;
padding = 2; // Make it easier to select
setZValue(2);
}
QRectF GraphicsSocket::boundingRect() const
{
return QRectF(-radius - outlineWidth,
-radius - outlineWidth,
padding + (radius + outlineWidth) * outlineWidth,
padding + (radius + outlineWidth) * outlineWidth).normalized();
}
void GraphicsSocket::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
QPen pen = painter->pen();
pen.setColor(QColor("#9AE6B4"));
pen.setWidth(outlineWidth);
painter->setPen(pen);
painter->setBrush(QBrush(QColor("#68D391")));
painter->drawEllipse(-radius, -radius, radius * 2, radius * 2);
// painter->drawRect(this->boundingRect());
}