diff --git a/src/processpiper/layout.py b/src/processpiper/layout.py index 40b00ad..8682f53 100644 --- a/src/processpiper/layout.py +++ b/src/processpiper/layout.py @@ -86,7 +86,7 @@ def add_shape_to_grid( if index == 0: Helper.printc( ( - " ==>Same lane: ", + " ==>Same lane (row 0): ", f"add_shape_to_lane [{current_shape.name}],", f" {previous_shape_row_number=}", ), @@ -95,25 +95,29 @@ def add_shape_to_grid( self.add_shape_to_lane( current_shape.lane_id, previous_shape_row_number, current_shape ) - else: + else: ### Next row Helper.printc( - f" ==>Same lane: add_shape_to_lane_rowcolumn [{current_shape.name}, {previous_shape_col_number + 1}]", + f" ==>Same lane (next row): add_shape_to_lane_rowcolumn [{current_shape.name}, {previous_shape_col_number}]", show_level="layout_grid", ) if self.is_column_empty( current_shape.lane_id, previous_shape_row_number, - previous_shape_col_number + 1, + previous_shape_col_number, ): Helper.printc("Is empty", 34, show_level="layout_grid") self.add_shape_to_lane_rowcolumn( current_shape.lane_id, previous_shape_row_number, - previous_shape_col_number + 1, + previous_shape_col_number, current_shape, ) else: Helper.printc("Not empty", 34, show_level="layout_grid") + Helper.printc( + f"Adding shape to {index + 1}, {previous_shape_col_number}", + show_level="layout_grid", + ) self.add_shape_to_lane_rowcolumn( current_shape.lane_id, index + 1, @@ -224,7 +228,7 @@ def add_shape_to_lane_rowcolumn( self._grid[lane_id][row_number].append(shape) else: if self._grid[lane_id][row_number][col_number - 1] is None: - self._grid[lane_id][row_number][len(self._grid[lane_id][row_number]) - 1] = shape + self._grid[lane_id][row_number][col_number - 1] = shape else: self._grid[lane_id][row_number].append(shape) @@ -268,6 +272,8 @@ def is_column_empty(self, lane_id: str, row_number: int, col_number: int): row_number = f"row{row_number}" for row, col in self._grid[lane_id].items(): if row == row_number and col[col_number - 1] is not None: + shape = col[col_number - 1] + Helper.printc(f" ### {shape.name}", show_level="layout_grid") return False return True @@ -285,6 +291,7 @@ def add_shape_to_lane(self, lane_id: str, row_number: int, current_shape: Shape) """Add the shape to the lane""" if lane_id is not None: col_number = self.get_next_column(lane_id, row_number) + # col_number = self.get_next_empty_column(lane_id, row_number) Helper.printc( f" ### {lane_id=}, {row_number=}, {col_number=}", 33,