From b1e54c84325e42cc776561ba8591c081358e8c79 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Tue, 29 Nov 2022 20:58:27 +0100 Subject: [PATCH] fixed typo in t1 calculation, extra context for graphs: fixes T242; fixes T245 --- AppImageBuilder.yml | 2 +- src/gui_qt/data/datawidget/datawidget.py | 138 ++++++++++++++--------- src/gui_qt/main/management.py | 3 + src/gui_qt/nmr/t1_from_tau.py | 2 +- 4 files changed, 89 insertions(+), 56 deletions(-) diff --git a/AppImageBuilder.yml b/AppImageBuilder.yml index cba8990..3ef9289 100644 --- a/AppImageBuilder.yml +++ b/AppImageBuilder.yml @@ -30,7 +30,7 @@ AppDir: arch: amd64 allow_unauthenticated: true sources: - - sourceline: 'deb [arch=amd64] http://mirror.infra.pkm/ bullseye main contrin non-free' + - sourceline: 'deb [arch=amd64] http://mirror.infra.pkm/ bullseye main contrib non-free' include: # for /usr/bin/env diff --git a/src/gui_qt/data/datawidget/datawidget.py b/src/gui_qt/data/datawidget/datawidget.py index 09ed6a0..08388cb 100644 --- a/src/gui_qt/data/datawidget/datawidget.py +++ b/src/gui_qt/data/datawidget/datawidget.py @@ -306,15 +306,13 @@ class DataTree(QtWidgets.QTreeWidget): iterator += 1 - def contextMenuEvent(self, evt, color_list=None): + def contextMenuEvent(self, evt): menu = QtWidgets.QMenu() _ = menu.addAction('Hello') _.setEnabled(False) menu.addSeparator() - idx = self.selectedIndexes() - - if self.invisibleRootItem().childCount() == 0 and len(idx) == 0: + if self.invisibleRootItem().childCount() == 0 and len(self.selectedIndexes()) == 0: rdn_action = menu.addAction('Randomness') action = menu.exec(evt.globalPos()) @@ -323,67 +321,99 @@ class DataTree(QtWidgets.QTreeWidget): import webbrowser webbrowser.open('https://en.wikipedia.org/wiki/Special:Random') + elif all([self.itemFromIndex(i).parent() is None for i in self.selectedIndexes()]): + # only graphs selected + self.ctx_graphs(evt, menu) + else: - del_action = menu.addAction('Exterminate') - cp_action = menu.addAction('Replicate') - cat_action = menu.addAction('Join us!') - plt_action = None - save_action = None + self.ctx_sets(evt, menu) + + def ctx_graphs(self, evt, menu): + del_action = menu.addAction('Exterminate graph!') + col_menu = menu.addMenu('Color cycle') + for c in available_cycles.keys(): + col_menu.addAction(c) + + graphs = [] + + for i in self.selectedIndexes(): + if i.column() == 0: + continue + + graphs.append(self.itemFromIndex(i).data(0, QtCore.Qt.UserRole)) + + action = menu.exec_(evt.globalPos()) + if action == del_action: + for gid in graphs: + self.management.delete_graph(gid) + + elif action.parent() == col_menu: + for gid in graphs: + self.management.set_cycle(self.management.graphs[gid].sets, action.text()) + + evt.accept() + + def ctx_sets(self, evt, menu): + del_action = menu.addAction('Exterminate sets') + cp_action = menu.addAction('Replicate sets') + cat_action = menu.addAction('Join us!') + plt_action = None + save_action = None + menu.addSeparator() + col_menu = menu.addMenu('Color cycle') + for c in available_cycles.keys(): + col_menu.addAction(c) + + idx = {} + has_fits = False + for i in self.selectedIndexes(): + if i.column() == 0: + continue + + item = self.itemFromIndex(i) + parent = item.parent() + if parent is None: + continue + + else: + graph_id = parent.data(0, QtCore.Qt.UserRole) + if graph_id not in idx: + idx[graph_id] = [] + # collect sets in their graph + idx[graph_id].append(item.data(0, QtCore.Qt.UserRole)) + data = self.management[item.data(0, QtCore.Qt.UserRole)] + if data.mode == 'fit': + has_fits = True + + if has_fits: menu.addSeparator() - col_menu = menu.addMenu('Color cycle') - for c in available_cycles.keys(): - col_menu.addAction(c) + plt_action = menu.addAction('Plot fit parameter') + save_action = menu.addAction('Save fit parameter') - idx = {} - has_fits = False - for i in self.selectedIndexes(): - if i.column() == 0: - continue + action = menu.exec(evt.globalPos()) - item = self.itemFromIndex(i) - parent = item.parent() - if parent is None: - continue + s = [] + for gid, sets in idx.items(): + s.extend(sets) - else: - graph_id = parent.data(0, QtCore.Qt.UserRole) - if graph_id not in idx: - idx[graph_id] = [] - # collect sets in their graph - idx[graph_id].append(item.data(0, QtCore.Qt.UserRole)) - data = self.management[item.data(0, QtCore.Qt.UserRole)] - if data.mode == 'fit': - has_fits = True + if action == del_action: + self.management.delete_sets(s) - if has_fits: - menu.addSeparator() - plt_action = menu.addAction('Plot fit parameter') - save_action = menu.addAction('Save fit parameter') - - action = menu.exec(evt.globalPos()) - - s = [] + elif action == cp_action: for gid, sets in idx.items(): - s.extend(sets) + self.management.copy_sets(sets, gid) - if action == del_action: - self.management.delete_sets(s) + elif action == cat_action: + self.management.cat(s) - elif action == cp_action: - for gid, sets in idx.items(): - self.management.copy_sets(sets, gid) + elif action == plt_action: + self.management.make_fit_parameter(s) - elif action == cat_action: - self.management.cat(s) + elif action == save_action: + self.saveFits.emit(s) - elif action == plt_action: - self.management.make_fit_parameter(s) - - elif action == save_action: - self.saveFits.emit(s) - - elif action.parent() == col_menu: - self.management.set_cycle(s, action.text()) + elif action.parent() == col_menu: + self.management.set_cycle(s, action.text()) evt.accept() diff --git a/src/gui_qt/main/management.py b/src/gui_qt/main/management.py index 1ae337f..af2c62a 100644 --- a/src/gui_qt/main/management.py +++ b/src/gui_qt/main/management.py @@ -291,6 +291,9 @@ class UpperManagement(QtCore.QObject): self.undostack.endMacro() + def delete_graph(self, gid): + self.delete_sets(self.graphs[gid].sets + [gid]) + @QtCore.pyqtSlot() def cat(self, src_sets=None): joined = None diff --git a/src/gui_qt/nmr/t1_from_tau.py b/src/gui_qt/nmr/t1_from_tau.py index 5e16eba..00e1f18 100644 --- a/src/gui_qt/nmr/t1_from_tau.py +++ b/src/gui_qt/nmr/t1_from_tau.py @@ -87,7 +87,7 @@ class QRelaxCalc(QtWidgets.QDialog, Ui_Dialog): else: self.label_7.setText('\u03c9 / Hz') - @QtCore.pyqtSlot(int, name='on_temp_combobox_curr#entIndexChanged') + @QtCore.pyqtSlot(int, name='on_temp_combobox_currentIndexChanged') def temp_combo_change(self, idx: int): self.arr_widget.setVisible(idx == 0) self.vft_widget.setVisible(idx == 1)