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 <noreply@anthropic.com>
This commit is contained in:
2026-05-20 17:39:49 +02:00
parent 88c8f33dfc
commit 23dbbc1555

View File

@@ -51,6 +51,7 @@ class MaskCanvas:
(0, 0), radius=5, fill=False, color="white", linewidth=1.5, visible=False (0, 0), radius=5, fill=False, color="white", linewidth=1.5, visible=False
) )
self.ax.add_patch(self.brush_circle) self.ax.add_patch(self.brush_circle)
self.ax.autoscale(False) # prevent polygon plot() calls from expanding the view
def _build_controls(self): def _build_controls(self):
self.btn_erase = QPushButton("Eraser") self.btn_erase = QPushButton("Eraser")
@@ -137,6 +138,8 @@ class MaskCanvas:
self._current_frame = frames[0] self._current_frame = frames[0]
self._clear_poly_state() self._clear_poly_state()
self.img_artist.set_data(self._apply_image_adjustments(frames[0])) 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.set_title(title)
self.redraw() self.redraw()