コード例 #1
0
ファイル: Node.py プロジェクト: robertsj/poropy
 def setInput(self, **args):
     """Set the values on input terminals. For most nodes, this will happen automatically through Terminal.inputChanged.
     This is normally only used for nodes with no connected inputs."""
     changed = False
     for k, v in args.iteritems():
         term = self._inputs[k]
         oldVal = term.value()
         if not eq(oldVal, v):
             changed = True
         term.setValue(v, process=False)
     if changed and '_updatesHandled_' not in args:
         self.update()
コード例 #2
0
ファイル: Terminal.py プロジェクト: archphy/poropy
 def recolor(self, color=None, recurse=True):
     if color is None:
         if not self.isConnected():       ## disconnected terminals are black
             color = QtGui.QColor(0,0,0)
         elif self.isInput() and not self.hasInput():   ## input terminal with no connected output terminals 
             color = QtGui.QColor(200,200,0)
         elif self._value is None or eq(self._value, {}):         ## terminal is connected but has no data (possibly due to processing error) 
             color = QtGui.QColor(255,255,255)
         elif self.valueIsAcceptable() is None:   ## terminal has data, but it is unknown if the data is ok
             color = QtGui.QColor(200, 200, 0)
         elif self.valueIsAcceptable() is True:   ## terminal has good input, all ok
             color = QtGui.QColor(0, 200, 0)
         else:                                    ## terminal has bad input
             color = QtGui.QColor(200, 0, 0)
     self.graphicsItem().setBrush(QtGui.QBrush(color))
     
     if recurse:
         for t in self.connections():
             t.recolor(color, recurse=False)
コード例 #3
0
ファイル: Terminal.py プロジェクト: archphy/poropy
 def setValue(self, val, process=True):
     """If this is a single-value terminal, val should be a single value.
     If this is a multi-value terminal, val should be a dict of terminal:value pairs"""
     if not self.isMultiValue():
         if eq(val, self._value):
             return
         self._value = val
     else:
         if val is not None:
             self._value.update(val)
         
     self.setValueAcceptable(None)  ## by default, input values are 'unchecked' until Node.update(). 
     if self.isInput() and process:
         self.node().update()
         
     ## Let the flowchart handle this.
     #if self.isOutput():
         #for c in self.connections():
             #if c.isInput():
                 #c.inputChanged(self)
     self.recolor()
コード例 #4
0
ファイル: Terminal.py プロジェクト: robertsj/poropy
    def setValue(self, val, process=True):
        """If this is a single-value terminal, val should be a single value.
        If this is a multi-value terminal, val should be a dict of terminal:value pairs"""
        if not self.isMultiValue():
            if eq(val, self._value):
                return
            self._value = val
        else:
            if val is not None:
                self._value.update(val)

        self.setValueAcceptable(
            None
        )  ## by default, input values are 'unchecked' until Node.update().
        if self.isInput() and process:
            self.node().update()

        ## Let the flowchart handle this.
        #if self.isOutput():
        #for c in self.connections():
        #if c.isInput():
        #c.inputChanged(self)
        self.recolor()
コード例 #5
0
ファイル: Terminal.py プロジェクト: robertsj/poropy
    def recolor(self, color=None, recurse=True):
        if color is None:
            if not self.isConnected():  ## disconnected terminals are black
                color = QtGui.QColor(0, 0, 0)
            elif self.isInput() and not self.hasInput(
            ):  ## input terminal with no connected output terminals
                color = QtGui.QColor(200, 200, 0)
            elif self._value is None or eq(
                    self._value, {}
            ):  ## terminal is connected but has no data (possibly due to processing error)
                color = QtGui.QColor(255, 255, 255)
            elif self.valueIsAcceptable(
            ) is None:  ## terminal has data, but it is unknown if the data is ok
                color = QtGui.QColor(200, 200, 0)
            elif self.valueIsAcceptable(
            ) is True:  ## terminal has good input, all ok
                color = QtGui.QColor(0, 200, 0)
            else:  ## terminal has bad input
                color = QtGui.QColor(200, 0, 0)
        self.graphicsItem().setBrush(QtGui.QBrush(color))

        if recurse:
            for t in self.connections():
                t.recolor(color, recurse=False)