def __init__(self, nodeID, parent=None): super(CNodeWidget, self).__init__(parent) self.m_NodeID = nodeID self.m_NodeDisplayName = interface.GetNodeAttr( nodeID, bddefine.NodeAttrName.DISPLAYNAME) self.m_IsFlowNode = False self.InitUI()
def S_Search(self): sText = self.m_Search.text() if not sText: return dInfo = interface.GetSearchInfo(self.m_BPID, sText, self.m_Status & define.FUZZY_MATCH) parentModel = self.m_Tree.model() parentModel.clear() for graphicID, dNode in dInfo.items(): graphicName = interface.GetGraphicAttr( graphicID, eddefine.GraphicAttrName.NAME) tInfo = (define.SearchTreeItemType.GRAPHIC, graphicID) oGItem = CStandardItem(graphicName, tInfo) parentModel.appendRow(oGItem) for nodeID, lstPin in dNode.items(): nodeName = interface.GetNodeAttr( nodeID, bddefine.NodeAttrName.DISPLAYNAME) tInfo = (define.SearchTreeItemType.NODE, nodeID) oNItem = CStandardItem(nodeName, tInfo) oGItem.appendRow(oNItem) for pinID in lstPin: pinName = interface.GetPinAttr( pinID, bddefine.PinAttrName.DISPLAYNAME) tInfo = (define.SearchTreeItemType.PIN, pinID) oPItem = CStandardItem(pinName, tInfo) oNItem.appendRow(oPItem) self.m_Tree.expandAll()
def DebugPinInfo(pinID, value): nodeID = interface.GetNodeIDByPinID(pinID) sNodeDisplayName = interface.GetNodeAttr(nodeID, bddefine.NodeAttrName.DISPLAYNAME) sPinDisplayName = interface.GetPinAttr(pinID, bddefine.PinAttrName.DISPLAYNAME) misc.Debug("%s-%s: %s\t%s" % (sNodeDisplayName, sPinDisplayName, value, type(value)))
def contextMenuEvent(self, event): super(CPinUI, self).contextMenuEvent(event) lstLineID = interface.GetAllLineByPin(self.m_PinID) menu = QMenu() for lineID in lstLineID: oPinID = interface.GetLineOtherPin(lineID, self.m_PinID) sPinDisplayName = interface.GetPinAttr(oPinID, bddefine.PinAttrName.DISPLAYNAME) nodeID = interface.GetNodeIDByPinID(oPinID) sNodeDisplayName = interface.GetNodeAttr(nodeID, bddefine.NodeAttrName.DISPLAYNAME) sMsg = "删除与\"%s\"-\"%s\"的连线" % (sNodeDisplayName, sPinDisplayName) func = functor.Functor(interface.DelLine, lineID) menu.addAction(sMsg, func) menu.exec_(QCursor.pos()) event.accept()
def RunBlueprint(bpID): """运行蓝图""" obj = GetRunObj() if obj: obj.Stop() while obj.isAlive(): time.sleep(0.5) iEventNode = interface.GetBlueprintAttr( bpID, eddefine.BlueprintAttrName.EVENT_NODE) if not iEventNode: return lstPin = interface.GetNodeAttr(iEventNode, bddefine.NodeAttrName.PINIDLIST) startPin = lstPin[0] obj = InitRunObj() obj.Run(startPin)
def S_FocusNode(self, graphicID, nodeID): if self.m_GraphicID != graphicID: return bpID = interface.GetBPIDByGraphicID(graphicID) GetSignal().UI_FOCUS_GRAPHIC.emit(bpID, graphicID) pos = interface.GetNodeAttr(nodeID, bddefine.NodeAttrName.POSITION) x, y = pos[0], pos[1] oNodeUI = GetUIMgr().GetNodeUI(nodeID) if oNodeUI: x += oNodeUI.size().width() / 2 y += oNodeUI.size().height() / 2 point = QPointF(x, y) self.centerOn(point) GetStatusMgr().SelectOneNode(graphicID, nodeID)
def RunInputFlow(self, inputPin, bNext=False): """输入流引脚永远只有一个""" if self.m_Statue & BLUEPRINT_STOP: return nodeID = interface.GetNodeIDByPinID(inputPin) if not bNext and nodeID in g_BreakPoint: self.m_Statue = BLUEPRINT_DEBUG_PAUSE while True: if self.m_Statue == BLUEPRINT_STOP: return if self.m_Statue == BLUEPRINT_RUNING: break time.sleep(0.5) func = GetPinFunc(inputPin) if func: sNodeDisplayName = interface.GetNodeAttr( nodeID, bddefine.NodeAttrName.DISPLAYNAME) misc.Debug("开始运行'%s'节点" % sNodeDisplayName) func()
def InitUI(self): self.setObjectName("CNodeWidget") self.setCursor(Qt.SizeAllCursor) self.verticalLayout = QtWidgets.QVBoxLayout(self) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setSpacing(0) self.verticalLayout.setObjectName("verticalLayout") self.outline = QtWidgets.QWidget(self) self.outline.setObjectName("outline") self.verticalLayout_outline = QtWidgets.QVBoxLayout(self.outline) self.verticalLayout_outline.setContentsMargins(4, 4, 4, 4) self.verticalLayout_outline.setObjectName("verticalLayout_outline") self.BCWidget = QtWidgets.QWidget(self.outline) self.BCWidget.setObjectName("BCWidget") self.verticalLayout_BCWidget = QtWidgets.QVBoxLayout(self.BCWidget) self.verticalLayout_BCWidget.setObjectName("verticalLayout_BCWidget") # self.verticalLayout_BCWidget.setContentsMargins(0, 0, 0, 0) # top self.top = QtWidgets.QWidget(self.BCWidget) self.top.setObjectName("top") self.horizontalLayout_top = QtWidgets.QHBoxLayout(self.top) self.horizontalLayout_top.setContentsMargins(6, 2, 4, 2) self.horizontalLayout_top.setObjectName("horizontalLayout_top") self.lb_Title = QtWidgets.QLabel(self.top) self.lb_Title.setObjectName("lb_Title") self.lb_Title.setText(self.m_NodeDisplayName) self.horizontalLayout_top.addWidget(self.lb_Title) spacerItem = QtWidgets.QSpacerItem(67, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_top.addItem(spacerItem) # add调试label图标 self.lable_debug = QtWidgets.QLabel(self.top) self.lable_debug.setMinimumSize(QtCore.QSize(20, 20)) self.lable_debug.setMaximumSize(QtCore.QSize(20, 20)) self.lable_debug.setPixmap(QtGui.QPixmap(":/icon/debug.png")) self.lable_debug.setScaledContents(True) self.lable_debug.hide() self.horizontalLayout_top.addWidget(self.lable_debug) self.verticalLayout_BCWidget.addWidget(self.top) # fot attr hBox = QtWidgets.QHBoxLayout() self.m_InputVBox = QtWidgets.QVBoxLayout() self.m_OutputVBox = QtWidgets.QVBoxLayout() lstPin = interface.GetNodeAttr(self.m_NodeID, bddefine.NodeAttrName.PINIDLIST) for pinID in lstPin: self._AddPinWidget(pinID) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) hBox.addLayout(self.m_InputVBox) hBox.addItem(spacerItem) hBox.addLayout(self.m_OutputVBox) self.verticalLayout_BCWidget.addLayout(hBox) self.verticalLayout_outline.addWidget(self.BCWidget) self.verticalLayout.addWidget(self.outline)
def _NewNodeUI(self, nodeID): tPos = interface.GetNodeAttr(nodeID, bddefine.NodeAttrName.POSITION) oNodeUI = nodeui.CNodeUI(nodeID) self.addItem(oNodeUI) x, y = tPos oNodeUI.setPos(x, y)