add block to graphwindow to stop rescale/legend uupdates

This commit is contained in:
Dominik Demuth 2023-04-15 14:54:25 +02:00
parent 99bb196e5c
commit c94231f9d9

View File

@ -54,6 +54,8 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
self._external_items = []
self.closable = True
self._block = False
self.log = [False, False]
self.scene = self.plotItem.scene()
@ -150,6 +152,16 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
return tuple(r)
def block(self, state: bool):
self._block = state
if not self._block:
self.graphic.enableAutoRange()
self._update_zorder()
self.show_legend()
else:
self.graphic.disableAutoRange()
def add(self, name: str | list, plots: list):
if isinstance(name, str):
name = [name]
@ -201,6 +213,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
self.listWidget.blockSignals(False)
if not self._block:
self._update_zorder()
self.show_legend()
@ -484,6 +497,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
self.ymax_lineedit.setText('%.5g' % r[1][1])
def _update_zorder(self):
print('update yorder')
for i, sid in enumerate(self.sets):
plt = self.real_plots[sid]
if plt.zValue() != 2*i+1:
@ -501,6 +515,10 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
self.checkBox.setVisible(visible)
def update_legend(self, sid, name):
if self._block:
return
print('update legend')
self.listWidget.blockSignals(True)
for i in range(self.listWidget.count()):
@ -512,6 +530,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
self.show_legend()
def show_legend(self):
print('show legend')
if not self.legend.isVisible():
return