summaryrefslogtreecommitdiff
path: root/silx/gui/plot/ImageStack.py
diff options
context:
space:
mode:
Diffstat (limited to 'silx/gui/plot/ImageStack.py')
-rw-r--r--silx/gui/plot/ImageStack.py43
1 files changed, 38 insertions, 5 deletions
diff --git a/silx/gui/plot/ImageStack.py b/silx/gui/plot/ImageStack.py
index 3b652ca..fe4b451 100644
--- a/silx/gui/plot/ImageStack.py
+++ b/silx/gui/plot/ImageStack.py
@@ -1,7 +1,7 @@
# coding: utf-8
# /*##########################################################################
#
-# Copyright (c) 2020 European Synchrotron Radiation Facility
+# Copyright (c) 2020-2021 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
@@ -41,7 +41,7 @@ import threading
import typing
import logging
-_logger = logging.getLogger(__file__)
+_logger = logging.getLogger(__name__)
class _PlotWithWaitingLabel(qt.QWidget):
@@ -71,6 +71,7 @@ class _PlotWithWaitingLabel(qt.QWidget):
def __init__(self, parent):
super(_PlotWithWaitingLabel, self).__init__(parent=parent)
+ self._autoResetZoom = True
layout = qt.QStackedLayout(self)
layout.setStackingMode(qt.QStackedLayout.StackAll)
@@ -88,6 +89,24 @@ class _PlotWithWaitingLabel(qt.QWidget):
super(_PlotWithWaitingLabel, self).close()
self.updateThread.stop()
+ def setAutoResetZoom(self, reset):
+ """
+ Should we reset the zoom when adding an image (eq. when browsing)
+
+ :param bool reset:
+ """
+ self._autoResetZoom = reset
+ if self._autoResetZoom:
+ self._plot.resetZoom()
+
+ def isAutoResetZoom(self):
+ """
+
+ :return: True if a reset is done when the image change
+ :rtype: bool
+ """
+ return self._autoResetZoom
+
def setWaiting(self, activate=True):
if activate is True:
self._plot.clear()
@@ -97,7 +116,7 @@ class _PlotWithWaitingLabel(qt.QWidget):
def setData(self, data):
self.setWaiting(activate=False)
- self._plot.addImage(data=data)
+ self._plot.addImage(data=data, resetzoom=self._autoResetZoom)
def clear(self):
self._plot.clear()
@@ -160,8 +179,7 @@ class UrlList(qt.QWidget):
sel_items = self._listWidget.findItems(url.path(), qt.Qt.MatchExactly)
if sel_items is None:
_logger.warning(url.path(), ' is not registered in the list.')
- else:
- assert len(sel_items) == 1
+ elif len(sel_items) > 0:
item = sel_items[0]
self._listWidget.setCurrentItem(item)
self.sigCurrentUrlChanged.emit(item.text())
@@ -601,3 +619,18 @@ class ImageStack(qt.QMainWindow):
"""display a simple image of loading..."""
self._plot.setWaiting(activate=True)
+ def setAutoResetZoom(self, reset):
+ """
+ Should we reset the zoom when adding an image (eq. when browsing)
+
+ :param bool reset:
+ """
+ self._plot.setAutoResetZoom(reset)
+
+ def isAutoResetZoom(self) -> bool:
+ """
+
+ :return: True if a reset is done when the image change
+ :rtype: bool
+ """
+ return self._plot.isAutoResetZoom()