diff --git a/src/gui_qt/_py/basewindow.py b/src/gui_qt/_py/basewindow.py index df4defd..3653193 100644 --- a/src/gui_qt/_py/basewindow.py +++ b/src/gui_qt/_py/basewindow.py @@ -372,6 +372,8 @@ class Ui_BaseWindow(object): self.actionTNMH_model.setObjectName("actionTNMH_model") self.actionBinning = QtWidgets.QAction(BaseWindow) self.actionBinning.setObjectName("actionBinning") + self.actionTNMH = QtWidgets.QAction(BaseWindow) + self.actionTNMH.setObjectName("actionTNMH") self.menuSave.addAction(self.actionSave) self.menuSave.addAction(self.actionExportGraphic) self.menuSave.addAction(self.action_save_fit_parameter) @@ -470,6 +472,7 @@ class Ui_BaseWindow(object): self.menuStuff.addAction(self.actionTetris) self.menuStuff.addAction(self.actionMine) self.menuDSC.addAction(self.actionTNMH_model) + self.menuDSC.addAction(self.actionTNMH) self.menubar.addAction(self.menuFile.menuAction()) self.menubar.addAction(self.menuWindow.menuAction()) self.menubar.addAction(self.menuData.menuAction()) @@ -639,6 +642,7 @@ class Ui_BaseWindow(object): self.actionAbout.setText(_translate("BaseWindow", "About...")) self.actionTNMH_model.setText(_translate("BaseWindow", "Tg determination,,,")) self.actionBinning.setText(_translate("BaseWindow", "Binning...")) + self.actionTNMH.setText(_translate("BaseWindow", "TNMH...")) from ..data.datawidget.datawidget import DataWidget from ..data.integral_widget import IntegralWidget from ..data.point_select import PointSelectWidget diff --git a/src/gui_qt/_py/tnmh_dialog.py b/src/gui_qt/_py/tnmh_dialog.py index e984863..a48664f 100644 --- a/src/gui_qt/_py/tnmh_dialog.py +++ b/src/gui_qt/_py/tnmh_dialog.py @@ -14,12 +14,12 @@ from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjectName("Dialog") - Dialog.resize(1042, 683) + Dialog.resize(1041, 773) self.gridLayout = QtWidgets.QGridLayout(Dialog) self.gridLayout.setObjectName("gridLayout") self.buttonBox = QtWidgets.QDialogButtonBox(Dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close|QtWidgets.QDialogButtonBox.Save) + self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close) self.buttonBox.setObjectName("buttonBox") self.gridLayout.addWidget(self.buttonBox, 5, 1, 1, 1) self.verticalLayout = QtWidgets.QVBoxLayout() @@ -53,81 +53,6 @@ class Ui_Dialog(object): self.label_5.setObjectName("label_5") self.verticalLayout.addWidget(self.label_5) self.gridLayout.addLayout(self.verticalLayout, 0, 0, 5, 1) - self.stackedWidget = QtWidgets.QStackedWidget(Dialog) - self.stackedWidget.setFrameShape(QtWidgets.QFrame.StyledPanel) - self.stackedWidget.setFrameShadow(QtWidgets.QFrame.Raised) - self.stackedWidget.setObjectName("stackedWidget") - self.stackedWidgetPage1 = QtWidgets.QWidget() - self.stackedWidgetPage1.setObjectName("stackedWidgetPage1") - self.gridLayout_3 = QtWidgets.QGridLayout(self.stackedWidgetPage1) - self.gridLayout_3.setObjectName("gridLayout_3") - self.hodge_selection = CheckCombobox(self.stackedWidgetPage1) - self.hodge_selection.setObjectName("hodge_selection") - self.hodge_selection.addItem("") - self.hodge_selection.addItem("") - self.hodge_selection.addItem("") - self.hodge_selection.addItem("") - self.gridLayout_3.addWidget(self.hodge_selection, 4, 2, 1, 1) - self.tau_plot = PlotWidget(self.stackedWidgetPage1) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.MinimumExpanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.tau_plot.sizePolicy().hasHeightForWidth()) - self.tau_plot.setSizePolicy(sizePolicy) - self.tau_plot.setObjectName("tau_plot") - self.gridLayout_3.addWidget(self.tau_plot, 0, 0, 7, 1) - self.tg_export_check = QtWidgets.QCheckBox(self.stackedWidgetPage1) - self.tg_export_check.setChecked(True) - self.tg_export_check.setObjectName("tg_export_check") - self.gridLayout_3.addWidget(self.tg_export_check, 2, 1, 1, 1) - self.tglines_export_check = QtWidgets.QCheckBox(self.stackedWidgetPage1) - self.tglines_export_check.setChecked(True) - self.tglines_export_check.setObjectName("tglines_export_check") - self.gridLayout_3.addWidget(self.tglines_export_check, 2, 2, 1, 1) - spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) - self.gridLayout_3.addItem(spacerItem, 6, 2, 1, 1) - self.new_graph_tau_combo = QtWidgets.QComboBox(self.stackedWidgetPage1) - self.new_graph_tau_combo.setObjectName("new_graph_tau_combo") - self.gridLayout_3.addWidget(self.new_graph_tau_combo, 5, 2, 1, 1) - self.label_6 = QtWidgets.QLabel(self.stackedWidgetPage1) - self.label_6.setObjectName("label_6") - self.gridLayout_3.addWidget(self.label_6, 4, 1, 1, 1) - self.new_graph_tau_check = QtWidgets.QCheckBox(self.stackedWidgetPage1) - self.new_graph_tau_check.setChecked(True) - self.new_graph_tau_check.setObjectName("new_graph_tau_check") - self.gridLayout_3.addWidget(self.new_graph_tau_check, 5, 1, 1, 1) - self.line = QtWidgets.QFrame(self.stackedWidgetPage1) - self.line.setFrameShape(QtWidgets.QFrame.HLine) - self.line.setFrameShadow(QtWidgets.QFrame.Sunken) - self.line.setObjectName("line") - self.gridLayout_3.addWidget(self.line, 3, 1, 1, 2) - self.stackedWidget.addWidget(self.stackedWidgetPage1) - self.page = QtWidgets.QWidget() - self.page.setObjectName("page") - self.gridLayout_2 = QtWidgets.QGridLayout(self.page) - self.gridLayout_2.setObjectName("gridLayout_2") - self.horizontalLayout = QtWidgets.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.label_2 = QtWidgets.QLabel(self.page) - self.label_2.setObjectName("label_2") - self.horizontalLayout.addWidget(self.label_2) - self.comboBox = QtWidgets.QComboBox(self.page) - self.comboBox.setObjectName("comboBox") - self.comboBox.addItem("") - self.comboBox.addItem("") - self.comboBox.addItem("") - self.comboBox.addItem("") - self.comboBox.addItem("") - self.horizontalLayout.addWidget(self.comboBox) - self.gridLayout_2.addLayout(self.horizontalLayout, 1, 1, 1, 1) - self.pushButton_3 = QtWidgets.QPushButton(self.page) - self.pushButton_3.setObjectName("pushButton_3") - self.gridLayout_2.addWidget(self.pushButton_3, 2, 1, 1, 1) - self.graphicsView_2 = PlotWidget(self.page) - self.graphicsView_2.setObjectName("graphicsView_2") - self.gridLayout_2.addWidget(self.graphicsView_2, 0, 0, 3, 1) - self.stackedWidget.addWidget(self.page) - self.gridLayout.addWidget(self.stackedWidget, 4, 1, 1, 1) self.dsc_plot = PlotWidget(Dialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) @@ -154,12 +79,114 @@ class Ui_Dialog(object): self.pushButton_2.setSizePolicy(sizePolicy) self.pushButton_2.setObjectName("pushButton_2") self.horizontalLayout_2.addWidget(self.pushButton_2) - spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.horizontalLayout_2.addItem(spacerItem1) + spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.horizontalLayout_2.addItem(spacerItem) self.gridLayout.addLayout(self.horizontalLayout_2, 2, 1, 1, 1) + self.tabWidget = QtWidgets.QTabWidget(Dialog) + self.tabWidget.setTabPosition(QtWidgets.QTabWidget.East) + self.tabWidget.setObjectName("tabWidget") + self.tabWidgetPage1 = QtWidgets.QWidget() + self.tabWidgetPage1.setObjectName("tabWidgetPage1") + self.gridLayout_3 = QtWidgets.QGridLayout(self.tabWidgetPage1) + self.gridLayout_3.setObjectName("gridLayout_3") + self.tg_export_check = QtWidgets.QCheckBox(self.tabWidgetPage1) + self.tg_export_check.setChecked(True) + self.tg_export_check.setObjectName("tg_export_check") + self.gridLayout_3.addWidget(self.tg_export_check, 2, 1, 1, 1) + self.tglines_export_check = QtWidgets.QCheckBox(self.tabWidgetPage1) + self.tglines_export_check.setChecked(True) + self.tglines_export_check.setObjectName("tglines_export_check") + self.gridLayout_3.addWidget(self.tglines_export_check, 2, 2, 1, 1) + self.label_6 = QtWidgets.QLabel(self.tabWidgetPage1) + self.label_6.setObjectName("label_6") + self.gridLayout_3.addWidget(self.label_6, 4, 1, 1, 1) + self.new_graph_tau_combo = QtWidgets.QComboBox(self.tabWidgetPage1) + self.new_graph_tau_combo.setObjectName("new_graph_tau_combo") + self.gridLayout_3.addWidget(self.new_graph_tau_combo, 5, 2, 1, 1) + self.new_graph_tau_check = QtWidgets.QCheckBox(self.tabWidgetPage1) + self.new_graph_tau_check.setChecked(True) + self.new_graph_tau_check.setObjectName("new_graph_tau_check") + self.gridLayout_3.addWidget(self.new_graph_tau_check, 5, 1, 1, 1) + self.line = QtWidgets.QFrame(self.tabWidgetPage1) + self.line.setFrameShape(QtWidgets.QFrame.HLine) + self.line.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line.setObjectName("line") + self.gridLayout_3.addWidget(self.line, 3, 1, 1, 2) + self.hodge_selection = CheckCombobox(self.tabWidgetPage1) + self.hodge_selection.setObjectName("hodge_selection") + self.hodge_selection.addItem("") + self.hodge_selection.addItem("") + self.hodge_selection.addItem("") + self.hodge_selection.addItem("") + self.hodge_selection.addItem("") + self.gridLayout_3.addWidget(self.hodge_selection, 4, 2, 1, 1) + self.tau_plot = PlotWidget(self.tabWidgetPage1) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.MinimumExpanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.tau_plot.sizePolicy().hasHeightForWidth()) + self.tau_plot.setSizePolicy(sizePolicy) + self.tau_plot.setObjectName("tau_plot") + self.gridLayout_3.addWidget(self.tau_plot, 0, 0, 8, 1) + spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_3.addItem(spacerItem1, 7, 2, 1, 1) + self.pushButton_4 = QtWidgets.QPushButton(self.tabWidgetPage1) + self.pushButton_4.setObjectName("pushButton_4") + self.gridLayout_3.addWidget(self.pushButton_4, 6, 1, 1, 2) + self.tabWidget.addTab(self.tabWidgetPage1, "") + self.tabWidgetPage2 = QtWidgets.QWidget() + self.tabWidgetPage2.setObjectName("tabWidgetPage2") + self.gridLayout_2 = QtWidgets.QGridLayout(self.tabWidgetPage2) + self.gridLayout_2.setObjectName("gridLayout_2") + self.pushButton_3 = QtWidgets.QPushButton(self.tabWidgetPage2) + self.pushButton_3.setObjectName("pushButton_3") + self.gridLayout_2.addWidget(self.pushButton_3, 1, 1, 1, 2) + self.graphicsView_2 = PlotWidget(self.tabWidgetPage2) + self.graphicsView_2.setObjectName("graphicsView_2") + self.gridLayout_2.addWidget(self.graphicsView_2, 0, 0, 9, 1) + self.checkBox = QtWidgets.QCheckBox(self.tabWidgetPage2) + self.checkBox.setChecked(True) + self.checkBox.setObjectName("checkBox") + self.gridLayout_2.addWidget(self.checkBox, 5, 1, 1, 1) + self.horizontalLayout = QtWidgets.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.label_2 = QtWidgets.QLabel(self.tabWidgetPage2) + self.label_2.setObjectName("label_2") + self.horizontalLayout.addWidget(self.label_2) + self.comboBox = QtWidgets.QComboBox(self.tabWidgetPage2) + self.comboBox.setObjectName("comboBox") + self.comboBox.addItem("") + self.comboBox.addItem("") + self.comboBox.addItem("") + self.comboBox.addItem("") + self.comboBox.addItem("") + self.horizontalLayout.addWidget(self.comboBox) + self.gridLayout_2.addLayout(self.horizontalLayout, 0, 1, 1, 2) + self.comboBox_2 = QtWidgets.QComboBox(self.tabWidgetPage2) + self.comboBox_2.setObjectName("comboBox_2") + self.gridLayout_2.addWidget(self.comboBox_2, 5, 2, 1, 1) + self.line_2 = QtWidgets.QFrame(self.tabWidgetPage2) + self.line_2.setMinimumSize(QtCore.QSize(0, 0)) + self.line_2.setFrameShape(QtWidgets.QFrame.HLine) + self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line_2.setObjectName("line_2") + self.gridLayout_2.addWidget(self.line_2, 2, 1, 1, 2) + self.checkBox_2 = QtWidgets.QCheckBox(self.tabWidgetPage2) + self.checkBox_2.setObjectName("checkBox_2") + self.gridLayout_2.addWidget(self.checkBox_2, 3, 1, 1, 2) + self.checkBox_3 = QtWidgets.QCheckBox(self.tabWidgetPage2) + self.checkBox_3.setObjectName("checkBox_3") + self.gridLayout_2.addWidget(self.checkBox_3, 4, 1, 1, 2) + spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_2.addItem(spacerItem2, 8, 1, 1, 1) + self.pushButton = QtWidgets.QPushButton(self.tabWidgetPage2) + self.pushButton.setObjectName("pushButton") + self.gridLayout_2.addWidget(self.pushButton, 7, 1, 1, 2) + self.tabWidget.addTab(self.tabWidgetPage2, "") + self.gridLayout.addWidget(self.tabWidget, 4, 1, 1, 1) self.retranslateUi(Dialog) - self.stackedWidget.setCurrentIndex(0) + self.tabWidget.setCurrentIndex(0) self.buttonBox.accepted.connect(Dialog.accept) # type: ignore self.buttonBox.rejected.connect(Dialog.reject) # type: ignore QtCore.QMetaObject.connectSlotsByName(Dialog) @@ -169,22 +196,30 @@ class Ui_Dialog(object): Dialog.setWindowTitle(_translate("Dialog", "SImba, everything the light touches is our kingdom")) self.label.setText(_translate("Dialog", "
Tg values:
")) self.label_4.setText(_translate("Dialog", "TNMH parameter:
")) + self.calctg_button.setText(_translate("Dialog", "Calculate Tg")) + self.pushButton_2.setText(_translate("Dialog", "Calculate fictive Cp")) + self.tg_export_check.setText(_translate("Dialog", "Export Tg")) + self.tglines_export_check.setText(_translate("Dialog", "Export lines")) + self.label_6.setText(_translate("Dialog", "Export Hodge:")) + self.new_graph_tau_check.setText(_translate("Dialog", "New graph")) self.hodge_selection.setItemText(0, _translate("Dialog", "Onset")) self.hodge_selection.setItemText(1, _translate("Dialog", "Midpoint")) self.hodge_selection.setItemText(2, _translate("Dialog", "End")) self.hodge_selection.setItemText(3, _translate("Dialog", "Inflection")) - self.tg_export_check.setText(_translate("Dialog", "Export Tg")) - self.tglines_export_check.setText(_translate("Dialog", "Export lines")) - self.label_6.setText(_translate("Dialog", "Hodge:")) - self.new_graph_tau_check.setText(_translate("Dialog", "New graph")) + self.hodge_selection.setItemText(4, _translate("Dialog", "Fictive")) + self.pushButton_4.setText(_translate("Dialog", "Save")) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabWidgetPage1), _translate("Dialog", "Tg / Hodge")) + self.pushButton_3.setText(_translate("Dialog", "Fit TNMH model")) + self.checkBox.setText(_translate("Dialog", "New graph")) self.label_2.setText(_translate("Dialog", "Tg for TNMH")) self.comboBox.setItemText(0, _translate("Dialog", "Fictive")) self.comboBox.setItemText(1, _translate("Dialog", "Onset")) self.comboBox.setItemText(2, _translate("Dialog", "Midpoint")) self.comboBox.setItemText(3, _translate("Dialog", "End")) self.comboBox.setItemText(4, _translate("Dialog", "Inflection")) - self.pushButton_3.setText(_translate("Dialog", "Fit TNMH model")) - self.calctg_button.setText(_translate("Dialog", "Calculate Tg")) - self.pushButton_2.setText(_translate("Dialog", "Calculate fictive Cp")) + self.checkBox_2.setText(_translate("Dialog", "Export dTf / dT")) + self.checkBox_3.setText(_translate("Dialog", "Export fit")) + self.pushButton.setText(_translate("Dialog", "Save")) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabWidgetPage2), _translate("Dialog", "TNMH")) from ..lib.forms import CheckCombobox from pyqtgraph import PlotWidget diff --git a/src/gui_qt/dsc/glass_dialog.py b/src/gui_qt/dsc/glass_dialog.py index d30ea57..2ece5d8 100644 --- a/src/gui_qt/dsc/glass_dialog.py +++ b/src/gui_qt/dsc/glass_dialog.py @@ -40,9 +40,6 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): for plt, _ in self._hodge.values(): self.tau_plot.addItem(plt) self.tau_plot.setLogMode(y=True) - self.pushButton_2.hide() - self.label_4.hide() - self.label_5.hide() self.limits = RegionItem(), RegionItem() for lim in self.limits: @@ -129,7 +126,13 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): self.graphicsView_2.addItem(tnmh_fit) self._plots[key] = (data_plot, tg_plot, glass, liquid, tangent, fictive_cp, tnmh_fit) - self._tg_value[key] = {'onset': (nan, nan), 'mid': (nan, nan), 'end': (nan, nan), 'inflection': (nan, nan)} # , 'fictive': (nan, nan)} + self._tg_value[key] = { + 'onset': (nan, nan), + 'mid': (nan, nan), + 'end': (nan, nan), + 'inflection': (nan, nan), + # 'fictive': (nan, nan), + } if self._limitless: dist = max_x - min_x @@ -216,7 +219,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): self._update_tg_plots() - @QtCore.pyqtSlot(name='on_pushButton_3_clicked') + @QtCore.pyqtSlot(name='on_fit_tnhm_fitbutton_clicked') def make_tnmh(self): baselines = tuple(lim.getRegion() for lim in self.limits) if baselines[0][0] > baselines[1][0]: @@ -247,11 +250,13 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): key = item.data(QtCore.Qt.UserRole) data, _ = self._dsc[key] - - tg_value = self._tg_value[key][tg_type][0] - if isnan(tg_value): + try: + tg_value = self._tg_value[key][tg_type][0] + if isnan(tg_value): + continue + except KeyError: continue - + m.append([tg_value, data.value]) if len(m) > 1: diff --git a/src/gui_qt/main/mainwindow.py b/src/gui_qt/main/mainwindow.py index 4d7327f..c7f3c2b 100644 --- a/src/gui_qt/main/mainwindow.py +++ b/src/gui_qt/main/mainwindow.py @@ -1139,6 +1139,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): QtWidgets.QMessageBox.about(self, 'Version', f'Build date of AppImage: {__version__}') @QtCore.pyqtSlot(name='on_actionTNMH_model_triggered') + @QtCore.pyqtSlot(name='on_actionTNMH_triggered') def show_tg_dialog(self): if self._tg_dialog is None: self._tg_dialog = TgCalculator(self.management, parent=self) diff --git a/src/nmreval/data/dsc.py b/src/nmreval/data/dsc.py index f9c82fa..afdefb4 100644 --- a/src/nmreval/data/dsc.py +++ b/src/nmreval/data/dsc.py @@ -46,8 +46,6 @@ class DSC(Points): regress2 = linregress(region.x[liquid_regime], region.y[liquid_regime]) region.y -= glass_extrapolation - - plt.plot(region.x, regress2.slope * region.x + regress2.intercept) real_area = cumulative_trapezoid(region.y, region.x, initial=0) real_area -= real_area[-1] diff --git a/src/resources/_ui/basewindow.ui b/src/resources/_ui/basewindow.ui index 3712e76..293724a 100644 --- a/src/resources/_ui/basewindow.ui +++ b/src/resources/_ui/basewindow.ui @@ -332,6 +332,7 @@