diff --git a/b_asic/scheduler_gui/graphics_graph_item.py b/b_asic/scheduler_gui/graphics_graph_item.py index 8465055b0f2823532e4795a362535662bf0b3d55..d72b89d83d561a64705ed97ee6bd9f42fa909080 100644 --- a/b_asic/scheduler_gui/graphics_graph_item.py +++ b/b_asic/scheduler_gui/graphics_graph_item.py @@ -34,7 +34,7 @@ class GraphicsGraphItem(GraphicsGraphEvent, QGraphicsItemGroup): # PySide2 / _components_height: float _x_axis_indent: float _event_items: List[QGraphicsItem] - _signal_dict: Dict[GraphicsComponentItem, Set[GraphicsSignal]] + _signal_dict: Dict[GraphicsComponentItem, Set[GraphicsSignal]] def __init__(self, schedule: Schedule, parent: Optional[QGraphicsItem] = None): @@ -152,7 +152,7 @@ class GraphicsGraphItem(GraphicsGraphEvent, QGraphicsItemGroup): # PySide2 / # if not isinstance(op, (Input, Output)): self._components_height += spacing - component = GraphicsComponentItem(operation) + component = GraphicsComponentItem(operation, parent=self) component.setPos(self._x_axis_indent + op_start_time, self._components_height) self._components.append(component) _components_dict[operation] = component @@ -179,7 +179,7 @@ class GraphicsGraphItem(GraphicsGraphEvent, QGraphicsItemGroup): # PySide2 / for output_port in component.operation.outputs: for signal in output_port.signals: dest_component = _components_dict[signal.destination.operation] - gui_signal = GraphicsSignal(component, dest_component, signal) + gui_signal = GraphicsSignal(component, dest_component, signal, parent=self) self.addToGroup(gui_signal) self._signal_dict[component].add(gui_signal) self._signal_dict[dest_component].add(gui_signal) diff --git a/b_asic/scheduler_gui/graphics_signal.py b/b_asic/scheduler_gui/graphics_signal.py index cc8f7acb78cc68d5427e8f3f2a97340c9c5c654e..ebfe9ad2f60ad35c717f07f38e58be73ad539099 100644 --- a/b_asic/scheduler_gui/graphics_signal.py +++ b/b_asic/scheduler_gui/graphics_signal.py @@ -7,7 +7,8 @@ from qtpy.QtCore import QPointF # B-ASIC from b_asic.signal import Signal from b_asic.scheduler_gui.graphics_component_item import GraphicsComponentItem -from b_asic.scheduler_gui._preferences import SIGNAL_ACTIVE, SIGNAL_INACTIVE, SIGNAL_WIDTH +from b_asic.scheduler_gui._preferences import (SIGNAL_ACTIVE, SIGNAL_INACTIVE, + SIGNAL_WIDTH) class GraphicsSignal(QGraphicsPathItem): _path: Optional[QPainterPath] = None @@ -44,15 +45,24 @@ class GraphicsSignal(QGraphicsPathItem): source_y = source_point.y() dest_x = dest_point.x() dest_y = dest_point.y() - if abs(source_x - dest_x) <= 0.1: - ctrl_point1 = QPointF(source_x + 0.5, source_y) - ctrl_point2 = QPointF(source_x - 0.5, dest_y) + if (dest_x - source_x <= -0.1 or + self.parentItem().schedule._laps[self._signal.graph_id]): + offset = 0.2 # TODO: Get from parent/axes... + laps = self.parentItem().schedule._laps[self._signal.graph_id] + path.lineTo(self.parentItem().schedule.schedule_time + offset, + source_y) + path.moveTo(0 + offset, dest_y) + path.lineTo(dest_x, dest_y) else: - mid_x = (source_x + dest_x)/2 - ctrl_point1 = QPointF(mid_x, source_y) - ctrl_point2 = QPointF(mid_x, dest_y) + if abs(source_x - dest_x) <= 0.1: # "== 0" + ctrl_point1 = QPointF(source_x + 0.5, source_y) + ctrl_point2 = QPointF(source_x - 0.5, dest_y) + else: + mid_x = (source_x + dest_x)/2 + ctrl_point1 = QPointF(mid_x, source_y) + ctrl_point2 = QPointF(mid_x, dest_y) - path.cubicTo(ctrl_point1, ctrl_point2, dest_point) + path.cubicTo(ctrl_point1, ctrl_point2, dest_point) self.setPath(path) def refresh_pens(self):