bec-widgets 1.25.1__py3-none-any.whl → 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- .gitlab-ci.yml +3 -5
- CHANGELOG.md +631 -0
- PKG-INFO +3 -3
- bec_widgets/__init__.py +4 -0
- bec_widgets/applications/bw_launch.py +23 -0
- bec_widgets/applications/launch_window.py +430 -0
- bec_widgets/assets/app_icons/auto_update.png +0 -0
- bec_widgets/assets/app_icons/ui_loader_tile.png +0 -0
- bec_widgets/cli/__init__.py +0 -1
- bec_widgets/cli/client.py +1779 -2064
- bec_widgets/cli/client_utils.py +346 -174
- bec_widgets/cli/generate_cli.py +143 -37
- bec_widgets/cli/rpc/rpc_base.py +152 -21
- bec_widgets/cli/rpc/rpc_register.py +113 -6
- bec_widgets/cli/rpc/rpc_widget_handler.py +13 -11
- bec_widgets/cli/server.py +125 -239
- bec_widgets/examples/jupyter_console/jupyter_console_window.py +97 -145
- bec_widgets/examples/plugin_example_pyside/tictactoetaskmenu.py +1 -1
- bec_widgets/utils/bec_connector.py +190 -21
- bec_widgets/utils/bec_designer.py +7 -0
- bec_widgets/utils/bec_dispatcher.py +71 -4
- bec_widgets/utils/bec_plugin_helper.py +89 -0
- bec_widgets/utils/bec_signal_proxy.py +1 -1
- bec_widgets/utils/bec_widget.py +26 -10
- bec_widgets/utils/colors.py +1 -1
- bec_widgets/{qt_utils → utils}/compact_popup.py +2 -0
- bec_widgets/utils/container_utils.py +37 -12
- bec_widgets/utils/crosshair.py +25 -8
- bec_widgets/utils/entry_validator.py +3 -1
- bec_widgets/{qt_utils → utils}/error_popups.py +18 -0
- bec_widgets/{qt_utils → utils}/expandable_frame.py +2 -2
- bec_widgets/utils/forms_from_types/forms.py +182 -0
- bec_widgets/{widgets/editors/scan_metadata/_metadata_widgets.py → utils/forms_from_types/items.py} +41 -30
- bec_widgets/utils/generate_designer_plugin.py +40 -36
- bec_widgets/utils/linear_region_selector.py +2 -0
- bec_widgets/utils/name_utils.py +16 -0
- bec_widgets/{qt_utils → utils}/palette_viewer.py +2 -2
- bec_widgets/utils/plot_indicator_items.py +2 -5
- bec_widgets/utils/plugin_utils.py +47 -1
- bec_widgets/{qt_utils → utils}/round_frame.py +14 -14
- bec_widgets/utils/rpc_server.py +277 -0
- bec_widgets/utils/serialization.py +44 -0
- bec_widgets/{qt_utils → utils}/settings_dialog.py +26 -1
- bec_widgets/{qt_utils → utils}/side_panel.py +17 -10
- bec_widgets/{qt_utils → utils}/toolbar.py +69 -25
- bec_widgets/utils/ui_loader.py +8 -8
- bec_widgets/utils/widget_io.py +166 -25
- bec_widgets/widgets/containers/auto_update/auto_updates.py +364 -0
- bec_widgets/widgets/containers/dock/dock.py +157 -49
- bec_widgets/widgets/containers/dock/dock_area.py +186 -138
- bec_widgets/widgets/containers/layout_manager/layout_manager.py +2 -1
- bec_widgets/widgets/containers/main_window/addons/web_links.py +15 -0
- bec_widgets/widgets/containers/main_window/main_window.py +189 -41
- bec_widgets/widgets/control/buttons/button_abort/button_abort.py +3 -4
- bec_widgets/widgets/control/buttons/button_reset/button_reset.py +3 -4
- bec_widgets/widgets/control/buttons/button_resume/button_resume.py +3 -3
- bec_widgets/widgets/control/buttons/stop_button/stop_button.py +18 -7
- bec_widgets/widgets/control/device_control/position_indicator/position_indicator.py +22 -3
- bec_widgets/widgets/control/device_control/positioner_box/_base/positioner_box_base.py +31 -13
- bec_widgets/widgets/control/device_control/positioner_box/positioner_box/positioner_box.py +3 -1
- bec_widgets/widgets/control/device_control/positioner_box/positioner_box/positioner_box.ui +27 -4
- bec_widgets/widgets/control/device_control/positioner_box/positioner_box_2d/positioner_box_2d.py +5 -2
- bec_widgets/widgets/control/device_control/positioner_box/positioner_box_2d/positioner_box_2d.ui +97 -31
- bec_widgets/widgets/control/device_control/positioner_box/positioner_control_line/positioner_control_line.ui +11 -4
- bec_widgets/widgets/control/device_control/positioner_group/positioner_group.py +2 -3
- bec_widgets/widgets/control/device_input/base_classes/device_input_base.py +29 -4
- bec_widgets/widgets/control/device_input/base_classes/device_signal_input_base.py +1 -0
- bec_widgets/widgets/control/device_input/device_combobox/device_combobox.py +2 -2
- bec_widgets/widgets/control/device_input/device_line_edit/device_line_edit.py +2 -2
- bec_widgets/widgets/control/device_input/signal_combobox/signal_combobox.py +1 -2
- bec_widgets/widgets/control/device_input/signal_line_edit/signal_line_edit.py +1 -2
- bec_widgets/widgets/control/scan_control/scan_control.py +7 -5
- bec_widgets/widgets/control/scan_control/scan_group_box.py +28 -5
- bec_widgets/widgets/dap/dap_combo_box/dap_combo_box.py +1 -2
- bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog.py +3 -4
- bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog_vertical.ui +14 -8
- bec_widgets/widgets/editors/console/console.py +1 -1
- bec_widgets/widgets/editors/{scan_metadata/additional_metadata_table.py → dict_backed_table.py} +29 -6
- bec_widgets/widgets/editors/scan_metadata/__init__.py +0 -7
- bec_widgets/widgets/editors/scan_metadata/_util.py +1 -1
- bec_widgets/widgets/{plots/motor_map/register_bec_motor_map_widget.py → editors/scan_metadata/register_scan_metadata.py} +2 -4
- bec_widgets/widgets/editors/scan_metadata/scan_metadata.py +42 -136
- bec_widgets/widgets/editors/scan_metadata/scan_metadata.pyproject +1 -0
- bec_widgets/widgets/{plots/multi_waveform/bec_multi_waveform_widget_plugin.py → editors/scan_metadata/scan_metadata_plugin.py} +9 -9
- bec_widgets/widgets/editors/text_box/text_box.py +2 -3
- bec_widgets/widgets/editors/website/website.py +2 -2
- bec_widgets/widgets/games/minesweeper.py +3 -2
- bec_widgets/widgets/plots/image/image.py +960 -0
- bec_widgets/widgets/plots/image/image.pyproject +1 -0
- bec_widgets/widgets/plots/image/image_item.py +279 -0
- bec_widgets/widgets/plots/{motor_map/bec_motor_map_widget_plugin.py → image/image_plugin.py} +11 -13
- bec_widgets/widgets/{containers/figure/plots → plots}/image/image_processor.py +31 -64
- bec_widgets/widgets/plots/image/{register_bec_image_widget.py → register_image.py} +2 -2
- bec_widgets/widgets/plots/image/toolbar_bundles/image_selection.py +59 -0
- bec_widgets/widgets/plots/image/toolbar_bundles/processing.py +79 -0
- bec_widgets/widgets/plots/motor_map/motor_map.py +832 -0
- bec_widgets/widgets/plots/motor_map/motor_map.pyproject +1 -0
- bec_widgets/widgets/plots/motor_map/motor_map_plugin.py +54 -0
- bec_widgets/widgets/plots/{multi_waveform/register_bec_multi_waveform_widget.py → motor_map/register_motor_map.py} +2 -4
- bec_widgets/widgets/plots/motor_map/settings/motor_map_settings.py +129 -0
- bec_widgets/widgets/plots/motor_map/settings/motor_map_settings.ui +120 -0
- bec_widgets/widgets/plots/motor_map/toolbar_bundles/motor_selection.py +70 -0
- bec_widgets/widgets/plots/multi_waveform/multi_waveform.py +508 -0
- bec_widgets/widgets/plots/multi_waveform/multi_waveform.pyproject +1 -0
- bec_widgets/widgets/plots/multi_waveform/multi_waveform_plugin.py +54 -0
- bec_widgets/widgets/plots/multi_waveform/register_multi_waveform.py +15 -0
- bec_widgets/widgets/plots/multi_waveform/settings/control_panel.py +144 -0
- bec_widgets/widgets/plots/multi_waveform/settings/multi_waveform_controls.ui +164 -0
- bec_widgets/widgets/plots/multi_waveform/toolbar_bundles/monitor_selection.py +65 -0
- bec_widgets/widgets/{plots_next_gen → plots}/plot_base.py +321 -40
- bec_widgets/widgets/plots/{waveform/register_bec_waveform_widget.py → scatter_waveform/register_scatter_waveform.py} +3 -3
- bec_widgets/widgets/plots/scatter_waveform/scatter_curve.py +197 -0
- bec_widgets/widgets/plots/scatter_waveform/scatter_waveform.py +553 -0
- bec_widgets/widgets/plots/scatter_waveform/scatter_waveform.pyproject +1 -0
- bec_widgets/widgets/plots/{image/bec_image_widget_plugin.py → scatter_waveform/scatter_waveform_plugin.py} +9 -13
- bec_widgets/widgets/plots/scatter_waveform/settings/scatter_curve_setting.py +138 -0
- bec_widgets/widgets/plots/scatter_waveform/settings/scatter_curve_settings_horizontal.ui +195 -0
- bec_widgets/widgets/plots/scatter_waveform/settings/scatter_curve_settings_vertical.ui +204 -0
- bec_widgets/widgets/{plots_next_gen → plots}/setting_menus/axis_settings.py +8 -8
- bec_widgets/widgets/{plots_next_gen → plots}/toolbar_bundles/mouse_interactions.py +4 -18
- bec_widgets/widgets/{plots_next_gen → plots}/toolbar_bundles/plot_export.py +14 -3
- bec_widgets/widgets/{plots_next_gen → plots}/toolbar_bundles/roi_bundle.py +6 -1
- bec_widgets/widgets/{plots_next_gen → plots}/toolbar_bundles/save_state.py +2 -2
- bec_widgets/widgets/{containers/figure/plots/waveform/waveform_curve.py → plots/waveform/curve.py} +119 -49
- bec_widgets/widgets/plots/waveform/register_waveform.py +15 -0
- bec_widgets/widgets/plots/waveform/settings/curve_settings/curve_setting.py +125 -0
- bec_widgets/widgets/plots/waveform/settings/curve_settings/curve_tree.py +576 -0
- bec_widgets/widgets/plots/waveform/utils/__init__.py +0 -0
- bec_widgets/widgets/plots/waveform/utils/roi_manager.py +84 -0
- bec_widgets/widgets/plots/waveform/waveform.py +1794 -0
- bec_widgets/widgets/plots/waveform/waveform.pyproject +1 -0
- bec_widgets/widgets/plots/waveform/{bec_waveform_widget_plugin.py → waveform_plugin.py} +9 -13
- bec_widgets/widgets/progress/bec_progressbar/bec_progressbar.py +1 -2
- bec_widgets/widgets/progress/ring_progress_bar/ring.py +11 -10
- bec_widgets/widgets/progress/ring_progress_bar/ring_progress_bar.py +24 -14
- bec_widgets/widgets/services/bec_queue/bec_queue.py +13 -11
- bec_widgets/widgets/services/bec_status_box/bec_status_box.py +3 -4
- bec_widgets/widgets/services/device_browser/device_browser.py +5 -2
- bec_widgets/widgets/services/device_browser/device_item/device_item.py +1 -1
- bec_widgets/widgets/utility/logpanel/logpanel.py +36 -17
- bec_widgets/widgets/utility/spinbox/decimal_spinbox.py +3 -3
- bec_widgets/widgets/utility/visual/color_button/color_button.py +1 -1
- bec_widgets/widgets/utility/visual/colormap_widget/colormap_widget.py +4 -6
- bec_widgets/widgets/utility/visual/dark_mode_button/dark_mode_button.py +4 -8
- {bec_widgets-1.25.1.dist-info → bec_widgets-2.0.0.dist-info}/METADATA +3 -3
- {bec_widgets-1.25.1.dist-info → bec_widgets-2.0.0.dist-info}/RECORD +168 -153
- pyproject.toml +3 -3
- bec_widgets/applications/alignment/alignment_1d/alignment_1d.py +0 -198
- bec_widgets/applications/alignment/alignment_1d/alignment_1d.ui +0 -615
- bec_widgets/applications/bec_app.py +0 -84
- bec_widgets/cli/auto_updates.py +0 -168
- bec_widgets/widgets/containers/figure/__init__.py +0 -1
- bec_widgets/widgets/containers/figure/figure.py +0 -796
- bec_widgets/widgets/containers/figure/plots/axis_settings.py +0 -91
- bec_widgets/widgets/containers/figure/plots/axis_settings.ui +0 -256
- bec_widgets/widgets/containers/figure/plots/image/image.py +0 -772
- bec_widgets/widgets/containers/figure/plots/image/image_item.py +0 -337
- bec_widgets/widgets/containers/figure/plots/motor_map/motor_map.py +0 -525
- bec_widgets/widgets/containers/figure/plots/multi_waveform/multi_waveform.py +0 -340
- bec_widgets/widgets/containers/figure/plots/plot_base.py +0 -505
- bec_widgets/widgets/containers/figure/plots/waveform/waveform.py +0 -1563
- bec_widgets/widgets/plots/image/bec_image_widget.pyproject +0 -1
- bec_widgets/widgets/plots/image/image_widget.py +0 -515
- bec_widgets/widgets/plots/motor_map/bec_motor_map_widget.pyproject +0 -1
- bec_widgets/widgets/plots/motor_map/motor_map_dialog/motor_map_settings.py +0 -56
- bec_widgets/widgets/plots/motor_map/motor_map_dialog/motor_map_settings.ui +0 -108
- bec_widgets/widgets/plots/motor_map/motor_map_widget.py +0 -234
- bec_widgets/widgets/plots/multi_waveform/bec_multi_waveform_widget.pyproject +0 -1
- bec_widgets/widgets/plots/multi_waveform/multi_waveform_controls.ui +0 -99
- bec_widgets/widgets/plots/multi_waveform/multi_waveform_widget.py +0 -536
- bec_widgets/widgets/plots/waveform/bec_waveform_widget.pyproject +0 -1
- bec_widgets/widgets/plots/waveform/waveform_popups/curve_dialog/curve_dialog.py +0 -336
- bec_widgets/widgets/plots/waveform/waveform_popups/curve_dialog/curve_dialog.ui +0 -372
- bec_widgets/widgets/plots/waveform/waveform_popups/dap_summary_dialog/dap_summary_dialog.py +0 -25
- bec_widgets/widgets/plots/waveform/waveform_widget.py +0 -751
- /bec_widgets/{qt_utils → utils}/collapsible_panel_manager.py +0 -0
- /bec_widgets/{applications/alignment → utils/forms_from_types}/__init__.py +0 -0
- /bec_widgets/{qt_utils → utils}/redis_message_waiter.py +0 -0
- /bec_widgets/{applications/alignment/alignment_1d → widgets/containers/auto_update}/__init__.py +0 -0
- /bec_widgets/{qt_utils → widgets/containers/main_window/addons}/__init__.py +0 -0
- /bec_widgets/widgets/{containers/figure/plots → plots/image/toolbar_bundles}/__init__.py +0 -0
- /bec_widgets/widgets/{containers/figure/plots/image → plots/motor_map/settings}/__init__.py +0 -0
- /bec_widgets/widgets/{containers/figure/plots/motor_map → plots/motor_map/toolbar_bundles}/__init__.py +0 -0
- /bec_widgets/widgets/{containers/figure/plots/multi_waveform → plots/multi_waveform/settings}/__init__.py +0 -0
- /bec_widgets/widgets/{containers/figure/plots/waveform → plots/multi_waveform/toolbar_bundles}/__init__.py +0 -0
- /bec_widgets/widgets/plots/{motor_map/motor_map_dialog → scatter_waveform}/__init__.py +0 -0
- /bec_widgets/widgets/plots/{waveform/waveform_popups → scatter_waveform/settings}/__init__.py +0 -0
- /bec_widgets/widgets/plots/{waveform/waveform_popups/curve_dialog → setting_menus}/__init__.py +0 -0
- /bec_widgets/widgets/{plots_next_gen → plots}/setting_menus/axis_settings_horizontal.ui +0 -0
- /bec_widgets/widgets/{plots_next_gen → plots}/setting_menus/axis_settings_vertical.ui +0 -0
- /bec_widgets/widgets/plots/{waveform/waveform_popups/dap_summary_dialog → toolbar_bundles}/__init__.py +0 -0
- /bec_widgets/widgets/{plots_next_gen/setting_menus → plots/waveform/settings}/__init__.py +0 -0
- /bec_widgets/widgets/{plots_next_gen/toolbar_bundles → plots/waveform/settings/curve_settings}/__init__.py +0 -0
- {bec_widgets-1.25.1.dist-info → bec_widgets-2.0.0.dist-info}/WHEEL +0 -0
- {bec_widgets-1.25.1.dist-info → bec_widgets-2.0.0.dist-info}/entry_points.txt +0 -0
- {bec_widgets-1.25.1.dist-info → bec_widgets-2.0.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,337 +0,0 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
|
-
from typing import TYPE_CHECKING, Literal, Optional
|
4
|
-
|
5
|
-
import numpy as np
|
6
|
-
import pyqtgraph as pg
|
7
|
-
from bec_lib.logger import bec_logger
|
8
|
-
from pydantic import Field
|
9
|
-
|
10
|
-
from bec_widgets.utils import BECConnector, ConnectionConfig
|
11
|
-
from bec_widgets.widgets.containers.figure.plots.image.image_processor import (
|
12
|
-
ImageStats,
|
13
|
-
ProcessingConfig,
|
14
|
-
)
|
15
|
-
|
16
|
-
if TYPE_CHECKING:
|
17
|
-
from bec_widgets.widgets.containers.figure.plots.image.image import BECImageShow
|
18
|
-
|
19
|
-
logger = bec_logger.logger
|
20
|
-
|
21
|
-
|
22
|
-
class ImageItemConfig(ConnectionConfig):
|
23
|
-
parent_id: Optional[str] = Field(None, description="The parent plot of the image.")
|
24
|
-
monitor: Optional[str] = Field(None, description="The name of the monitor.")
|
25
|
-
source: Optional[str] = Field(None, description="The source of the curve.")
|
26
|
-
color_map: Optional[str] = Field("magma", description="The color map of the image.")
|
27
|
-
downsample: Optional[bool] = Field(True, description="Whether to downsample the image.")
|
28
|
-
opacity: Optional[float] = Field(1.0, description="The opacity of the image.")
|
29
|
-
vrange: Optional[tuple[float | int, float | int]] = Field(
|
30
|
-
None, description="The range of the color bar. If None, the range is automatically set."
|
31
|
-
)
|
32
|
-
color_bar: Optional[Literal["simple", "full"]] = Field(
|
33
|
-
"simple", description="The type of the color bar."
|
34
|
-
)
|
35
|
-
autorange: Optional[bool] = Field(True, description="Whether to autorange the color bar.")
|
36
|
-
autorange_mode: Optional[Literal["max", "mean"]] = Field(
|
37
|
-
"mean", description="Whether to use the mean of the image for autoscaling."
|
38
|
-
)
|
39
|
-
processing: ProcessingConfig = Field(
|
40
|
-
default_factory=ProcessingConfig, description="The post processing of the image."
|
41
|
-
)
|
42
|
-
|
43
|
-
|
44
|
-
class BECImageItem(BECConnector, pg.ImageItem):
|
45
|
-
USER_ACCESS = [
|
46
|
-
"_rpc_id",
|
47
|
-
"_config_dict",
|
48
|
-
"set",
|
49
|
-
"set_fft",
|
50
|
-
"set_log",
|
51
|
-
"set_rotation",
|
52
|
-
"set_transpose",
|
53
|
-
"set_opacity",
|
54
|
-
"set_autorange",
|
55
|
-
"set_autorange_mode",
|
56
|
-
"set_color_map",
|
57
|
-
"set_auto_downsample",
|
58
|
-
"set_monitor",
|
59
|
-
"set_vrange",
|
60
|
-
"get_data",
|
61
|
-
]
|
62
|
-
|
63
|
-
def __init__(
|
64
|
-
self,
|
65
|
-
config: Optional[ImageItemConfig] = None,
|
66
|
-
gui_id: Optional[str] = None,
|
67
|
-
parent_image: Optional[BECImageShow] = None,
|
68
|
-
**kwargs,
|
69
|
-
):
|
70
|
-
if config is None:
|
71
|
-
config = ImageItemConfig(widget_class=self.__class__.__name__)
|
72
|
-
self.config = config
|
73
|
-
else:
|
74
|
-
self.config = config
|
75
|
-
super().__init__(config=config, gui_id=gui_id, **kwargs)
|
76
|
-
pg.ImageItem.__init__(self)
|
77
|
-
|
78
|
-
self.parent_image = parent_image
|
79
|
-
self.colorbar_bar = None
|
80
|
-
self._raw_data = None
|
81
|
-
|
82
|
-
self._add_color_bar(
|
83
|
-
self.config.color_bar, self.config.vrange
|
84
|
-
) # TODO can also support None to not have any colorbar
|
85
|
-
self.apply_config()
|
86
|
-
if kwargs:
|
87
|
-
self.set(**kwargs)
|
88
|
-
self.connected = False
|
89
|
-
|
90
|
-
@property
|
91
|
-
def raw_data(self) -> np.ndarray:
|
92
|
-
return self._raw_data
|
93
|
-
|
94
|
-
@raw_data.setter
|
95
|
-
def raw_data(self, data: np.ndarray):
|
96
|
-
self._raw_data = data
|
97
|
-
|
98
|
-
def apply_config(self):
|
99
|
-
"""
|
100
|
-
Apply current configuration.
|
101
|
-
"""
|
102
|
-
self.set_color_map(self.config.color_map)
|
103
|
-
self.set_auto_downsample(self.config.downsample)
|
104
|
-
if self.config.vrange is not None:
|
105
|
-
self.set_vrange(vrange=self.config.vrange)
|
106
|
-
|
107
|
-
def set(self, **kwargs):
|
108
|
-
"""
|
109
|
-
Set the properties of the image.
|
110
|
-
|
111
|
-
Args:
|
112
|
-
**kwargs: Keyword arguments for the properties to be set.
|
113
|
-
|
114
|
-
Possible properties:
|
115
|
-
- downsample
|
116
|
-
- color_map
|
117
|
-
- monitor
|
118
|
-
- opacity
|
119
|
-
- vrange
|
120
|
-
- fft
|
121
|
-
- log
|
122
|
-
- rot
|
123
|
-
- transpose
|
124
|
-
- autorange_mode
|
125
|
-
"""
|
126
|
-
method_map = {
|
127
|
-
"downsample": self.set_auto_downsample,
|
128
|
-
"color_map": self.set_color_map,
|
129
|
-
"monitor": self.set_monitor,
|
130
|
-
"opacity": self.set_opacity,
|
131
|
-
"vrange": self.set_vrange,
|
132
|
-
"fft": self.set_fft,
|
133
|
-
"log": self.set_log,
|
134
|
-
"rot": self.set_rotation,
|
135
|
-
"transpose": self.set_transpose,
|
136
|
-
"autorange_mode": self.set_autorange_mode,
|
137
|
-
}
|
138
|
-
for key, value in kwargs.items():
|
139
|
-
if key in method_map:
|
140
|
-
method_map[key](value)
|
141
|
-
else:
|
142
|
-
logger.warning(f"Warning: '{key}' is not a recognized property.")
|
143
|
-
|
144
|
-
def set_fft(self, enable: bool = False):
|
145
|
-
"""
|
146
|
-
Set the FFT of the image.
|
147
|
-
|
148
|
-
Args:
|
149
|
-
enable(bool): Whether to perform FFT on the monitor data.
|
150
|
-
"""
|
151
|
-
self.config.processing.fft = enable
|
152
|
-
|
153
|
-
def set_log(self, enable: bool = False):
|
154
|
-
"""
|
155
|
-
Set the log of the image.
|
156
|
-
|
157
|
-
Args:
|
158
|
-
enable(bool): Whether to perform log on the monitor data.
|
159
|
-
"""
|
160
|
-
self.config.processing.log = enable
|
161
|
-
if enable and self.color_bar and self.config.color_bar == "full":
|
162
|
-
self.color_bar.autoHistogramRange()
|
163
|
-
|
164
|
-
def set_rotation(self, deg_90: int = 0):
|
165
|
-
"""
|
166
|
-
Set the rotation of the image.
|
167
|
-
|
168
|
-
Args:
|
169
|
-
deg_90(int): The rotation angle of the monitor data before displaying.
|
170
|
-
"""
|
171
|
-
self.config.processing.rotation = deg_90
|
172
|
-
|
173
|
-
def set_transpose(self, enable: bool = False):
|
174
|
-
"""
|
175
|
-
Set the transpose of the image.
|
176
|
-
|
177
|
-
Args:
|
178
|
-
enable(bool): Whether to transpose the image.
|
179
|
-
"""
|
180
|
-
self.config.processing.transpose = enable
|
181
|
-
|
182
|
-
def set_opacity(self, opacity: float = 1.0):
|
183
|
-
"""
|
184
|
-
Set the opacity of the image.
|
185
|
-
|
186
|
-
Args:
|
187
|
-
opacity(float): The opacity of the image.
|
188
|
-
"""
|
189
|
-
self.setOpacity(opacity)
|
190
|
-
self.config.opacity = opacity
|
191
|
-
|
192
|
-
def set_autorange(self, autorange: bool = False):
|
193
|
-
"""
|
194
|
-
Set the autorange of the color bar.
|
195
|
-
|
196
|
-
Args:
|
197
|
-
autorange(bool): Whether to autorange the color bar.
|
198
|
-
"""
|
199
|
-
self.config.autorange = autorange
|
200
|
-
if self.color_bar and autorange:
|
201
|
-
self.color_bar.autoHistogramRange()
|
202
|
-
|
203
|
-
def set_autorange_mode(self, mode: Literal["max", "mean"] = "mean"):
|
204
|
-
"""
|
205
|
-
Set the autorange mode to scale the vrange of the color bar. Choose between min/max or mean +/- std.
|
206
|
-
|
207
|
-
Args:
|
208
|
-
mode(Literal["max","mean"]): Max for min/max or mean for mean +/- std.
|
209
|
-
"""
|
210
|
-
self.config.autorange_mode = mode
|
211
|
-
|
212
|
-
def set_color_map(self, cmap: str = "magma"):
|
213
|
-
"""
|
214
|
-
Set the color map of the image.
|
215
|
-
|
216
|
-
Args:
|
217
|
-
cmap(str): The color map of the image.
|
218
|
-
"""
|
219
|
-
self.setColorMap(cmap)
|
220
|
-
if self.color_bar is not None:
|
221
|
-
if self.config.color_bar == "simple":
|
222
|
-
self.color_bar.setColorMap(cmap)
|
223
|
-
elif self.config.color_bar == "full":
|
224
|
-
self.color_bar.gradient.loadPreset(cmap)
|
225
|
-
self.config.color_map = cmap
|
226
|
-
|
227
|
-
def set_auto_downsample(self, auto: bool = True):
|
228
|
-
"""
|
229
|
-
Set the auto downsample of the image.
|
230
|
-
|
231
|
-
Args:
|
232
|
-
auto(bool): Whether to downsample the image.
|
233
|
-
"""
|
234
|
-
self.setAutoDownsample(auto)
|
235
|
-
self.config.downsample = auto
|
236
|
-
|
237
|
-
def set_monitor(self, monitor: str):
|
238
|
-
"""
|
239
|
-
Set the monitor of the image.
|
240
|
-
|
241
|
-
Args:
|
242
|
-
monitor(str): The name of the monitor.
|
243
|
-
"""
|
244
|
-
self.config.monitor = monitor
|
245
|
-
|
246
|
-
def auto_update_vrange(self, stats: ImageStats) -> None:
|
247
|
-
"""Auto update of the vrange base on the stats of the image.
|
248
|
-
|
249
|
-
Args:
|
250
|
-
stats(ImageStats): The stats of the image.
|
251
|
-
"""
|
252
|
-
fumble_factor = 2
|
253
|
-
if self.config.autorange_mode == "mean":
|
254
|
-
vmin = max(stats.mean - fumble_factor * stats.std, 0)
|
255
|
-
vmax = stats.mean + fumble_factor * stats.std
|
256
|
-
self.set_vrange(vmin, vmax, change_autorange=False)
|
257
|
-
return
|
258
|
-
if self.config.autorange_mode == "max":
|
259
|
-
self.set_vrange(max(stats.minimum, 0), stats.maximum, change_autorange=False)
|
260
|
-
return
|
261
|
-
|
262
|
-
def set_vrange(
|
263
|
-
self,
|
264
|
-
vmin: float = None,
|
265
|
-
vmax: float = None,
|
266
|
-
vrange: tuple[float, float] = None,
|
267
|
-
change_autorange: bool = True,
|
268
|
-
):
|
269
|
-
"""
|
270
|
-
Set the range of the color bar.
|
271
|
-
|
272
|
-
Args:
|
273
|
-
vmin(float): Minimum value of the color bar.
|
274
|
-
vmax(float): Maximum value of the color bar.
|
275
|
-
"""
|
276
|
-
if vrange is not None:
|
277
|
-
vmin, vmax = vrange
|
278
|
-
self.setLevels([vmin, vmax])
|
279
|
-
self.config.vrange = (vmin, vmax)
|
280
|
-
if change_autorange:
|
281
|
-
self.config.autorange = False
|
282
|
-
if self.color_bar is not None:
|
283
|
-
if self.config.color_bar == "simple":
|
284
|
-
self.color_bar.setLevels(low=vmin, high=vmax)
|
285
|
-
elif self.config.color_bar == "full":
|
286
|
-
# pylint: disable=unexpected-keyword-arg
|
287
|
-
self.color_bar.setLevels(min=vmin, max=vmax)
|
288
|
-
self.color_bar.setHistogramRange(vmin - 0.1 * vmin, vmax + 0.1 * vmax)
|
289
|
-
|
290
|
-
def get_data(self) -> np.ndarray:
|
291
|
-
"""
|
292
|
-
Get the data of the image.
|
293
|
-
Returns:
|
294
|
-
np.ndarray: The data of the image.
|
295
|
-
"""
|
296
|
-
return self.image
|
297
|
-
|
298
|
-
def _add_color_bar(
|
299
|
-
self, color_bar_style: str = "simple", vrange: Optional[tuple[int, int]] = None
|
300
|
-
):
|
301
|
-
"""
|
302
|
-
Add color bar to the layout.
|
303
|
-
|
304
|
-
Args:
|
305
|
-
style(Literal["simple,full"]): The style of the color bar.
|
306
|
-
vrange(tuple[int,int]): The range of the color bar.
|
307
|
-
"""
|
308
|
-
if color_bar_style == "simple":
|
309
|
-
self.color_bar = pg.ColorBarItem(colorMap=self.config.color_map)
|
310
|
-
if vrange is not None:
|
311
|
-
self.color_bar.setLevels(low=vrange[0], high=vrange[1])
|
312
|
-
self.color_bar.setImageItem(self)
|
313
|
-
self.parent_image.addItem(self.color_bar, row=1, col=1)
|
314
|
-
self.config.color_bar = "simple"
|
315
|
-
elif color_bar_style == "full":
|
316
|
-
# Setting histogram
|
317
|
-
self.color_bar = pg.HistogramLUTItem()
|
318
|
-
self.color_bar.setImageItem(self)
|
319
|
-
self.color_bar.gradient.loadPreset(self.config.color_map)
|
320
|
-
if vrange is not None:
|
321
|
-
self.color_bar.setLevels(min=vrange[0], max=vrange[1])
|
322
|
-
self.color_bar.setHistogramRange(
|
323
|
-
vrange[0] - 0.1 * vrange[0], vrange[1] + 0.1 * vrange[1]
|
324
|
-
)
|
325
|
-
|
326
|
-
# Adding histogram to the layout
|
327
|
-
self.parent_image.addItem(self.color_bar, row=1, col=1)
|
328
|
-
|
329
|
-
# save settings
|
330
|
-
self.config.color_bar = "full"
|
331
|
-
else:
|
332
|
-
raise ValueError("style should be 'simple' or 'full'")
|
333
|
-
|
334
|
-
def remove(self):
|
335
|
-
"""Remove the curve from the plot."""
|
336
|
-
self.parent_image.remove_image(self.config.monitor)
|
337
|
-
self.rpc_register.remove_rpc(self)
|