Exemplo n.º 1
0
class BaseDataModel(NodeDataModel):
    # Enable Model title
    caption_visible = True
    # Define port
    num_ports = {
        'input': 2,
        'output': 1,
    }
    # Port Caption
    port_caption_visible = True
    # Define datatype for checks later
    data_type = NodeDataType("Signal", "Signal")

    # Style and parent could be changed later if wanted, if not it uses standard nodeeditor style
    def __init__(self, style=None, parent=None):
        super().__init__(style=style)
        self._in_1 = None
        self._in_2 = None
        self._out = None

    @property
    def caption(self):
        return self.name

    # Overwritten in submodules
    def compute(self):
        pass
Exemplo n.º 2
0
class IntegerData(NodeData):
    'Node data holding an integer value'
    data_type = NodeDataType("integer", "Integer")

    def __init__(self, number: int = 0):
        self._number = number
        self._lock = threading.RLock()

    @property
    def lock(self):
        return self._lock

    def number(self) -> int:
        'The number data'
        return self._number

    def number_as_text(self) -> str:
        'Number as a string'
        return str(self._number)
Exemplo n.º 3
0
class DecimalData(NodeData):
    'Node data holding a decimal (floating point) number'
    data_type = NodeDataType("decimal", "Decimal")

    def __init__(self, number: float = 0.0):
        self._number = number
        # self._lock = threading.RLock()

    @property
    def lock(self):
        return self._lock

    @property
    def number(self) -> float:
        'The number data'
        return self._number

    def number_as_text(self) -> str:
        'Number as a string'
        return '%g' % self._number
Exemplo n.º 4
0
class RGBInModel(InModel):
    name = "RGB_IN"

    num_ports = {
        'input': 0,
        'output': 3,
    }
    port_caption = {
        'output': {
            0: 'R',
            1: 'G',
            2: 'B'
        },
    }
    port_caption_visible = {
        'output': {
            0: 'R',
            1: 'G',
            2: 'B'
        },
    }
    data_type = NodeDataType("Signal", "Signal")

    def __init__(self, style=None, parent=None):
        super().__init__(style=style)
        self._number = None
        self._line_edit = QLineEdit()
        self._line_edit.setMaximumSize(self._line_edit.sizeHint())
        self._line_edit.setText("Yee")

    def embedded_widget(self):
        'The number source has a line edit widget for the user to type in'
        return self._line_edit

    def compute(self):
        pass
Exemplo n.º 5
0
class RGBOutModel(OutModel):
    name = "RGB_OUT"

    num_ports = {
        'input': 3,
        'output': 0,
    }

    port_caption = {
        'input': {
            0: 'R',
            1: 'G',
            2: 'B',
        },
        'output': {}
    }
    data_type = NodeDataType("Signal", "Signal")
    port_caption_visible = True

    def __init__(self, style=None, parent=None):
        super().__init__(style=style)

    def compute(self):
        pass
Exemplo n.º 6
0
class MyNodeData(NodeData):
    data_type = NodeDataType(id='MyNodeData', name='My Node Data')
Exemplo n.º 7
0
class SimpleNodeData(NodeData):
    data_type = NodeDataType(id='SimpleData', name='Simple Data')
Exemplo n.º 8
0
class PixmapData(NodeData):
    data_type = NodeDataType(id='Pixmap', name='PixmapData')

    def __init__(self, pixmap):
        self.pixmap = pixmap