forked from IPKM/nmreval
list of active sets uses actual order instead order they were displayed; closes #111
This commit is contained in:
parent
dde7b7006d
commit
bae7ee2db6
@ -45,7 +45,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
self.id = str(uuid.uuid4())
|
self.id = str(uuid.uuid4())
|
||||||
|
|
||||||
self.sets = []
|
self.sets = []
|
||||||
self.active = []
|
self._active = []
|
||||||
|
|
||||||
self.real_plots = {}
|
self.real_plots = {}
|
||||||
self.imag_plots = {}
|
self.imag_plots = {}
|
||||||
@ -118,11 +118,11 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
return iter(self.active)
|
return iter(self.active)
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self.active)
|
return len(self._active)
|
||||||
|
|
||||||
def curves(self) -> tuple:
|
def curves(self) -> tuple:
|
||||||
for set_id in self.sets:
|
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.real_button.isChecked():
|
||||||
if self.error_plots[set_id] is not None:
|
if self.error_plots[set_id] is not None:
|
||||||
yield self.real_plots[set_id], self.error_plots[set_id]
|
yield self.real_plots[set_id], self.error_plots[set_id]
|
||||||
@ -157,6 +157,10 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
|
|
||||||
return tuple(r)
|
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):
|
def block(self, state: bool):
|
||||||
self._block = state
|
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]:
|
for plot in [self.real_plots, self.imag_plots, self.error_plots]:
|
||||||
self.graphic.removeItem(plot[n])
|
self.graphic.removeItem(plot[n])
|
||||||
|
|
||||||
if n in self.active:
|
if n in self._active:
|
||||||
self.active.remove(n)
|
self._active.remove(n)
|
||||||
|
|
||||||
# remove from label list
|
# remove from label list
|
||||||
self.listWidget.blockSignals(True)
|
self.listWidget.blockSignals(True)
|
||||||
@ -250,8 +254,8 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
return
|
return
|
||||||
|
|
||||||
for a in idlist:
|
for a in idlist:
|
||||||
if a not in self.active:
|
if a not in self._active:
|
||||||
self.active.append(a)
|
self._active.append(a)
|
||||||
|
|
||||||
for (bttn, plot_dic) in [
|
for (bttn, plot_dic) in [
|
||||||
(self.real_button, self.real_plots),
|
(self.real_button, self.real_plots),
|
||||||
@ -270,8 +274,8 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
return
|
return
|
||||||
|
|
||||||
for r in idlist:
|
for r in idlist:
|
||||||
if r in self.active:
|
if r in self._active:
|
||||||
self.active.remove(r)
|
self._active.remove(r)
|
||||||
|
|
||||||
for plt in [self.real_plots, self.imag_plots, self.error_plots]:
|
for plt in [self.real_plots, self.imag_plots, self.error_plots]:
|
||||||
item = plt[r]
|
item = plt[r]
|
||||||
@ -293,7 +297,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
else:
|
else:
|
||||||
func = self.graphic.removeItem
|
func = self.graphic.removeItem
|
||||||
|
|
||||||
for a in self.active:
|
for a in self._active:
|
||||||
item = plots[a]
|
item = plots[a]
|
||||||
if item is not None:
|
if item is not None:
|
||||||
func(item)
|
func(item)
|
||||||
@ -310,12 +314,12 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if visible:
|
if visible:
|
||||||
for a in self.active:
|
for a in self._active:
|
||||||
item = self.error_plots[a]
|
item = self.error_plots[a]
|
||||||
if (item is not None) and (item not in self.graphic.items()):
|
if (item is not None) and (item not in self.graphic.items()):
|
||||||
self.graphic.addItem(item)
|
self.graphic.addItem(item)
|
||||||
else:
|
else:
|
||||||
for a in self.active:
|
for a in self._active:
|
||||||
item = self.error_plots[a]
|
item = self.error_plots[a]
|
||||||
if (item is not None) and (item in self.graphic.items()):
|
if (item is not None) and (item in self.graphic.items()):
|
||||||
self.graphic.removeItem(item)
|
self.graphic.removeItem(item)
|
||||||
@ -677,7 +681,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
'legend': self.legend.isVisible(),
|
'legend': self.legend.isVisible(),
|
||||||
'plots': (self.real_button.isChecked(), self.imag_button.isChecked(), self.error_button.isChecked()),
|
'plots': (self.real_button.isChecked(), self.imag_button.isChecked(), self.error_button.isChecked()),
|
||||||
'children': self.sets,
|
'children': self.sets,
|
||||||
'active': self.active,
|
'active': self._active,
|
||||||
}
|
}
|
||||||
|
|
||||||
in_legend = []
|
in_legend = []
|
||||||
|
Loading…
Reference in New Issue
Block a user