diff --git a/src/gui_qt/_py/basewindow.py b/src/gui_qt/_py/basewindow.py
index 3b24795..d916548 100644
--- a/src/gui_qt/_py/basewindow.py
+++ b/src/gui_qt/_py/basewindow.py
@@ -365,6 +365,9 @@ class Ui_BaseWindow(object):
self.actionBinning.setObjectName("actionBinning")
self.actionTNMH = QtWidgets.QAction(BaseWindow)
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.actionExportGraphic)
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_x_range)
self.menuLimits.addAction(self.action_custom_range)
+ self.menuLimits.addAction(self.actionExclude_region)
self.menuFit.addAction(self.action_FitWidget)
self.menuFit.addSeparator()
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.actionBinning.setText(_translate("BaseWindow", "Binning..."))
self.actionTNMH.setText(_translate("BaseWindow", "TNMH..."))
+ self.actionExclude_region.setText(_translate("BaseWindow", "Exclude region"))
from ..data.datawidget.datawidget import DataWidget
from ..data.integral_widget import IntegralWidget
from ..data.point_select import PointSelectWidget
diff --git a/src/gui_qt/fit/fit_toolbar.py b/src/gui_qt/fit/fit_toolbar.py
index 4cfa091..283c335 100644
--- a/src/gui_qt/fit/fit_toolbar.py
+++ b/src/gui_qt/fit/fit_toolbar.py
@@ -58,7 +58,8 @@ class FitToolbar(QtWidgets.QToolBar):
@QtCore.pyqtSlot(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]:
w.setEnabled(is_custom)
@@ -93,5 +94,6 @@ class FitToolbar(QtWidgets.QToolBar):
return {
'None': 'none',
'Visible x range': 'x',
- 'Custom': self.region.getRegion(),
+ 'Custom': ('in', self.region.getRegion()),
+ 'Exclude region': ('out', self.region.getRegion()),
}[action_text]
diff --git a/src/gui_qt/main/mainwindow.py b/src/gui_qt/main/mainwindow.py
index 80935b6..d91b3ac 100644
--- a/src/gui_qt/main/mainwindow.py
+++ b/src/gui_qt/main/mainwindow.py
@@ -888,7 +888,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
self.fit_dialog.load(self.management.active_sets)
for item in self.fit_dialog.preview_lines:
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)
block_window = True
@@ -904,7 +904,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
if self.current_graph_widget is None:
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)
else:
self.current_graph_widget.remove_external(self.fit_toolbar.region)
diff --git a/src/gui_qt/main/management.py b/src/gui_qt/main/management.py
index b8758b2..ab07037 100644
--- a/src/gui_qt/main/management.py
+++ b/src/gui_qt/main/management.py
@@ -511,13 +511,16 @@ class UpperManagement(QtCore.QObject):
_x = data_i.x
+ # options for fit limits 'none', 'x', ('in', custom region), ('out', excluded region)
if fit_limits == 'none':
inside = slice(None)
elif fit_limits == 'x':
x_lim, _ = self.graphs[self.current_graph].ranges
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:
- 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:
if isinstance(we, str):
diff --git a/src/resources/_ui/basewindow.ui b/src/resources/_ui/basewindow.ui
index bf3de79..01987b8 100644
--- a/src/resources/_ui/basewindow.ui
+++ b/src/resources/_ui/basewindow.ui
@@ -247,6 +247,7 @@
+
@@ -1021,6 +1022,14 @@
TNMH...
+
+
+ true
+
+
+ Exclude region
+
+