def __init__(self):

        # ID OF THE NODE
        GeneralNode.id_counter += 1
        self.id = GeneralNode.id_counter

        # BASIC NODE PROPERTIES
        self.extra_header = 0
        self.widget = None
        self.max_streams = 16
        self.is_selected = False

        # STREAMS
        self.stream_count = 0
        self.streams = []

        # GRAPHICS OF THE NODE
        QtWidgets.QGraphicsPathItem.__init__(self)
        self.setFlags(QtWidgets.QGraphicsPathItem.ItemIsMovable)

        self.id_text = QtWidgets.QGraphicsSimpleTextItem(parent=self)
        self.proxy_add_btn = QtWidgets.QGraphicsProxyWidget(parent=self)
        self.proxy_remove_btn = QtWidgets.QGraphicsProxyWidget(parent=self)

        self.marquee = QtWidgets.QGraphicsPathItem(parent=self)

        # SETUP
        self.setup_node()
        self.add_stream()
        self.setup_widget()
    def __init__(self, coordinates, relation_type, host=None, reverse=False):
        self.coordinates = coordinates
        self.host = host
        self.relation_type = relation_type
        self.graphics_item = QtWidgets.QGraphicsPathItem()
        self.reverse = reverse

        self.graphics_item.setZValue(1)
Beispiel #3
0
    def draw_valid_line(self, p1, p2):
        new_path = QtGui.QPainterPath(p1)

        c_p1 = QtCore.QPoint(((p2.x() + p1.x()) / 2) + 10, p1.y())
        c_p2 = QtCore.QPoint(((p2.x() + p1.x()) / 2) - 10, p2.y())
        new_path.cubicTo(c_p1, c_p2, p2)

        new_valid_line = QtWidgets.QGraphicsPathItem(new_path)
        new_valid_line.setPen(QtGui.QPen(QtGui.QColor(QtCore.Qt.green), 2))
        self.addItem(new_valid_line)
        new_valid_line.setZValue(-1)

        return new_valid_line
Beispiel #4
0
    def __init__(self, parent, cmdp, state):
        pg.GraphicsObject.__init__(self, parent)
        self._parent = parent
        self._cmdp = cmdp
        self._log = logging.getLogger('%s.%s' % (__name__, state['x']))
        self._move_start_point = None
        y = state.get('y')
        if y is not None:
            y = float(y)

        my_id = state.get('id')
        if my_id is None:  # assign an id
            my_id = id(self)
            while my_id in _registry:
                my_id += 1
        elif my_id in _registry:
            raise RuntimeError(f'id {my_id} already in annotation registry')

        self._state = {
            'id': my_id,
            'signal_name': state['signal_name'],
            'x': float(state['x']),
            'y': y,
            'group_id': 0,
            'text': state.get('text'),
            'text_visible': True,
            'size': state.get('size', 6),
        }
        _registry[my_id] = weakref.ref(self)
        self._pathItem = QtWidgets.QGraphicsPathItem()
        self._pathItem.setParentItem(self)

        self._text_item = QtWidgets.QGraphicsTextItem(self)
        self._text_item.setParentItem(self)
        self._text_item.setVisible(bool(self._state['text_visible']))

        self.group_id = state.get('group_id', 0)

        self._lastTransform = None
        self._lastScene = None
        self._fill = pg.mkBrush(None)
        self._border = pg.mkPen(None)

        self.group_id = self._state['group_id']
        self.setPos(self._state['x'], 0.0)
        self._z_value_set()

        self.text = self._state['text']
        self._update_colors()
        self.prepareGeometryChange()
Beispiel #5
0
    def __init__(self):
        QtWidgets.QGraphicsScene.__init__(self)

        # NODES
        self.all_nodes = []
        self.selected_node = None

        # PATH TESTS
        self.testing_origin = None
        self.testing_path = QtWidgets.QGraphicsPathItem()
        self.testing_path.setPen(QtGui.QPen(QtCore.Qt.magenta, 2))
        self.testing_path.setZValue(-1)

        # CONNECTORS (Tests)
        self.testing_origin_connector = None
        self.testing_target_connector = None
Beispiel #6
0
    def check_connectables(self):

        origin_connector, target_connector = self.testing_origin_connector, self.testing_target_connector

        checks = [
            origin_connector.type != target_connector.type,
            origin_connector.parent_node != target_connector.parent_node,
            origin_connector.can_recieve_connection,
            target_connector.can_recieve_connection
        ]

        # CONNECTION CHECKS
        if False in checks:
            return

        # RIGHT-TO-LEFT CONNECTION
        if not ((origin_connector.type == 'output'
                 and origin_connector.x < target_connector.x) or
                (origin_connector.type == 'input'
                 and origin_connector.x > target_connector.x)):
            return

        p1 = origin_connector.center_point
        p2 = target_connector.center_point
        if p1.x() < p2.x():
            new_path = QtGui.QPainterPath(p1)
            c_p1 = QtCore.QPoint(((p2.x() + p1.x()) / 2) + 10, p1.y())
            c_p2 = QtCore.QPoint(((p2.x() + p1.x()) / 2) - 10, p2.y())
            new_path.cubicTo(c_p1, c_p2, p2)
        else:
            new_path = QtGui.QPainterPath(p2)
            c_p1 = QtCore.QPoint(((p2.x() + p1.x()) / 2) + 10, p1.y())
            c_p2 = QtCore.QPoint(((p2.x() + p1.x()) / 2) - 10, p2.y())
            new_path.cubicTo(c_p2, c_p1, p1)

        valid_line = QtWidgets.QGraphicsPathItem(new_path)
        valid_line.setPen(QtGui.QPen(QtCore.Qt.green, 2))
        valid_line.setZValue(-1)
        self.addItem(valid_line)

        target_connector.register_connection(origin_connector, valid_line)
        origin_connector.register_connection(target_connector, valid_line)

        self.color_streams(recolor=False, only_starts=False)
 def __init__(self, name, relationships, function, item_color):
     self.name = name
     self.relationships = relationships
     self.functions = function
     self.item_color = item_color
     self.graphics_item = QtWidgets.QGraphicsPathItem()