GUI: reactivated show coordinates
This commit is contained in:
1 parent
09080b4227
commit
4d075eb79a
3 files changed
+31
-13
No files matched your search
+12
-3
@@ -1787,13 +1787,22 @@ class AareDAQ:
|
||||
@zoom.setter
|
||||
def zoom(self, val: float):
|
||||
self.__saved_box = None
|
||||
if self.__cfg.zoom_mode == ZoomModeEnum.BeamLocation:
|
||||
# Decide off the beamline STATE (persisted in Redis) so it is robust to
|
||||
# how/when beam-location was entered, rather than a separate flag that
|
||||
# must be set exactly on the state transition.
|
||||
beam_location = self.__cfg.state == BeamlineStateEnum.BeamLocation
|
||||
logger.debug(f"zoom -> {val} (state={self.__cfg.state}, beam_location_presets={beam_location})")
|
||||
if beam_location:
|
||||
# Auto-exposure is too dark to see the beam at high zoom, so apply
|
||||
# the preset per-zoom gain/exposure (interpolated between the stored
|
||||
# zoom stops). Other modes keep auto-exposure.
|
||||
# zoom stops). Every other state keeps auto-exposure.
|
||||
if self.__cfg.zoom_mode != ZoomModeEnum.BeamLocation:
|
||||
self.__cfg.zoom_mode = ZoomModeEnum.BeamLocation
|
||||
self.__devs.zoom = val
|
||||
time.sleep(0.2)
|
||||
self.__devs.samcam_settings = self.__cfg.zoom_settings.get_camera_settings(val)
|
||||
settings = self.__cfg.zoom_settings.get_camera_settings(val)
|
||||
self.__devs.samcam_settings = settings
|
||||
logger.debug(f"applied beam-location preset for zoom {val}: gain={settings.gain}, exposure={settings.exposure}")
|
||||
else:
|
||||
self.__devs.samcam_auto(AutoEnum.AUTO)
|
||||
self.__devs.zoom = val
|
||||
|
||||
@@ -55,7 +55,7 @@ class SamcamPanel(QWidget):
|
||||
|
||||
# Persist the current gain/exposure as the beam-location preset for the
|
||||
# current zoom (only meaningful in beam-location mode).
|
||||
self.save_beam_location_button = QPushButton("Save exposure for this zoom (beam location)")
|
||||
self.save_beam_location_button = QPushButton("Save samcam settings (bl)")
|
||||
self.save_beam_location_button.clicked.connect(self.save_beam_location_setting.emit)
|
||||
|
||||
screenshot_filename_layout = QHBoxLayout()
|
||||
|
||||
@@ -116,6 +116,10 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
self.setScene(self.scene)
|
||||
|
||||
self.setMouseTracking(True)
|
||||
# QGraphicsView delivers mouse moves through its viewport, so hover
|
||||
# events (no button pressed) only fire if the viewport tracks the mouse.
|
||||
# Without this the "Show coordinates" hover tooltip never appears.
|
||||
self.viewport().setMouseTracking(True)
|
||||
self.__update_camera_interaction_feedback()
|
||||
|
||||
if default_image is not None:
|
||||
@@ -430,6 +434,18 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
|
||||
mouse_pos = self.mapToScene(event.pos())
|
||||
|
||||
# Hover tooltips (completed-grid info / pixel coordinates) should work in
|
||||
# any state, not only IDLE -- e.g. while beam-marking in beam location.
|
||||
grid_txt = self.__raster_mgr.is_part_of_completed_grid(mouse_pos)
|
||||
if grid_txt:
|
||||
QToolTip.showText(self.mapToGlobal(event.pos()), grid_txt, self)
|
||||
elif self.__show_coords:
|
||||
QToolTip.showText(
|
||||
self.mapToGlobal(event.pos()),
|
||||
f"{mouse_pos.x():.0f}, {mouse_pos.y():.0f} pxl",
|
||||
self,
|
||||
)
|
||||
|
||||
if self.__state == SampleCameraImageState.IDLE:
|
||||
if event.modifiers() & Qt.KeyboardModifier.ShiftModifier:
|
||||
if not self.raster_timer.isActive():
|
||||
@@ -437,15 +453,6 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
self.raster_timer.start(self.raster_timer_interval)
|
||||
else:
|
||||
self.__pending_load_pos = mouse_pos
|
||||
else:
|
||||
txt = self.__raster_mgr.is_part_of_completed_grid(mouse_pos)
|
||||
if txt != "":
|
||||
QToolTip.showText(self.mapToGlobal(event.pos()), txt, self)
|
||||
elif self.__show_coords:
|
||||
x, y = mouse_pos.x(), mouse_pos.y()
|
||||
QToolTip.showText(
|
||||
self.mapToGlobal(event.pos()), f"{x:.0f}, {y:.0f} pxl", self
|
||||
)
|
||||
|
||||
self.end_point = mouse_pos
|
||||
|
||||
@@ -534,6 +541,8 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
return
|
||||
elif action == show_coord_action:
|
||||
self.__show_coords = not self.__show_coords
|
||||
logger.info(f"Show-coordinates hover tooltip {'enabled' if self.__show_coords else 'disabled'}")
|
||||
self.update()
|
||||
elif action == scale_action:
|
||||
self.__autoscale = not self.__autoscale
|
||||
self.__scaling()
|
||||
|
||||
Reference in new issue
Block a user