From 7732544f69cb3fb580194230687ca18001bbd103 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Thu, 15 Jun 2023 17:24:35 +0200 Subject: [PATCH] start tg saving --- src/gui_qt/_py/asciidialog.py | 7 ++- src/gui_qt/_py/basewindow.py | 6 ++- src/gui_qt/_py/tnmh_dialog.py | 44 +++++++++++------- src/gui_qt/dsc/glass_dialog.py | 48 +++++++++++++------- src/resources/_ui/asciidialog.ui | 21 +++++---- src/resources/_ui/basewindow.ui | 8 +++- src/resources/_ui/tnmh_dialog.ui | 77 +++++++++++++++++++++----------- 7 files changed, 133 insertions(+), 78 deletions(-) diff --git a/src/gui_qt/_py/asciidialog.py b/src/gui_qt/_py/asciidialog.py index feac8f5..f3c89db 100644 --- a/src/gui_qt/_py/asciidialog.py +++ b/src/gui_qt/_py/asciidialog.py @@ -258,11 +258,11 @@ class Ui_ascii_reader(object): self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setContentsMargins(-1, 0, -1, -1) self.horizontalLayout_2.setObjectName("horizontalLayout_2") + spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.horizontalLayout_2.addItem(spacerItem4) self.skippy_checkbox = QtWidgets.QCheckBox(ascii_reader) self.skippy_checkbox.setObjectName("skippy_checkbox") self.horizontalLayout_2.addWidget(self.skippy_checkbox) - spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.horizontalLayout_2.addItem(spacerItem4) self.verticalLayout.addLayout(self.horizontalLayout_2) self.buttonbox = QtWidgets.QDialogButtonBox(ascii_reader) self.buttonbox.setStandardButtons(QtWidgets.QDialogButtonBox.Apply|QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) @@ -274,8 +274,7 @@ class Ui_ascii_reader(object): self.buttonbox.rejected.connect(ascii_reader.close) # type: ignore QtCore.QMetaObject.connectSlotsByName(ascii_reader) ascii_reader.setTabOrder(self.tabWidget, self.ascii_table) - ascii_reader.setTabOrder(self.ascii_table, self.skippy_checkbox) - ascii_reader.setTabOrder(self.skippy_checkbox, self.delay_textfield) + ascii_reader.setTabOrder(self.ascii_table, self.delay_textfield) ascii_reader.setTabOrder(self.delay_textfield, self.delay_lineedit) ascii_reader.setTabOrder(self.delay_lineedit, self.start_lineedit) ascii_reader.setTabOrder(self.start_lineedit, self.end_lineedit) diff --git a/src/gui_qt/_py/basewindow.py b/src/gui_qt/_py/basewindow.py index eae9ecf..df4defd 100644 --- a/src/gui_qt/_py/basewindow.py +++ b/src/gui_qt/_py/basewindow.py @@ -370,6 +370,8 @@ class Ui_BaseWindow(object): self.actionAbout.setObjectName("actionAbout") self.actionTNMH_model = QtWidgets.QAction(BaseWindow) self.actionTNMH_model.setObjectName("actionTNMH_model") + self.actionBinning = QtWidgets.QAction(BaseWindow) + self.actionBinning.setObjectName("actionBinning") self.menuSave.addAction(self.actionSave) self.menuSave.addAction(self.actionExportGraphic) self.menuSave.addAction(self.action_save_fit_parameter) @@ -413,6 +415,7 @@ class Ui_BaseWindow(object): self.menuExtra.addSeparator() self.menuExtra.addAction(self.menuNormalize.menuAction()) self.menuExtra.addAction(self.actionInterpolation) + self.menuExtra.addAction(self.actionBinning) self.menuExtra.addAction(self.actionRunning_values) self.menuExtra.addAction(self.actionShift) self.menuExtra.addSeparator() @@ -634,7 +637,8 @@ class Ui_BaseWindow(object): self.actionShow_error_log.setText(_translate("BaseWindow", "Show error log")) self.actionCreate_starter.setText(_translate("BaseWindow", "Create starter..")) self.actionAbout.setText(_translate("BaseWindow", "About...")) - self.actionTNMH_model.setText(_translate("BaseWindow", "TNMH model...")) + self.actionTNMH_model.setText(_translate("BaseWindow", "Tg determination,,,")) + self.actionBinning.setText(_translate("BaseWindow", "Binning...")) 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 63fcb7c..8d7b462 100644 --- a/src/gui_qt/_py/tnmh_dialog.py +++ b/src/gui_qt/_py/tnmh_dialog.py @@ -19,9 +19,9 @@ class Ui_Dialog(object): self.gridLayout.setObjectName("gridLayout") self.buttonBox = QtWidgets.QDialogButtonBox(Dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok|QtWidgets.QDialogButtonBox.Save) + self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close|QtWidgets.QDialogButtonBox.Save) self.buttonBox.setObjectName("buttonBox") - self.gridLayout.addWidget(self.buttonBox, 3, 1, 1, 1) + self.gridLayout.addWidget(self.buttonBox, 5, 1, 1, 1) self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.listWidget = QtWidgets.QListWidget(Dialog) @@ -51,15 +51,7 @@ class Ui_Dialog(object): self.label_5.setText("") self.label_5.setObjectName("label_5") self.verticalLayout.addWidget(self.label_5) - self.gridLayout.addLayout(self.verticalLayout, 0, 0, 3, 1) - self.dsc_plot = PlotWidget(Dialog) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.dsc_plot.sizePolicy().hasHeightForWidth()) - self.dsc_plot.setSizePolicy(sizePolicy) - self.dsc_plot.setObjectName("dsc_plot") - self.gridLayout.addWidget(self.dsc_plot, 0, 1, 1, 1) + 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) @@ -110,9 +102,6 @@ class Ui_Dialog(object): self.page.setObjectName("page") self.gridLayout_2 = QtWidgets.QGridLayout(self.page) self.gridLayout_2.setObjectName("gridLayout_2") - self.pushButton_2 = QtWidgets.QPushButton(self.page) - self.pushButton_2.setObjectName("pushButton_2") - self.gridLayout_2.addWidget(self.pushButton_2, 0, 1, 1, 1) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.label_2 = QtWidgets.QLabel(self.page) @@ -134,7 +123,17 @@ class Ui_Dialog(object): 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, 2, 1, 1, 1) + 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) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.dsc_plot.sizePolicy().hasHeightForWidth()) + self.dsc_plot.setSizePolicy(sizePolicy) + self.dsc_plot.setObjectName("dsc_plot") + self.gridLayout.addWidget(self.dsc_plot, 0, 1, 1, 1) + self.horizontalLayout_2 = QtWidgets.QHBoxLayout() + self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.calctg_button = QtWidgets.QPushButton(Dialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) @@ -142,7 +141,18 @@ class Ui_Dialog(object): sizePolicy.setHeightForWidth(self.calctg_button.sizePolicy().hasHeightForWidth()) self.calctg_button.setSizePolicy(sizePolicy) self.calctg_button.setObjectName("calctg_button") - self.gridLayout.addWidget(self.calctg_button, 1, 1, 1, 1) + self.horizontalLayout_2.addWidget(self.calctg_button) + self.pushButton_2 = QtWidgets.QPushButton(Dialog) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.pushButton_2.sizePolicy().hasHeightForWidth()) + 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) + self.gridLayout.addLayout(self.horizontalLayout_2, 2, 1, 1, 1) self.retranslateUi(Dialog) self.stackedWidget.setCurrentIndex(0) @@ -164,7 +174,6 @@ class Ui_Dialog(object): 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.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")) @@ -173,5 +182,6 @@ class Ui_Dialog(object): 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")) 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 470c304..8f79cb1 100644 --- a/src/gui_qt/dsc/glass_dialog.py +++ b/src/gui_qt/dsc/glass_dialog.py @@ -24,16 +24,16 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): self._plots = {} self._tg_value = {} self._fit = {} - self._hodge_plots = { - 'onset': PlotItem(x=[], y=[], pen=None, symbol='o', symbolBrush=Tab10.TabBlue.rgb(), name='Onset'), - 'mid': PlotItem(x=[], y=[], pen=None, symbol='s', symbolBrush=Tab10.TabOrange.rgb(), name='Midpoint'), - 'end': PlotItem(x=[], y=[], pen=None, symbol='t', symbolBrush=Tab10.TabGreen.rgb(), name='End'), - 'inflection': PlotItem(x=[], y=[], pen=None, symbol='d', symbolBrush=Tab10.TabRed.rgb(), name='Inflection'), + self._hodge = { + 'onset': (PlotItem(x=[], y=[], pen=None, symbol='o', symbolBrush=Tab10.TabBlue.rgb(), name='Onset'), None), + 'mid': (PlotItem(x=[], y=[], pen=None, symbol='s', symbolBrush=Tab10.TabOrange.rgb(), name='Midpoint'), None), + 'end': (PlotItem(x=[], y=[], pen=None, symbol='t', symbolBrush=Tab10.TabGreen.rgb(), name='End'), None), + 'inflection': (PlotItem(x=[], y=[], pen=None, symbol='d', symbolBrush=Tab10.TabRed.rgb(), name='Inflection'), None), # 'fictive': PlotItem(x=[], y=[], pen=None, symbol='t1', symbolBrush=Tab10.TabPurple.rgb(), name='Fictive'), # 'TNMH': PlotItem(x=[], y=[], pen=None, symbol='star', symbolBrush=Tab10.TabPurple.rgb(), name='TNMH'), } self.tau_plot.getPlotItem().addLegend() - for plt in self._hodge_plots.values(): + for plt, _ in self._hodge.values(): self.tau_plot.addItem(plt) self.tau_plot.setLogMode(y=True) @@ -46,18 +46,14 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): self.listWidget.itemClicked.connect(self.show_tg_values) - # for x in self._hodge_plots: - # self.hodge_selection.addItem(x) + self.new_graph_tau_combo.setEnabled(False) + self.new_graph_tau_check.stateChanged.connect(lambda state: self.new_graph_tau_combo.setEnabled(bool(state))) def __call__(self): - print('call') self.clear() self._colors = cycle(Tab10) self.add_sets() - for g in self._management.graphs.list(): - print(g) - return self def clear(self): @@ -67,16 +63,19 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): self.dsc_plot.removeItem(val) self.graphicsView_2.removeItem(val) - for plt in self._hodge_plots.values(): + for plt in self._hodge.values(): plt.setData(x=[], y=[]) self._dsc = {} self._plots = {} self._tg_value = {} self._fit = {} - self.gra def add_sets(self): + self.new_graph_tau_combo.clear() + for graphs in self._management.graphs.list(): + self.new_graph_tau_combo.addItem(graphs[1], userData=graphs[0]) + min_x = 10_000_000 max_x = -10_000_000 for (key, name), c in zip(self._management.active_sets, self._colors): @@ -230,7 +229,8 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): plot[-1].setData(res.x, res.y) def hodge(self): - for tg_type, plot in self._hodge_plots.items(): + for tg_type, (plot, data) in self._hodge.items(): + m = [] for idx in range(self.listWidget.count()): item = self.listWidget.item(idx) @@ -245,9 +245,23 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): m.append([tg_value, data.value]) if len(m) > 1: - r = tau_hodge(*array(m).T) - plot.setData(r.x, r.y) + data = tau_hodge(*array(m).T) + plot.setData(data.x, data.y) def close(self) -> bool: self.clear() return super().close() + + def accept(self) -> None: + if self.new_graph_tau_check.isChecked(): + graph_id = '' + else: + graph_id = self.new_graph_tau_combo.currentData() + + print(graph_id) + print(self._tg_value) + print(self._hodge) + for v in self._plots.values(): + # (data_plot, tg_plot, glass, liquid, tangent, fictive_cp, tnmh_fit) + print(v.getData()) + print(self._plots) diff --git a/src/resources/_ui/asciidialog.ui b/src/resources/_ui/asciidialog.ui index 4813898..7218f42 100644 --- a/src/resources/_ui/asciidialog.ui +++ b/src/resources/_ui/asciidialog.ui @@ -512,16 +512,6 @@ 0 - - - - Use selection for next files. Deletes possible delay values. - - - Skip next dialogues? - - - @@ -535,6 +525,16 @@ + + + + Use selection for next files. Deletes possible delay values. + + + Skip next dialogues? + + + @@ -557,7 +557,6 @@ tabWidget ascii_table - skippy_checkbox delay_textfield delay_lineedit start_lineedit diff --git a/src/resources/_ui/basewindow.ui b/src/resources/_ui/basewindow.ui index 49827b0..3712e76 100644 --- a/src/resources/_ui/basewindow.ui +++ b/src/resources/_ui/basewindow.ui @@ -222,6 +222,7 @@ + @@ -1031,7 +1032,12 @@ - TNMH model... + Tg determination,,, + + + + + Binning... diff --git a/src/resources/_ui/tnmh_dialog.ui b/src/resources/_ui/tnmh_dialog.ui index 8273241..fd29a3c 100644 --- a/src/resources/_ui/tnmh_dialog.ui +++ b/src/resources/_ui/tnmh_dialog.ui @@ -14,17 +14,17 @@ SImba, everything the light touches is our kingdom - + Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Save + QDialogButtonBox::Close|QDialogButtonBox::Save - + @@ -75,17 +75,7 @@ - - - - - 0 - 0 - - - - - + QFrame::StyledPanel @@ -187,13 +177,6 @@ - - - - Fictive Cp - - - @@ -248,19 +231,59 @@ - - + + - + 0 0 - - Calculate Tg - + + + + + + + 0 + 0 + + + + Calculate Tg + + + + + + + + 0 + 0 + + + + Calculate fictive Cp + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + +