From 8de4a0cbd30645dd9b0aaff45ecdb1c5096bafa1 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 5 Jul 2023 17:35:31 +0200 Subject: [PATCH] interim save --- src/gui_qt/dsc/glass_dialog.py | 38 +++++++++++++++++++++++----------- src/gui_qt/main/mainwindow.py | 2 +- src/gui_qt/main/management.py | 36 +++++++++++++++++++------------- 3 files changed, 49 insertions(+), 27 deletions(-) diff --git a/src/gui_qt/dsc/glass_dialog.py b/src/gui_qt/dsc/glass_dialog.py index 11e388d..f1c542f 100644 --- a/src/gui_qt/dsc/glass_dialog.py +++ b/src/gui_qt/dsc/glass_dialog.py @@ -15,14 +15,15 @@ from nmreval.data import DSC, Points class TgCalculator(QtWidgets.QWizard, Ui_Wizard): - newTg = QtCore.pyqtSignal(dict) + newData = QtCore.pyqtSignal(dict, str) def __init__(self, management, parent=None): super().__init__(parent=parent) self.setupUi(self) self.listWidget = QListWidgetSelect(parent=self) - self.listWidget.setObjectName('listWidget') + self.listWidget.setSelectionMode(self.listWidget.ExtendedSelection) + self.listWidget.itemChanged.connect(self.change_visibility) self.setSideWidget(self.listWidget) self.listWidget.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)) @@ -241,9 +242,9 @@ class TgCalculator(QtWidgets.QWizard, Ui_Wizard): ret_dic[key] = (tg_pts, line) - self.newTg.emit(ret_dic) + self.newData.emit(ret_dic, 'tg') - @QtCore.pyqtSlot(QtWidgets.QListWidgetItem, name='on_listWidget_itemChanged') + @QtCore.pyqtSlot(QtWidgets.QListWidgetItem) def change_visibility(self, item: QtWidgets.QListWidgetItem): is_checked = bool(item.checkState()) plot = self._plots[item.data(QtCore.Qt.UserRole)] @@ -303,6 +304,8 @@ class TgCalculator(QtWidgets.QWizard, Ui_Wizard): m = [] for idx in range(self.listWidget.count()): item = self.listWidget.item(idx) + if item.checkState() == QtCore.Qt.Unchecked: + continue key = item.data(QtCore.Qt.UserRole) data, _ = self._dsc[key] @@ -324,6 +327,25 @@ class TgCalculator(QtWidgets.QWizard, Ui_Wizard): self._hodge[tg_type] = (plot, data, fitplots, fit) + @QtCore.pyqtSlot(name='on_pushButton_4_clicked') + def export_hodge(self): + ret_dic2 = {} + + for cb in (self.checkBox, self.checkBox_4, self.checkBox_6, self.checkBox_5, self.checkBox_7): + if cb.isChecked(): + item = cb.text().lower() + v = self._hodge.get(item) + ret_dic2[item] = v[1] + + if self.new_graph_tau_check.isChecked(): + ret_dic2['graph'] = self.new_graph_tau_combo.currentData() + else: + ret_dic2['graph'] = '' + + print(ret_dic2) + + self.newData.emit(ret_dic2, 'hodge') + def close(self) -> bool: self.clear() return super().close() @@ -350,13 +372,5 @@ class TgCalculator(QtWidgets.QWizard, Ui_Wizard): ret_dic[key] = (tg_pts, line) - ret_dic2 = [] - - for i in range(self.hodge_selection.count()): - if self.hodge_selection.isChecked(i): - item = self.hodge_selection.itemText(i).lower() - v = self._hodge.get(item) - ret_dic2.append(v[1]) - self.newTg.emit(ret_dic, ret_dic2, graph_id) self.close() diff --git a/src/gui_qt/main/mainwindow.py b/src/gui_qt/main/mainwindow.py index c7f3c2b..5cefcac 100644 --- a/src/gui_qt/main/mainwindow.py +++ b/src/gui_qt/main/mainwindow.py @@ -1143,7 +1143,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): def show_tg_dialog(self): if self._tg_dialog is None: self._tg_dialog = TgCalculator(self.management, parent=self) - self._tg_dialog.newTg.connect(self.management.addTg) + self._tg_dialog.newData.connect(self.management.addTg) else: self._tg_dialog() self._tg_dialog.show() diff --git a/src/gui_qt/main/management.py b/src/gui_qt/main/management.py index e181d60..9fde3a5 100644 --- a/src/gui_qt/main/management.py +++ b/src/gui_qt/main/management.py @@ -773,24 +773,32 @@ class UpperManagement(QtCore.QObject): self.newData.emit(new_data, self.current_graph) - @QtCore.pyqtSlot(dict) - def addTg(self, dic1: dict): - for k, (tg, lines) in dic1.items(): - p: ExperimentContainer = self[k] - col = p.plot_real.linecolor + @QtCore.pyqtSlot(dict, str) + def addTg(self, dic1: dict, dtype: str): + if dtype == 'tg': + for k, (tg, lines) in dic1.items(): + p: ExperimentContainer = self[k] + col = p.plot_real.linecolor - tg_data_id = [] + tg_data_id = [] - if tg is not None: - tg_data_id.append(self.add(tg, color=col)) + if tg is not None: + tg_data_id.append(self.add(tg, color=col)) - for line in lines: - set_id = self.add(line, color=col) - self[set_id].setLine(style=LineStyle.Dashed) - self[set_id].setSymbol(symbol=SymbolStyle.No) - tg_data_id.append(set_id) + for line in lines: + set_id = self.add(line, color=col) + self[set_id].setLine(style=LineStyle.Dashed) + self[set_id].setSymbol(symbol=SymbolStyle.No) + tg_data_id.append(set_id) - self.newData.emit(tg_data_id, self.current_graph) + self.newData.emit(tg_data_id, self.current_graph) + + elif dtype == 'hodge': + set_id_list = [] + graph_id = dic1.pop('graph') + for v in dic1.values(): + set_id_list.append(self.add(v)) + self.newData.emit(set_id_list, graph_id) @QtCore.pyqtSlot(int, dict) def smooth_data(self, npoints, param_kwargs):