forked from IPKM/nmreval
add block to graphwindow to stop rescale/legend uupdates
This commit is contained in:
parent
99bb196e5c
commit
c94231f9d9
@ -54,6 +54,8 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
self._external_items = []
|
self._external_items = []
|
||||||
self.closable = True
|
self.closable = True
|
||||||
|
|
||||||
|
self._block = False
|
||||||
|
|
||||||
self.log = [False, False]
|
self.log = [False, False]
|
||||||
|
|
||||||
self.scene = self.plotItem.scene()
|
self.scene = self.plotItem.scene()
|
||||||
@ -150,6 +152,16 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
|
|
||||||
return tuple(r)
|
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):
|
def add(self, name: str | list, plots: list):
|
||||||
if isinstance(name, str):
|
if isinstance(name, str):
|
||||||
name = [name]
|
name = [name]
|
||||||
@ -201,6 +213,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
|
|
||||||
self.listWidget.blockSignals(False)
|
self.listWidget.blockSignals(False)
|
||||||
|
|
||||||
|
if not self._block:
|
||||||
self._update_zorder()
|
self._update_zorder()
|
||||||
self.show_legend()
|
self.show_legend()
|
||||||
|
|
||||||
@ -484,6 +497,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
self.ymax_lineedit.setText('%.5g' % r[1][1])
|
self.ymax_lineedit.setText('%.5g' % r[1][1])
|
||||||
|
|
||||||
def _update_zorder(self):
|
def _update_zorder(self):
|
||||||
|
print('update yorder')
|
||||||
for i, sid in enumerate(self.sets):
|
for i, sid in enumerate(self.sets):
|
||||||
plt = self.real_plots[sid]
|
plt = self.real_plots[sid]
|
||||||
if plt.zValue() != 2*i+1:
|
if plt.zValue() != 2*i+1:
|
||||||
@ -501,6 +515,10 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
self.checkBox.setVisible(visible)
|
self.checkBox.setVisible(visible)
|
||||||
|
|
||||||
def update_legend(self, sid, name):
|
def update_legend(self, sid, name):
|
||||||
|
if self._block:
|
||||||
|
return
|
||||||
|
|
||||||
|
print('update legend')
|
||||||
self.listWidget.blockSignals(True)
|
self.listWidget.blockSignals(True)
|
||||||
|
|
||||||
for i in range(self.listWidget.count()):
|
for i in range(self.listWidget.count()):
|
||||||
@ -512,6 +530,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
self.show_legend()
|
self.show_legend()
|
||||||
|
|
||||||
def show_legend(self):
|
def show_legend(self):
|
||||||
|
print('show legend')
|
||||||
if not self.legend.isVisible():
|
if not self.legend.isVisible():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user