Skip to content
Snippets Groups Projects
Commit 56446a1f authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Refactor for easier modification

parent 43b1ece1
No related branches found
No related tags found
No related merge requests found
...@@ -158,12 +158,27 @@ class GraphicsComponentItem(QGraphicsItemGroup): ...@@ -158,12 +158,27 @@ class GraphicsComponentItem(QGraphicsItemGroup):
pen3.setColor(execution_time) pen3.setColor(execution_time)
pen3.setWidthF(3 / self._scale) pen3.setWidthF(3 / self._scale)
# make lists of sorted keys. reverse output port list.
input_keys = [
key for key in self._ports.keys() if key.lower().startswith("in")
]
input_keys = sorted(input_keys)
output_keys = [
key for key in self._ports.keys() if key.lower().startswith("out")
]
output_keys = sorted(output_keys, reverse=True)
# Set the starting position
x = old_x = self._ports[input_keys[0]]["latency"] if input_keys else 0
y = old_y = 0
component_path = QPainterPath(QPointF(x, y)) # starting point
# component path # component path
def draw_component_path(keys: List[str], reversed: bool) -> None: def draw_component_path(keys: List[str], reversed: bool) -> None:
""" """
Draws component path and also register port positions in self._ports dictionary. Draws component path and also register port positions in self._ports dictionary.
""" """
nonlocal x
nonlocal y nonlocal y
nonlocal old_x nonlocal old_x
nonlocal old_y nonlocal old_y
...@@ -185,22 +200,6 @@ class GraphicsComponentItem(QGraphicsItemGroup): ...@@ -185,22 +200,6 @@ class GraphicsComponentItem(QGraphicsItemGroup):
old_x = x old_x = x
old_y = y old_y = y
# make lists of sorted keys. reverse output port list.
input_keys = [
key for key in self._ports.keys() if key.lower().startswith("in")
]
input_keys = sorted(input_keys)
output_keys = [
key for key in self._ports.keys() if key.lower().startswith("out")
]
output_keys = sorted(output_keys, reverse=True)
# Set the starting position
x = old_x = self._ports[input_keys[0]]["latency"] if input_keys else 0
y = old_y = 0
component_path = QPainterPath(QPointF(x, y)) # starting point
# draw the path # draw the path
if input_keys: if input_keys:
draw_component_path(input_keys, False) # draw input side draw_component_path(input_keys, False) # draw input side
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment