From 06d9717222550cc47d6dd871a01899312daf87ef Mon Sep 17 00:00:00 2001 From: wyzula-jan Date: Mon, 22 Apr 2024 19:16:33 +0200 Subject: [PATCH] refactor(plots): WidgetConfig renamed to SubplotConfig --- bec_widgets/widgets/figure/figure.py | 6 +++--- bec_widgets/widgets/plots/__init__.py | 2 +- bec_widgets/widgets/plots/image.py | 8 ++++---- bec_widgets/widgets/plots/motor_map.py | 4 ++-- bec_widgets/widgets/plots/plot_base.py | 6 +++--- bec_widgets/widgets/plots/waveform.py | 8 ++++---- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/bec_widgets/widgets/figure/figure.py b/bec_widgets/widgets/figure/figure.py index 1a512590..b480e05a 100644 --- a/bec_widgets/widgets/figure/figure.py +++ b/bec_widgets/widgets/figure/figure.py @@ -21,7 +21,7 @@ from bec_widgets.widgets.plots import ( BECPlotBase, BECWaveform, Waveform1DConfig, - WidgetConfig, + SubplotConfig, ) from bec_widgets.widgets.plots.image import ImageConfig from bec_widgets.widgets.plots.motor_map import MotorMapConfig @@ -33,7 +33,7 @@ class FigureConfig(ConnectionConfig): theme: Literal["dark", "light"] = Field("dark", description="The theme of the figure widget.") num_cols: int = Field(1, description="The number of columns in the figure widget.") num_rows: int = Field(1, description="The number of rows in the figure widget.") - widgets: dict[str, WidgetConfig] = Field( + widgets: dict[str, SubplotConfig] = Field( {}, description="The list of widgets to be added to the figure widget." ) @@ -43,7 +43,7 @@ class WidgetHandler: def __init__(self): self.widget_factory = { - "PlotBase": (BECPlotBase, WidgetConfig), + "PlotBase": (BECPlotBase, SubplotConfig), "Waveform1D": (BECWaveform, Waveform1DConfig), "ImShow": (BECImageShow, ImageConfig), "MotorMap": (BECMotorMap, MotorMapConfig), diff --git a/bec_widgets/widgets/plots/__init__.py b/bec_widgets/widgets/plots/__init__.py index a2f182c7..8d73cb20 100644 --- a/bec_widgets/widgets/plots/__init__.py +++ b/bec_widgets/widgets/plots/__init__.py @@ -1,4 +1,4 @@ from .image import BECImageItem, BECImageShow, ImageItemConfig from .motor_map import BECMotorMap, MotorMapConfig -from .plot_base import AxisConfig, BECPlotBase, WidgetConfig +from .plot_base import AxisConfig, BECPlotBase, SubplotConfig from .waveform import BECCurve, BECWaveform, Waveform1DConfig diff --git a/bec_widgets/widgets/plots/image.py b/bec_widgets/widgets/plots/image.py index c6b2a40c..2ee5f595 100644 --- a/bec_widgets/widgets/plots/image.py +++ b/bec_widgets/widgets/plots/image.py @@ -14,7 +14,7 @@ from qtpy.QtWidgets import QWidget from bec_widgets.utils import BECConnector, ConnectionConfig, EntryValidator -from .plot_base import BECPlotBase, WidgetConfig +from .plot_base import BECPlotBase, SubplotConfig class ProcessingConfig(BaseModel): @@ -50,7 +50,7 @@ class ImageItemConfig(ConnectionConfig): ) -class ImageConfig(WidgetConfig): +class ImageConfig(SubplotConfig): images: dict[str, ImageItemConfig] = Field( {}, description="The configuration of the images. The key is the name of the image (source).", @@ -390,11 +390,11 @@ class BECImageShow(BECPlotBase): if result is not None: return result - def apply_config(self, config: dict | WidgetConfig): + def apply_config(self, config: dict | SubplotConfig): """ Apply the configuration to the 1D waveform widget. Args: - config(dict|WidgetConfig): Configuration settings. + config(dict|SubplotConfig): Configuration settings. replot_last_scan(bool, optional): If True, replot the last scan. Defaults to False. """ if isinstance(config, dict): diff --git a/bec_widgets/widgets/plots/motor_map.py b/bec_widgets/widgets/plots/motor_map.py index 769d2cf1..b221d15a 100644 --- a/bec_widgets/widgets/plots/motor_map.py +++ b/bec_widgets/widgets/plots/motor_map.py @@ -13,11 +13,11 @@ from qtpy.QtCore import Slot as pyqtSlot from qtpy.QtWidgets import QWidget from bec_widgets.utils import EntryValidator -from bec_widgets.widgets.plots.plot_base import BECPlotBase, WidgetConfig +from bec_widgets.widgets.plots.plot_base import BECPlotBase, SubplotConfig from bec_widgets.widgets.plots.waveform import Signal, SignalData -class MotorMapConfig(WidgetConfig): +class MotorMapConfig(SubplotConfig): signals: Optional[Signal] = Field(None, description="Signals of the motor map") color_map: Optional[str] = Field( "Greys", description="Color scheme of the motor position gradient." diff --git a/bec_widgets/widgets/plots/plot_base.py b/bec_widgets/widgets/plots/plot_base.py index 541d3992..7c68fcec 100644 --- a/bec_widgets/widgets/plots/plot_base.py +++ b/bec_widgets/widgets/plots/plot_base.py @@ -22,7 +22,7 @@ class AxisConfig(BaseModel): y_grid: bool = Field(False, description="Show grid on the y-axis.") -class WidgetConfig(ConnectionConfig): +class SubplotConfig(ConnectionConfig): parent_id: Optional[str] = Field(None, description="The parent figure of the plot.") # Coordinates in the figure @@ -56,12 +56,12 @@ class BECPlotBase(BECConnector, pg.GraphicsLayout): self, parent: Optional[QWidget] = None, # TODO decide if needed for this class parent_figure=None, - config: Optional[WidgetConfig] = None, + config: Optional[SubplotConfig] = None, client=None, gui_id: Optional[str] = None, ): if config is None: - config = WidgetConfig(widget_class=self.__class__.__name__) + config = SubplotConfig(widget_class=self.__class__.__name__) super().__init__(client=client, config=config, gui_id=gui_id) pg.GraphicsLayout.__init__(self, parent) diff --git a/bec_widgets/widgets/plots/waveform.py b/bec_widgets/widgets/plots/waveform.py index 470438a8..7b487bf8 100644 --- a/bec_widgets/widgets/plots/waveform.py +++ b/bec_widgets/widgets/plots/waveform.py @@ -15,7 +15,7 @@ from qtpy.QtCore import Slot as pyqtSlot from qtpy.QtWidgets import QWidget from bec_widgets.utils import BECConnector, Colors, ConnectionConfig, EntryValidator -from bec_widgets.widgets.plots.plot_base import BECPlotBase, WidgetConfig +from bec_widgets.widgets.plots.plot_base import BECPlotBase, SubplotConfig class SignalData(BaseModel): @@ -53,7 +53,7 @@ class CurveConfig(ConnectionConfig): colormap: Optional[str] = Field("plasma", description="The colormap of the curves z gradient.") -class Waveform1DConfig(WidgetConfig): +class Waveform1DConfig(SubplotConfig): color_palette: Literal["plasma", "viridis", "inferno", "magma"] = Field( "plasma", description="The color palette of the figure widget." ) # TODO can be extended to all colormaps from current pyqtgraph session @@ -299,11 +299,11 @@ class BECWaveform(BECPlotBase): if curve.gui_id == item_id: return curve - def apply_config(self, config: dict | WidgetConfig, replot_last_scan: bool = False): + def apply_config(self, config: dict | SubplotConfig, replot_last_scan: bool = False): """ Apply the configuration to the 1D waveform widget. Args: - config(dict|WidgetConfig): Configuration settings. + config(dict|SubplotConfig): Configuration settings. replot_last_scan(bool, optional): If True, replot the last scan. Defaults to False. """ if isinstance(config, dict):