From 25f7ff5616b53512556988165e3136f2d8243711 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Sat, 3 Jun 2023 20:27:56 +0200 Subject: [PATCH] ui adjustments --- src/gui_qt/_py/tnmh_dialog.py | 117 ++++++++------------ src/gui_qt/dsc/glass_dialog.py | 34 ++++-- src/resources/_ui/tnmh_dialog.ui | 181 ++++++++++++++----------------- 3 files changed, 150 insertions(+), 182 deletions(-) diff --git a/src/gui_qt/_py/tnmh_dialog.py b/src/gui_qt/_py/tnmh_dialog.py index c698e63..58933b0 100644 --- a/src/gui_qt/_py/tnmh_dialog.py +++ b/src/gui_qt/_py/tnmh_dialog.py @@ -14,14 +14,9 @@ from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjectName("Dialog") - Dialog.resize(1176, 714) + Dialog.resize(842, 683) 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.Cancel|QtWidgets.QDialogButtonBox.Ok) - self.buttonBox.setObjectName("buttonBox") - self.gridLayout.addWidget(self.buttonBox, 2, 3, 1, 1) self.graphicsView = PlotWidget(Dialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) @@ -29,60 +24,24 @@ class Ui_Dialog(object): sizePolicy.setHeightForWidth(self.graphicsView.sizePolicy().hasHeightForWidth()) self.graphicsView.setSizePolicy(sizePolicy) self.graphicsView.setObjectName("graphicsView") - self.gridLayout.addWidget(self.graphicsView, 0, 3, 1, 1) + self.gridLayout.addWidget(self.graphicsView, 0, 2, 1, 1) self.graphicsView_2 = PlotWidget(Dialog) self.graphicsView_2.setObjectName("graphicsView_2") - self.gridLayout.addWidget(self.graphicsView_2, 1, 3, 1, 1) - self.formLayout = QtWidgets.QFormLayout() - self.formLayout.setObjectName("formLayout") + self.gridLayout.addWidget(self.graphicsView_2, 1, 2, 1, 1) + self.buttonBox = QtWidgets.QDialogButtonBox(Dialog) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) + self.buttonBox.setObjectName("buttonBox") + self.gridLayout.addWidget(self.buttonBox, 3, 2, 1, 1) self.label = QtWidgets.QLabel(Dialog) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth()) + self.label.setSizePolicy(sizePolicy) + self.label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) self.label.setObjectName("label") - self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label) - self.lineEdit = QtWidgets.QLineEdit(Dialog) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.lineEdit.sizePolicy().hasHeightForWidth()) - self.lineEdit.setSizePolicy(sizePolicy) - self.lineEdit.setObjectName("lineEdit") - self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.lineEdit) - self.label_2 = QtWidgets.QLabel(Dialog) - self.label_2.setObjectName("label_2") - self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_2) - self.lineEdit_3 = QtWidgets.QLineEdit(Dialog) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.lineEdit_3.sizePolicy().hasHeightForWidth()) - self.lineEdit_3.setSizePolicy(sizePolicy) - self.lineEdit_3.setObjectName("lineEdit_3") - self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.lineEdit_3) - self.label_3 = QtWidgets.QLabel(Dialog) - self.label_3.setObjectName("label_3") - self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.label_3) - self.lineEdit_2 = QtWidgets.QLineEdit(Dialog) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.lineEdit_2.sizePolicy().hasHeightForWidth()) - self.lineEdit_2.setSizePolicy(sizePolicy) - self.lineEdit_2.setObjectName("lineEdit_2") - self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.lineEdit_2) - self.label_4 = QtWidgets.QLabel(Dialog) - self.label_4.setObjectName("label_4") - self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.label_4) - self.lineEdit_4 = QtWidgets.QLineEdit(Dialog) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.lineEdit_4.sizePolicy().hasHeightForWidth()) - self.lineEdit_4.setSizePolicy(sizePolicy) - self.lineEdit_4.setObjectName("lineEdit_4") - self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.lineEdit_4) - self.pushButton_2 = QtWidgets.QPushButton(Dialog) - self.pushButton_2.setObjectName("pushButton_2") - self.formLayout.setWidget(0, QtWidgets.QFormLayout.SpanningRole, self.pushButton_2) - self.gridLayout.addLayout(self.formLayout, 0, 1, 2, 1) + self.gridLayout.addWidget(self.label, 2, 2, 1, 1) self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.listWidget = QtWidgets.QListWidget(Dialog) @@ -96,15 +55,27 @@ class Ui_Dialog(object): self.pushButton = QtWidgets.QPushButton(Dialog) self.pushButton.setObjectName("pushButton") self.verticalLayout.addWidget(self.pushButton) - self.listWidget_2 = QtWidgets.QListWidget(Dialog) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.listWidget_2.sizePolicy().hasHeightForWidth()) - self.listWidget_2.setSizePolicy(sizePolicy) - self.listWidget_2.setObjectName("listWidget_2") - self.verticalLayout.addWidget(self.listWidget_2) - self.gridLayout.addLayout(self.verticalLayout, 0, 0, 2, 1) + self.pushButton_2 = QtWidgets.QPushButton(Dialog) + self.pushButton_2.setObjectName("pushButton_2") + self.verticalLayout.addWidget(self.pushButton_2) + self.horizontalLayout = QtWidgets.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.label_2 = QtWidgets.QLabel(Dialog) + self.label_2.setObjectName("label_2") + self.horizontalLayout.addWidget(self.label_2) + self.comboBox = QtWidgets.QComboBox(Dialog) + 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.verticalLayout.addLayout(self.horizontalLayout) + self.pushButton_3 = QtWidgets.QPushButton(Dialog) + self.pushButton_3.setObjectName("pushButton_3") + self.verticalLayout.addWidget(self.pushButton_3) + self.gridLayout.addLayout(self.verticalLayout, 0, 0, 3, 1) self.retranslateUi(Dialog) self.buttonBox.accepted.connect(Dialog.accept) # type: ignore @@ -113,11 +84,15 @@ class Ui_Dialog(object): def retranslateUi(self, Dialog): _translate = QtCore.QCoreApplication.translate - Dialog.setWindowTitle(_translate("Dialog", "Dialog")) - self.label.setText(_translate("Dialog", "τg / s")) - self.label_2.setText(_translate("Dialog", "β")) - self.label_3.setText(_translate("Dialog", "ΔH/R / K")) - self.label_4.setText(_translate("Dialog", "x")) - self.pushButton_2.setText(_translate("Dialog", "Fictive Cp")) + Dialog.setWindowTitle(_translate("Dialog", "SImba, everything the light touches is our kingdom")) + self.label.setText(_translate("Dialog", "sdff")) self.pushButton.setText(_translate("Dialog", "Calculate Tg")) + self.pushButton_2.setText(_translate("Dialog", "Fictive Cp")) + 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")) from pyqtgraph import PlotWidget diff --git a/src/gui_qt/dsc/glass_dialog.py b/src/gui_qt/dsc/glass_dialog.py index a6d0776..5a23cc1 100644 --- a/src/gui_qt/dsc/glass_dialog.py +++ b/src/gui_qt/dsc/glass_dialog.py @@ -26,6 +26,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): self.limits = RegionItem(), RegionItem() for lim in self.limits: self.graphicsView.addItem(lim) + self._limitless = True self.add_sets() @@ -88,9 +89,11 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): self._plots[key] = (data_plot, tg_plot, glass, liquid, tangent, fictive_cp, tnmh_fit) - dist = max_x - min_x - self.limits[0].setRegion((min_x, min_x+0.1*dist)) - self.limits[1].setRegion((max_x-0.1*dist, max_x)) + if self._limitless: + dist = max_x - min_x + self.limits[0].setRegion((min_x, min_x+0.1*dist)) + self.limits[1].setRegion((max_x-0.1*dist, max_x)) + self._limitless = False @QtCore.pyqtSlot(name='on_pushButton_clicked') def calc_tg(self): @@ -100,9 +103,10 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): for idx in range(self.listWidget.count()): item = self.listWidget.item(idx) - key = item.data(QtCore.Qt.UserRole) - color = item.foreground() + if item.checkState() == QtCore.Qt.Unchecked: + continue + key = item.data(QtCore.Qt.UserRole) plot = self._plots[key] data = self._dsc[key] @@ -118,10 +122,15 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): values = self._tg_value.get(item.data(QtCore.Qt.UserRole)) if values is not None: - self.listWidget_2.clear() - for name, pos in values.items(): - tg_item = QtWidgets.QListWidgetItem(f'{name.capitalize()}: {pos[0]:.2f} K') - self.listWidget_2.addItem(tg_item) + label = '\n'.join((f'{name.capitalize()}: {pos[0]:.2f} K' for name, pos in values.items())) + self.label.setText(label) + + @QtCore.pyqtSlot(QtWidgets.QListWidgetItem, name='on_listWidget_itemChanged') + def change_visibility(self, item: QtWidgets.QListWidgetItem): + is_checked = bool(item.checkState()) + plot = self._plots[item.data(QtCore.Qt.UserRole)] + for val in plot: + val.setVisible(is_checked) @QtCore.pyqtSlot(name='on_pushButton_2_clicked') def get_fictive(self): @@ -131,10 +140,13 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): for idx in range(self.listWidget.count()): item = self.listWidget.item(idx) - key = item.data(QtCore.Qt.UserRole) + if item.checkState() == QtCore.Qt.Unchecked: + continue + key = item.data(QtCore.Qt.UserRole) plot = self._plots[key] data = self._dsc[key] + cp, tg = data.get_fictive_cp(*baselines) plot[5].setData(cp.x, cp.y) @@ -143,7 +155,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): plot[1].setData(array(list(self._tg_value[key].values()))) - res = data.calculate_tnmh([60, 0.5, 1, 2e5], *baselines, return_fictive=False) + res = cp.calculate_tnmh([60, 0.5, 1, 2e5], *baselines, return_fictive=False) print(res.pprint()) plot[-1].setData(res.x, res.y) diff --git a/src/resources/_ui/tnmh_dialog.ui b/src/resources/_ui/tnmh_dialog.ui index c57d7ba..1367664 100644 --- a/src/resources/_ui/tnmh_dialog.ui +++ b/src/resources/_ui/tnmh_dialog.ui @@ -6,25 +6,15 @@ 0 0 - 1176 - 714 + 842 + 683 - Dialog + SImba, everything the light touches is our kingdom - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - + @@ -34,89 +24,36 @@ - + - - - - - - τ<sub>g</sub> / s - - - - - - - - 0 - 0 - - - - - - - - β - - - - - - - - 0 - 0 - - - - - - - - ΔH/R / K - - - - - - - - 0 - 0 - - - - - - - - x - - - - - - - - 0 - 0 - - - - - - - - Fictive Cp - - - - + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + - + + + + + 0 + 0 + + + + sdff + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + @@ -136,12 +73,56 @@ - - - - 0 - 0 - + + + Fictive Cp + + + + + + + + + Tg for TNMH + + + + + + + + Fictive + + + + + Onset + + + + + Midpoint + + + + + End + + + + + Inflection + + + + + + + + + + Fit TNMH model