Skip to content

Commit

Permalink
Add warning if points extend image boundary when importing TACtool CSV
Browse files Browse the repository at this point in the history
  • Loading branch information
leorudczenko committed Aug 16, 2023
1 parent 69975db commit 7843fc1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tactool/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,27 @@ def load_tactool_csv_data(self, filepath: str) -> None:
analysis_points = parse_tactool_csv(filepath, self.default_settings)
self.clear_analysis_points()
self.reset_settings()
# Track if any of the points extend the image boundary
extends_boundary = False
image_size = self.graphics_view._image.pixmap().size()
for analysis_point in analysis_points:
self.add_analysis_point(**analysis_point, from_click=False)
ap_x = analysis_point["x"]
ap_y = analysis_point["y"]
if ap_x > image_size.width() or ap_x < 0 or ap_y > image_size.height() or ap_y < 0:
extends_boundary = True
self.table_view.scrollToTop()

# Create a message informing the user that the points extend the image boundary
if extends_boundary:
message = "At least 1 of the imported analysis points goes beyond the current image boundary"
self.logger.warning(message)
self.show_message(
"Imported Points Warning",
message,
"warning",
)

# A KeyError and UnicodeError usually occur with an incorrectly formatted CSV file
except (KeyError, UnicodeError):
# Show a message to the user informing them of which headers should be in the CSV file
Expand Down

0 comments on commit 7843fc1

Please sign in to comment.