From 16be464d5b01d8b80ca6aa53e00daebaa605ab11 Mon Sep 17 00:00:00 2001 From: GotthardG <51994228+GotthardG@users.noreply.github.com> Date: Thu, 2 Jul 2026 08:59:32 +0200 Subject: [PATCH] feat(daq): compute beam size for the mark overlay (rectangle, not crosshair) Fill in the beam SIZE in save_screenshot_db using the same conversion the raster grid uses: beam_size_mm / pixel_to_mm(zoom) (sample-camera mm/px). The frontend now draws the beam rectangle (matching the gridscan) instead of a centre-only crosshair. Best-effort; falls back to crosshair on error. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/aare/daq/daq.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/aare/daq/daq.py b/src/aare/daq/daq.py index 25d47bb4..2b2c322a 100644 --- a/src/aare/daq/daq.py +++ b/src/aare/daq/daq.py @@ -2506,18 +2506,19 @@ class AareDAQ: filename: Name to give to the uploaded image. settle_time_s: float time to wait before taking the screenshot. """ - # Beam-mark centre in sample-camera pixels at the current zoom, for the - # DB overlay (drawn in the frontend, never baked into the JPEG). Best - # effort — a calibration hiccup must never block the screenshot upload. + # Beam-mark centre + size in sample-camera pixels at the current zoom, + # for the DB overlay (drawn in the frontend, never baked into the JPEG). + # Best effort — a calibration hiccup must never block the screenshot. beam_mark_pxl = None beam_size_pxl = None try: beam_mark_pxl = self.get_beam_mark() - # TODO(calibration): beam SIZE in sample-camera pixels so the overlay - # is a rectangle instead of a crosshair, e.g. - # px_per_mm = ... # sample-camera scale at self.__devs.zoom - # bs = self.__cfg.beam_size_mm - # beam_size_pxl = (bs.x * px_per_mm, bs.y * px_per_mm) + # Same conversion the raster grid uses (size_mm / pixel_in_mm); + # pixel_to_mm(zoom) is the sample-camera scale in mm per pixel. + pixel_in_mm = self.__cfg.pixel_to_mm(self.__devs.zoom) + if pixel_in_mm and pixel_in_mm > 0: + bs = self.__cfg.beam_size_mm + beam_size_pxl = (bs.x / pixel_in_mm, bs.y / pixel_in_mm) except Exception: logger.warning("Could not read beam mark for screenshot overlay", exc_info=True)