summaryrefslogtreecommitdiff
path: root/silx/gui/data/DataViewer.py
diff options
context:
space:
mode:
Diffstat (limited to 'silx/gui/data/DataViewer.py')
-rw-r--r--silx/gui/data/DataViewer.py53
1 files changed, 34 insertions, 19 deletions
diff --git a/silx/gui/data/DataViewer.py b/silx/gui/data/DataViewer.py
index b33a931..67db5f9 100644
--- a/silx/gui/data/DataViewer.py
+++ b/silx/gui/data/DataViewer.py
@@ -1,7 +1,7 @@
# coding: utf-8
# /*##########################################################################
#
-# Copyright (c) 2016-2018 European Synchrotron Radiation Facility
+# Copyright (c) 2016-2019 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -31,8 +31,10 @@ from silx.gui.data import DataViews
from silx.gui.data.DataViews import _normalizeData
import logging
from silx.gui import qt
+from silx.gui.utils import blockSignals
from silx.gui.data.NumpyAxesSelector import NumpyAxesSelector
+
__authors__ = ["V. Valls"]
__license__ = "MIT"
__date__ = "12/02/2019"
@@ -197,25 +199,38 @@ class DataViewer(qt.QFrame):
"""
Update the numpy-selector according to the needed axis names
"""
- previous = self.__numpySelection.blockSignals(True)
- self.__numpySelection.clear()
- info = self._getInfo()
- axisNames = self.__currentView.axesNames(self.__data, info)
- if info.isArray and info.size != 0 and self.__data is not None and axisNames is not None:
- self.__useAxisSelection = True
- self.__numpySelection.setAxisNames(axisNames)
- self.__numpySelection.setCustomAxis(self.__currentView.customAxisNames())
- data = self.normalizeData(self.__data)
- self.__numpySelection.setData(data)
- if hasattr(data, "shape"):
- isVisible = not (len(axisNames) == 1 and len(data.shape) == 1)
+ with blockSignals(self.__numpySelection):
+ previousPermutation = self.__numpySelection.permutation()
+ previousSelection = self.__numpySelection.selection()
+
+ self.__numpySelection.clear()
+
+ info = self._getInfo()
+ axisNames = self.__currentView.axesNames(self.__data, info)
+ if (info.isArray and info.size != 0 and
+ self.__data is not None and axisNames is not None):
+ self.__useAxisSelection = True
+ self.__numpySelection.setAxisNames(axisNames)
+ self.__numpySelection.setCustomAxis(
+ self.__currentView.customAxisNames())
+ data = self.normalizeData(self.__data)
+ self.__numpySelection.setData(data)
+
+ # Try to restore previous permutation and selection
+ try:
+ self.__numpySelection.setSelection(
+ previousSelection, previousPermutation)
+ except ValueError as e:
+ _logger.error("Not restoring selection because: %s", e)
+
+ if hasattr(data, "shape"):
+ isVisible = not (len(axisNames) == 1 and len(data.shape) == 1)
+ else:
+ isVisible = True
+ self.__axisSelection.setVisible(isVisible)
else:
- isVisible = True
- self.__axisSelection.setVisible(isVisible)
- else:
- self.__useAxisSelection = False
- self.__axisSelection.setVisible(False)
- self.__numpySelection.blockSignals(previous)
+ self.__useAxisSelection = False
+ self.__axisSelection.setVisible(False)
def __updateDataInView(self):
"""