forked from IPKM/nmreval
add exclude range to fit limits (#237)
Co-authored-by: Dominik Demuth <dominik.demuth@physik.tu-darmstadt.de> Reviewed-on: IPKM/nmreval#237
This commit is contained in:
parent
567148b7e6
commit
40746bfa7c
@ -365,6 +365,9 @@ class Ui_BaseWindow(object):
|
|||||||
self.actionBinning.setObjectName("actionBinning")
|
self.actionBinning.setObjectName("actionBinning")
|
||||||
self.actionTNMH = QtWidgets.QAction(BaseWindow)
|
self.actionTNMH = QtWidgets.QAction(BaseWindow)
|
||||||
self.actionTNMH.setObjectName("actionTNMH")
|
self.actionTNMH.setObjectName("actionTNMH")
|
||||||
|
self.actionExclude_region = QtWidgets.QAction(BaseWindow)
|
||||||
|
self.actionExclude_region.setCheckable(True)
|
||||||
|
self.actionExclude_region.setObjectName("actionExclude_region")
|
||||||
self.menuSave.addAction(self.actionSave)
|
self.menuSave.addAction(self.actionSave)
|
||||||
self.menuSave.addAction(self.actionExportGraphic)
|
self.menuSave.addAction(self.actionExportGraphic)
|
||||||
self.menuSave.addAction(self.action_save_fit_parameter)
|
self.menuSave.addAction(self.action_save_fit_parameter)
|
||||||
@ -419,6 +422,7 @@ class Ui_BaseWindow(object):
|
|||||||
self.menuLimits.addAction(self.action_no_range)
|
self.menuLimits.addAction(self.action_no_range)
|
||||||
self.menuLimits.addAction(self.action_x_range)
|
self.menuLimits.addAction(self.action_x_range)
|
||||||
self.menuLimits.addAction(self.action_custom_range)
|
self.menuLimits.addAction(self.action_custom_range)
|
||||||
|
self.menuLimits.addAction(self.actionExclude_region)
|
||||||
self.menuFit.addAction(self.action_FitWidget)
|
self.menuFit.addAction(self.action_FitWidget)
|
||||||
self.menuFit.addSeparator()
|
self.menuFit.addSeparator()
|
||||||
self.menuFit.addAction(self.action_create_fit_function)
|
self.menuFit.addAction(self.action_create_fit_function)
|
||||||
@ -631,6 +635,7 @@ class Ui_BaseWindow(object):
|
|||||||
self.actionTNMH_model.setText(_translate("BaseWindow", "Tg , Hodge, TNMH,,,"))
|
self.actionTNMH_model.setText(_translate("BaseWindow", "Tg , Hodge, TNMH,,,"))
|
||||||
self.actionBinning.setText(_translate("BaseWindow", "Binning..."))
|
self.actionBinning.setText(_translate("BaseWindow", "Binning..."))
|
||||||
self.actionTNMH.setText(_translate("BaseWindow", "TNMH..."))
|
self.actionTNMH.setText(_translate("BaseWindow", "TNMH..."))
|
||||||
|
self.actionExclude_region.setText(_translate("BaseWindow", "Exclude region"))
|
||||||
from ..data.datawidget.datawidget import DataWidget
|
from ..data.datawidget.datawidget import DataWidget
|
||||||
from ..data.integral_widget import IntegralWidget
|
from ..data.integral_widget import IntegralWidget
|
||||||
from ..data.point_select import PointSelectWidget
|
from ..data.point_select import PointSelectWidget
|
||||||
|
@ -58,7 +58,8 @@ class FitToolbar(QtWidgets.QToolBar):
|
|||||||
|
|
||||||
@QtCore.pyqtSlot(QtWidgets.QAction)
|
@QtCore.pyqtSlot(QtWidgets.QAction)
|
||||||
def change_limit_type(self, action: QtWidgets.QAction):
|
def change_limit_type(self, action: QtWidgets.QAction):
|
||||||
is_custom = (action.text() == 'Custom')
|
is_custom = (action.text() in ['Custom', 'Exclude region'])
|
||||||
|
print(is_custom)
|
||||||
|
|
||||||
for w in [self.label, self.label2, self.lineedit, self.lineedit2]:
|
for w in [self.label, self.label2, self.lineedit, self.lineedit2]:
|
||||||
w.setEnabled(is_custom)
|
w.setEnabled(is_custom)
|
||||||
@ -93,5 +94,6 @@ class FitToolbar(QtWidgets.QToolBar):
|
|||||||
return {
|
return {
|
||||||
'None': 'none',
|
'None': 'none',
|
||||||
'Visible x range': 'x',
|
'Visible x range': 'x',
|
||||||
'Custom': self.region.getRegion(),
|
'Custom': ('in', self.region.getRegion()),
|
||||||
|
'Exclude region': ('out', self.region.getRegion()),
|
||||||
}[action_text]
|
}[action_text]
|
||||||
|
@ -888,7 +888,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
|||||||
self.fit_dialog.load(self.management.active_sets)
|
self.fit_dialog.load(self.management.active_sets)
|
||||||
for item in self.fit_dialog.preview_lines:
|
for item in self.fit_dialog.preview_lines:
|
||||||
self.current_graph_widget.add_external(item)
|
self.current_graph_widget.add_external(item)
|
||||||
if self.action_custom_range.isChecked():
|
if self.action_custom_range.isChecked() or self.actionExclude_region.isChecked():
|
||||||
self.current_graph_widget.add_external(self.fit_toolbar.region)
|
self.current_graph_widget.add_external(self.fit_toolbar.region)
|
||||||
|
|
||||||
block_window = True
|
block_window = True
|
||||||
@ -904,7 +904,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
|||||||
if self.current_graph_widget is None:
|
if self.current_graph_widget is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
if action == self.action_custom_range and self.fit_dialog.isVisible():
|
if action in [self.action_custom_range, self.actionExclude_region] and self.fit_dialog.isVisible():
|
||||||
self.current_graph_widget.add_external(self.fit_toolbar.region)
|
self.current_graph_widget.add_external(self.fit_toolbar.region)
|
||||||
else:
|
else:
|
||||||
self.current_graph_widget.remove_external(self.fit_toolbar.region)
|
self.current_graph_widget.remove_external(self.fit_toolbar.region)
|
||||||
|
@ -511,13 +511,16 @@ class UpperManagement(QtCore.QObject):
|
|||||||
|
|
||||||
_x = data_i.x
|
_x = data_i.x
|
||||||
|
|
||||||
|
# options for fit limits 'none', 'x', ('in', custom region), ('out', excluded region)
|
||||||
if fit_limits == 'none':
|
if fit_limits == 'none':
|
||||||
inside = slice(None)
|
inside = slice(None)
|
||||||
elif fit_limits == 'x':
|
elif fit_limits == 'x':
|
||||||
x_lim, _ = self.graphs[self.current_graph].ranges
|
x_lim, _ = self.graphs[self.current_graph].ranges
|
||||||
inside = np.where((_x >= x_lim[0]) & (_x <= x_lim[1]))
|
inside = np.where((_x >= x_lim[0]) & (_x <= x_lim[1]))
|
||||||
|
elif fit_limits[0] == 'in':
|
||||||
|
inside = np.where((_x >= fit_limits[1][0]) & (_x <= fit_limits[1][1]))
|
||||||
else:
|
else:
|
||||||
inside = np.where((_x >= fit_limits[0]) & (_x <= fit_limits[1]))
|
inside = np.where((_x < fit_limits[1][0]) | (_x > fit_limits[1][1]))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if isinstance(we, str):
|
if isinstance(we, str):
|
||||||
|
@ -247,6 +247,7 @@
|
|||||||
<addaction name="action_no_range"/>
|
<addaction name="action_no_range"/>
|
||||||
<addaction name="action_x_range"/>
|
<addaction name="action_x_range"/>
|
||||||
<addaction name="action_custom_range"/>
|
<addaction name="action_custom_range"/>
|
||||||
|
<addaction name="actionExclude_region"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="action_FitWidget"/>
|
<addaction name="action_FitWidget"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
@ -1021,6 +1022,14 @@
|
|||||||
<string>TNMH...</string>
|
<string>TNMH...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionExclude_region">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Exclude region</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
Loading…
Reference in New Issue
Block a user