1
0
forked from IPKM/nmreval

list of active sets uses actual order instead order they were displayed; closes #111

This commit is contained in:
Dominik Demuth 2023-07-30 16:18:18 +02:00
parent dde7b7006d
commit bae7ee2db6

View File

@ -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 = []