diff --git a/bec_widgets/widgets/motor_control/motor_control.py b/bec_widgets/widgets/motor_control/motor_control.py index 2c68fcc2..4556b5b3 100644 --- a/bec_widgets/widgets/motor_control/motor_control.py +++ b/bec_widgets/widgets/motor_control/motor_control.py @@ -383,6 +383,9 @@ class MotorControlRelative(MotorControlWidget): lambda error: MotorControlErrors.display_error_message(error) ) + # Stop Button + self.pushButton_stop.clicked.connect(self.motor_thread.stop_movement) + def _init_keyboard_shortcuts(self) -> None: """Initialize the keyboard shortcuts""" diff --git a/bec_widgets/widgets/motor_control/motor_control_compilations.py b/bec_widgets/widgets/motor_control/motor_control_compilations.py index 70fe36d2..1398cfa7 100644 --- a/bec_widgets/widgets/motor_control/motor_control_compilations.py +++ b/bec_widgets/widgets/motor_control/motor_control_compilations.py @@ -74,6 +74,11 @@ class MotorControlMap(QWidget): layout.addWidget(splitter) self.setLayout(layout) + # Connecting signals and slots + self.motor_control_panel.selection_widget.selected_motors_signal.connect( + lambda x, y: self.motion_map.change_motors(x, y, 0) + ) + class MotorControlPanel(QWidget): def __init__(self, parent=None, client=None, config=None): diff --git a/bec_widgets/widgets/motor_map/motor_map.py b/bec_widgets/widgets/motor_map/motor_map.py index ed370c9f..df9df48d 100644 --- a/bec_widgets/widgets/motor_map/motor_map.py +++ b/bec_widgets/widgets/motor_map/motor_map.py @@ -122,6 +122,28 @@ class MotorMap(pg.GraphicsLayoutWidget): else: # TODO implement validator print("Do validation") + @pyqtSlot(str, str, int) + def change_motors(self, motor_x: str, motor_y: str, subplot: int = 0) -> None: + """ + Change the active motors for the plot. + Args: + motor_x(str): Motor name for the X axis. + motor_y(str): Motor name for the Y axis. + subplot(int): Subplot number. + """ + if subplot >= len(self.plot_data): + print(f"Invalid subplot index: {subplot}. Available subplots: {len(self.plot_data)}") + return + + # Update the motor names in the plot configuration + self.config["motors"][subplot]["signals"]["x"][0]["name"] = motor_x + self.config["motors"][subplot]["signals"]["x"][0]["entry"] = motor_x + self.config["motors"][subplot]["signals"]["y"][0]["name"] = motor_y + self.config["motors"][subplot]["signals"]["y"][0]["entry"] = motor_y + + # reinitialise the config and UI + self._init_config() + def _init_config(self): """Initiate the configuration.""" @@ -146,6 +168,9 @@ class MotorMap(pg.GraphicsLayoutWidget): # Connect motors to slots self._connect_motors_to_slots() + # Render init position of selected motors + self._update_plots() + def _get_global_settings(self): """Get global settings from the config.""" self.plot_settings = self.config.get("plot_settings", {})