feat: hover HUD with pixel coords and grey scale bar on sample camera

Bottom-right corner shows the hovered pixel coordinates with a grey
1-2-5 scale bar above them, derived from geom.pixel_in_mm and the
current zoom. Works in viewing mode (before the interaction gate),
clears on leave, and skips drawing outside the image.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
duan_jandClaude Fable 5 authored and duan_j committed 2026-08-20 10:05:23 +02:00
1 parent c57098c4d4
commit 54bd4fbd41
3 files changed
+99

No files matched your search

+24
View File
@@ -229,6 +229,30 @@ def test_alt_wheel_axis_swap_still_changes_exposure(camera):
assert len(sent) == n
def test_hover_hud_coords_and_scale_bar(camera):
# Hover inside the image: bottom-right HUD paints coords + grey scale bar.
_mouse_move(camera, QPoint(400, 300))
assert camera._hover_pos is not None
camera.grab()
# Hover outside the image (negative scene coords): HUD skips drawing.
_mouse_move(camera, QPoint(-10, -10))
camera.grab()
# Leaving the view clears the readout entirely.
camera.leaveEvent(QEvent(QEvent.Type.Leave))
assert camera._hover_pos is None
camera.grab()
def test_scale_bar_nice_numbers():
# 1-2-5 progression against the ~120 px target, and the mm label swap.
assert SampleCameraImageLabel._scale_bar(1.0) == (100.0, "100 µm")
assert SampleCameraImageLabel._scale_bar(2.0) == (200.0, "200 µm")
assert SampleCameraImageLabel._scale_bar(5.0) == (500.0, "500 µm")
assert SampleCameraImageLabel._scale_bar(10.0) == (1000.0, "1 mm")
def test_autoscale_fits_from_the_first_frame(camera):
from PySide6.QtGui import QPixmap