style: remove pointless name-mangled attrs
the fact that removing them didn't break anything shows that they were completely unneccessary - there is no inheritance tree using the same names
This commit is contained in:
+13
-5
@@ -26,7 +26,7 @@ from aare.daq.config import BeamlineConfig
|
||||
|
||||
logger = logging.getLogger("aareDAQ")
|
||||
|
||||
|
||||
_SECRET_KEY: str | None = None
|
||||
ALGORITHM = "HS256"
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES = 24 * 60 * 7 # 1 week
|
||||
SESSION_EXPIRE_SECONDS = 60 * 10
|
||||
@@ -46,14 +46,22 @@ class TokenData(BaseModel):
|
||||
|
||||
|
||||
def init_jwt_key(dispatch: AuthDispatch):
|
||||
global SECRET_KEY
|
||||
SECRET_KEY = dispatch.get_jwt_key()
|
||||
global _SECRET_KEY
|
||||
_SECRET_KEY = dispatch.get_jwt_key()
|
||||
|
||||
|
||||
def jwt_key() -> str:
|
||||
if _SECRET_KEY is None:
|
||||
raise RuntimeError(
|
||||
"Run auth.init_jwt_key() to initialize it from the environment before trying to use the key."
|
||||
)
|
||||
return _SECRET_KEY
|
||||
|
||||
|
||||
def create_access_token(token: TokenData):
|
||||
to_encode = token.model_dump()
|
||||
to_encode.update({"exp": datetime.now(UTC) + timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)})
|
||||
encoded_jwt = jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)
|
||||
encoded_jwt = jwt.encode(to_encode, jwt_key(), algorithm=ALGORITHM)
|
||||
return encoded_jwt
|
||||
|
||||
|
||||
@@ -93,7 +101,7 @@ def authenticate_user(cfg: BeamlineConfig, username: str) -> str:
|
||||
|
||||
def parse_token(token: str = Depends(oauth2_scheme)) -> TokenData:
|
||||
try:
|
||||
payload = jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])
|
||||
payload = jwt.decode(token, jwt_key(), algorithms=[ALGORITHM])
|
||||
token = TokenData(**payload)
|
||||
return token
|
||||
except jwt.PyJWTError as e:
|
||||
|
||||
@@ -672,7 +672,7 @@ class BeamlineConfig:
|
||||
self._client.set(f"{self._bl}:beam_size_x", data.x)
|
||||
self._client.set(f"{self._bl}:beam_size_y", data.y)
|
||||
|
||||
def __get_settings(self) -> BeamlineSettingsModel:
|
||||
def _get_settings(self) -> BeamlineSettingsModel:
|
||||
tmp = self._client.get(f"{self._bl}:settings")
|
||||
if tmp is None:
|
||||
return BeamlineSettingsModel()
|
||||
|
||||
+17
-17
@@ -165,7 +165,7 @@ class _DAQPGroupProvider:
|
||||
|
||||
@property
|
||||
def pgroup(self) -> str | None:
|
||||
return self._daq._AareDAQ__cfg.pgroup
|
||||
return self._daq._cfg.pgroup
|
||||
|
||||
|
||||
class _DAQStatusProvider:
|
||||
@@ -182,7 +182,7 @@ class _DAQStateSetter:
|
||||
self._daq = daq
|
||||
|
||||
def set_state(self, target: BeamlineStateEnum) -> None:
|
||||
self._daq._AareDAQ__set_state(target)
|
||||
self._daq._set_state(target)
|
||||
|
||||
|
||||
class _DAQTraceAppender:
|
||||
@@ -198,7 +198,7 @@ class _DAQSampleEventSender:
|
||||
self._daq = daq
|
||||
|
||||
def send_sample_event(self, sample_id: int, event_type, comment: str | None = None) -> None:
|
||||
self._daq._AareDAQ__aare.send_sample_event(sample_id, event_type, comment)
|
||||
self._daq._aare.send_sample_event(sample_id, event_type, comment)
|
||||
|
||||
|
||||
class _DAQScanIngestor:
|
||||
@@ -206,14 +206,14 @@ class _DAQScanIngestor:
|
||||
self._daq = daq
|
||||
|
||||
def ingest_scan(self, *, sample, result, geom, beam_mark_pxl) -> None:
|
||||
self._daq._AareDAQ__aare.ingest_scan(
|
||||
self._daq._aare.ingest_scan(
|
||||
sample=sample, result=result, geom=geom, beam_mark_pxl=beam_mark_pxl
|
||||
)
|
||||
|
||||
def ingest_gridscan(
|
||||
self, *, sample, raster_result, raster_request, geom, com, beam_mark_pxl
|
||||
) -> None:
|
||||
self._daq._AareDAQ__aare.ingest_gridscan(
|
||||
self._daq._aare.ingest_gridscan(
|
||||
sample=sample,
|
||||
raster_result=raster_result,
|
||||
raster_request=raster_request,
|
||||
@@ -228,7 +228,7 @@ class _DAQDatacollectionSetupRunner:
|
||||
self._daq = daq
|
||||
|
||||
def prepare(self, request, screening: bool = False) -> None:
|
||||
self._daq._AareDAQ__setup_datacollection(request=request, screening=screening)
|
||||
self._daq._setup_datacollection(request=request, screening=screening)
|
||||
|
||||
|
||||
class _LoopCenteringPredictionGetter:
|
||||
@@ -237,7 +237,7 @@ class _LoopCenteringPredictionGetter:
|
||||
self._settings = settings
|
||||
|
||||
def get_predictions(self):
|
||||
return self._daq._AareDAQ__mlbox.predict_all_best(
|
||||
return self._daq._mlbox.predict_all_best(
|
||||
overlap_with_pin=self._settings.overlap_with_pin,
|
||||
confidence_min=self._settings.confidence_min,
|
||||
return_image=True,
|
||||
@@ -566,8 +566,8 @@ class AareDAQ:
|
||||
|
||||
def _get_tell_events_from_redis(self) -> list[dict]:
|
||||
try:
|
||||
redis_client = getattr(self._AareDAQ__cfg, "_BeamlineConfig__client", None)
|
||||
beamline_key = getattr(self._AareDAQ__cfg, "_BeamlineConfig__bl", None)
|
||||
redis_client = getattr(self._cfg, "_client", None)
|
||||
beamline_key = getattr(self._cfg, "_bl", None)
|
||||
|
||||
if redis_client is None or beamline_key is None:
|
||||
return []
|
||||
@@ -1189,7 +1189,7 @@ class AareDAQ:
|
||||
logger.error("Failed to get current sample")
|
||||
sample = None
|
||||
|
||||
aare = getattr(self, "_AareDAQ__aare", None)
|
||||
aare = getattr(self, "_aare", None)
|
||||
if aare is not None and sample is not None and sample.db_id is not None:
|
||||
aare.send_sample_event(sample.db_id, SampleEventType.LOOPFACEDETECTING)
|
||||
|
||||
@@ -1648,7 +1648,7 @@ class AareDAQ:
|
||||
def omega(self) -> float:
|
||||
return self._devs.aerotech_omega
|
||||
|
||||
def __omega(self, val: float):
|
||||
def _omega(self, val: float):
|
||||
self._saved_box = None
|
||||
logger.info(f"Set omega to {val}")
|
||||
if -2000 < val < 2000:
|
||||
@@ -1903,7 +1903,7 @@ class AareDAQ:
|
||||
def list_loaded_pucks(self) -> List[PuckLoadedInfo]:
|
||||
return []
|
||||
|
||||
def __auto_focus(self, settings: AutofocusSettings, settle_time_s: float = 1.0) -> float:
|
||||
def _auto_focus(self, settings: AutofocusSettings, settle_time_s: float = 1.0) -> float:
|
||||
# TODO uses old code change
|
||||
"""
|
||||
Scan smargon Z and find the position with maximum focus measure.
|
||||
@@ -1940,7 +1940,7 @@ class AareDAQ:
|
||||
def auto_exposure(self):
|
||||
self._devs.samcam_auto(AutoEnum.ONCE)
|
||||
|
||||
def __setup_datacollection(
|
||||
def _setup_datacollection(
|
||||
self, request: RasterGridRequest | RotationScanRequest, screening: bool = False
|
||||
):
|
||||
request_omega = getattr(request, "omega_deg", None)
|
||||
@@ -2056,7 +2056,7 @@ class AareDAQ:
|
||||
self._cfg.state_busy = False
|
||||
raise
|
||||
|
||||
def __rotation(self, request: RotationScanRequest) -> CompletedRotationScan:
|
||||
def _rotation(self, request: RotationScanRequest) -> CompletedRotationScan:
|
||||
omega_start = self.omega
|
||||
status = self.status
|
||||
|
||||
@@ -2916,7 +2916,7 @@ class AareDAQ:
|
||||
return self._end_operation(start, DAQOperation.AUTOMATION, error=False)
|
||||
|
||||
@log_timing(logger, "Changing Beamline State")
|
||||
def __set_state(self, target: BeamlineStateEnum):
|
||||
def _set_state(self, target: BeamlineStateEnum):
|
||||
"""__set_state assumes that beamline is already in busy state
|
||||
it will apply a proper transformation and change state afterward
|
||||
specifically:
|
||||
@@ -3329,8 +3329,8 @@ class AareDAQ:
|
||||
|
||||
def _safe_tell_state(self) -> TellStateModel | None:
|
||||
try:
|
||||
redis_client = getattr(self._AareDAQ__cfg, "_BeamlineConfig__client", None)
|
||||
beamline_key = getattr(self._AareDAQ__cfg, "_BeamlineConfig__bl", None)
|
||||
redis_client = getattr(self._cfg, "_client", None)
|
||||
beamline_key = getattr(self._cfg, "_bl", None)
|
||||
|
||||
if redis_client is None or beamline_key is None:
|
||||
return None
|
||||
|
||||
@@ -27,7 +27,7 @@ def set_spreadsheet_in_redis(spreadsheet):
|
||||
"[REDIS][DEBUG] Data to write:", json.dumps(spreadsheet, indent=4)
|
||||
) # Pretty-print the data
|
||||
print("[REDIS][INFO] Writing spreadsheet to Redis...")
|
||||
config.__client.set(f"{config._BeamlineConfig__bl}:spreadsheet", json.dumps(spreadsheet))
|
||||
config.__client.set(f"{config._bl}:spreadsheet", json.dumps(spreadsheet))
|
||||
|
||||
|
||||
def on_message(ws, message):
|
||||
@@ -88,21 +88,21 @@ def on_message(ws, message):
|
||||
target_list.append(info)
|
||||
|
||||
# Write normal pucks to sample_spreadsheet
|
||||
normal_key = f"{config._BeamlineConfig__bl}:sample_spreadsheet"
|
||||
normal_key = f"{config._bl}:sample_spreadsheet"
|
||||
normal_list = SampleShortInfoList(s=normal_short_infos)
|
||||
config._BeamlineConfig__client.set(normal_key, normal_list.model_dump_json())
|
||||
config._client.set(normal_key, normal_list.model_dump_json())
|
||||
print("[REDIS][INFO] Written normal spreadsheet to:", normal_key)
|
||||
|
||||
# Write reference tools to reference-tools
|
||||
ref_key = f"{config._BeamlineConfig__bl}:reference-tools"
|
||||
ref_key = f"{config._bl}:reference-tools"
|
||||
if reference_short_infos:
|
||||
ref_list = SampleShortInfoList(s=reference_short_infos)
|
||||
config._BeamlineConfig__client.set(ref_key, ref_list.model_dump_json())
|
||||
config._client.set(ref_key, ref_list.model_dump_json())
|
||||
print("[REDIS][INFO] Written reference tools to:", ref_key)
|
||||
else:
|
||||
# Clear key if empty
|
||||
try:
|
||||
config._BeamlineConfig__client.delete(ref_key)
|
||||
config._client.delete(ref_key)
|
||||
print("[REDIS][INFO] Cleared reference tools key:", ref_key)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -98,8 +98,8 @@ def _get_redis_context() -> tuple[Any | None, str | None]:
|
||||
logger.debug("[REDIS] BeamlineConfig unavailable; skipping TELL redis write")
|
||||
return None, None
|
||||
|
||||
redis_client = getattr(config, "_BeamlineConfig__client", None)
|
||||
beamline_key = getattr(config, "_BeamlineConfig__bl", None)
|
||||
redis_client = getattr(config, "_client", None)
|
||||
beamline_key = getattr(config, "_bl", None)
|
||||
if redis_client is None or beamline_key is None:
|
||||
logger.error("[REDIS] BeamlineConfig internals unavailable; skipping TELL redis write")
|
||||
return None, None
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from typing import Optional, Union
|
||||
|
||||
from aarecommon.config.beamline import cfg_get, mx_beamline
|
||||
from aarecommon.config.logger import setup_logger
|
||||
from aarecommon.errors.exception_handler import AerotechCommunicationError
|
||||
from aarecommon.math.coordinate import AerotechCoordinate, Coordinate
|
||||
from aarecommon.models.beamline import MXBeamline
|
||||
@@ -18,7 +19,6 @@ from aarescan_client.models.screen_request import ScreenRequest
|
||||
|
||||
AEROTECH_HOME = AerotechCoordinate(at_mm=Coordinate(x=0, y=0, z=0), omega_deg=0)
|
||||
|
||||
from aarecommon.config.logger import setup_logger
|
||||
|
||||
logger = setup_logger("aareDAQ")
|
||||
|
||||
@@ -48,7 +48,7 @@ class AerotechController(object):
|
||||
self._client = ApiClient(Configuration(host=self._base))
|
||||
self._api = DefaultApi(self._client)
|
||||
|
||||
def __make_aerotech_target(
|
||||
def _make_aerotech_target(
|
||||
self, coord: AerotechCoordinate, wait: bool = False, incremental: bool = False
|
||||
) -> Target:
|
||||
at_mm = coord.at_mm
|
||||
@@ -62,7 +62,7 @@ class AerotechController(object):
|
||||
incremental=incremental,
|
||||
)
|
||||
|
||||
def __make_aerotech_coordinate(self, target: Target) -> AerotechCoordinate:
|
||||
def _make_aerotech_coordinate(self, target: Target) -> AerotechCoordinate:
|
||||
return AerotechCoordinate(
|
||||
at_mm=Coordinate(x=target.x, y=target.y, z=target.z), omega_deg=target.u
|
||||
)
|
||||
|
||||
@@ -64,7 +64,7 @@ class epicsAD(object):
|
||||
except:
|
||||
pass
|
||||
|
||||
def __init_auto_exp(self, settings: AutoExposureSettings = AutoExposureSettings()):
|
||||
def _init_auto_exp(self, settings: AutoExposureSettings = AutoExposureSettings()):
|
||||
self.acquire.put(0)
|
||||
self.aoi_start_x.put(settings.aoi_offset_x)
|
||||
self.aoi_start_y.put(settings.aoi_offset_y)
|
||||
|
||||
@@ -102,7 +102,7 @@ class BECClientWorker:
|
||||
exit(1)
|
||||
logger.debug(f"simulated is {self.simulated}")
|
||||
|
||||
def __init_beamline_environment(self):
|
||||
def _init_beamline_environment(self):
|
||||
try:
|
||||
self.position_devices, self.planner = init_beamline_environment()
|
||||
self._backlight_brightness = self.position_devices["bl_bright"]
|
||||
@@ -163,7 +163,7 @@ class BECClientWorker:
|
||||
|
||||
raise BECCommunicationError(message, operation=operation, exception=exc) from exc
|
||||
|
||||
def __set_scilog_tags(self, tags: Optional[List[str]] = None):
|
||||
def _set_scilog_tags(self, tags: Optional[List[str]] = None):
|
||||
try:
|
||||
if tags:
|
||||
self.client.messaging.scilog.set_default_tags(tags)
|
||||
@@ -307,7 +307,7 @@ class BECClientWorker:
|
||||
except Exception as e:
|
||||
self._raise_bec_error(e, operation="list_all_user_macros")
|
||||
|
||||
def __list_all_macros(self):
|
||||
def _list_all_macros(self):
|
||||
result = self.macros.list_user_macros()
|
||||
if result is None:
|
||||
return []
|
||||
@@ -322,7 +322,7 @@ class BECClientWorker:
|
||||
except Exception as e:
|
||||
self._raise_bec_error(e, operation="load_user_macros")
|
||||
|
||||
def __load_user_macros(self):
|
||||
def _load_user_macros(self):
|
||||
result = self.macros.load_all_user_macros()
|
||||
if result is None:
|
||||
logger.warning("BEC load_all_user_macros returned None")
|
||||
|
||||
@@ -80,7 +80,7 @@ class JFJochWrapper:
|
||||
status = self._api.status_get()
|
||||
return status.state == "Idle"
|
||||
|
||||
def __format_dataset_settings(
|
||||
def _format_dataset_settings(
|
||||
self,
|
||||
r: RasterGridRequest | RotationScanRequest,
|
||||
s: DAQStatusModel,
|
||||
@@ -192,7 +192,7 @@ class JFJochWrapper:
|
||||
|
||||
return dataset_settings
|
||||
|
||||
def __start_scan(
|
||||
def _start_scan(
|
||||
self,
|
||||
scan_type: ScanTypeEnum,
|
||||
r: RasterGridRequest | RotationScanRequest,
|
||||
|
||||
@@ -1141,8 +1141,8 @@ class MainWindow(QMainWindow):
|
||||
# ── Camera: scale-to-fit + hide legend ─────────────────────────────
|
||||
self.portrait_sample_camera.set_show_overlay_legend(False)
|
||||
try:
|
||||
self.portrait_sample_camera._SampleCameraImageLabel__autoscale = True
|
||||
self.portrait_sample_camera._SampleCameraImageLabel__scaling()
|
||||
self.portrait_sample_camera._autoscale = True
|
||||
self.portrait_sample_camera._scaling()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
@@ -726,7 +726,7 @@ class PortraitModePanel(QWidget):
|
||||
return
|
||||
|
||||
# Still busy, wait
|
||||
if getattr(self._job_list_panel, "_SampleQueuePanel__busy", False):
|
||||
if getattr(self._job_list_panel, "_busy", False):
|
||||
return
|
||||
|
||||
# Safe to restart
|
||||
|
||||
@@ -160,14 +160,14 @@ class SamcamPanel(QWidget):
|
||||
layout.addLayout(target_color_layout)
|
||||
self.setLayout(layout)
|
||||
|
||||
def __changed(self):
|
||||
def _changed(self):
|
||||
self.changed.emit(
|
||||
SampleCameraSettings(
|
||||
gain=self.gain_spinbox.value(), exposure=self.exposure_spinbox.value()
|
||||
)
|
||||
)
|
||||
|
||||
def __request_screenshot(self):
|
||||
def _request_screenshot(self):
|
||||
self.screenshot_requested.emit(
|
||||
self.screenshot_filename_edit.text(), self.screenshot_message_edit.text()
|
||||
)
|
||||
|
||||
@@ -43,7 +43,7 @@ class SampleCameraThread(QThread):
|
||||
self._camera_available = False
|
||||
self._last_camera_error: str | None = None
|
||||
|
||||
def __set_camera_available(self, available: bool, error: str | None = None) -> None:
|
||||
def _set_camera_available(self, available: bool, error: str | None = None) -> None:
|
||||
if available != self._camera_available:
|
||||
self._camera_available = available
|
||||
self.camera_availability_changed.emit(available)
|
||||
|
||||
@@ -2525,7 +2525,7 @@ class DAQWorker(QObject):
|
||||
logger.warning(f"Failed to stop _baton_timeout_timer: {e}")
|
||||
|
||||
try:
|
||||
if hasattr(self, "_DAQWorker__timer") and self._timer is not None:
|
||||
if hasattr(self, "_timer") and self._timer is not None:
|
||||
self._timer.stop()
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to stop __timer: {e}")
|
||||
|
||||
@@ -161,7 +161,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
self._detections = [] # list of dicts from publisher
|
||||
self._det_shape = None # shape from payload [h,w] so we can scale
|
||||
|
||||
def __update_camera_interaction_feedback(self) -> None:
|
||||
def _update_camera_interaction_feedback(self) -> None:
|
||||
if self._camera_available:
|
||||
self.viewport().setCursor(Qt.CursorShape.ArrowCursor)
|
||||
self.setToolTip("")
|
||||
@@ -169,7 +169,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
self.viewport().setCursor(Qt.CursorShape.ForbiddenCursor)
|
||||
self.setToolTip("Sample camera feed unavailable")
|
||||
|
||||
def __show_camera_unavailable_tooltip(
|
||||
def _show_camera_unavailable_tooltip(
|
||||
self, event, action: str = "Sample camera interaction"
|
||||
) -> None:
|
||||
QToolTip.showText(
|
||||
@@ -178,7 +178,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
self,
|
||||
)
|
||||
|
||||
def __camera_interaction_enabled(self) -> bool:
|
||||
def _camera_interaction_enabled(self) -> bool:
|
||||
return self._camera_available
|
||||
|
||||
@Slot(bool)
|
||||
@@ -229,7 +229,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
self._smoothed_target_point = None
|
||||
self.update()
|
||||
|
||||
def __busy_overlay_text(self) -> str:
|
||||
def _busy_overlay_text(self) -> str:
|
||||
tell_state = self._tell_state
|
||||
if tell_state is None:
|
||||
return "BEAMLINE BUSY"
|
||||
@@ -242,7 +242,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
|
||||
return f"TELL {activity_name}".upper()
|
||||
|
||||
def __draw_busy_overlay(self, painter: QPainter):
|
||||
def _draw_busy_overlay(self, painter: QPainter):
|
||||
if self._busy_overlay_style is None:
|
||||
return
|
||||
|
||||
@@ -282,7 +282,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
|
||||
painter.restore()
|
||||
|
||||
def __draw_session_overlay(self, painter: QPainter):
|
||||
def _draw_session_overlay(self, painter: QPainter):
|
||||
if self._busy_overlay_style is not None:
|
||||
return
|
||||
|
||||
@@ -333,7 +333,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
|
||||
painter.restore()
|
||||
|
||||
def __draw_camera_unavailable_overlay(self, painter: QPainter):
|
||||
def _draw_camera_unavailable_overlay(self, painter: QPainter):
|
||||
if self._camera_available:
|
||||
return
|
||||
|
||||
@@ -461,7 +461,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
self._update_grid()
|
||||
self.update()
|
||||
|
||||
def __on_raster_timer_timeout(self):
|
||||
def _on_raster_timer_timeout(self):
|
||||
if self._pending_load_pos is not None:
|
||||
self.load_image.emit(self._pending_load_pos)
|
||||
self._pending_load_pos = None
|
||||
@@ -497,7 +497,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
if self._state != SampleCameraImageState.BEAM_MARKING:
|
||||
self._state = SampleCameraImageState.IDLE
|
||||
|
||||
def __right_click_menu(self, event):
|
||||
def _right_click_menu(self, event):
|
||||
if not self._camera_interaction_enabled():
|
||||
self._show_camera_unavailable_tooltip(event)
|
||||
return
|
||||
@@ -572,7 +572,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
self.update_beam_mark.emit(c.x(), c.y())
|
||||
self.update()
|
||||
|
||||
def __screenshot_with_dialog(self, overlay: bool):
|
||||
def _screenshot_with_dialog(self, overlay: bool):
|
||||
file_path, _ = QFileDialog.getSaveFileName(
|
||||
self, "Save View As", "", "JPEG Files (*.jpg; *.jpeg);;All Files (*)"
|
||||
)
|
||||
@@ -580,7 +580,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
if file_path:
|
||||
self._screenshot(file_path=file_path, overlay=overlay)
|
||||
|
||||
def __screenshot(self, file_path: str, overlay: bool):
|
||||
def _screenshot(self, file_path: str, overlay: bool):
|
||||
scene_rect = self.scene.sceneRect()
|
||||
pixmap = QPixmap(scene_rect.size().toSize())
|
||||
painter = QPainter(pixmap)
|
||||
@@ -590,7 +590,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
painter.end()
|
||||
pixmap.save(file_path, "JPEG")
|
||||
|
||||
def __scaling(self):
|
||||
def _scaling(self):
|
||||
if not self._autoscale:
|
||||
self.setTransform(QTransform())
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded)
|
||||
@@ -665,7 +665,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
elif self._state == SampleCameraImageState.BEAM_MARKING:
|
||||
self._state = SampleCameraImageState.IDLE
|
||||
|
||||
def __left_single_click(self, event):
|
||||
def _left_single_click(self, event):
|
||||
if not self._camera_interaction_enabled():
|
||||
logger.info("Ignoring click because sample camera feed is unavailable")
|
||||
self._show_camera_unavailable_tooltip(event, "Point-on-click")
|
||||
@@ -697,10 +697,10 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
)
|
||||
self.smargon.emit(smargon_coord)
|
||||
|
||||
def __draw_detections(self, painter: QPainter, rect):
|
||||
def _draw_detections(self, painter: QPainter, rect):
|
||||
if not self._show_detections:
|
||||
return
|
||||
if not getattr(self, "_SampleCameraImageLabel__detections", None):
|
||||
if not getattr(self, "_detections", None):
|
||||
return
|
||||
if self.pixmap_item is None:
|
||||
return
|
||||
@@ -761,7 +761,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
painter.setPen(QPen(QColor(255, 255, 255)))
|
||||
painter.drawText(QPoint(int(x1) + 2, int(y1 - 4)), f"{label} {conf:.2f}")
|
||||
|
||||
def __target_color(self) -> QColor:
|
||||
def _target_color(self) -> QColor:
|
||||
color_map = {
|
||||
"Cyan": QColor(0, 255, 255),
|
||||
"Dark Blue": QColor(0, 70, 160),
|
||||
@@ -769,7 +769,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
}
|
||||
return color_map.get(self._target_color_name, QColor(0, 255, 255))
|
||||
|
||||
def __coerce_target_point(self, raw) -> tuple[float, float] | None:
|
||||
def _coerce_target_point(self, raw) -> tuple[float, float] | None:
|
||||
try:
|
||||
if isinstance(raw, dict):
|
||||
return float(raw["x"]), float(raw["y"])
|
||||
@@ -779,7 +779,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
logger.debug(f"Error parsing target point {raw}: {e}")
|
||||
return None
|
||||
|
||||
def __draw_target_point(self, painter: QPainter):
|
||||
def _draw_target_point(self, painter: QPainter):
|
||||
if not self._show_target_point:
|
||||
return
|
||||
if self._smoothed_target_point is None:
|
||||
@@ -855,7 +855,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
|
||||
painter.restore()
|
||||
|
||||
def __legend_should_show(self) -> bool:
|
||||
def _legend_should_show(self) -> bool:
|
||||
return self._show_overlay_legend and (
|
||||
self._show_target_point
|
||||
or self._show_detections
|
||||
@@ -863,7 +863,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
or self._state == SampleCameraImageState.BEAM_MARKING
|
||||
)
|
||||
|
||||
def __legend_lines(self) -> list[tuple[str, QColor | None]]:
|
||||
def _legend_lines(self) -> list[tuple[str, QColor | None]]:
|
||||
lines: list[tuple[str, QColor | None]] = []
|
||||
|
||||
if self._compact_overlay_legend:
|
||||
@@ -919,7 +919,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
|
||||
return lines
|
||||
|
||||
def __draw_overlay_legend(self, painter: QPainter):
|
||||
def _draw_overlay_legend(self, painter: QPainter):
|
||||
if not self._legend_should_show():
|
||||
return
|
||||
|
||||
@@ -1022,7 +1022,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
"target_color": self._target_color_name,
|
||||
}
|
||||
|
||||
def __draw_ml_bounding_box(self, painter: QPainter):
|
||||
def _draw_ml_bounding_box(self, painter: QPainter):
|
||||
if self._bounding_box is None:
|
||||
return
|
||||
|
||||
@@ -1038,7 +1038,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
)
|
||||
)
|
||||
|
||||
def __draw_beam_center(self, painter: QPainter):
|
||||
def _draw_beam_center(self, painter: QPainter):
|
||||
beam_size_pxl = self._geom.beam_size_pxl
|
||||
|
||||
if self._state == SampleCameraImageState.BEAM_MARKING:
|
||||
@@ -1064,13 +1064,13 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def __draw_circle(painter, coord: Coordinate, color: QColor, radius=10):
|
||||
def _draw_circle(painter, coord: Coordinate, color: QColor, radius=10):
|
||||
painter.setPen(QPen(Qt.PenStyle.NoPen))
|
||||
painter.setBrush(color)
|
||||
painter.drawEllipse(coord.x - radius, coord.y - radius, 2 * radius, 2 * radius)
|
||||
|
||||
@staticmethod
|
||||
def __draw_arrow(painter: QPainter, start: Coordinate, end: Coordinate):
|
||||
def _draw_arrow(painter: QPainter, start: Coordinate, end: Coordinate):
|
||||
gradient = QLinearGradient()
|
||||
gradient.setStart(QPointF(start.x, start.y)) # Start of the gradient (green)
|
||||
gradient.setFinalStop(QPointF(end.x, end.y)) # End of the gradient (red)
|
||||
@@ -1086,7 +1086,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
|
||||
painter.drawLine(QPointF(start.x, start.y), QPointF(end.x, end.y))
|
||||
|
||||
def __draw_helical(self, painter: QPainter):
|
||||
def _draw_helical(self, painter: QPainter):
|
||||
if self._helical_start.sh_mm is not None:
|
||||
start_pxl = self._geom.smargon_to_picture(self._helical_start.sh_mm)
|
||||
self._draw_circle(painter, start_pxl, QColor("green"))
|
||||
|
||||
@@ -584,7 +584,7 @@ class StatusBar(QStatusBar):
|
||||
def open_shutter_clicked(self):
|
||||
self.open_shutter.emit()
|
||||
|
||||
def __list_staff_pgroups(self):
|
||||
def _list_staff_pgroups(self):
|
||||
self.get_all_pgroups.emit()
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user