1
0
forked from IPKM/nmreval

ui adjustments

This commit is contained in:
Dominik Demuth 2023-06-03 20:27:56 +02:00
parent bec789318d
commit 25f7ff5616
3 changed files with 150 additions and 182 deletions

View File

@ -14,14 +14,9 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object): class Ui_Dialog(object):
def setupUi(self, Dialog): def setupUi(self, Dialog):
Dialog.setObjectName("Dialog") Dialog.setObjectName("Dialog")
Dialog.resize(1176, 714) Dialog.resize(842, 683)
self.gridLayout = QtWidgets.QGridLayout(Dialog) self.gridLayout = QtWidgets.QGridLayout(Dialog)
self.gridLayout.setObjectName("gridLayout") 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) self.graphicsView = PlotWidget(Dialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
@ -29,60 +24,24 @@ class Ui_Dialog(object):
sizePolicy.setHeightForWidth(self.graphicsView.sizePolicy().hasHeightForWidth()) sizePolicy.setHeightForWidth(self.graphicsView.sizePolicy().hasHeightForWidth())
self.graphicsView.setSizePolicy(sizePolicy) self.graphicsView.setSizePolicy(sizePolicy)
self.graphicsView.setObjectName("graphicsView") 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 = PlotWidget(Dialog)
self.graphicsView_2.setObjectName("graphicsView_2") self.graphicsView_2.setObjectName("graphicsView_2")
self.gridLayout.addWidget(self.graphicsView_2, 1, 3, 1, 1) self.gridLayout.addWidget(self.graphicsView_2, 1, 2, 1, 1)
self.formLayout = QtWidgets.QFormLayout() self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
self.formLayout.setObjectName("formLayout") 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) 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.label.setObjectName("label")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label) self.gridLayout.addWidget(self.label, 2, 2, 1, 1)
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.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout") self.verticalLayout.setObjectName("verticalLayout")
self.listWidget = QtWidgets.QListWidget(Dialog) self.listWidget = QtWidgets.QListWidget(Dialog)
@ -96,15 +55,27 @@ class Ui_Dialog(object):
self.pushButton = QtWidgets.QPushButton(Dialog) self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setObjectName("pushButton") self.pushButton.setObjectName("pushButton")
self.verticalLayout.addWidget(self.pushButton) self.verticalLayout.addWidget(self.pushButton)
self.listWidget_2 = QtWidgets.QListWidget(Dialog) self.pushButton_2 = QtWidgets.QPushButton(Dialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum) self.pushButton_2.setObjectName("pushButton_2")
sizePolicy.setHorizontalStretch(0) self.verticalLayout.addWidget(self.pushButton_2)
sizePolicy.setVerticalStretch(0) self.horizontalLayout = QtWidgets.QHBoxLayout()
sizePolicy.setHeightForWidth(self.listWidget_2.sizePolicy().hasHeightForWidth()) self.horizontalLayout.setObjectName("horizontalLayout")
self.listWidget_2.setSizePolicy(sizePolicy) self.label_2 = QtWidgets.QLabel(Dialog)
self.listWidget_2.setObjectName("listWidget_2") self.label_2.setObjectName("label_2")
self.verticalLayout.addWidget(self.listWidget_2) self.horizontalLayout.addWidget(self.label_2)
self.gridLayout.addLayout(self.verticalLayout, 0, 0, 2, 1) 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.retranslateUi(Dialog)
self.buttonBox.accepted.connect(Dialog.accept) # type: ignore self.buttonBox.accepted.connect(Dialog.accept) # type: ignore
@ -113,11 +84,15 @@ class Ui_Dialog(object):
def retranslateUi(self, Dialog): def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate _translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog")) Dialog.setWindowTitle(_translate("Dialog", "SImba, everything the light touches is our kingdom"))
self.label.setText(_translate("Dialog", "τ<sub>g</sub> / s")) self.label.setText(_translate("Dialog", "sdff"))
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"))
self.pushButton.setText(_translate("Dialog", "Calculate Tg")) 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 from pyqtgraph import PlotWidget

View File

@ -26,6 +26,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
self.limits = RegionItem(), RegionItem() self.limits = RegionItem(), RegionItem()
for lim in self.limits: for lim in self.limits:
self.graphicsView.addItem(lim) self.graphicsView.addItem(lim)
self._limitless = True
self.add_sets() 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) self._plots[key] = (data_plot, tg_plot, glass, liquid, tangent, fictive_cp, tnmh_fit)
dist = max_x - min_x if self._limitless:
self.limits[0].setRegion((min_x, min_x+0.1*dist)) dist = max_x - min_x
self.limits[1].setRegion((max_x-0.1*dist, max_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') @QtCore.pyqtSlot(name='on_pushButton_clicked')
def calc_tg(self): def calc_tg(self):
@ -100,9 +103,10 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
for idx in range(self.listWidget.count()): for idx in range(self.listWidget.count()):
item = self.listWidget.item(idx) item = self.listWidget.item(idx)
key = item.data(QtCore.Qt.UserRole) if item.checkState() == QtCore.Qt.Unchecked:
color = item.foreground() continue
key = item.data(QtCore.Qt.UserRole)
plot = self._plots[key] plot = self._plots[key]
data = self._dsc[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)) values = self._tg_value.get(item.data(QtCore.Qt.UserRole))
if values is not None: if values is not None:
self.listWidget_2.clear() label = '\n'.join((f'{name.capitalize()}: {pos[0]:.2f} K' for name, pos in values.items()))
for name, pos in values.items(): self.label.setText(label)
tg_item = QtWidgets.QListWidgetItem(f'{name.capitalize()}: {pos[0]:.2f} K')
self.listWidget_2.addItem(tg_item) @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') @QtCore.pyqtSlot(name='on_pushButton_2_clicked')
def get_fictive(self): def get_fictive(self):
@ -131,10 +140,13 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
for idx in range(self.listWidget.count()): for idx in range(self.listWidget.count()):
item = self.listWidget.item(idx) 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] plot = self._plots[key]
data = self._dsc[key] data = self._dsc[key]
cp, tg = data.get_fictive_cp(*baselines) cp, tg = data.get_fictive_cp(*baselines)
plot[5].setData(cp.x, cp.y) 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()))) 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()) print(res.pprint())
plot[-1].setData(res.x, res.y) plot[-1].setData(res.x, res.y)

View File

@ -6,25 +6,15 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1176</width> <width>842</width>
<height>714</height> <height>683</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>SImba, everything the light touches is our kingdom</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="2" column="3"> <item row="0" column="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="PlotWidget" name="graphicsView"> <widget class="PlotWidget" name="graphicsView">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
@ -34,89 +24,36 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="3"> <item row="1" column="2">
<widget class="PlotWidget" name="graphicsView_2"/> <widget class="PlotWidget" name="graphicsView_2"/>
</item> </item>
<item row="0" column="1" rowspan="2"> <item row="3" column="2">
<layout class="QFormLayout" name="formLayout"> <widget class="QDialogButtonBox" name="buttonBox">
<item row="1" column="0"> <property name="orientation">
<widget class="QLabel" name="label"> <enum>Qt::Horizontal</enum>
<property name="text"> </property>
<string>τ&lt;sub&gt;g&lt;/sub&gt; / s</string> <property name="standardButtons">
</property> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</widget> </property>
</item> </widget>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>β</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>ΔH/R / K</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>x</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Fictive Cp</string>
</property>
</widget>
</item>
</layout>
</item> </item>
<item row="0" column="0" rowspan="2"> <item row="2" column="2">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>sdff</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="3">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QListWidget" name="listWidget"> <widget class="QListWidget" name="listWidget">
@ -136,12 +73,56 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QListWidget" name="listWidget_2"> <widget class="QPushButton" name="pushButton_2">
<property name="sizePolicy"> <property name="text">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum"> <string>Fictive Cp</string>
<horstretch>0</horstretch> </property>
<verstretch>0</verstretch> </widget>
</sizepolicy> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Tg for TNMH</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>Fictive</string>
</property>
</item>
<item>
<property name="text">
<string>Onset</string>
</property>
</item>
<item>
<property name="text">
<string>Midpoint</string>
</property>
</item>
<item>
<property name="text">
<string>End</string>
</property>
</item>
<item>
<property name="text">
<string>Inflection</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>Fit TNMH model</string>
</property> </property>
</widget> </widget>
</item> </item>