-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_graphics_socket.py
More file actions
50 lines (43 loc) · 1.43 KB
/
node_graphics_socket.py
File metadata and controls
50 lines (43 loc) · 1.43 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
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
DEBUG = False
class QDMGraphicsSocket(QGraphicsItem):
def __init__(self, socket, parent):
self.socket = socket
#parent
super().__init__(parent)
self.console = self.socket.console
self.radius = 6.0
self.outline_width = 1.0
self._colors = [
QColor("#FFFF7700"),
QColor("#FF52e220"),
QColor("#FF0056a6"),
QColor("#FFa86db1"),
QColor("#FFb54747"),
QColor("#FFdbe220"),
]
self._color_background = self._colors[socket.socket_gr_type]
self._color_outline = QColor("#FF000000")
self._pen = QPen(self._color_outline)
self._debugpen = QPen(QColor("#FF00EE"))
self._pen.setWidthF(self.outline_width)
self._brush = QBrush(self._color_background)
def paint(self, painter, QStyleOptionGraphicsItem, widget=None):
r = self.radius
painter.setBrush(self._brush)
if DEBUG and len(self.socket.edgeList) != 0:
painter.setPen(self._debugpen)
else:
painter.setPen(self._pen)
painter.drawEllipse(int(-r), int(-r), int(2*r), int(2*r))
def boundingRect(self):
olw = self.outline_width
r = self.radius
return QRectF(
-r - olw,
-r - olw,
2*(r + olw),
2*(r + olw)
)