From 644a97aee848c973125375d5f28d3edf2ffc20cf Mon Sep 17 00:00:00 2001 From: wyzula-jan <133381102+wyzula-jan@users.noreply.github.com> Date: Thu, 26 Oct 2023 15:56:44 +0200 Subject: [PATCH] fix: device_monitor.py crosshairs can be attached again --- bec_widgets/widgets/monitor/device_monitor.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/bec_widgets/widgets/monitor/device_monitor.py b/bec_widgets/widgets/monitor/device_monitor.py index 6f15ccef..1beb374f 100644 --- a/bec_widgets/widgets/monitor/device_monitor.py +++ b/bec_widgets/widgets/monitor/device_monitor.py @@ -48,7 +48,9 @@ config_simple = { class BECDeviceMonitor(pg.GraphicsLayoutWidget): update_signal = pyqtSignal() - def __init__(self, config: dict = config_simple, client=None, parent=None): + def __init__( + self, config: dict = config_simple, client=None, enable_crosshair: bool = False, parent=None + ): super(BECDeviceMonitor, self).__init__(parent=None) # Client and device manager from BEC @@ -61,6 +63,9 @@ class BECDeviceMonitor(pg.GraphicsLayoutWidget): # Current configuration self.config = config + # Enable crosshair + self.enable_crosshair = enable_crosshair + # Displayed Data self.data = {} @@ -211,7 +216,17 @@ class BECDeviceMonitor(pg.GraphicsLayoutWidget): self.curves_data[plot_name] = curve_list - # TODO hook crosshairs here + # Hook Crosshair + if self.enable_crosshair == True: + self.hook_crosshair() + + def hook_crosshair(self) -> None: + """Hook the crosshair to all plots.""" + # TODO can be extendet to hook crosshair signal for mouse move/clicked + self.crosshairs = {} + for plot_name, plot in self.plots.items(): + crosshair = Crosshair(plot, precision=3) + self.crosshairs[plot_name] = crosshair def update_plot(self) -> None: """Update the plot data based on the stored data dictionary."""