diff --git a/bec_widgets/cli/client.py b/bec_widgets/cli/client.py index 21b31a1a..98a1d5a8 100644 --- a/bec_widgets/cli/client.py +++ b/bec_widgets/cli/client.py @@ -540,3 +540,46 @@ class BECConnector(RPCBase): Returns: dict: The configuration of the plot widget. """ + + +class BECImageItem(RPCBase): + @rpc_call + def set(self, **kwargs): + """ + None + """ + + @rpc_call + def set_color_map(self, cmap: "str" = "magma"): + """ + Set the color map of the image. + Args: + cmap(str): The color map of the image. + """ + + @rpc_call + def set_auto_downsample(self, auto: "bool" = True): + """ + Set the auto downsample of the image. + Args: + auto(bool): Whether to downsample the image. + """ + + @rpc_call + def set_monitor(self, monitor: "str"): + """ + Set the monitor of the image. + Args: + monitor(str): The name of the monitor. + """ + + @rpc_call + def set_vrange( + self, vmin: "float" = None, vmax: "float" = None, vrange: "tuple[int, int]" = None + ): + """ + Set the range of the color bar. + Args: + vmin(float): Minimum value of the color bar. + vmax(float): Maximum value of the color bar. + """ diff --git a/bec_widgets/cli/client_utils.py b/bec_widgets/cli/client_utils.py index 2cc06b58..8c6b20ec 100644 --- a/bec_widgets/cli/client_utils.py +++ b/bec_widgets/cli/client_utils.py @@ -132,7 +132,8 @@ class RPCBase: print(f"RPCBase: {rpc_msg}") # pylint: disable=protected-access receiver = self._root._gui_id - self._client.connector.send(MessageEndpoints.gui_instructions(receiver), rpc_msg) + # self._client.connector.send(MessageEndpoints.gui_instructions(receiver), rpc_msg) + self._client.connector.set_and_publish(MessageEndpoints.gui_instructions(receiver), rpc_msg) if not wait_for_rpc_response: return None diff --git a/bec_widgets/cli/generate_cli.py b/bec_widgets/cli/generate_cli.py index 104d48bc..eff4579a 100644 --- a/bec_widgets/cli/generate_cli.py +++ b/bec_widgets/cli/generate_cli.py @@ -107,13 +107,22 @@ if __name__ == "__main__": # pragma: no cover import os from bec_widgets.widgets.figure import BECFigure - from bec_widgets.widgets.plots import BECPlotBase, BECWaveform1D, BECImageShow # ,BECCurve + from bec_widgets.widgets.plots import BECPlotBase, BECWaveform1D, BECImageShow from bec_widgets.widgets.plots.waveform1d import BECCurve + from bec_widgets.widgets.plots.image import BECImageItem from bec_widgets.utils import BECConnector current_path = os.path.dirname(__file__) client_path = os.path.join(current_path, "client.py") - clss = [BECPlotBase, BECWaveform1D, BECFigure, BECCurve, BECImageShow, BECConnector] + clss = [ + BECPlotBase, + BECWaveform1D, + BECFigure, + BECCurve, + BECImageShow, + BECConnector, + BECImageItem, + ] generator = ClientGenerator() generator.generate_client(clss) generator.write(client_path) diff --git a/bec_widgets/cli/server.py b/bec_widgets/cli/server.py index 1077edb7..6dd54b3c 100644 --- a/bec_widgets/cli/server.py +++ b/bec_widgets/cli/server.py @@ -42,7 +42,7 @@ class BECWidgetsCLIServer: self.send_response(request_id, True, {"result": res}) def send_response(self, request_id: str, accepted: bool, msg: dict): - self.client.connector.set( + self.client.connector.set_and_publish( MessageEndpoints.gui_instruction_response(request_id), messages.RequestResponseMessage(accepted=accepted, message=msg), expire=60, diff --git a/bec_widgets/widgets/plots/image.py b/bec_widgets/widgets/plots/image.py index 1c5607dc..275fef98 100644 --- a/bec_widgets/widgets/plots/image.py +++ b/bec_widgets/widgets/plots/image.py @@ -53,7 +53,7 @@ class ImageConfig(WidgetConfig): ) -class BECImageItem(BECConnector, pg.ImageItem): # TODO decide how complex it should be +class BECImageItem(BECConnector, pg.ImageItem): USER_ACCESS = ["set", "set_color_map", "set_auto_downsample", "set_monitor", "set_vrange"] def __init__(