Ejemplo n.º 1
0
 def SetIcon(self, iDataType=None):
     if iDataType is None:
         iPinType = interface.GetPinAttr(self.m_PinID, bddefine.PinAttrName.PIN_TYPE)
         if bddefine.PinIsFlow(iPinType):
             iDataType = -1
         else:
             iDataType = interface.GetPinAttr(self.m_PinID, bddefine.PinAttrName.DATA_TYPE)
     icon = QIcon()
     pix = ":/icon/btn_%s.png" % iDataType
     icon.addPixmap(QPixmap(pix), QIcon.Normal, QIcon.Off)
     self.m_Btn.setIcon(icon)
Ejemplo n.º 2
0
 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()
Ejemplo n.º 3
0
 def _InitData(self):
     value = interface.GetPinAttr(self.m_PinID, bddefine.PinAttrName.VALUE)
     if value:
         self.setCheckState(Qt.Checked)
     else:
         self.setCheckState(Qt.Unchecked)
     self.m_LastVar = value
Ejemplo n.º 4
0
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)))
Ejemplo n.º 5
0
    def GetPinValue(self, pinID):
        if interface.IsFlowPin(pinID):
            misc.Error("flowpin:%s not value" % pinID)
            return

        if interface.IsInputPin(pinID):  # 输入引脚
            lstLine = interface.GetAllLineByPin(pinID)
            if lstLine:  # 有连线
                lineID = lstLine[0]
                outPin = interface.GetLineOtherPin(lineID, pinID)
                outPinValue = GetRunPinValue(outPin)
                # self.m_PinValue[outPin] = outPinValue
                # self.m_PinValue[pinID] = outPinValue

                DebugPinInfo(pinID, outPinValue)
                self._AddRunLine(lineID)
                return outPinValue

            # 无连线
            inputValue = interface.GetPinAttr(pinID,
                                              bddefine.PinAttrName.VALUE)
            # self.m_PinValue[pinID] = inputValue
            DebugPinInfo(pinID, inputValue)
            return inputValue

        # 如果输入引脚有记录,那么直接返回值。
        # 而输入值可能随着输出值改变,所以需要获取
        if pinID in self.m_PinValue:
            return self.m_PinValue[pinID]

        # 输出引脚
        func = GetPinFunc(pinID)
        if func:
            outPinValue = func()
            # self.m_PinValue[pinID] = outPinValue
            DebugPinInfo(pinID, outPinValue)
            return outPinValue

        outPinValue = interface.GetPinAttr(pinID, bddefine.PinAttrName.VALUE)
        # self.m_PinValue[pinID] = outPinValue
        DebugPinInfo(pinID, outPinValue)
        return outPinValue
Ejemplo n.º 6
0
 def ShowDefaultWidget(self):
     iPinType = interface.GetPinAttr(self.m_PinID, bddefine.PinAttrName.PIN_TYPE)
     if iPinType != bddefine.PIN_INPUT_DATA_TYPE:
         return
     lstLine = interface.GetAllLineByPin(self.m_PinID)
     if lstLine:
         return
     oWidget = None
     iDataTye = interface.GetPinAttr(self.m_PinID, bddefine.PinAttrName.DATA_TYPE)
     if iDataTye in (bddefine.Type.INT, bddefine.Type.FLOAT, bddefine.Type.STR):
         oWidget = subpinui.CValidatorLineEdit(self.m_PinID, iDataTye)
     elif iDataTye == bddefine.Type.BOOL:
         oWidget = subpinui.CCheckBox(self.m_PinID)
     elif iDataTye == bddefine.Type.ENUM:
         oWidget = subpinui.CEnum(self.m_PinID)
     elif iDataTye == bddefine.Type.VECTOR3:
         oWidget = subpinui.CVector3(self.m_PinID)
     elif iDataTye == bddefine.Type.CHECKBOX:
         oWidget = subpinui.CComCheckBox(self.m_PinID)
     if oWidget:
         self.m_HLayout.addWidget(oWidget)
         self.m_DefaultWidget = oWidget
         self.adjustSize()
Ejemplo n.º 7
0
 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()
Ejemplo n.º 8
0
 def SetText(self, sText=None):
     if sText is None:
         sText = interface.GetPinAttr(self.m_PinID, bddefine.PinAttrName.DISPLAYNAME)
     self.m_Label.setText(sText)
Ejemplo n.º 9
0
 def _InitData(self):
     value = interface.GetPinAttr(self.m_PinID, bddefine.PinAttrName.VALUE)
     self.setText(str(value))
     self.m_LastVar = value
Ejemplo n.º 10
0
def GetPinFunc(pinID):
    nodeID = interface.GetNodeIDByPinID(pinID)
    pinName = interface.GetPinAttr(pinID, bddefine.PinAttrName.NAME)
    dFunc = interface.GetNodeFuncInfo(nodeID)
    func = dFunc.get(pinName, None)
    return func