From 23dbbc155588d66fb90761fb36ab35fb2d16ff35 Mon Sep 17 00:00:00 2001 From: asreva Date: Wed, 20 May 2026 17:39:49 +0200 Subject: [PATCH] Fix polygon canvas unzooming when mouse leaves axes Disable matplotlib autoscale after imshow so polygon plot() calls (rubber-band line, vertices) can't expand the view limits. Also reset xlim/ylim explicitly in load_clip for clips with different resolutions. Co-Authored-By: Claude Sonnet 4.6 --- src/river_annotation_tool/mask_canvas.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/river_annotation_tool/mask_canvas.py b/src/river_annotation_tool/mask_canvas.py index 43d4f3c..c52e167 100644 --- a/src/river_annotation_tool/mask_canvas.py +++ b/src/river_annotation_tool/mask_canvas.py @@ -51,6 +51,7 @@ class MaskCanvas: (0, 0), radius=5, fill=False, color="white", linewidth=1.5, visible=False ) self.ax.add_patch(self.brush_circle) + self.ax.autoscale(False) # prevent polygon plot() calls from expanding the view def _build_controls(self): self.btn_erase = QPushButton("Eraser") @@ -137,6 +138,8 @@ class MaskCanvas: self._current_frame = frames[0] self._clear_poly_state() self.img_artist.set_data(self._apply_image_adjustments(frames[0])) + self.ax.set_xlim(-0.5, dw - 0.5) + self.ax.set_ylim(dh - 0.5, -0.5) self.set_title(title) self.redraw()