From bae7ee2db6addc5bfc801768aa1c646f69bb023a Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Sun, 30 Jul 2023 16:18:18 +0200 Subject: [PATCH] list of active sets uses actual order instead order they were displayed; closes #111 --- src/gui_qt/graphs/graphwindow.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/gui_qt/graphs/graphwindow.py b/src/gui_qt/graphs/graphwindow.py index 7540b23..61f318c 100644 --- a/src/gui_qt/graphs/graphwindow.py +++ b/src/gui_qt/graphs/graphwindow.py @@ -45,7 +45,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): self.id = str(uuid.uuid4()) self.sets = [] - self.active = [] + self._active = [] self.real_plots = {} self.imag_plots = {} @@ -118,11 +118,11 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): return iter(self.active) def __len__(self): - return len(self.active) + return len(self._active) def curves(self) -> tuple: for set_id in self.sets: - if set_id in self.active: + if set_id in self._active: if self.real_button.isChecked(): if self.error_plots[set_id] is not None: yield self.real_plots[set_id], self.error_plots[set_id] @@ -157,6 +157,10 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): return tuple(r) + @property + def active(self) -> list: + return [set_id for set_id in self.sets if set_id in self._active] + def block(self, state: bool): self._block = state @@ -205,8 +209,8 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): for plot in [self.real_plots, self.imag_plots, self.error_plots]: self.graphic.removeItem(plot[n]) - if n in self.active: - self.active.remove(n) + if n in self._active: + self._active.remove(n) # remove from label list self.listWidget.blockSignals(True) @@ -250,8 +254,8 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): return for a in idlist: - if a not in self.active: - self.active.append(a) + if a not in self._active: + self._active.append(a) for (bttn, plot_dic) in [ (self.real_button, self.real_plots), @@ -270,8 +274,8 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): return for r in idlist: - if r in self.active: - self.active.remove(r) + if r in self._active: + self._active.remove(r) for plt in [self.real_plots, self.imag_plots, self.error_plots]: item = plt[r] @@ -293,7 +297,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): else: func = self.graphic.removeItem - for a in self.active: + for a in self._active: item = plots[a] if item is not None: func(item) @@ -310,12 +314,12 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): return if visible: - for a in self.active: + for a in self._active: item = self.error_plots[a] if (item is not None) and (item not in self.graphic.items()): self.graphic.addItem(item) else: - for a in self.active: + for a in self._active: item = self.error_plots[a] if (item is not None) and (item in self.graphic.items()): self.graphic.removeItem(item) @@ -677,7 +681,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): 'legend': self.legend.isVisible(), 'plots': (self.real_button.isChecked(), self.imag_button.isChecked(), self.error_button.isChecked()), 'children': self.sets, - 'active': self.active, + 'active': self._active, } in_legend = []