minor changes

This commit is contained in:
Dominik Demuth 2024-01-04 13:22:48 +01:00
parent 71fd0675fc
commit 9068ec2b83
2 changed files with 27 additions and 9 deletions

View File

@ -51,13 +51,14 @@ class FitToolbar(QtWidgets.QToolBar):
self.limit_group.triggered.connect(self.change_limit_type)
self.region.sigRegionChanged.connect(self.change_labels)
self.change_labels()
self.lineedit.textChanged.connect(self.move_region)
self.lineedit2.textChanged.connect(self.move_region)
@QtCore.pyqtSlot(QtWidgets.QAction)
def change_limit_type(self, action: QtWidgets.QAction):
is_custom = action.text() == 'Custom'
is_custom = (action.text() == 'Custom')
for w in [self.label, self.label2, self.lineedit, self.lineedit2]:
w.setEnabled(is_custom)
@ -73,6 +74,24 @@ class FitToolbar(QtWidgets.QToolBar):
self.lineedit2.blockSignals(False)
def move_region(self):
r_min = self.lineedit.text()
r_max = self.lineedit2.text()
self.region.setRegion((float(r_min), float(r_max)), use_log=True)
try:
r_min = float(self.lineedit.text())
except ValueError:
r_min = None
try:
r_max = float(self.lineedit2.text())
except ValueError:
r_max = None
if r_min is not None and r_max is not None:
self.region.setRegion((r_min, r_max), use_log=True)
def get_limit(self):
action_text = self.limit_group.checkedAction().text()
return {
'None': 'none',
'Visible x range': 'x',
'Custom': self.region.getRegion(),
}[action_text]

View File

@ -904,17 +904,16 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
@QtCore.pyqtSlot(QtWidgets.QAction)
def change_fit_limits(self, action: QtWidgets.QAction):
if self.current_graph_widget is None:
return
if action == self.action_custom_range and self.fit_dialog.isVisible():
self.current_graph_widget.add_external(self.fitregion)
else:
self.current_graph_widget.remove_external(self.fitregion)
def start_fit(self, parameter, links, fit_options):
fit_options['limits'] = {
self.action_no_range: 'none',
self.action_x_range: 'x',
self.action_custom_range: self.fitregion.getRegion()
}[self.ac_group2.checkedAction()]
fit_options['limits'] = self.fit_toolbar.get_limit()
fit_options['fit_mode'] = {
self.action_lm_fit: 'lsq',