From c94231f9d9f206477a7490097aad64d5b4e70281 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Sat, 15 Apr 2023 14:54:25 +0200 Subject: [PATCH] add block to graphwindow to stop rescale/legend uupdates --- src/gui_qt/graphs/graphwindow.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/gui_qt/graphs/graphwindow.py b/src/gui_qt/graphs/graphwindow.py index b0dee37..5c182ca 100644 --- a/src/gui_qt/graphs/graphwindow.py +++ b/src/gui_qt/graphs/graphwindow.py @@ -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,8 +213,9 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): self.listWidget.blockSignals(False) - self._update_zorder() - self.show_legend() + if not self._block: + self._update_zorder() + self.show_legend() def move_sets(self, sets: list, position: int): move_plots = [] @@ -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