def onTextEdited(self, string: str):
     try:
         number = float(self._lineEdit.text())
         self._number = DecimalData(num=number)
         self.dataUpdated.emit(self, 0)
     except ValueError as e:
         self.dataInvalidated.emit(self, 0)
 def setInData(self, nodeData:NodeData, portIndex:PortIndex):
     numberData = IntegerData(nodeData)
     
     if(portIndex == 0):
         self._integer = numberData
         
     if(self._integer):
         self._decimal = DecimalData(self._integer.number())
    def restore(self, p: dict):
        v = p["number"]

        if (not v.isUndefined()):
            strNum = v.toString()

            ok, d = strNum.toDouble()

            if (ok):
                self._number = DecimalData(d)
                self._lineEdit.setText(strNum)
    def compute(self):
        outPortIndex = 0

        n1 = self._number1
        n2 = self._number2

        if (n1 and n2):
            self.modelValidationState = NodeValidationState.VALID
            self.modelValidationError = ""
            self._result = DecimalData(num=(n1.number() * n2.number()))
        else:
            self.modelValidationState = NodeValidationState.WARNING
            self.modelValidationError = "Missing or incorrect inputs"
            self._result = None

        self.dataUpdated.emit(self, outPortIndex)
 def setInData(self, nodeData:NodeData, portIndex:PortIndex):
     if(isinstance(nodeData, NodeData) and not isinstance(nodeData, IntegerData)):
         numberData = None
     elif(isinstance(nodeData, IntegerData)):
         numberData = nodeData
     else:
         numberData = None
         
     if(portIndex == 0):
         self._integer = numberData
         
     if(self._integer):
         self._decimal = DecimalData(num=self._integer.number())
         
     outPortIndex = 0
     
     self.dataUpdated.emit(self, outPortIndex)
 def dataType(self, portType:PortType, portIndex:PortIndex):
     return DecimalData().type()
 def dataType(self, portType: PortType, portIndex: PortIndex):
     if(portType == PortType.In):
         return DecimalData().type()
     
     return IntegerData().type()
 def __init__(self):
     super().__init__()
     
     self._decimal = DecimalData()
     self._integer = IntegerData()
class DecimalToIntegerModel(NodeDataModel):
    def __init__(self):
        super().__init__()
        
        self._decimal = DecimalData()
        self._integer = IntegerData()
        
    #--------------------------------------------------------------------------
    #override
    def caption(self):
        return "Decimal to integer"
    
    #--------------------------------------------------------------------------
    #override
    def captionVisible(self):
        return True
    
    #--------------------------------------------------------------------------
    #override
    def name(self):
        return "DecimalToInteger"
    
    #--------------------------------------------------------------------------
    #override
    def clone(self):
        return DecimalToIntegerModel() 
    
    #--------------------------------------------------------------------------
    #override
    def save(self):
        modelJson = dict()
        
        modelJson["name"] = name()
        
        return modelJson
    
    #--------------------------------------------------------------------------
    #override
    def nPorts(self, portType: PortType):
        result = 1
        
        if(portType == PortType.In):
            result = 1
        elif(portType == PortType.Out):
            result = 1
        
        return result
        
    #--------------------------------------------------------------------------
    #override
    def dataType(self, portType: PortType, portIndex: PortIndex):
        if(portType == PortType.In):
            return DecimalData().type()
        
        return IntegerData().type()
    
    #--------------------------------------------------------------------------
    #override
    def outData(self, port: PortIndex):
        return self._integer
    
    #--------------------------------------------------------------------------
    #override
    def setInData(self, nodeData: NodeData, portIndex: PortIndex):
        if(isinstance(nodeData, NodeData) and not isinstance(nodeData, DecimalData)):
            numberData = None
        elif(isinstance(nodeData, DecimalData)):
            numberData = nodeData
        
        if(portIndex == 0):
            self._decimal = numberData
        
        if(self._decimal):
            self._integer = IntegerData(num=self._decimal.number())
            
        outPortIndex = 0
        
        self.dataUpdated.emit(self, outPortIndex)
    
    #--------------------------------------------------------------------------
    #override
    def embeddedWidget(self):
        return None