bec-widgets 0.53.2__py3-none-any.whl → 0.54.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 (67) hide show
  1. CHANGELOG.md +24 -25
  2. PKG-INFO +1 -1
  3. bec_widgets/cli/client.py +13 -13
  4. bec_widgets/cli/client_utils.py +0 -4
  5. bec_widgets/cli/generate_cli.py +7 -5
  6. bec_widgets/cli/server.py +5 -7
  7. bec_widgets/examples/jupyter_console/jupyter_console_window.py +7 -3
  8. bec_widgets/examples/motor_movement/motor_control_compilations.py +17 -16
  9. bec_widgets/widgets/__init__.py +0 -10
  10. bec_widgets/widgets/figure/figure.py +40 -23
  11. bec_widgets/widgets/figure/plots/__init__.py +0 -0
  12. bec_widgets/widgets/figure/plots/image/__init__.py +0 -0
  13. bec_widgets/widgets/{plots → figure/plots/image}/image.py +6 -416
  14. bec_widgets/widgets/figure/plots/image/image_item.py +277 -0
  15. bec_widgets/widgets/figure/plots/image/image_processor.py +152 -0
  16. bec_widgets/widgets/figure/plots/motor_map/__init__.py +0 -0
  17. bec_widgets/widgets/{plots → figure/plots/motor_map}/motor_map.py +2 -2
  18. bec_widgets/widgets/figure/plots/waveform/__init__.py +0 -0
  19. bec_widgets/widgets/{plots → figure/plots/waveform}/waveform.py +9 -222
  20. bec_widgets/widgets/figure/plots/waveform/waveform_curve.py +227 -0
  21. bec_widgets/widgets/motor_control/__init__.py +0 -7
  22. bec_widgets/widgets/motor_control/motor_control.py +2 -948
  23. bec_widgets/widgets/motor_control/motor_table/__init__.py +0 -0
  24. bec_widgets/widgets/motor_control/motor_table/motor_table.py +483 -0
  25. bec_widgets/widgets/motor_control/movement_absolute/__init__.py +0 -0
  26. bec_widgets/widgets/motor_control/movement_absolute/movement_absolute.py +157 -0
  27. bec_widgets/widgets/motor_control/movement_relative/__init__.py +0 -0
  28. bec_widgets/widgets/motor_control/movement_relative/movement_relative.py +227 -0
  29. bec_widgets/widgets/motor_control/selection/__init__.py +0 -0
  30. bec_widgets/widgets/motor_control/selection/selection.py +110 -0
  31. {bec_widgets-0.53.2.dist-info → bec_widgets-0.54.0.dist-info}/METADATA +1 -1
  32. {bec_widgets-0.53.2.dist-info → bec_widgets-0.54.0.dist-info}/RECORD +51 -52
  33. docs/requirements.txt +1 -0
  34. pyproject.toml +1 -1
  35. tests/end-2-end/test_bec_dock_rpc_e2e.py +1 -1
  36. tests/end-2-end/test_bec_figure_rpc_e2e.py +4 -4
  37. tests/end-2-end/test_rpc_register_e2e.py +1 -1
  38. tests/unit_tests/test_bec_dock.py +1 -1
  39. tests/unit_tests/test_bec_figure.py +6 -4
  40. tests/unit_tests/test_bec_motor_map.py +2 -3
  41. tests/unit_tests/test_motor_control.py +6 -5
  42. tests/unit_tests/test_waveform1d.py +13 -1
  43. bec_widgets/validation/__init__.py +0 -2
  44. bec_widgets/validation/monitor_config_validator.py +0 -258
  45. bec_widgets/widgets/monitor/__init__.py +0 -1
  46. bec_widgets/widgets/monitor/config_dialog.py +0 -574
  47. bec_widgets/widgets/monitor/config_dialog.ui +0 -210
  48. bec_widgets/widgets/monitor/example_configs/config_device.yaml +0 -60
  49. bec_widgets/widgets/monitor/example_configs/config_scans.yaml +0 -92
  50. bec_widgets/widgets/monitor/monitor.py +0 -845
  51. bec_widgets/widgets/monitor/tab_template.ui +0 -180
  52. bec_widgets/widgets/motor_map/__init__.py +0 -1
  53. bec_widgets/widgets/motor_map/motor_map.py +0 -594
  54. bec_widgets/widgets/plots/__init__.py +0 -4
  55. tests/unit_tests/test_bec_monitor.py +0 -220
  56. tests/unit_tests/test_config_dialog.py +0 -178
  57. tests/unit_tests/test_motor_map.py +0 -171
  58. tests/unit_tests/test_validator_errors.py +0 -110
  59. /bec_widgets/{cli → assets}/bec_widgets_icon.png +0 -0
  60. /bec_widgets/{examples/jupyter_console → assets}/terminal_icon.png +0 -0
  61. /bec_widgets/widgets/{plots → figure/plots}/plot_base.py +0 -0
  62. /bec_widgets/widgets/motor_control/{motor_control_table.ui → motor_table/motor_table.ui} +0 -0
  63. /bec_widgets/widgets/motor_control/{motor_control_absolute.ui → movement_absolute/movement_absolute.ui} +0 -0
  64. /bec_widgets/widgets/motor_control/{motor_control_relative.ui → movement_relative/movement_relative.ui} +0 -0
  65. /bec_widgets/widgets/motor_control/{motor_control_selection.ui → selection/selection.ui} +0 -0
  66. {bec_widgets-0.53.2.dist-info → bec_widgets-0.54.0.dist-info}/WHEEL +0 -0
  67. {bec_widgets-0.53.2.dist-info → bec_widgets-0.54.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,227 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any, Literal, Optional
4
+
5
+ import pyqtgraph as pg
6
+ from pydantic import BaseModel, Field
7
+ from qtpy import QtCore
8
+
9
+ from bec_widgets.utils import BECConnector, ConnectionConfig
10
+
11
+
12
+ class SignalData(BaseModel):
13
+ """The data configuration of a signal in the 1D waveform widget for x and y axis."""
14
+
15
+ name: str
16
+ entry: str
17
+ unit: Optional[str] = None # todo implement later
18
+ modifier: Optional[str] = None # todo implement later
19
+ limits: Optional[list[float]] = None # todo implement later
20
+
21
+
22
+ class Signal(BaseModel):
23
+ """The configuration of a signal in the 1D waveform widget."""
24
+
25
+ source: str
26
+ x: SignalData # TODO maybe add metadata for config gui later
27
+ y: SignalData
28
+ z: Optional[SignalData] = None
29
+
30
+
31
+ class CurveConfig(ConnectionConfig):
32
+ parent_id: Optional[str] = Field(None, description="The parent plot of the curve.")
33
+ label: Optional[str] = Field(None, description="The label of the curve.")
34
+ color: Optional[Any] = Field(None, description="The color of the curve.")
35
+ symbol: Optional[str] = Field("o", description="The symbol of the curve.")
36
+ symbol_color: Optional[str] = Field(None, description="The color of the symbol of the curve.")
37
+ symbol_size: Optional[int] = Field(5, description="The size of the symbol of the curve.")
38
+ pen_width: Optional[int] = Field(2, description="The width of the pen of the curve.")
39
+ pen_style: Optional[Literal["solid", "dash", "dot", "dashdot"]] = Field(
40
+ "solid", description="The style of the pen of the curve."
41
+ )
42
+ source: Optional[str] = Field(None, description="The source of the curve.")
43
+ signals: Optional[Signal] = Field(None, description="The signal of the curve.")
44
+ colormap: Optional[str] = Field("plasma", description="The colormap of the curves z gradient.")
45
+
46
+
47
+ class BECCurve(BECConnector, pg.PlotDataItem):
48
+ USER_ACCESS = [
49
+ "remove",
50
+ "rpc_id",
51
+ "config_dict",
52
+ "set",
53
+ "set_data",
54
+ "set_color",
55
+ "set_colormap",
56
+ "set_symbol",
57
+ "set_symbol_color",
58
+ "set_symbol_size",
59
+ "set_pen_width",
60
+ "set_pen_style",
61
+ "get_data",
62
+ ]
63
+
64
+ def __init__(
65
+ self,
66
+ name: Optional[str] = None,
67
+ config: Optional[CurveConfig] = None,
68
+ gui_id: Optional[str] = None,
69
+ parent_item: Optional[pg.PlotItem] = None,
70
+ **kwargs,
71
+ ):
72
+ if config is None:
73
+ config = CurveConfig(label=name, widget_class=self.__class__.__name__)
74
+ self.config = config
75
+ else:
76
+ self.config = config
77
+ # config.widget_class = self.__class__.__name__
78
+ super().__init__(config=config, gui_id=gui_id)
79
+ pg.PlotDataItem.__init__(self, name=name)
80
+
81
+ self.parent_item = parent_item
82
+ self.apply_config()
83
+ if kwargs:
84
+ self.set(**kwargs)
85
+
86
+ def apply_config(self):
87
+ pen_style_map = {
88
+ "solid": QtCore.Qt.SolidLine,
89
+ "dash": QtCore.Qt.DashLine,
90
+ "dot": QtCore.Qt.DotLine,
91
+ "dashdot": QtCore.Qt.DashDotLine,
92
+ }
93
+ pen_style = pen_style_map.get(self.config.pen_style, QtCore.Qt.SolidLine)
94
+
95
+ pen = pg.mkPen(color=self.config.color, width=self.config.pen_width, style=pen_style)
96
+ self.setPen(pen)
97
+
98
+ if self.config.symbol:
99
+ symbol_color = self.config.symbol_color or self.config.color
100
+ brush = pg.mkBrush(color=symbol_color)
101
+
102
+ self.setSymbolBrush(brush)
103
+ self.setSymbolSize(self.config.symbol_size)
104
+ self.setSymbol(self.config.symbol)
105
+
106
+ def set_data(self, x, y):
107
+ if self.config.source == "custom":
108
+ self.setData(x, y)
109
+ else:
110
+ raise ValueError(f"Source {self.config.source} do not allow custom data setting.")
111
+
112
+ def set(self, **kwargs):
113
+ """
114
+ Set the properties of the curve.
115
+
116
+ Args:
117
+ **kwargs: Keyword arguments for the properties to be set.
118
+
119
+ Possible properties:
120
+ - color: str
121
+ - symbol: str
122
+ - symbol_color: str
123
+ - symbol_size: int
124
+ - pen_width: int
125
+ - pen_style: Literal["solid", "dash", "dot", "dashdot"]
126
+ """
127
+
128
+ # Mapping of keywords to setter methods
129
+ method_map = {
130
+ "color": self.set_color,
131
+ "colormap": self.set_colormap,
132
+ "symbol": self.set_symbol,
133
+ "symbol_color": self.set_symbol_color,
134
+ "symbol_size": self.set_symbol_size,
135
+ "pen_width": self.set_pen_width,
136
+ "pen_style": self.set_pen_style,
137
+ }
138
+ for key, value in kwargs.items():
139
+ if key in method_map:
140
+ method_map[key](value)
141
+ else:
142
+ print(f"Warning: '{key}' is not a recognized property.")
143
+
144
+ def set_color(self, color: str, symbol_color: Optional[str] = None):
145
+ """
146
+ Change the color of the curve.
147
+
148
+ Args:
149
+ color(str): Color of the curve.
150
+ symbol_color(str, optional): Color of the symbol. Defaults to None.
151
+ """
152
+ self.config.color = color
153
+ self.config.symbol_color = symbol_color or color
154
+ self.apply_config()
155
+
156
+ def set_symbol(self, symbol: str):
157
+ """
158
+ Change the symbol of the curve.
159
+
160
+ Args:
161
+ symbol(str): Symbol of the curve.
162
+ """
163
+ self.config.symbol = symbol
164
+ self.apply_config()
165
+
166
+ def set_symbol_color(self, symbol_color: str):
167
+ """
168
+ Change the symbol color of the curve.
169
+
170
+ Args:
171
+ symbol_color(str): Color of the symbol.
172
+ """
173
+ self.config.symbol_color = symbol_color
174
+ self.apply_config()
175
+
176
+ def set_symbol_size(self, symbol_size: int):
177
+ """
178
+ Change the symbol size of the curve.
179
+
180
+ Args:
181
+ symbol_size(int): Size of the symbol.
182
+ """
183
+ self.config.symbol_size = symbol_size
184
+ self.apply_config()
185
+
186
+ def set_pen_width(self, pen_width: int):
187
+ """
188
+ Change the pen width of the curve.
189
+
190
+ Args:
191
+ pen_width(int): Width of the pen.
192
+ """
193
+ self.config.pen_width = pen_width
194
+ self.apply_config()
195
+
196
+ def set_pen_style(self, pen_style: Literal["solid", "dash", "dot", "dashdot"]):
197
+ """
198
+ Change the pen style of the curve.
199
+
200
+ Args:
201
+ pen_style(Literal["solid", "dash", "dot", "dashdot"]): Style of the pen.
202
+ """
203
+ self.config.pen_style = pen_style
204
+ self.apply_config()
205
+
206
+ def set_colormap(self, colormap: str):
207
+ """
208
+ Set the colormap for the scatter plot z gradient.
209
+
210
+ Args:
211
+ colormap(str): Colormap for the scatter plot.
212
+ """
213
+ self.config.colormap = colormap
214
+
215
+ def get_data(self) -> tuple[np.ndarray, np.ndarray]:
216
+ """
217
+ Get the data of the curve.
218
+ Returns:
219
+ tuple[np.ndarray,np.ndarray]: X and Y data of the curve.
220
+ """
221
+ x_data, y_data = self.getData()
222
+ return x_data, y_data
223
+
224
+ def remove(self):
225
+ """Remove the curve from the plot."""
226
+ self.parent_item.removeItem(self)
227
+ self.cleanup()
@@ -1,7 +0,0 @@
1
- from .motor_control import (
2
- MotorControlAbsolute,
3
- MotorControlRelative,
4
- MotorControlSelection,
5
- MotorCoordinateTable,
6
- MotorThread,
7
- )