diff --git a/bec_widgets/cli/client.py b/bec_widgets/cli/client.py index bb532532..c1d3dd82 100644 --- a/bec_widgets/cli/client.py +++ b/bec_widgets/cli/client.py @@ -2057,6 +2057,19 @@ class BECWaveformWidget(RPCBase): legend_label_size(int): Size of the legend labels. """ + @rpc_call + def set_auto_range(self, enabled: "bool", axis: "str" = "xy"): + """ + Set the auto range of the plot widget. + + Args: + enabled(bool): If True, enable the auto range. + axis(str, optional): The axis to enable the auto range. + - "xy": Enable auto range for both x and y axis. + - "x": Enable auto range for x axis. + - "y": Enable auto range for y axis. + """ + @rpc_call def set_grid(self, x_grid: "bool", y_grid: "bool"): """ diff --git a/bec_widgets/widgets/figure/plots/plot_base.py b/bec_widgets/widgets/figure/plots/plot_base.py index a146288b..427852bc 100644 --- a/bec_widgets/widgets/figure/plots/plot_base.py +++ b/bec_widgets/widgets/figure/plots/plot_base.py @@ -291,6 +291,19 @@ class BECPlotBase(BECConnector, pg.GraphicsLayout): """ self.plot_item.setAspectLocked(lock) + def set_auto_range(self, enabled: bool, axis: str = "xy"): + """ + Set the auto range of the plot widget. + + Args: + enabled(bool): If True, enable the auto range. + axis(str, optional): The axis to enable the auto range. + - "xy": Enable auto range for both x and y axis. + - "x": Enable auto range for x axis. + - "y": Enable auto range for y axis. + """ + self.plot_item.enableAutoRange(axis, enabled) + def export(self): """Show the Export Dialog of the plot widget.""" scene = self.plot_item.scene() diff --git a/bec_widgets/widgets/waveform/waveform_widget.py b/bec_widgets/widgets/waveform/waveform_widget.py index dc573e1e..24f3c964 100644 --- a/bec_widgets/widgets/waveform/waveform_widget.py +++ b/bec_widgets/widgets/waveform/waveform_widget.py @@ -47,6 +47,7 @@ class BECWaveformWidget(BECWidget, QWidget): "set_x_lim", "set_y_lim", "set_legend_label_size", + "set_auto_range", "set_grid", "lock_aspect_ratio", "export",