Skip to content

Commit

Permalink
Merge pull request #28 from csgoh/hot-fix
Browse files Browse the repository at this point in the history
Hot fix
  • Loading branch information
csgoh authored Jul 24, 2023
2 parents a9685ed + 0d96447 commit 771f7d3
Show file tree
Hide file tree
Showing 16 changed files with 143 additions and 36 deletions.
Binary file modified images/test/test_case10-BLUEMOUNTAIN.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case10-DEFAULT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case10-GREENTURTLE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case10-GREYWOOF.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case10-ORANGEPEEL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_case3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/test/test_sample01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/test/test_sample02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/test/test_sample03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 16 additions & 6 deletions src/processpiper/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=}",
),
Expand All @@ -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,
Expand Down Expand Up @@ -223,7 +227,10 @@ def add_shape_to_lane_rowcolumn(
elif col_number == 1:
self._grid[lane_id][row_number].append(shape)
else:
self._grid[lane_id][row_number][col_number - 1] = shape
if self._grid[lane_id][row_number][col_number - 1] is None:
self._grid[lane_id][row_number][col_number - 1] = shape
else:
self._grid[lane_id][row_number].append(shape)

Helper.printc(
f" ### {shape.name=}, {lane_id=}, {row_number=}, {col_number=}",
Expand Down Expand Up @@ -265,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

Expand All @@ -282,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,
Expand Down
103 changes: 76 additions & 27 deletions src/processpiper/painter.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,8 @@ def draw_right_angle_line(
x1, y1, face_source, x2, y2, face_target
)
Helper.printc(
f"\t" * 2 + f"DRAW_RIGHT_ANGLE_LINE() {x1=}, {y1=}, {face_source=}, {x2=}, {y2=}, {face_target=}",
f"\t" * 2
+ f"DRAW_RIGHT_ANGLE_LINE() {x1=}, {y1=}, {face_source=}, {x2=}, {y2=}, {face_target=}",
show_level="draw_connection",
)

Expand All @@ -729,11 +730,12 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
if x1 == x2 and y1 == y2:
# Shapes are on top of each other / overlapping. NOTE: This should never happen
Helper.printc(
"\t" * tab_count + "Shapes are on top of each other / overlapping",
"\t" * tab_count + "Shapes are on top of each other / overlapping",
show_level="draw_connection",
)
Helper.printc(
f"\t" * tab_count + "A: right_angle_line: x1 == x2 and y1 == y2: {x1}, {y1}, {x2}, {y2}",
f"\t" * tab_count
+ "A: right_angle_line: x1 == x2 and y1 == y2: {x1}, {y1}, {x2}, {y2}",
show_level="draw_connection",
)
points = [(x1, y1)]
Expand All @@ -742,11 +744,12 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
if x1 != x2 and y1 == y2:
# Shapes are on the same horizontal line
Helper.printc(
"\t" * tab_count + "Shapes are on the same horizontal line",
"\t" * tab_count + "Shapes are on the same horizontal line",
show_level="draw_connection",
)
Helper.printc(
f"\t" * tab_count + "B: right_angle_line: x1 != x2 and y1 == y2: {x1}, {y1}, {x2}, {y2}",
f"\t" * tab_count
+ "B: right_angle_line: x1 != x2 and y1 == y2: {x1}, {y1}, {x2}, {y2}",
show_level="draw_connection",
)
elbow_height = 40
Expand All @@ -759,20 +762,36 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
]
right_angle_point = [(x1, y1 - elbow_height), (x2, y2 - elbow_height)]
elif face_source.find("bottom") != -1:
points = [(x1, y1), (x1, y1 + elbow_height), (x2, y2 + elbow_height)]
right_angle_point = [(x1, y1 + elbow_height)]
# points = [(x1, y1), (x1, y1 + elbow_height), (x2, y2 + elbow_height)]
# right_angle_point = [(x1, y1 + elbow_height)]
if y2 <= y1:
angle_height = 40
else:
angle_height = y2 - y1 + 40

points = [
(x1, y1),
(x1, y1 + angle_height),
(x2, y1 + angle_height),
(x2, y2),
]
right_angle_point = [
(x1, y1 + angle_height),
(x2, y1 + angle_height),
]
else:
points = [(x1, y1), (x2, y1)]
right_angle_point = [(x1, y1)]

if x1 == x2 and y1 != y2:
# Shapes are on the same vertical line
Helper.printc(
"\t" * tab_count + "Shapes are on the same vertical line",
"\t" * tab_count + "Shapes are on the same vertical line",
show_level="draw_connection",
)
Helper.printc(
f"\t" * tab_count + "C: right_angle_line: x1 == x2 and y1 != y2: {x1}, {y1}, {x2}, {y2}",
f"\t" * tab_count
+ "C: right_angle_line: x1 == x2 and y1 != y2: {x1}, {y1}, {x2}, {y2}",
show_level="draw_connection",
)
points = [(x1, y1), (x1, y2)]
Expand All @@ -782,17 +801,22 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
# Shapes are on different horizontal and vertical lines
# check if face1 string contained the word "right"
Helper.printc(
"\t" * tab_count + "Shapes are on different horizontal and vertical lines",
"\t" * tab_count
+ "Shapes are on different horizontal and vertical lines",
show_level="draw_connection",
)
if face_source.find("bottom") != -1:
if face_target.find("bottom") != -1:
Helper.printc(
"\t" * tab_count + "D-bottom: both bottom",
"\t" * tab_count + "D-bottom: both bottom",
show_level="draw_connection",
)
# if so, then the line should be drawn from the bottom side of the box
angle_height = 40
if y2 <= y1:
angle_height = 50
else:
angle_height = y2 - y1 + 50

points = [
(x1, y1),
(x1, y1 + angle_height),
Expand All @@ -803,9 +827,25 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
(x1, y1 + angle_height),
(x2, y1 + angle_height),
]
else:
elif face_target.find("top") != -1:
Helper.printc(
"\t" * tab_count + "D-bottom: source bottom",
"\t" * tab_count + "D-bottom: source bottom, target top",
show_level="draw_connection",
)
elbow_height = 40
points = [
(x1, y1),
(x1, y1 + elbow_height),
(x2, y1 + elbow_height),
(x2, y2),
]
right_angle_point = [
(x1, y1 + elbow_height),
(x2, y1 + elbow_height),
]
else: ### target face is
Helper.printc(
"\t" * tab_count + "D-bottom: source bottom",
show_level="draw_connection",
)
# if so, then the line should be drawn from the bottom side of the box
Expand All @@ -817,11 +857,12 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
right_angle_point = [(x1, y2)]
elif face_source.find("right") != -1:
Helper.printc(
f"\t" * tab_count + "D-right: right_angle_line: x1 != x2 and y1 != y2: {x1}, {y1}, {x2}, {y2}",
f"\t" * tab_count
+ "D-right: right_angle_line: x1 != x2 and y1 != y2: {x1}, {y1}, {x2}, {y2}",
show_level="draw_connection",
)
if face_target.find("left") != -1:
elbow_height = 40
elbow_height = x2 - x1 - 40
points = [
(x1, y1),
(x1 + elbow_height, y1),
Expand All @@ -836,7 +877,7 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
elbow_height = 40
### both faces are right
Helper.printc(
"\t" * tab_count + "D-right-right (x1 < x2)",
"\t" * tab_count + "D-right-right (x1 < x2)",
show_level="draw_connection",
)
points = [
Expand All @@ -852,7 +893,7 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
elif face_target.find("top") != -1:
if y1 < y2:
Helper.printc(
"\t" * 2 + "D-right-top (y1 < y2)",
"\t" * 2 + "D-right-top (y1 < y2)",
show_level="draw_connection",
)
points = [
Expand All @@ -865,7 +906,7 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
]
else:
Helper.printc(
"\t" * tab_count + "D-right-top (y1 >= y2)",
"\t" * tab_count + "D-right-top (y1 >= y2)",
show_level="draw_connection",
)
vertical_elbow_height = 40
Expand All @@ -884,7 +925,8 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
]
else:
Helper.printc(
"\t" * tab_count + "D-right-bottom", show_level="draw_connection"
"\t" * tab_count + "D-right-bottom",
show_level="draw_connection",
)
points = [
(x1, y1),
Expand All @@ -896,7 +938,8 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
]
elif face_source.find("top") != -1 and face_target.find("top") != -1:
Helper.printc(
f"\t" * tab_count + "D-top: x1 != x2 and y1 != y2: {x1}, {y1}, {x2}, {y2}",
f"\t" * tab_count
+ "D-top: x1 != x2 and y1 != y2: {x1}, {y1}, {x2}, {y2}",
show_level="draw_connection",
)
# draw 1 right angle line
Expand All @@ -911,7 +954,8 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
right_angle_point = [(x1, y1 - elbow_height), (x2, y1 - elbow_height)]
elif face_source.find("top") != -1 and face_target.find("bottom") != -1:
Helper.printc(
f"\t" * tab_count + "D-top/bottom: x1 != x2 and y1 != y2: {x1}, {y1}, {x2}, {y2}",
f"\t" * tab_count
+ "D-top/bottom: x1 != x2 and y1 != y2: {x1}, {y1}, {x2}, {y2}",
show_level="draw_connection",
)
# draw 1 right angle line
Expand All @@ -926,7 +970,8 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
right_angle_point = [(x1, y1 - elbow_height), (x2, y1 - elbow_height)]
else:
Helper.printc(
f"\t" * tab_count + "D-else: x1 != x2 and y1 != y2: {x1}, {y1}, {x2}, {y2}",
f"\t" * tab_count
+ "D-else: x1 != x2 and y1 != y2: {x1}, {y1}, {x2}, {y2}",
show_level="draw_connection",
)
# if so, then the line should be drawn from the bottom side of the box
Expand All @@ -939,7 +984,8 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
if y1 <= y2:
if abs(y1 - y2) == 10:
Helper.printc(
f"\t" * tab_count + "E: x1 > x2 and y1 <= y2: {x1}, {y1}, {x2}, {y2}",
f"\t" * tab_count
+ "E: x1 > x2 and y1 <= y2: {x1}, {y1}, {x2}, {y2}",
show_level="draw_connection",
)
elbow_height = 40
Expand All @@ -961,7 +1007,8 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
or face_target.find("right") == -1
):
Helper.printc(
f"\t" * tab_count + "F2: x1 > x2 and y1 <= y2: {x1}, {y1}, {x2}, {y2}",
f"\t" * tab_count
+ "F2: x1 > x2 and y1 <= y2: {x1}, {y1}, {x2}, {y2}",
show_level="draw_connection",
)
points = [
Expand All @@ -977,7 +1024,8 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
]
else:
Helper.printc(
f"\t" * tab_count + "F1: x1 > x2 and y1 <= y2: {x1}, {y1}, {x2}, {y2}",
f"\t" * tab_count
+ "F1: x1 > x2 and y1 <= y2: {x1}, {y1}, {x2}, {y2}",
show_level="draw_connection",
)
points = [
Expand All @@ -988,7 +1036,8 @@ def get_connection_points(self, x1, y1, face_source, x2, y2, face_target):
right_angle_point = [(x1, y2)]
elif len(points) == 0:
Helper.printc(
f"\t" * tab_count + "G: x1 > x2 and y1 > y2: {x1=}, {y1=}, {x2=}, {y2=}",
f"\t" * tab_count
+ "G: x1 > x2 and y1 > y2: {x1=}, {y1=}, {x2=}, {y2=}",
show_level="draw_connection",
)
elbow_height = (y1 - y2) / 2
Expand Down
2 changes: 1 addition & 1 deletion src/processpiper/processmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __post_init__(self):

logging.basicConfig(
# filename="processpiper.log",
level=logging.ERROR,
level=logging.INFO,
format="%(asctime)s [%(levelname)s] : %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
Expand Down
2 changes: 1 addition & 1 deletion src/processpiper/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
# SOFTWARE.

"""Version information for processpiper."""
__version__ = "v0.4.2"
__version__ = "v0.4.3"
Loading

0 comments on commit 771f7d3

Please sign in to comment.