bec-widgets 0.89.0__py3-none-any.whl → 0.91.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.
Files changed (116) hide show
  1. CHANGELOG.md +50 -52
  2. PKG-INFO +1 -1
  3. bec_widgets/assets/designer_icons/code.png +0 -0
  4. bec_widgets/assets/designer_icons/color_button.png +0 -0
  5. bec_widgets/assets/designer_icons/device_box.png +0 -0
  6. bec_widgets/assets/designer_icons/device_combo_box.png +0 -0
  7. bec_widgets/assets/designer_icons/device_line_edit.png +0 -0
  8. bec_widgets/assets/designer_icons/dock_area.png +0 -0
  9. bec_widgets/assets/designer_icons/games.png +0 -0
  10. bec_widgets/assets/designer_icons/image.png +0 -0
  11. bec_widgets/assets/designer_icons/position_indicator.png +0 -0
  12. bec_widgets/assets/designer_icons/queue.png +0 -0
  13. bec_widgets/assets/designer_icons/ring_progress.png +0 -0
  14. bec_widgets/assets/designer_icons/scan_control.png +0 -0
  15. bec_widgets/assets/designer_icons/spinner.png +0 -0
  16. bec_widgets/assets/designer_icons/status.png +0 -0
  17. bec_widgets/assets/designer_icons/stop.png +0 -0
  18. bec_widgets/assets/designer_icons/text.png +0 -0
  19. bec_widgets/assets/designer_icons/toggle.png +0 -0
  20. bec_widgets/assets/designer_icons/web.png +0 -0
  21. bec_widgets/assets/status_icons/error.svg +3 -0
  22. bec_widgets/assets/status_icons/not_connected.svg +3 -0
  23. bec_widgets/assets/status_icons/refresh.svg +3 -0
  24. bec_widgets/assets/status_icons/running.svg +3 -0
  25. bec_widgets/assets/status_icons/warning.svg +3 -0
  26. bec_widgets/assets/toolbar_icons/attach_all.svg +3 -0
  27. bec_widgets/assets/toolbar_icons/auto_range.svg +1 -1
  28. bec_widgets/assets/toolbar_icons/compare.svg +3 -0
  29. bec_widgets/assets/toolbar_icons/device_box.svg +3 -0
  30. bec_widgets/assets/toolbar_icons/fft.svg +11 -0
  31. bec_widgets/assets/toolbar_icons/image.svg +3 -0
  32. bec_widgets/assets/toolbar_icons/image_autorange.svg +3 -0
  33. bec_widgets/assets/toolbar_icons/line_curve.svg +3 -0
  34. bec_widgets/assets/toolbar_icons/lock_aspect_ratio.svg +3 -0
  35. bec_widgets/assets/toolbar_icons/log_scale.png +0 -0
  36. bec_widgets/assets/toolbar_icons/motor_map.svg +3 -0
  37. bec_widgets/assets/toolbar_icons/progress.svg +3 -0
  38. bec_widgets/assets/toolbar_icons/queue.svg +3 -0
  39. bec_widgets/assets/toolbar_icons/reset_settings.svg +3 -0
  40. bec_widgets/assets/toolbar_icons/restore_state.svg +3 -0
  41. bec_widgets/assets/toolbar_icons/ring_progress.svg +3 -0
  42. bec_widgets/assets/toolbar_icons/rotate_left.svg +3 -0
  43. bec_widgets/assets/toolbar_icons/rotate_right.svg +3 -0
  44. bec_widgets/assets/toolbar_icons/save_state.svg +3 -0
  45. bec_widgets/assets/toolbar_icons/scan_control.svg +3 -0
  46. bec_widgets/assets/toolbar_icons/status.svg +3 -0
  47. bec_widgets/assets/toolbar_icons/terminal.svg +3 -0
  48. bec_widgets/assets/toolbar_icons/transform.svg +3 -0
  49. bec_widgets/assets/toolbar_icons/waveform.svg +3 -0
  50. bec_widgets/cli/client.py +188 -3
  51. bec_widgets/examples/jupyter_console/jupyter_console_window.py +18 -19
  52. bec_widgets/examples/plugin_example_pyside/tictactoeplugin.py +8 -2
  53. bec_widgets/qt_utils/toolbar.py +52 -2
  54. bec_widgets/utils/generate_designer_plugin.py +1 -1
  55. bec_widgets/widgets/bec_queue/bec_queue_plugin.py +7 -2
  56. bec_widgets/widgets/bec_status_box/bec_status_box_plugin.py +7 -2
  57. bec_widgets/widgets/bec_status_box/status_item.py +14 -8
  58. bec_widgets/widgets/color_button/color_button_plugin.py +3 -2
  59. bec_widgets/widgets/device_box/device_box_plugin.py +6 -1
  60. bec_widgets/widgets/device_combobox/{device_combobox_plugin.py → device_combo_box_plugin.py} +5 -3
  61. bec_widgets/widgets/device_combobox/device_combobox.py +0 -1
  62. bec_widgets/widgets/device_combobox/{register_device_combobox.py → register_device_combo_box.py} +1 -1
  63. bec_widgets/widgets/device_line_edit/device_line_edit_plugin.py +5 -3
  64. bec_widgets/widgets/dock/dock.py +5 -2
  65. bec_widgets/widgets/dock/dock_area.py +139 -29
  66. bec_widgets/widgets/dock/dock_area.pyproject +1 -0
  67. bec_widgets/widgets/dock/dock_area_plugin.py +59 -0
  68. bec_widgets/widgets/dock/register_dock_area.py +15 -0
  69. bec_widgets/widgets/figure/figure.py +1 -3
  70. bec_widgets/widgets/figure/plots/axis_settings.ui +86 -100
  71. bec_widgets/widgets/figure/plots/image/image.py +85 -3
  72. bec_widgets/widgets/figure/plots/image/image_item.py +14 -0
  73. bec_widgets/widgets/image/__init__.py +0 -0
  74. bec_widgets/widgets/image/bec_image_widget.pyproject +1 -0
  75. bec_widgets/widgets/image/bec_image_widget_plugin.py +59 -0
  76. bec_widgets/widgets/image/image_widget.py +475 -0
  77. bec_widgets/widgets/image/register_bec_image_widget.py +15 -0
  78. bec_widgets/widgets/position_indicator/__init__.py +0 -0
  79. bec_widgets/widgets/position_indicator/position_indicator_plugin.py +7 -2
  80. bec_widgets/widgets/ring_progress_bar/register_ring_progress_bar.py +15 -0
  81. bec_widgets/widgets/ring_progress_bar/ring_progress_bar.pyproject +1 -0
  82. bec_widgets/widgets/ring_progress_bar/ring_progress_bar_plugin.py +58 -0
  83. bec_widgets/widgets/scan_control/register_scan_control.py +15 -0
  84. bec_widgets/widgets/scan_control/scan_control.pyproject +1 -0
  85. bec_widgets/widgets/scan_control/scan_control_plugin.py +58 -0
  86. bec_widgets/widgets/spinner/spinner_widget_plugin.py +7 -2
  87. bec_widgets/widgets/stop_button/stop_button_plugin.py +5 -3
  88. bec_widgets/widgets/text_box/register_text_box.py +15 -0
  89. bec_widgets/widgets/text_box/text_box.pyproject +1 -0
  90. bec_widgets/widgets/text_box/text_box_plugin.py +58 -0
  91. bec_widgets/widgets/toggle/toggle_switch_plugin.py +7 -2
  92. bec_widgets/widgets/vscode/register_vs_code_editor.py +15 -0
  93. bec_widgets/widgets/vscode/vs_code_editor.pyproject +1 -0
  94. bec_widgets/widgets/vscode/vs_code_editor_plugin.py +59 -0
  95. bec_widgets/widgets/waveform/bec_waveform_widget_plugin.py +1 -1
  96. bec_widgets/widgets/website/register_website_widget.py +15 -0
  97. bec_widgets/widgets/website/website_widget.pyproject +1 -0
  98. bec_widgets/widgets/website/website_widget_plugin.py +58 -0
  99. {bec_widgets-0.89.0.dist-info → bec_widgets-0.91.0.dist-info}/METADATA +1 -1
  100. {bec_widgets-0.89.0.dist-info → bec_widgets-0.91.0.dist-info}/RECORD +112 -45
  101. pyproject.toml +1 -1
  102. tests/unit_tests/client_mocks.py +9 -1
  103. tests/unit_tests/test_bec_dock.py +70 -30
  104. tests/unit_tests/test_bec_image_widget.py +218 -0
  105. tests/unit_tests/test_device_input_base.py +1 -1
  106. tests/unit_tests/test_device_input_widgets.py +2 -0
  107. tests/unit_tests/test_waveform_widget.py +1 -1
  108. bec_widgets/widgets/color_button/assets/color_button.png +0 -0
  109. bec_widgets/widgets/device_combobox/assets/device_combobox_icon.png +0 -0
  110. bec_widgets/widgets/device_line_edit/assets/line_edit_icon.png +0 -0
  111. bec_widgets/widgets/stop_button/assets/stop.png +0 -0
  112. /bec_widgets/assets/designer_icons/{BECWaveformWidget.png → waveform.png} +0 -0
  113. /bec_widgets/widgets/device_combobox/{device_combobox.pyproject → device_combo_box.pyproject} +0 -0
  114. {bec_widgets-0.89.0.dist-info → bec_widgets-0.91.0.dist-info}/WHEEL +0 -0
  115. {bec_widgets-0.89.0.dist-info → bec_widgets-0.91.0.dist-info}/entry_points.txt +0 -0
  116. {bec_widgets-0.89.0.dist-info → bec_widgets-0.91.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,475 @@
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+ from typing import Literal, Optional
5
+
6
+ import pyqtgraph as pg
7
+ from qtpy.QtWidgets import QVBoxLayout, QWidget
8
+
9
+ from bec_widgets.qt_utils.error_popups import SafeSlot, WarningPopupUtility
10
+ from bec_widgets.qt_utils.settings_dialog import SettingsDialog
11
+ from bec_widgets.qt_utils.toolbar import (
12
+ DeviceSelectionAction,
13
+ IconAction,
14
+ ModularToolBar,
15
+ SeparatorAction,
16
+ )
17
+ from bec_widgets.utils.bec_widget import BECWidget
18
+ from bec_widgets.widgets.device_combobox.device_combobox import DeviceComboBox
19
+ from bec_widgets.widgets.figure import BECFigure
20
+ from bec_widgets.widgets.figure.plots.axis_settings import AxisSettings
21
+ from bec_widgets.widgets.figure.plots.image.image import ImageConfig
22
+ from bec_widgets.widgets.figure.plots.image.image_item import BECImageItem
23
+
24
+
25
+ class BECImageWidget(BECWidget, QWidget):
26
+ USER_ACCESS = [
27
+ "image",
28
+ "set",
29
+ "set_title",
30
+ "set_x_label",
31
+ "set_y_label",
32
+ "set_x_scale",
33
+ "set_y_scale",
34
+ "set_x_lim",
35
+ "set_y_lim",
36
+ "set_vrange",
37
+ "set_fft",
38
+ "set_transpose",
39
+ "set_rotation",
40
+ "set_log",
41
+ "set_grid",
42
+ "lock_aspect_ratio",
43
+ ]
44
+
45
+ def __init__(
46
+ self,
47
+ parent: QWidget | None = None,
48
+ config: ImageConfig | dict = None,
49
+ client=None,
50
+ gui_id: str | None = None,
51
+ ) -> None:
52
+ if config is None:
53
+ config = ImageConfig(widget_class=self.__class__.__name__)
54
+ else:
55
+ if isinstance(config, dict):
56
+ config = ImageConfig(**config)
57
+ super().__init__(client=client, gui_id=gui_id)
58
+ QWidget.__init__(self, parent)
59
+ self.layout = QVBoxLayout(self)
60
+ self.layout.setSpacing(0)
61
+ self.layout.setContentsMargins(0, 0, 0, 0)
62
+
63
+ self.fig = BECFigure()
64
+ self.toolbar = ModularToolBar(
65
+ actions={
66
+ "monitor": DeviceSelectionAction(
67
+ "Monitor:", DeviceComboBox(device_filter="Device")
68
+ ),
69
+ "connect": IconAction(icon_path="connection.svg", tooltip="Connect Device"),
70
+ "separator_0": SeparatorAction(),
71
+ "save": IconAction(icon_path="save.svg", tooltip="Open Export Dialog"),
72
+ "separator_1": SeparatorAction(),
73
+ "drag_mode": IconAction(
74
+ icon_path="drag_pan_mode.svg", tooltip="Drag Mouse Mode", checkable=True
75
+ ),
76
+ "rectangle_mode": IconAction(
77
+ icon_path="rectangle_mode.svg", tooltip="Rectangle Zoom Mode", checkable=True
78
+ ),
79
+ "auto_range": IconAction(icon_path="auto_range.svg", tooltip="Autorange Plot"),
80
+ "auto_range_image": IconAction(
81
+ icon_path="image_autorange.svg",
82
+ tooltip="Autorange Image Intensity",
83
+ checkable=True,
84
+ ),
85
+ "aspect_ratio": IconAction(
86
+ icon_path="lock_aspect_ratio.svg",
87
+ tooltip="Lock image aspect ratio",
88
+ checkable=True,
89
+ ),
90
+ "separator_2": SeparatorAction(),
91
+ "FFT": IconAction(icon_path="fft.svg", tooltip="Toggle FFT", checkable=True),
92
+ "log": IconAction(
93
+ icon_path="log_scale.png", tooltip="Toggle log scale", checkable=True
94
+ ),
95
+ "transpose": IconAction(
96
+ icon_path="transform.svg", tooltip="Transpose Image", checkable=True
97
+ ),
98
+ "rotate_right": IconAction(
99
+ icon_path="rotate_right.svg", tooltip="Rotate image clockwise by 90 deg"
100
+ ),
101
+ "rotate_left": IconAction(
102
+ icon_path="rotate_left.svg", tooltip="Rotate image counterclockwise by 90 deg"
103
+ ),
104
+ "reset": IconAction(icon_path="reset_settings.svg", tooltip="Reset Image Settings"),
105
+ "separator_3": SeparatorAction(),
106
+ "axis_settings": IconAction(
107
+ icon_path="settings.svg", tooltip="Open Configuration Dialog"
108
+ ),
109
+ },
110
+ target_widget=self,
111
+ )
112
+
113
+ self.layout.addWidget(self.toolbar)
114
+ self.layout.addWidget(self.fig)
115
+
116
+ self.warning_util = WarningPopupUtility(self)
117
+
118
+ self._image = self.fig.image()
119
+ self._image.apply_config(config)
120
+ self.rotation = 0
121
+
122
+ self.config = config
123
+
124
+ self._hook_actions()
125
+
126
+ self.toolbar.widgets["drag_mode"].action.setChecked(True)
127
+ self.toolbar.widgets["auto_range_image"].action.setChecked(True)
128
+
129
+ def _hook_actions(self):
130
+ self.toolbar.widgets["connect"].action.triggered.connect(self._connect_action)
131
+ # sepatator
132
+ self.toolbar.widgets["save"].action.triggered.connect(self.export)
133
+ # sepatator
134
+ self.toolbar.widgets["drag_mode"].action.triggered.connect(self.enable_mouse_pan_mode)
135
+ self.toolbar.widgets["rectangle_mode"].action.triggered.connect(
136
+ self.enable_mouse_rectangle_mode
137
+ )
138
+ self.toolbar.widgets["auto_range"].action.triggered.connect(self.toggle_auto_range)
139
+ self.toolbar.widgets["auto_range_image"].action.triggered.connect(
140
+ self.toggle_image_autorange
141
+ )
142
+ self.toolbar.widgets["aspect_ratio"].action.triggered.connect(self.toggle_aspect_ratio)
143
+ # sepatator
144
+ self.toolbar.widgets["FFT"].action.triggered.connect(self.toggle_fft)
145
+ self.toolbar.widgets["log"].action.triggered.connect(self.toggle_log)
146
+ self.toolbar.widgets["transpose"].action.triggered.connect(self.toggle_transpose)
147
+ self.toolbar.widgets["rotate_left"].action.triggered.connect(self.rotate_left)
148
+ self.toolbar.widgets["rotate_right"].action.triggered.connect(self.rotate_right)
149
+ self.toolbar.widgets["reset"].action.triggered.connect(self.reset_settings)
150
+ # sepatator
151
+ self.toolbar.widgets["axis_settings"].action.triggered.connect(self.show_axis_settings)
152
+
153
+ ###################################
154
+ # Dialog Windows
155
+ ###################################
156
+ @SafeSlot(popup_error=True)
157
+ def _connect_action(self):
158
+ monitor_combo = self.toolbar.widgets["monitor"].device_combobox
159
+ monitor_name = monitor_combo.currentText()
160
+ self.image(monitor_name)
161
+ monitor_combo.setStyleSheet("QComboBox { background-color: " "; }")
162
+
163
+ def show_axis_settings(self):
164
+ dialog = SettingsDialog(
165
+ self,
166
+ settings_widget=AxisSettings(),
167
+ window_title="Axis Settings",
168
+ config=self._config_dict["axis"],
169
+ )
170
+ dialog.exec()
171
+
172
+ ###################################
173
+ # User Access Methods from image
174
+ ###################################
175
+ @SafeSlot(popup_error=True)
176
+ def image(
177
+ self,
178
+ monitor: str,
179
+ color_map: Optional[str] = "magma",
180
+ color_bar: Optional[Literal["simple", "full"]] = "full",
181
+ downsample: Optional[bool] = True,
182
+ opacity: Optional[float] = 1.0,
183
+ vrange: Optional[tuple[int, int]] = None,
184
+ # post_processing: Optional[PostProcessingConfig] = None,
185
+ **kwargs,
186
+ ) -> BECImageItem:
187
+ if self.toolbar.widgets["monitor"].device_combobox.currentText() != monitor:
188
+ self.toolbar.widgets["monitor"].device_combobox.setCurrentText(monitor)
189
+ self.toolbar.widgets["monitor"].device_combobox.setStyleSheet(
190
+ "QComboBox {{ background-color: " "; }}"
191
+ )
192
+ return self._image.image(
193
+ monitor=monitor,
194
+ color_map=color_map,
195
+ color_bar=color_bar,
196
+ downsample=downsample,
197
+ opacity=opacity,
198
+ vrange=vrange,
199
+ **kwargs,
200
+ )
201
+
202
+ def set_vrange(self, vmin: float, vmax: float, name: str = None):
203
+ """
204
+ Set the range of the color bar.
205
+ If name is not specified, then set vrange for all images.
206
+
207
+ Args:
208
+ vmin(float): Minimum value of the color bar.
209
+ vmax(float): Maximum value of the color bar.
210
+ name(str): The name of the image. If None, apply to all images.
211
+ """
212
+ self._image.set_vrange(vmin, vmax, name)
213
+
214
+ def set_color_map(self, color_map: str, name: str = None):
215
+ """
216
+ Set the color map of the image.
217
+ If name is not specified, then set color map for all images.
218
+
219
+ Args:
220
+ cmap(str): The color map of the image.
221
+ name(str): The name of the image. If None, apply to all images.
222
+ """
223
+ self._image.set_color_map(color_map, name)
224
+
225
+ def set_fft(self, enable: bool = False, name: str = None):
226
+ """
227
+ Set the FFT of the image.
228
+ If name is not specified, then set FFT for all images.
229
+
230
+ Args:
231
+ enable(bool): Whether to perform FFT on the monitor data.
232
+ name(str): The name of the image. If None, apply to all images.
233
+ """
234
+ self._image.set_fft(enable, name)
235
+ self.toolbar.widgets["FFT"].action.setChecked(enable)
236
+
237
+ def set_transpose(self, enable: bool = False, name: str = None):
238
+ """
239
+ Set the transpose of the image.
240
+ If name is not specified, then set transpose for all images.
241
+
242
+ Args:
243
+ enable(bool): Whether to transpose the monitor data before displaying.
244
+ name(str): The name of the image. If None, apply to all images.
245
+ """
246
+ self._image.set_transpose(enable, name)
247
+ self.toolbar.widgets["transpose"].action.setChecked(enable)
248
+
249
+ def set_rotation(self, deg_90: int = 0, name: str = None):
250
+ """
251
+ Set the rotation of the image.
252
+ If name is not specified, then set rotation for all images.
253
+
254
+ Args:
255
+ deg_90(int): The rotation angle of the monitor data before displaying.
256
+ name(str): The name of the image. If None, apply to all images.
257
+ """
258
+ self._image.set_rotation(deg_90, name)
259
+
260
+ def set_log(self, enable: bool = False, name: str = None):
261
+ """
262
+ Set the log of the image.
263
+ If name is not specified, then set log for all images.
264
+
265
+ Args:
266
+ enable(bool): Whether to perform log on the monitor data.
267
+ name(str): The name of the image. If None, apply to all images.
268
+ """
269
+ self._image.set_log(enable, name)
270
+ self.toolbar.widgets["log"].action.setChecked(enable)
271
+
272
+ ###################################
273
+ # User Access Methods from Plotbase
274
+ ###################################
275
+
276
+ def set(self, **kwargs):
277
+ """
278
+ Set the properties of the plot widget.
279
+
280
+ Args:
281
+ **kwargs: Keyword arguments for the properties to be set.
282
+
283
+ Possible properties:
284
+ - title: str
285
+ - x_label: str
286
+ - y_label: str
287
+ - x_scale: Literal["linear", "log"]
288
+ - y_scale: Literal["linear", "log"]
289
+ - x_lim: tuple
290
+ - y_lim: tuple
291
+ - legend_label_size: int
292
+ """
293
+ self._image.set(**kwargs)
294
+
295
+ def set_title(self, title: str):
296
+ """
297
+ Set the title of the plot widget.
298
+
299
+ Args:
300
+ title(str): Title of the plot.
301
+ """
302
+ self._image.set_title(title)
303
+
304
+ def set_x_label(self, x_label: str):
305
+ """
306
+ Set the x-axis label of the plot widget.
307
+
308
+ Args:
309
+ x_label(str): Label of the x-axis.
310
+ """
311
+ self._image.set_x_label(x_label)
312
+
313
+ def set_y_label(self, y_label: str):
314
+ """
315
+ Set the y-axis label of the plot widget.
316
+
317
+ Args:
318
+ y_label(str): Label of the y-axis.
319
+ """
320
+ self._image.set_y_label(y_label)
321
+
322
+ def set_x_scale(self, x_scale: Literal["linear", "log"]):
323
+ """
324
+ Set the scale of the x-axis of the plot widget.
325
+
326
+ Args:
327
+ x_scale(Literal["linear", "log"]): Scale of the x-axis.
328
+ """
329
+ self._image.set_x_scale(x_scale)
330
+
331
+ def set_y_scale(self, y_scale: Literal["linear", "log"]):
332
+ """
333
+ Set the scale of the y-axis of the plot widget.
334
+
335
+ Args:
336
+ y_scale(Literal["linear", "log"]): Scale of the y-axis.
337
+ """
338
+ self._image.set_y_scale(y_scale)
339
+
340
+ def set_x_lim(self, x_lim: tuple):
341
+ """
342
+ Set the limits of the x-axis of the plot widget.
343
+
344
+ Args:
345
+ x_lim(tuple): Limits of the x-axis.
346
+ """
347
+ self._image.set_x_lim(x_lim)
348
+
349
+ def set_y_lim(self, y_lim: tuple):
350
+ """
351
+ Set the limits of the y-axis of the plot widget.
352
+
353
+ Args:
354
+ y_lim(tuple): Limits of the y-axis.
355
+ """
356
+ self._image.set_y_lim(y_lim)
357
+
358
+ def set_grid(self, x_grid: bool, y_grid: bool):
359
+ """
360
+ Set the grid visibility of the plot widget.
361
+
362
+ Args:
363
+ x_grid(bool): Visibility of the x-axis grid.
364
+ y_grid(bool): Visibility of the y-axis grid.
365
+ """
366
+ self._image.set_grid(x_grid, y_grid)
367
+
368
+ def lock_aspect_ratio(self, lock: bool):
369
+ """
370
+ Lock the aspect ratio of the plot widget.
371
+
372
+ Args:
373
+ lock(bool): Lock the aspect ratio.
374
+ """
375
+ self._image.lock_aspect_ratio(lock)
376
+
377
+ ###################################
378
+ # Toolbar Actions
379
+ ###################################
380
+ @SafeSlot()
381
+ def toggle_auto_range(self):
382
+ """
383
+ Set the auto range of the plot widget from the toolbar.
384
+ """
385
+ self._image.set_auto_range(True, "xy")
386
+
387
+ @SafeSlot()
388
+ def toggle_fft(self):
389
+ checked = self.toolbar.widgets["FFT"].action.isChecked()
390
+ self.set_fft(checked)
391
+
392
+ @SafeSlot()
393
+ def toggle_log(self):
394
+ checked = self.toolbar.widgets["log"].action.isChecked()
395
+ self.set_log(checked)
396
+
397
+ @SafeSlot()
398
+ def toggle_transpose(self):
399
+ checked = self.toolbar.widgets["transpose"].action.isChecked()
400
+ self.set_transpose(checked)
401
+
402
+ @SafeSlot()
403
+ def rotate_left(self):
404
+ self.rotation = (self.rotation + 1) % 4
405
+ self.set_rotation(self.rotation)
406
+
407
+ @SafeSlot()
408
+ def rotate_right(self):
409
+ self.rotation = (self.rotation - 1) % 4
410
+ self.set_rotation(self.rotation)
411
+
412
+ @SafeSlot()
413
+ def reset_settings(self):
414
+ self.set_log(False)
415
+ self.set_fft(False)
416
+ self.set_transpose(False)
417
+ self.rotation = 0
418
+ self.set_rotation(0)
419
+
420
+ self.toolbar.widgets["FFT"].action.setChecked(False)
421
+ self.toolbar.widgets["log"].action.setChecked(False)
422
+ self.toolbar.widgets["transpose"].action.setChecked(False)
423
+
424
+ @SafeSlot()
425
+ def toggle_image_autorange(self):
426
+ """
427
+ Enable the auto range of the image intensity.
428
+ """
429
+ checked = self.toolbar.widgets["auto_range_image"].action.isChecked()
430
+ self._image.set_autorange(checked)
431
+
432
+ @SafeSlot()
433
+ def toggle_aspect_ratio(self):
434
+ """
435
+ Enable the auto range of the image intensity.
436
+ """
437
+ checked = self.toolbar.widgets["aspect_ratio"].action.isChecked()
438
+ self._image.lock_aspect_ratio(checked)
439
+
440
+ @SafeSlot()
441
+ def enable_mouse_rectangle_mode(self):
442
+ self.toolbar.widgets["rectangle_mode"].action.setChecked(True)
443
+ self.toolbar.widgets["drag_mode"].action.setChecked(False)
444
+ self._image.plot_item.getViewBox().setMouseMode(pg.ViewBox.RectMode)
445
+
446
+ @SafeSlot()
447
+ def enable_mouse_pan_mode(self):
448
+ self.toolbar.widgets["drag_mode"].action.setChecked(True)
449
+ self.toolbar.widgets["rectangle_mode"].action.setChecked(False)
450
+ self._image.plot_item.getViewBox().setMouseMode(pg.ViewBox.PanMode)
451
+
452
+ def export(self):
453
+ """
454
+ Show the export dialog for the plot widget.
455
+ """
456
+ self._image.export()
457
+
458
+ def cleanup(self):
459
+ self.fig.cleanup()
460
+ self.client.shutdown()
461
+ return super().cleanup()
462
+
463
+
464
+ def main(): # pragma: no cover
465
+
466
+ from qtpy.QtWidgets import QApplication
467
+
468
+ app = QApplication(sys.argv)
469
+ widget = BECImageWidget()
470
+ widget.show()
471
+ sys.exit(app.exec_())
472
+
473
+
474
+ if __name__ == "__main__": # pragma: no cover
475
+ main()
@@ -0,0 +1,15 @@
1
+ def main(): # pragma: no cover
2
+ from qtpy import PYSIDE6
3
+
4
+ if not PYSIDE6:
5
+ print("PYSIDE6 is not available in the environment. Cannot patch designer.")
6
+ return
7
+ from PySide6.QtDesigner import QPyDesignerCustomWidgetCollection
8
+
9
+ from bec_widgets.widgets.image.bec_image_widget_plugin import BECImageWidgetPlugin
10
+
11
+ QPyDesignerCustomWidgetCollection.addCustomWidget(BECImageWidgetPlugin())
12
+
13
+
14
+ if __name__ == "__main__": # pragma: no cover
15
+ main()
File without changes
@@ -1,9 +1,11 @@
1
1
  # Copyright (C) 2022 The Qt Company Ltd.
2
2
  # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
+ import os
3
4
 
4
5
  from qtpy.QtDesigner import QDesignerCustomWidgetInterface
5
6
  from qtpy.QtGui import QIcon
6
7
 
8
+ import bec_widgets
7
9
  from bec_widgets.widgets.position_indicator.position_indicator import PositionIndicator
8
10
 
9
11
  DOM_XML = """
@@ -13,6 +15,8 @@ DOM_XML = """
13
15
  </ui>
14
16
  """
15
17
 
18
+ MODULE_PATH = os.path.dirname(bec_widgets.__file__)
19
+
16
20
 
17
21
  class PositionIndicatorPlugin(QDesignerCustomWidgetInterface): # pragma: no cover
18
22
  def __init__(self):
@@ -27,10 +31,11 @@ class PositionIndicatorPlugin(QDesignerCustomWidgetInterface): # pragma: no cov
27
31
  return DOM_XML
28
32
 
29
33
  def group(self):
30
- return ""
34
+ return "BEC Utils"
31
35
 
32
36
  def icon(self):
33
- return QIcon()
37
+ icon_path = os.path.join(MODULE_PATH, "assets", "designer_icons", "position_indicator.png")
38
+ return QIcon(icon_path)
34
39
 
35
40
  def includeFile(self):
36
41
  return "position_indicator"
@@ -0,0 +1,15 @@
1
+ def main(): # pragma: no cover
2
+ from qtpy import PYSIDE6
3
+
4
+ if not PYSIDE6:
5
+ print("PYSIDE6 is not available in the environment. Cannot patch designer.")
6
+ return
7
+ from PySide6.QtDesigner import QPyDesignerCustomWidgetCollection
8
+
9
+ from bec_widgets.widgets.ring_progress_bar.ring_progress_bar_plugin import RingProgressBarPlugin
10
+
11
+ QPyDesignerCustomWidgetCollection.addCustomWidget(RingProgressBarPlugin())
12
+
13
+
14
+ if __name__ == "__main__": # pragma: no cover
15
+ main()
@@ -0,0 +1 @@
1
+ {'files': ['ring_progress_bar.py']}
@@ -0,0 +1,58 @@
1
+ # Copyright (C) 2022 The Qt Company Ltd.
2
+ # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
+ import os
4
+
5
+ from qtpy.QtDesigner import QDesignerCustomWidgetInterface
6
+ from qtpy.QtGui import QIcon
7
+
8
+ import bec_widgets
9
+ from bec_widgets.widgets.ring_progress_bar.ring_progress_bar import RingProgressBar
10
+
11
+ DOM_XML = """
12
+ <ui language='c++'>
13
+ <widget class='RingProgressBar' name='ring_progress_bar'>
14
+ </widget>
15
+ </ui>
16
+ """
17
+ MODULE_PATH = os.path.dirname(bec_widgets.__file__)
18
+
19
+
20
+ class RingProgressBarPlugin(QDesignerCustomWidgetInterface): # pragma: no cover
21
+ def __init__(self):
22
+ super().__init__()
23
+ self._form_editor = None
24
+
25
+ def createWidget(self, parent):
26
+ t = RingProgressBar(parent)
27
+ return t
28
+
29
+ def domXml(self):
30
+ return DOM_XML
31
+
32
+ def group(self):
33
+ return "BEC Utils"
34
+
35
+ def icon(self):
36
+ icon_path = os.path.join(MODULE_PATH, "assets", "designer_icons", "ring_progress.png")
37
+ return QIcon(icon_path)
38
+
39
+ def includeFile(self):
40
+ return "ring_progress_bar"
41
+
42
+ def initialize(self, form_editor):
43
+ self._form_editor = form_editor
44
+
45
+ def isContainer(self):
46
+ return False
47
+
48
+ def isInitialized(self):
49
+ return self._form_editor is not None
50
+
51
+ def name(self):
52
+ return "RingProgressBar"
53
+
54
+ def toolTip(self):
55
+ return "RingProgressBar"
56
+
57
+ def whatsThis(self):
58
+ return self.toolTip()
@@ -0,0 +1,15 @@
1
+ def main(): # pragma: no cover
2
+ from qtpy import PYSIDE6
3
+
4
+ if not PYSIDE6:
5
+ print("PYSIDE6 is not available in the environment. Cannot patch designer.")
6
+ return
7
+ from PySide6.QtDesigner import QPyDesignerCustomWidgetCollection
8
+
9
+ from bec_widgets.widgets.scan_control.scan_control_plugin import ScanControlPlugin
10
+
11
+ QPyDesignerCustomWidgetCollection.addCustomWidget(ScanControlPlugin())
12
+
13
+
14
+ if __name__ == "__main__": # pragma: no cover
15
+ main()
@@ -0,0 +1 @@
1
+ {'files': ['scan_control.py']}
@@ -0,0 +1,58 @@
1
+ # Copyright (C) 2022 The Qt Company Ltd.
2
+ # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
+ import os
4
+
5
+ from qtpy.QtDesigner import QDesignerCustomWidgetInterface
6
+ from qtpy.QtGui import QIcon
7
+
8
+ import bec_widgets
9
+ from bec_widgets.widgets.scan_control.scan_control import ScanControl
10
+
11
+ DOM_XML = """
12
+ <ui language='c++'>
13
+ <widget class='ScanControl' name='scan_control'>
14
+ </widget>
15
+ </ui>
16
+ """
17
+ MODULE_PATH = os.path.dirname(bec_widgets.__file__)
18
+
19
+
20
+ class ScanControlPlugin(QDesignerCustomWidgetInterface): # pragma: no cover
21
+ def __init__(self):
22
+ super().__init__()
23
+ self._form_editor = None
24
+
25
+ def createWidget(self, parent):
26
+ t = ScanControl(parent)
27
+ return t
28
+
29
+ def domXml(self):
30
+ return DOM_XML
31
+
32
+ def group(self):
33
+ return "Device Control"
34
+
35
+ def icon(self):
36
+ icon_path = os.path.join(MODULE_PATH, "assets", "designer_icons", "scan_control.png")
37
+ return QIcon(icon_path)
38
+
39
+ def includeFile(self):
40
+ return "scan_control"
41
+
42
+ def initialize(self, form_editor):
43
+ self._form_editor = form_editor
44
+
45
+ def isContainer(self):
46
+ return False
47
+
48
+ def isInitialized(self):
49
+ return self._form_editor is not None
50
+
51
+ def name(self):
52
+ return "ScanControl"
53
+
54
+ def toolTip(self):
55
+ return "ScanControl"
56
+
57
+ def whatsThis(self):
58
+ return self.toolTip()