0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 03:31:50 +02:00

fix: change default colormap to plasma

This commit is contained in:
2025-04-23 17:52:22 +02:00
parent 3709cdc866
commit 074bbbc166
17 changed files with 32 additions and 34 deletions

View File

@ -2196,7 +2196,7 @@ class MultiWaveform(RPCBase):
""" """
@rpc_call @rpc_call
def plot(self, monitor: "str", color_palette: "str | None" = "magma"): def plot(self, monitor: "str", color_palette: "str | None" = "plasma"):
""" """
Create a plot for the given monitor. Create a plot for the given monitor.
Args: Args:
@ -2966,7 +2966,7 @@ class ScatterWaveform(RPCBase):
x_entry: "None | str" = None, x_entry: "None | str" = None,
y_entry: "None | str" = None, y_entry: "None | str" = None,
z_entry: "None | str" = None, z_entry: "None | str" = None,
color_map: "str | None" = "magma", color_map: "str | None" = "plasma",
label: "str | None" = None, label: "str | None" = None,
validate_bec: "bool" = True, validate_bec: "bool" = True,
) -> "ScatterCurve": ) -> "ScatterCurve":

View File

@ -27,7 +27,7 @@ logger = bec_logger.logger
# noinspection PyDataclass # noinspection PyDataclass
class ImageConfig(ConnectionConfig): class ImageConfig(ConnectionConfig):
color_map: str = Field( color_map: str = Field(
"magma", description="The colormap of the figure widget.", validate_default=True "plasma", description="The colormap of the figure widget.", validate_default=True
) )
color_bar: Literal["full", "simple"] | None = Field( color_bar: Literal["full", "simple"] | None = Field(
None, description="The type of the color bar." None, description="The type of the color bar."
@ -142,8 +142,8 @@ class Image(PlotBase):
self.plot_item.addItem(self._main_image) self.plot_item.addItem(self._main_image)
self.scan_id = None self.scan_id = None
# Default Color map to magma # Default Color map to plasma
self.color_map = "magma" self.color_map = "plasma"
################################################################################ ################################################################################
# Widget Specific GUI interactions # Widget Specific GUI interactions

View File

@ -24,7 +24,7 @@ class ImageItemConfig(ConnectionConfig): # TODO review config
monitor: str | None = Field(None, description="The name of the monitor.") monitor: str | None = Field(None, description="The name of the monitor.")
monitor_type: Literal["1d", "2d", "auto"] = Field("auto", description="The type of monitor.") monitor_type: Literal["1d", "2d", "auto"] = Field("auto", description="The type of monitor.")
source: str | None = Field(None, description="The source of the curve.") source: str | None = Field(None, description="The source of the curve.")
color_map: str | None = Field("magma", description="The color map of the image.") color_map: str | None = Field("plasma", description="The color map of the image.")
downsample: bool | None = Field(True, description="Whether to downsample the image.") downsample: bool | None = Field(True, description="Whether to downsample the image.")
opacity: float | None = Field(1.0, description="The opacity of the image.") opacity: float | None = Field(1.0, description="The opacity of the image.")
v_range: tuple[float | int, float | int] | None = Field( v_range: tuple[float | int, float | int] | None = Field(

View File

@ -25,7 +25,7 @@ logger = bec_logger.logger
class MultiWaveformConfig(ConnectionConfig): class MultiWaveformConfig(ConnectionConfig):
color_palette: str | None = Field( color_palette: str | None = Field(
"magma", description="The color palette of the figure widget.", validate_default=True "plasma", description="The color palette of the figure widget.", validate_default=True
) )
curve_limit: int | None = Field( curve_limit: int | None = Field(
200, description="The maximum number of curves to display on the plot." 200, description="The maximum number of curves to display on the plot."
@ -308,7 +308,7 @@ class MultiWaveform(PlotBase):
################################################################################ ################################################################################
@SafeSlot(popup_error=True) @SafeSlot(popup_error=True)
def plot(self, monitor: str, color_palette: str | None = "magma"): def plot(self, monitor: str, color_palette: str | None = "plasma"):
""" """
Create a plot for the given monitor. Create a plot for the given monitor.
Args: Args:

View File

@ -40,7 +40,7 @@ class MultiWaveformSelectionToolbarBundle(ToolbarBundle):
self.add_action("monitor", WidgetAction(widget=self.monitor, adjust_size=False)) self.add_action("monitor", WidgetAction(widget=self.monitor, adjust_size=False))
# Colormap Selection # Colormap Selection
self.colormap_widget = BECColorMapWidget(cmap="magma", parent_id=self.target_widget.gui_id) self.colormap_widget = BECColorMapWidget(cmap="plasma", parent_id=self.target_widget.gui_id)
self.add_action("color_map", WidgetAction(widget=self.colormap_widget, adjust_size=False)) self.add_action("color_map", WidgetAction(widget=self.colormap_widget, adjust_size=False))
# Connect slots, a device will be connected upon change of any combobox # Connect slots, a device will be connected upon change of any combobox

View File

@ -38,7 +38,7 @@ class ScatterCurveConfig(ConnectionConfig):
"solid", description="The style of the pen of the curve." "solid", description="The style of the pen of the curve."
) )
color_map: str | None = Field( color_map: str | None = Field(
"magma", description="The color palette of the figure widget.", validate_default=True "plasma", description="The color palette of the figure widget.", validate_default=True
) )
x_device: ScatterDeviceSignal | None = Field( x_device: ScatterDeviceSignal | None = Field(
None, description="The x device signal of the scatter waveform." None, description="The x device signal of the scatter waveform."

View File

@ -30,7 +30,7 @@ logger = bec_logger.logger
# noinspection PyDataclass # noinspection PyDataclass
class ScatterWaveformConfig(ConnectionConfig): class ScatterWaveformConfig(ConnectionConfig):
color_map: str | None = Field( color_map: str | None = Field(
"magma", "plasma",
description="The color map of the z scaling of scatter waveform.", description="The color map of the z scaling of scatter waveform.",
validate_default=True, validate_default=True,
) )
@ -266,7 +266,7 @@ class ScatterWaveform(PlotBase):
x_entry: None | str = None, x_entry: None | str = None,
y_entry: None | str = None, y_entry: None | str = None,
z_entry: None | str = None, z_entry: None | str = None,
color_map: str | None = "magma", color_map: str | None = "plasma",
label: str | None = None, label: str | None = None,
validate_bec: bool = True, validate_bec: bool = True,
) -> ScatterCurve: ) -> ScatterCurve:

View File

@ -373,7 +373,7 @@ class CurveTree(BECWidget, QWidget):
if self.waveform and hasattr(self.waveform, "color_palette"): if self.waveform and hasattr(self.waveform, "color_palette"):
self.color_palette = self.waveform.color_palette self.color_palette = self.waveform.color_palette
else: else:
self.color_palette = "magma" self.color_palette = "plasma"
self.get_bec_shortcuts() self.get_bec_shortcuts()
@ -413,7 +413,7 @@ class CurveTree(BECWidget, QWidget):
self.toolbar.add_action("renormalize_colors", renorm_action, self) self.toolbar.add_action("renormalize_colors", renorm_action, self)
renorm_action.action.triggered.connect(lambda checked: self.renormalize_colors()) renorm_action.action.triggered.connect(lambda checked: self.renormalize_colors())
self.colormap_widget = BECColorMapWidget(cmap=self.color_palette or "magma") self.colormap_widget = BECColorMapWidget(cmap=self.color_palette or "plasma")
self.toolbar.addWidget(self.colormap_widget) self.toolbar.addWidget(self.colormap_widget)
self.colormap_widget.colormap_changed_signal.connect(self.handle_colormap_changed) self.colormap_widget.colormap_changed_signal.connect(self.handle_colormap_changed)

View File

@ -30,7 +30,7 @@ logger = bec_logger.logger
# noinspection PyDataclass # noinspection PyDataclass
class WaveformConfig(ConnectionConfig): class WaveformConfig(ConnectionConfig):
color_palette: str | None = Field( color_palette: str | None = Field(
"magma", description="The color palette of the figure widget.", validate_default=True "plasma", description="The color palette of the figure widget.", validate_default=True
) )
model_config: dict = {"validate_assignment": True} model_config: dict = {"validate_assignment": True}
@ -1748,12 +1748,10 @@ class Waveform(PlotBase):
self.proxy_dap_request.cleanup() self.proxy_dap_request.cleanup()
self.clear_all() self.clear_all()
if self.curve_settings_dialog is not None: if self.curve_settings_dialog is not None:
self.curve_settings_dialog.close() self.curve_settings_dialog.reject()
self.curve_settings_dialog.deleteLater()
self.curve_settings_dialog = None self.curve_settings_dialog = None
if self.dap_summary_dialog is not None: if self.dap_summary_dialog is not None:
self.dap_summary_dialog.close() self.dap_summary_dialog.reject()
self.dap_summary_dialog.deleteLater()
self.dap_summary_dialog = None self.dap_summary_dialog = None
super().cleanup() super().cleanup()

View File

@ -20,7 +20,7 @@ logger = bec_logger.logger
class RingProgressBarConfig(ConnectionConfig): class RingProgressBarConfig(ConnectionConfig):
color_map: Optional[str] = Field( color_map: Optional[str] = Field(
"magma", description="Color scheme for the progress bars.", validate_default=True "plasma", description="Color scheme for the progress bars.", validate_default=True
) )
min_number_of_bars: int | None = Field( min_number_of_bars: int | None = Field(
1, description="Minimum number of progress bars to display." 1, description="Minimum number of progress bars to display."

View File

@ -12,7 +12,7 @@ class BECColorMapWidget(BECWidget, QWidget):
PLUGIN = True PLUGIN = True
RPC = False RPC = False
def __init__(self, parent=None, cmap: str = "magma", **kwargs): def __init__(self, parent=None, cmap: str = "plasma", **kwargs):
super().__init__(parent=parent, **kwargs) super().__init__(parent=parent, **kwargs)
# Create the ColorMapButton # Create the ColorMapButton
self.button = ColorMapButton() self.button = ColorMapButton()

View File

@ -16,10 +16,10 @@ def test_color_map_widget_init(color_map_widget):
"""Test that the widget initializes correctly.""" """Test that the widget initializes correctly."""
assert color_map_widget is not None assert color_map_widget is not None
assert isinstance(color_map_widget, BECColorMapWidget) assert isinstance(color_map_widget, BECColorMapWidget)
assert color_map_widget.colormap == "magma" assert color_map_widget.colormap == "plasma"
assert isinstance(color_map_widget.button, ColorMapButton) assert isinstance(color_map_widget.button, ColorMapButton)
# Check that the button has the correct initial colormap # Check that the button has the correct initial colormap
assert color_map_widget.button.colorMap().name == "magma" assert color_map_widget.button.colorMap().name == "plasma"
def test_color_map_widget_set_valid_colormap(color_map_widget): def test_color_map_widget_set_valid_colormap(color_map_widget):
@ -44,7 +44,7 @@ def test_color_map_widget_set_invalid_colormap(color_map_widget):
def test_color_map_widget_signal_emitted(color_map_widget, qtbot): def test_color_map_widget_signal_emitted(color_map_widget, qtbot):
"""Test that the signal is emitted when the colormap changes.""" """Test that the signal is emitted when the colormap changes."""
new_cmap = "plasma" new_cmap = "magma"
with qtbot.waitSignal(color_map_widget.colormap_changed_signal, timeout=1000) as blocker: with qtbot.waitSignal(color_map_widget.colormap_changed_signal, timeout=1000) as blocker:
color_map_widget.colormap = new_cmap color_map_widget.colormap = new_cmap
assert blocker.signal_triggered assert blocker.signal_triggered
@ -58,7 +58,7 @@ def test_color_map_widget_signal_not_emitted_for_invalid_colormap(color_map_widg
with qtbot.assertNotEmitted(color_map_widget.colormap_changed_signal): with qtbot.assertNotEmitted(color_map_widget.colormap_changed_signal):
color_map_widget.colormap = invalid_cmap color_map_widget.colormap = invalid_cmap
# The colormap should remain unchanged # The colormap should remain unchanged
assert color_map_widget.colormap == "magma" assert color_map_widget.colormap == "plasma"
def test_color_map_widget_resize(color_map_widget): def test_color_map_widget_resize(color_map_widget):

View File

@ -142,7 +142,7 @@ def curve_tree_fixture(qtbot, mocked_client_with_dap):
Creates a CurveTree widget referencing a mocked or real Waveform. Creates a CurveTree widget referencing a mocked or real Waveform.
""" """
wf = create_widget(qtbot, Waveform, client=mocked_client_with_dap) wf = create_widget(qtbot, Waveform, client=mocked_client_with_dap)
wf.color_palette = "magma" wf.color_palette = "plasma"
curve_tree = create_widget(qtbot, CurveTree, parent=None, waveform=wf) curve_tree = create_widget(qtbot, CurveTree, parent=None, waveform=wf)
return curve_tree, wf return curve_tree, wf
@ -154,7 +154,7 @@ def test_curve_tree_init(curve_tree_fixture):
""" """
curve_tree, wf = curve_tree_fixture curve_tree, wf = curve_tree_fixture
assert curve_tree.waveform == wf assert curve_tree.waveform == wf
assert curve_tree.color_palette == "magma" assert curve_tree.color_palette == "plasma"
assert curve_tree.tree.columnCount() == 7 assert curve_tree.tree.columnCount() == 7
assert "add" in curve_tree.toolbar.widgets assert "add" in curve_tree.toolbar.widgets

View File

@ -13,7 +13,7 @@ from tests.unit_tests.conftest import create_widget
def test_initialization_defaults(qtbot, mocked_client): def test_initialization_defaults(qtbot, mocked_client):
bec_image_view = create_widget(qtbot, Image, client=mocked_client) bec_image_view = create_widget(qtbot, Image, client=mocked_client)
assert bec_image_view.color_map == "magma" assert bec_image_view.color_map == "plasma"
assert bec_image_view.autorange is True assert bec_image_view.autorange is True
assert bec_image_view.autorange_mode == "mean" assert bec_image_view.autorange_mode == "mean"
assert bec_image_view.config.lock_aspect_ratio is True assert bec_image_view.config.lock_aspect_ratio is True

View File

@ -25,7 +25,7 @@ def test_multiwaveform_initialization(qtbot, mocked_client):
assert len(mw.plot_item.curves) == 0 assert len(mw.plot_item.curves) == 0
# Multiwaveform specific # Multiwaveform specific
assert mw.monitor is None assert mw.monitor is None
assert mw.color_palette == "magma" assert mw.color_palette == "plasma"
assert mw.max_trace == 200 assert mw.max_trace == 200
assert mw.flush_buffer is False assert mw.flush_buffer is False
assert mw.highlight_last_curve is True assert mw.highlight_last_curve is True
@ -50,7 +50,7 @@ def test_multiwaveform_set_properties(qtbot, mocked_client):
mw = create_widget(qtbot, MultiWaveform, client=mocked_client) mw = create_widget(qtbot, MultiWaveform, client=mocked_client)
# Default checks # Default checks
assert mw.color_palette == "magma" assert mw.color_palette == "plasma"
assert mw.max_trace == 200 assert mw.max_trace == 200
assert mw.flush_buffer is False assert mw.flush_buffer is False
assert mw.highlight_last_curve is True assert mw.highlight_last_curve is True
@ -162,7 +162,7 @@ def test_multiwaveform_set_colormap(qtbot, mocked_client):
mw.on_monitor_1d_update(msg_data, metadata={"scan_id": "scan_1"}) mw.on_monitor_1d_update(msg_data, metadata={"scan_id": "scan_1"})
# Default color_palette is "magma" # Default color_palette is "magma"
assert mw.color_palette == "magma" assert mw.color_palette == "plasma"
# Now change to a new colormap # Now change to a new colormap
mw.color_palette = "viridis" mw.color_palette = "viridis"
assert mw.color_palette == "viridis" assert mw.color_palette == "viridis"

View File

@ -40,7 +40,7 @@ def test_scatter_waveform_plot(qtbot, mocked_client):
def test_scatter_waveform_color_map(qtbot, mocked_client): def test_scatter_waveform_color_map(qtbot, mocked_client):
swf = create_widget(qtbot, ScatterWaveform, client=mocked_client) swf = create_widget(qtbot, ScatterWaveform, client=mocked_client)
assert swf.color_map == "magma" assert swf.color_map == "plasma"
swf.color_map = "plasma" swf.color_map = "plasma"
assert swf.color_map == "plasma" assert swf.color_map == "plasma"

View File

@ -180,8 +180,8 @@ def test_color_palette_update(qtbot, mocked_client):
curve = wf.plot(x=[1, 2, 3], y=[4, 5, 6], label="test_curve") curve = wf.plot(x=[1, 2, 3], y=[4, 5, 6], label="test_curve")
original_color = curve.config.color original_color = curve.config.color
# Change to a different valid palette # Change to a different valid palette
wf.color_palette = "plasma" wf.color_palette = "magma"
assert wf.config.color_palette == "plasma" assert wf.config.color_palette == "magma"
# After updating the palette, the curve's color should be re-generated. # After updating the palette, the curve's color should be re-generated.
assert curve.config.color != original_color assert curve.config.color != original_color