bec-widgets 0.100.0__py3-none-any.whl → 0.102.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.
- CHANGELOG.md +30 -24
- PKG-INFO +1 -1
- bec_widgets/cli/client.py +30 -11
- bec_widgets/qt_utils/toolbar.py +1 -0
- bec_widgets/widgets/bec_queue/bec_queue.py +133 -11
- bec_widgets/widgets/button_abort/button_abort.py +12 -4
- bec_widgets/widgets/button_reset/button_reset.py +23 -6
- bec_widgets/widgets/button_resume/button_resume.py +3 -3
- bec_widgets/widgets/figure/plots/waveform/waveform.py +6 -5
- bec_widgets/widgets/lmfit_dialog/__init__.py +0 -0
- bec_widgets/widgets/lmfit_dialog/lm_fit_dialog.pyproject +1 -0
- bec_widgets/widgets/lmfit_dialog/lm_fit_dialog_plugin.py +54 -0
- bec_widgets/widgets/lmfit_dialog/lmfit_dialog.py +194 -0
- bec_widgets/widgets/lmfit_dialog/lmfit_dialog_compact.ui +120 -0
- bec_widgets/widgets/lmfit_dialog/lmfit_dialog_vertical.ui +147 -0
- bec_widgets/widgets/lmfit_dialog/register_lm_fit_dialog.py +15 -0
- bec_widgets/widgets/stop_button/stop_button.py +3 -3
- bec_widgets/widgets/waveform/waveform_popups/dap_summary_dialog/dap_summary_dialog.py +15 -55
- bec_widgets/widgets/waveform/waveform_widget.py +8 -7
- {bec_widgets-0.100.0.dist-info → bec_widgets-0.102.0.dist-info}/METADATA +1 -1
- {bec_widgets-0.100.0.dist-info → bec_widgets-0.102.0.dist-info}/RECORD +25 -19
- pyproject.toml +1 -1
- bec_widgets/widgets/waveform/waveform_popups/dap_summary_dialog/dap_summary.ui +0 -127
- {bec_widgets-0.100.0.dist-info → bec_widgets-0.102.0.dist-info}/WHEEL +0 -0
- {bec_widgets-0.100.0.dist-info → bec_widgets-0.102.0.dist-info}/entry_points.txt +0 -0
- {bec_widgets-0.100.0.dist-info → bec_widgets-0.102.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,194 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
from bec_lib.endpoints import MessageEndpoints
|
4
|
+
from bec_lib.logger import bec_logger
|
5
|
+
from qtpy.QtCore import Property, Signal, Slot
|
6
|
+
from qtpy.QtWidgets import QTreeWidgetItem, QVBoxLayout, QWidget
|
7
|
+
|
8
|
+
from bec_widgets.utils import UILoader
|
9
|
+
from bec_widgets.utils.bec_widget import BECWidget
|
10
|
+
|
11
|
+
logger = bec_logger.logger
|
12
|
+
|
13
|
+
|
14
|
+
class LMFitDialog(BECWidget, QWidget):
|
15
|
+
"""Dialog for displaying the fit summary and params for LMFit DAP processes"""
|
16
|
+
|
17
|
+
ICON_NAME = "monitoring"
|
18
|
+
selected_fit = Signal(str)
|
19
|
+
|
20
|
+
def __init__(
|
21
|
+
self,
|
22
|
+
parent=None,
|
23
|
+
client=None,
|
24
|
+
config=None,
|
25
|
+
target_widget=None,
|
26
|
+
gui_id: str | None = None,
|
27
|
+
ui_file="lmfit_dialog_vertical.ui",
|
28
|
+
):
|
29
|
+
"""
|
30
|
+
Initialises the LMFitDialog widget.
|
31
|
+
|
32
|
+
Args:
|
33
|
+
parent (QWidget): The parent widget.
|
34
|
+
client: BEC client object.
|
35
|
+
config: Configuration of the widget.
|
36
|
+
target_widget: The widget that the settings will be taken from and applied to.
|
37
|
+
gui_id (str): GUI ID.
|
38
|
+
ui_file (str): The UI file to be loaded.
|
39
|
+
"""
|
40
|
+
super().__init__(client=client, config=config, gui_id=gui_id)
|
41
|
+
QWidget.__init__(self, parent=parent)
|
42
|
+
self._ui_file = ui_file
|
43
|
+
self.target_widget = target_widget
|
44
|
+
|
45
|
+
current_path = os.path.dirname(__file__)
|
46
|
+
self.ui = UILoader(self).loader(os.path.join(current_path, self._ui_file))
|
47
|
+
self.layout = QVBoxLayout(self)
|
48
|
+
self.layout.addWidget(self.ui)
|
49
|
+
self.summary_data = {}
|
50
|
+
self._fit_curve_id = None
|
51
|
+
self._deci_precision = 3
|
52
|
+
self.ui.curve_list.currentItemChanged.connect(self.display_fit_details)
|
53
|
+
self.layout.setContentsMargins(0, 0, 0, 0)
|
54
|
+
self.setLayout(self.layout)
|
55
|
+
|
56
|
+
@Property(bool)
|
57
|
+
def hide_curve_selection(self):
|
58
|
+
"""Property for showing the curve selection."""
|
59
|
+
return not self.ui.group_curve_selection.isVisible()
|
60
|
+
|
61
|
+
@hide_curve_selection.setter
|
62
|
+
def hide_curve_selection(self, show: bool):
|
63
|
+
"""Setter for showing the curve selection.
|
64
|
+
|
65
|
+
Args:
|
66
|
+
show (bool): Whether to show the curve selection.
|
67
|
+
"""
|
68
|
+
self.ui.group_curve_selection.setVisible(not show)
|
69
|
+
|
70
|
+
@property
|
71
|
+
def fit_curve_id(self):
|
72
|
+
"""Property for the currently displayed fit curve_id."""
|
73
|
+
return self._fit_curve_id
|
74
|
+
|
75
|
+
@fit_curve_id.setter
|
76
|
+
def fit_curve_id(self, curve_id: str):
|
77
|
+
"""Setter for the currently displayed fit curve_id.
|
78
|
+
|
79
|
+
Args:
|
80
|
+
fit_curve_id (str): The curve_id of the fit curve to be displayed.
|
81
|
+
"""
|
82
|
+
self._fit_curve_id = curve_id
|
83
|
+
self.selected_fit.emit(curve_id)
|
84
|
+
|
85
|
+
@Slot(str)
|
86
|
+
def remove_dap_data(self, curve_id: str):
|
87
|
+
"""Remove the DAP data for the given curve_id.
|
88
|
+
|
89
|
+
Args:
|
90
|
+
curve_id (str): The curve_id of the DAP data to be removed.
|
91
|
+
"""
|
92
|
+
self.summary_data.pop(curve_id, None)
|
93
|
+
self.refresh_curve_list()
|
94
|
+
|
95
|
+
@Slot(str)
|
96
|
+
def select_curve(self, curve_id: str):
|
97
|
+
"""Select active curve_id in the curve list.
|
98
|
+
|
99
|
+
Args:
|
100
|
+
curve_id (str): curve_id to be selected.
|
101
|
+
"""
|
102
|
+
self.fit_curve_id = curve_id
|
103
|
+
|
104
|
+
@Slot(dict, dict)
|
105
|
+
def update_summary_tree(self, data: dict, metadata: dict):
|
106
|
+
"""Update the summary tree with the given data.
|
107
|
+
|
108
|
+
Args:
|
109
|
+
data (dict): Data for the DAP Summary.
|
110
|
+
metadata (dict): Metadata of the fit curve.
|
111
|
+
"""
|
112
|
+
curve_id = metadata.get("curve_id", "")
|
113
|
+
self.summary_data.update({curve_id: data})
|
114
|
+
self.refresh_curve_list()
|
115
|
+
if self.fit_curve_id is None:
|
116
|
+
self.fit_curve_id = curve_id
|
117
|
+
if curve_id != self.fit_curve_id:
|
118
|
+
return
|
119
|
+
if data is None:
|
120
|
+
return
|
121
|
+
self.ui.summary_tree.clear()
|
122
|
+
properties = [
|
123
|
+
("Model", data.get("model", "")),
|
124
|
+
("Method", data.get("method", "")),
|
125
|
+
("Chi-Squared", f"{data.get('chisqr', 0.0):.{self._deci_precision}f}"),
|
126
|
+
("Reduced Chi-Squared", f"{data.get('redchi', 0.0):.{self._deci_precision}f}"),
|
127
|
+
("R-Squared", f"{data.get('rsquared', 0.0):.{self._deci_precision}f}"),
|
128
|
+
("Message", data.get("message", "")),
|
129
|
+
]
|
130
|
+
for prop, val in properties:
|
131
|
+
QTreeWidgetItem(self.ui.summary_tree, [prop, val])
|
132
|
+
self.update_param_tree(data.get("params", []))
|
133
|
+
|
134
|
+
def _update_summary_data(self, curve_id: str, data: dict):
|
135
|
+
"""Update the summary data with the given data.
|
136
|
+
|
137
|
+
Args:
|
138
|
+
curve_id (str): The curve_id of the fit curve.
|
139
|
+
data (dict): The data to be updated.
|
140
|
+
"""
|
141
|
+
self.summary_data.update({curve_id: data})
|
142
|
+
if self.fit_curve_id is not None:
|
143
|
+
return
|
144
|
+
self.fit_curve_id = curve_id
|
145
|
+
|
146
|
+
def update_param_tree(self, params):
|
147
|
+
"""Update the parameter tree with the given parameters.
|
148
|
+
|
149
|
+
Args:
|
150
|
+
params (list): List of LMFit parameters for the fit curve.
|
151
|
+
"""
|
152
|
+
self.ui.param_tree.clear()
|
153
|
+
for param in params:
|
154
|
+
param_name, param_value, param_std = (
|
155
|
+
param[0],
|
156
|
+
f"{param[1]:.{self._deci_precision}f}",
|
157
|
+
f"{param[7]:.{self._deci_precision}f}",
|
158
|
+
)
|
159
|
+
QTreeWidgetItem(self.ui.param_tree, [param_name, param_value, param_std])
|
160
|
+
|
161
|
+
def populate_curve_list(self):
|
162
|
+
"""Populate the curve list with the available fit curves."""
|
163
|
+
for curve_name in self.summary_data.keys():
|
164
|
+
self.ui.curve_list.addItem(curve_name)
|
165
|
+
|
166
|
+
def refresh_curve_list(self):
|
167
|
+
"""Refresh the curve list with the updated data."""
|
168
|
+
self.ui.curve_list.clear()
|
169
|
+
self.populate_curve_list()
|
170
|
+
|
171
|
+
def display_fit_details(self, current):
|
172
|
+
"""Callback for displaying the fit details of the selected curve.
|
173
|
+
|
174
|
+
Args:
|
175
|
+
current: The current item in the curve list.
|
176
|
+
"""
|
177
|
+
if current:
|
178
|
+
curve_name = current.text()
|
179
|
+
self.fit_curve_id = curve_name
|
180
|
+
data = self.summary_data[curve_name]
|
181
|
+
if data is None:
|
182
|
+
return
|
183
|
+
self.update_summary_tree(data, {"curve_id": curve_name})
|
184
|
+
|
185
|
+
|
186
|
+
if __name__ == "__main__":
|
187
|
+
import sys
|
188
|
+
|
189
|
+
from qtpy.QtWidgets import QApplication
|
190
|
+
|
191
|
+
app = QApplication(sys.argv)
|
192
|
+
dialog = LMFitDialog()
|
193
|
+
dialog.show()
|
194
|
+
sys.exit(app.exec_())
|
@@ -0,0 +1,120 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ui version="4.0">
|
3
|
+
<class>Form</class>
|
4
|
+
<widget class="QWidget" name="Form">
|
5
|
+
<property name="geometry">
|
6
|
+
<rect>
|
7
|
+
<x>0</x>
|
8
|
+
<y>0</y>
|
9
|
+
<width>655</width>
|
10
|
+
<height>520</height>
|
11
|
+
</rect>
|
12
|
+
</property>
|
13
|
+
<property name="windowTitle">
|
14
|
+
<string>Form</string>
|
15
|
+
</property>
|
16
|
+
<layout class="QGridLayout" name="gridLayout">
|
17
|
+
<item row="0" column="0">
|
18
|
+
<widget class="QSplitter" name="splitter_2">
|
19
|
+
<property name="sizePolicy">
|
20
|
+
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
21
|
+
<horstretch>1</horstretch>
|
22
|
+
<verstretch>0</verstretch>
|
23
|
+
</sizepolicy>
|
24
|
+
</property>
|
25
|
+
<property name="frameShape">
|
26
|
+
<enum>QFrame::Shape::VLine</enum>
|
27
|
+
</property>
|
28
|
+
<property name="frameShadow">
|
29
|
+
<enum>QFrame::Shadow::Plain</enum>
|
30
|
+
</property>
|
31
|
+
<property name="lineWidth">
|
32
|
+
<number>1</number>
|
33
|
+
</property>
|
34
|
+
<property name="orientation">
|
35
|
+
<enum>Qt::Orientation::Horizontal</enum>
|
36
|
+
</property>
|
37
|
+
<property name="opaqueResize">
|
38
|
+
<bool>true</bool>
|
39
|
+
</property>
|
40
|
+
<property name="childrenCollapsible">
|
41
|
+
<bool>true</bool>
|
42
|
+
</property>
|
43
|
+
<widget class="QGroupBox" name="group_curve_selection">
|
44
|
+
<property name="title">
|
45
|
+
<string>Select Curve</string>
|
46
|
+
</property>
|
47
|
+
<layout class="QVBoxLayout" name="verticalLayout">
|
48
|
+
<item>
|
49
|
+
<widget class="QListWidget" name="curve_list"/>
|
50
|
+
</item>
|
51
|
+
</layout>
|
52
|
+
</widget>
|
53
|
+
<widget class="QSplitter" name="splitter">
|
54
|
+
<property name="sizePolicy">
|
55
|
+
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
56
|
+
<horstretch>2</horstretch>
|
57
|
+
<verstretch>0</verstretch>
|
58
|
+
</sizepolicy>
|
59
|
+
</property>
|
60
|
+
<property name="orientation">
|
61
|
+
<enum>Qt::Orientation::Vertical</enum>
|
62
|
+
</property>
|
63
|
+
<widget class="QGroupBox" name="group_summary">
|
64
|
+
<property name="title">
|
65
|
+
<string>Fit Summary</string>
|
66
|
+
</property>
|
67
|
+
<layout class="QVBoxLayout" name="verticalLayout_2">
|
68
|
+
<item>
|
69
|
+
<widget class="QTreeWidget" name="summary_tree">
|
70
|
+
<property name="uniformRowHeights">
|
71
|
+
<bool>false</bool>
|
72
|
+
</property>
|
73
|
+
<column>
|
74
|
+
<property name="text">
|
75
|
+
<string>Property</string>
|
76
|
+
</property>
|
77
|
+
</column>
|
78
|
+
<column>
|
79
|
+
<property name="text">
|
80
|
+
<string>Value</string>
|
81
|
+
</property>
|
82
|
+
</column>
|
83
|
+
</widget>
|
84
|
+
</item>
|
85
|
+
</layout>
|
86
|
+
</widget>
|
87
|
+
<widget class="QGroupBox" name="group_parameters">
|
88
|
+
<property name="title">
|
89
|
+
<string>Parameter Details</string>
|
90
|
+
</property>
|
91
|
+
<layout class="QVBoxLayout" name="verticalLayout_3">
|
92
|
+
<item>
|
93
|
+
<widget class="QTreeWidget" name="param_tree">
|
94
|
+
<column>
|
95
|
+
<property name="text">
|
96
|
+
<string>Parameter</string>
|
97
|
+
</property>
|
98
|
+
</column>
|
99
|
+
<column>
|
100
|
+
<property name="text">
|
101
|
+
<string>Value</string>
|
102
|
+
</property>
|
103
|
+
</column>
|
104
|
+
<column>
|
105
|
+
<property name="text">
|
106
|
+
<string>Std</string>
|
107
|
+
</property>
|
108
|
+
</column>
|
109
|
+
</widget>
|
110
|
+
</item>
|
111
|
+
</layout>
|
112
|
+
</widget>
|
113
|
+
</widget>
|
114
|
+
</widget>
|
115
|
+
</item>
|
116
|
+
</layout>
|
117
|
+
</widget>
|
118
|
+
<resources/>
|
119
|
+
<connections/>
|
120
|
+
</ui>
|
@@ -0,0 +1,147 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ui version="4.0">
|
3
|
+
<class>Form</class>
|
4
|
+
<widget class="QWidget" name="Form">
|
5
|
+
<property name="geometry">
|
6
|
+
<rect>
|
7
|
+
<x>0</x>
|
8
|
+
<y>0</y>
|
9
|
+
<width>274</width>
|
10
|
+
<height>568</height>
|
11
|
+
</rect>
|
12
|
+
</property>
|
13
|
+
<property name="sizePolicy">
|
14
|
+
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
15
|
+
<horstretch>0</horstretch>
|
16
|
+
<verstretch>0</verstretch>
|
17
|
+
</sizepolicy>
|
18
|
+
</property>
|
19
|
+
<property name="windowTitle">
|
20
|
+
<string>Form</string>
|
21
|
+
</property>
|
22
|
+
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,0">
|
23
|
+
<item>
|
24
|
+
<widget class="QGroupBox" name="group_curve_selection">
|
25
|
+
<property name="title">
|
26
|
+
<string>Select Curve</string>
|
27
|
+
</property>
|
28
|
+
<layout class="QVBoxLayout" name="verticalLayout" stretch="3">
|
29
|
+
<item>
|
30
|
+
<widget class="QListWidget" name="curve_list"/>
|
31
|
+
</item>
|
32
|
+
</layout>
|
33
|
+
</widget>
|
34
|
+
</item>
|
35
|
+
<item>
|
36
|
+
<widget class="QGroupBox" name="group_summary">
|
37
|
+
<property name="sizePolicy">
|
38
|
+
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
39
|
+
<horstretch>0</horstretch>
|
40
|
+
<verstretch>0</verstretch>
|
41
|
+
</sizepolicy>
|
42
|
+
</property>
|
43
|
+
<property name="minimumSize">
|
44
|
+
<size>
|
45
|
+
<width>250</width>
|
46
|
+
<height>200</height>
|
47
|
+
</size>
|
48
|
+
</property>
|
49
|
+
<property name="title">
|
50
|
+
<string>Fit Summary</string>
|
51
|
+
</property>
|
52
|
+
<layout class="QVBoxLayout" name="verticalLayout_2">
|
53
|
+
<item>
|
54
|
+
<widget class="QTreeWidget" name="summary_tree">
|
55
|
+
<property name="sizePolicy">
|
56
|
+
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
57
|
+
<horstretch>0</horstretch>
|
58
|
+
<verstretch>0</verstretch>
|
59
|
+
</sizepolicy>
|
60
|
+
</property>
|
61
|
+
<property name="minimumSize">
|
62
|
+
<size>
|
63
|
+
<width>0</width>
|
64
|
+
<height>0</height>
|
65
|
+
</size>
|
66
|
+
</property>
|
67
|
+
<property name="uniformRowHeights">
|
68
|
+
<bool>false</bool>
|
69
|
+
</property>
|
70
|
+
<attribute name="headerDefaultSectionSize">
|
71
|
+
<number>80</number>
|
72
|
+
</attribute>
|
73
|
+
<column>
|
74
|
+
<property name="text">
|
75
|
+
<string>Property</string>
|
76
|
+
</property>
|
77
|
+
</column>
|
78
|
+
<column>
|
79
|
+
<property name="text">
|
80
|
+
<string>Value</string>
|
81
|
+
</property>
|
82
|
+
</column>
|
83
|
+
</widget>
|
84
|
+
</item>
|
85
|
+
</layout>
|
86
|
+
</widget>
|
87
|
+
</item>
|
88
|
+
<item>
|
89
|
+
<widget class="QGroupBox" name="group_parameters">
|
90
|
+
<property name="sizePolicy">
|
91
|
+
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
92
|
+
<horstretch>0</horstretch>
|
93
|
+
<verstretch>0</verstretch>
|
94
|
+
</sizepolicy>
|
95
|
+
</property>
|
96
|
+
<property name="minimumSize">
|
97
|
+
<size>
|
98
|
+
<width>250</width>
|
99
|
+
<height>200</height>
|
100
|
+
</size>
|
101
|
+
</property>
|
102
|
+
<property name="title">
|
103
|
+
<string>Parameter Details</string>
|
104
|
+
</property>
|
105
|
+
<layout class="QVBoxLayout" name="verticalLayout_3">
|
106
|
+
<item>
|
107
|
+
<widget class="QTreeWidget" name="param_tree">
|
108
|
+
<property name="sizePolicy">
|
109
|
+
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
110
|
+
<horstretch>0</horstretch>
|
111
|
+
<verstretch>0</verstretch>
|
112
|
+
</sizepolicy>
|
113
|
+
</property>
|
114
|
+
<property name="minimumSize">
|
115
|
+
<size>
|
116
|
+
<width>0</width>
|
117
|
+
<height>0</height>
|
118
|
+
</size>
|
119
|
+
</property>
|
120
|
+
<attribute name="headerDefaultSectionSize">
|
121
|
+
<number>80</number>
|
122
|
+
</attribute>
|
123
|
+
<column>
|
124
|
+
<property name="text">
|
125
|
+
<string>Parameter</string>
|
126
|
+
</property>
|
127
|
+
</column>
|
128
|
+
<column>
|
129
|
+
<property name="text">
|
130
|
+
<string>Value</string>
|
131
|
+
</property>
|
132
|
+
</column>
|
133
|
+
<column>
|
134
|
+
<property name="text">
|
135
|
+
<string>Std</string>
|
136
|
+
</property>
|
137
|
+
</column>
|
138
|
+
</widget>
|
139
|
+
</item>
|
140
|
+
</layout>
|
141
|
+
</widget>
|
142
|
+
</item>
|
143
|
+
</layout>
|
144
|
+
</widget>
|
145
|
+
<resources/>
|
146
|
+
<connections/>
|
147
|
+
</ui>
|
@@ -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.lmfit_dialog.lm_fit_dialog_plugin import LMFitDialogPlugin
|
10
|
+
|
11
|
+
QPyDesignerCustomWidgetCollection.addCustomWidget(LMFitDialogPlugin())
|
12
|
+
|
13
|
+
|
14
|
+
if __name__ == "__main__": # pragma: no cover
|
15
|
+
main()
|
@@ -23,16 +23,16 @@ class StopButton(BECWidget, QWidget):
|
|
23
23
|
self.layout.setAlignment(Qt.AlignmentFlag.AlignVCenter)
|
24
24
|
|
25
25
|
if toolbar:
|
26
|
-
icon = material_icon("stop", color="#cc181e", filled=True)
|
26
|
+
icon = material_icon("stop", color="#cc181e", filled=True, convert_to_pixmap=False)
|
27
27
|
self.button = QToolButton(icon=icon)
|
28
|
-
self.button.
|
28
|
+
self.button.setToolTip("Stop the scan queue")
|
29
29
|
else:
|
30
30
|
self.button = QPushButton()
|
31
31
|
self.button.setText("Stop")
|
32
32
|
self.button.setStyleSheet(
|
33
33
|
"background-color: #cc181e; color: white; font-weight: bold; font-size: 12px;"
|
34
34
|
)
|
35
|
-
|
35
|
+
self.button.clicked.connect(self.stop_scan)
|
36
36
|
|
37
37
|
self.layout.addWidget(self.button)
|
38
38
|
|
@@ -4,66 +4,26 @@ from qtpy.QtWidgets import QDialog, QTreeWidgetItem, QVBoxLayout
|
|
4
4
|
|
5
5
|
from bec_widgets.qt_utils.error_popups import SafeSlot as Slot
|
6
6
|
from bec_widgets.utils import UILoader
|
7
|
+
from bec_widgets.widgets.lmfit_dialog.lmfit_dialog import LMFitDialog
|
7
8
|
|
8
9
|
|
9
10
|
class FitSummaryWidget(QDialog):
|
11
|
+
|
10
12
|
def __init__(self, parent=None, target_widget=None):
|
11
13
|
super().__init__(parent=parent)
|
12
14
|
|
13
|
-
self.target_widget = target_widget
|
14
|
-
self.summary_data = self.target_widget.get_dap_summary()
|
15
|
-
|
16
15
|
self.setModal(True)
|
17
|
-
|
18
|
-
|
19
|
-
self.ui = UILoader(self).loader(os.path.join(current_path, "dap_summary.ui"))
|
16
|
+
self.target_widget = target_widget
|
17
|
+
self.dap_dialog = LMFitDialog(parent=self, ui_file="lmfit_dialog_compact.ui")
|
20
18
|
self.layout = QVBoxLayout(self)
|
21
|
-
self.layout.addWidget(self.
|
22
|
-
|
23
|
-
self.
|
24
|
-
self.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
for
|
30
|
-
|
31
|
-
|
32
|
-
def display_fit_details(self, current):
|
33
|
-
if current:
|
34
|
-
curve_name = current.text()
|
35
|
-
data = self.summary_data[curve_name]
|
36
|
-
if data is None:
|
37
|
-
return
|
38
|
-
self.refresh_trees(data)
|
39
|
-
|
40
|
-
@Slot()
|
41
|
-
def refresh_dap(self):
|
42
|
-
self.ui.curve_list.clear()
|
43
|
-
self.summary_data = self.target_widget.get_dap_summary()
|
44
|
-
self.populate_curve_list()
|
45
|
-
|
46
|
-
def refresh_trees(self, data):
|
47
|
-
self.update_summary_tree(data)
|
48
|
-
self.update_param_tree(data["params"])
|
49
|
-
|
50
|
-
def update_summary_tree(self, data):
|
51
|
-
self.ui.summary_tree.clear()
|
52
|
-
properties = [
|
53
|
-
("Model", data.get("model", "")),
|
54
|
-
("Method", data.get("method", "")),
|
55
|
-
("Chi-Squared", str(data.get("chisqr", ""))),
|
56
|
-
("Reduced Chi-Squared", str(data.get("redchi", ""))),
|
57
|
-
("AIC", str(data.get("aic", ""))),
|
58
|
-
("BIC", str(data.get("bic", ""))),
|
59
|
-
("R-Squared", str(data.get("rsquared", ""))),
|
60
|
-
("Message", data.get("message", "")),
|
61
|
-
]
|
62
|
-
for prop, val in properties:
|
63
|
-
QTreeWidgetItem(self.ui.summary_tree, [prop, val])
|
64
|
-
|
65
|
-
def update_param_tree(self, params):
|
66
|
-
self.ui.param_tree.clear()
|
67
|
-
for param in params:
|
68
|
-
param_name, param_value, param_std = param[0], str(param[1]), str(param[7])
|
69
|
-
QTreeWidgetItem(self.ui.param_tree, [param_name, param_value, param_std])
|
19
|
+
self.layout.addWidget(self.dap_dialog)
|
20
|
+
self.target_widget.dap_summary_update.connect(self.dap_dialog.update_summary_tree)
|
21
|
+
self.setLayout(self.layout)
|
22
|
+
self._get_dap_from_target_widget()
|
23
|
+
|
24
|
+
def _get_dap_from_target_widget(self) -> None:
|
25
|
+
"""Get the DAP data from the target widget and update the DAP dialog manually on creation."""
|
26
|
+
dap_summary = self.target_widget.get_dap_summary()
|
27
|
+
for curve_id, data in dap_summary.items():
|
28
|
+
md = {"curve_id": curve_id}
|
29
|
+
self.dap_dialog.update_summary_tree(data=data, metadata=md)
|
@@ -55,8 +55,8 @@ class BECWaveformWidget(BECWidget, QWidget):
|
|
55
55
|
]
|
56
56
|
scan_signal_update = Signal()
|
57
57
|
async_signal_update = Signal()
|
58
|
-
|
59
|
-
|
58
|
+
dap_summary_update = Signal(dict, dict)
|
59
|
+
dap_params_update = Signal(dict, dict)
|
60
60
|
autorange_signal = Signal()
|
61
61
|
new_scan = Signal()
|
62
62
|
crosshair_position_changed = Signal(tuple)
|
@@ -218,7 +218,7 @@ class BECWaveformWidget(BECWidget, QWidget):
|
|
218
218
|
def show_fit_summary_dialog(self):
|
219
219
|
dialog = FitSummaryWidget(target_widget=self)
|
220
220
|
dialog.resize(800, 600)
|
221
|
-
dialog.
|
221
|
+
dialog.exec()
|
222
222
|
|
223
223
|
###################################
|
224
224
|
# User Access Methods from Waveform
|
@@ -257,7 +257,7 @@ class BECWaveformWidget(BECWidget, QWidget):
|
|
257
257
|
"""
|
258
258
|
self.waveform.set_colormap(colormap)
|
259
259
|
|
260
|
-
@SafeSlot(popup_error=True)
|
260
|
+
@SafeSlot(str, popup_error=True)
|
261
261
|
def set_x(self, x_name: str, x_entry: str | None = None):
|
262
262
|
"""
|
263
263
|
Change the x axis of the plot widget.
|
@@ -272,7 +272,7 @@ class BECWaveformWidget(BECWidget, QWidget):
|
|
272
272
|
"""
|
273
273
|
self.waveform.set_x(x_name, x_entry)
|
274
274
|
|
275
|
-
@SafeSlot(popup_error=True)
|
275
|
+
@SafeSlot(str, popup_error=True)
|
276
276
|
def plot(
|
277
277
|
self,
|
278
278
|
arg1: list | np.ndarray | str | None = None,
|
@@ -331,15 +331,16 @@ class BECWaveformWidget(BECWidget, QWidget):
|
|
331
331
|
**kwargs,
|
332
332
|
)
|
333
333
|
|
334
|
-
@SafeSlot(popup_error=True)
|
334
|
+
@SafeSlot(str, str, str, popup_error=True)
|
335
335
|
def add_dap(
|
336
336
|
self,
|
337
337
|
x_name: str,
|
338
338
|
y_name: str,
|
339
|
+
dap: str,
|
339
340
|
x_entry: str | None = None,
|
340
341
|
y_entry: str | None = None,
|
341
342
|
color: str | None = None,
|
342
|
-
dap: str = "GaussianModel",
|
343
|
+
# dap: str = "GaussianModel",
|
343
344
|
validate_bec: bool = True,
|
344
345
|
**kwargs,
|
345
346
|
) -> BECCurve:
|