-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gpu.py
73 lines (73 loc) · 2.45 KB
/
Gpu.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from PyQt5.QtCore import *
from calc_conf import *
from calc_node_base import *
from utils import dumpException
import multiprocessing
import os
import sys
class CalcGraphicsNode(QDMGraphicsNode):
def initSizes(self):
super().initSizes()
self.width = 120
self.height = 120
self.edge_roundness = 6
self.edge_padding = 0
self.title_horizontal_padding = 8
self.title_vertical_padding = 10
def initAssets(self):
super().initAssets()
self.icons = QImage("icons/status_icons.png")
def paint(self, painter, QStyleOptionGraphicsItem, widget=None):
super().paint(painter, QStyleOptionGraphicsItem, widget)
offset = 24.0
if self.node.isDirty(): offset = 0.0
if self.node.isInvalid(): offset = 48.0
painter.drawImage(
QRectF(-10, -10, 24.0, 24.0),
self.icons,
QRectF(offset, 0, 24.0, 24.0)
)
class CalcGPUContent(QDMNodeContentWidget):
def initUI(self):
self.lb1 = QLabel("Select Mode: ", self)
self.lb1.setObjectName(self.node.content_label_objname1)
self.edit1 = QLineEdit("1", self)
self.edit1.setObjectName(self.node.content_label_objname2)
def serialize(self):
res = super().serialize()
res['value'] = self.edit1.text()
return res
def deserialize(self, data, hashmap={}):
res = super().deserialize(data, hashmap)
try:
value = data['value']
self.edit1.setText(value)
return True & res
except Exception as e:
dumpException(e)
return res
@register_node(OP_NODE_GPU)
class CalcNode_GPU(CalcNode):
icon = "icons/g.png"
op_code = OP_NODE_GPU
op_title = "GPU"
content_label_objname1 = "calc_node_gpulb"
content_label_objname2 = "calc_node_gpuedit1"
GraphicsNode_class = CalcGraphicsNode
def __init__(self, scene):
super().__init__(scene, inputs=[], outputs=[2])
self.eval()
def initInnerClasses(self):
self.content = CalcGPUContent(self)
self.grNode = CalcGraphicsNode(self)
def evalImplementation(self):
u_value = self.content.edit1.text()
s_value = str(u_value)
self.value = s_value
self.markDirty(False)
self.markInvalid(False)
self.markDescendantsInvalid(False)
self.markDescendantsDirty()
self.grNode.setToolTip("")
self.evalChildren()
return self.value