diff options
author | Alexandre Marie <alexandre.marie@synchrotron-soleil.fr> | 2019-07-09 10:20:20 +0200 |
---|---|---|
committer | Alexandre Marie <alexandre.marie@synchrotron-soleil.fr> | 2019-07-09 10:20:20 +0200 |
commit | 654a6ac93513c3cc1ef97cacd782ff674c6f4559 (patch) | |
tree | 3b986e4972de7c57fa465820367602fc34bcb0d3 /silx/gui/plot/PlotWindow.py | |
parent | a763e5d1b3921b3194f3d4e94ab9de3fbe08bbdd (diff) |
New upstream version 0.11.0+dfsg
Diffstat (limited to 'silx/gui/plot/PlotWindow.py')
-rw-r--r-- | silx/gui/plot/PlotWindow.py | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/silx/gui/plot/PlotWindow.py b/silx/gui/plot/PlotWindow.py index b44a512..a39430e 100644 --- a/silx/gui/plot/PlotWindow.py +++ b/silx/gui/plot/PlotWindow.py @@ -29,15 +29,19 @@ The :class:`PlotWindow` is a subclass of :class:`.PlotWidget`. __authors__ = ["V.A. Sole", "T. Vincent"] __license__ = "MIT" -__date__ = "21/12/2018" +__date__ = "12/04/2019" -import collections +try: + from collections import abc +except ImportError: # Python2 support + import collections as abc import logging import weakref import silx from silx.utils.weakref import WeakMethodProxy from silx.utils.deprecation import deprecated +from silx.utils.proxy import docstring from . import PlotWidget from . import actions @@ -128,53 +132,53 @@ class PlotWindow(PlotWidget): self.group.setExclusive(False) self.resetZoomAction = self.group.addAction( - actions.control.ResetZoomAction(self)) + actions.control.ResetZoomAction(self, parent=self)) self.resetZoomAction.setVisible(resetzoom) self.addAction(self.resetZoomAction) - self.zoomInAction = actions.control.ZoomInAction(self) + self.zoomInAction = actions.control.ZoomInAction(self, parent=self) self.addAction(self.zoomInAction) - self.zoomOutAction = actions.control.ZoomOutAction(self) + self.zoomOutAction = actions.control.ZoomOutAction(self, parent=self) self.addAction(self.zoomOutAction) self.xAxisAutoScaleAction = self.group.addAction( - actions.control.XAxisAutoScaleAction(self)) + actions.control.XAxisAutoScaleAction(self, parent=self)) self.xAxisAutoScaleAction.setVisible(autoScale) self.addAction(self.xAxisAutoScaleAction) self.yAxisAutoScaleAction = self.group.addAction( - actions.control.YAxisAutoScaleAction(self)) + actions.control.YAxisAutoScaleAction(self, parent=self)) self.yAxisAutoScaleAction.setVisible(autoScale) self.addAction(self.yAxisAutoScaleAction) self.xAxisLogarithmicAction = self.group.addAction( - actions.control.XAxisLogarithmicAction(self)) + actions.control.XAxisLogarithmicAction(self, parent=self)) self.xAxisLogarithmicAction.setVisible(logScale) self.addAction(self.xAxisLogarithmicAction) self.yAxisLogarithmicAction = self.group.addAction( - actions.control.YAxisLogarithmicAction(self)) + actions.control.YAxisLogarithmicAction(self, parent=self)) self.yAxisLogarithmicAction.setVisible(logScale) self.addAction(self.yAxisLogarithmicAction) self.gridAction = self.group.addAction( - actions.control.GridAction(self, gridMode='both')) + actions.control.GridAction(self, gridMode='both', parent=self)) self.gridAction.setVisible(grid) self.addAction(self.gridAction) self.curveStyleAction = self.group.addAction( - actions.control.CurveStyleAction(self)) + actions.control.CurveStyleAction(self, parent=self)) self.curveStyleAction.setVisible(curveStyle) self.addAction(self.curveStyleAction) self.colormapAction = self.group.addAction( - actions.control.ColormapAction(self)) + actions.control.ColormapAction(self, parent=self)) self.colormapAction.setVisible(colormap) self.addAction(self.colormapAction) self.colorbarAction = self.group.addAction( - actions_control.ColorBarAction(self, self)) + actions_control.ColorBarAction(self, parent=self)) self.colorbarAction.setVisible(False) self.addAction(self.colorbarAction) self._colorbar.setVisible(False) @@ -194,18 +198,18 @@ class PlotWindow(PlotWidget): self.getMaskAction().setVisible(mask) self._intensityHistoAction = self.group.addAction( - actions_histogram.PixelIntensitiesHistoAction(self)) + actions_histogram.PixelIntensitiesHistoAction(self, parent=self)) self._intensityHistoAction.setVisible(False) self._medianFilter2DAction = self.group.addAction( - actions_medfilt.MedianFilter2DAction(self)) + actions_medfilt.MedianFilter2DAction(self, parent=self)) self._medianFilter2DAction.setVisible(False) self._medianFilter1DAction = self.group.addAction( - actions_medfilt.MedianFilter1DAction(self)) + actions_medfilt.MedianFilter1DAction(self, parent=self)) self._medianFilter1DAction.setVisible(False) - self.fitAction = self.group.addAction(actions_fit.FitAction(self)) + self.fitAction = self.group.addAction(actions_fit.FitAction(self, parent=self)) self.fitAction.setVisible(fit) self.addAction(self.fitAction) @@ -250,7 +254,7 @@ class PlotWindow(PlotWidget): hbox.addWidget(self.controlButton) if position: # Add PositionInfo widget to the bottom of the plot - if isinstance(position, collections.Iterable): + if isinstance(position, abc.Iterable): # Use position as a set of converters converters = position else: @@ -278,7 +282,7 @@ class PlotWindow(PlotWidget): parent=self, plot=self) self.addToolBar(self._interactiveModeToolBar) - self._toolbar = self._createToolBar(title='Plot', parent=None) + self._toolbar = self._createToolBar(title='Plot', parent=self) self.addToolBar(self._toolbar) self._outputToolBar = tools.OutputToolBar(parent=self, plot=self) @@ -292,24 +296,21 @@ class PlotWindow(PlotWidget): for action in toolbar.actions(): self.addAction(action) + @docstring(PlotWidget) def setBackgroundColor(self, color): super(PlotWindow, self).setBackgroundColor(color) self._updateColorBarBackground() - setBackgroundColor.__doc__ = PlotWidget.setBackgroundColor.__doc__ - + @docstring(PlotWidget) def setDataBackgroundColor(self, color): super(PlotWindow, self).setDataBackgroundColor(color) self._updateColorBarBackground() - setDataBackgroundColor.__doc__ = PlotWidget.setDataBackgroundColor.__doc__ - + @docstring(PlotWidget) def setForegroundColor(self, color): super(PlotWindow, self).setForegroundColor(color) self._updateColorBarBackground() - setForegroundColor.__doc__ = PlotWidget.setForegroundColor.__doc__ - def _updateColorBarBackground(self): """Update the colorbar background according to the state of the plot""" if self._isAxesDisplayed(): @@ -824,7 +825,9 @@ class Plot2D(PlotWindow): posInfo = [ ('X', lambda x, y: x), ('Y', lambda x, y: y), - ('Data', WeakMethodProxy(self._getImageValue))] + ('Data', WeakMethodProxy(self._getImageValue)), + ('Dims', WeakMethodProxy(self._getImageDims)), + ] super(Plot2D, self).__init__(parent=parent, backend=backend, resetzoom=True, autoScale=False, @@ -924,6 +927,15 @@ class Plot2D(PlotWindow): return value, "Masked" return value + def _getImageDims(self, *args): + activeImage = self.getActiveImage() + if (activeImage is not None and + activeImage.getData(copy=False) is not None): + dims = activeImage.getData(copy=False).shape[1::-1] + return 'x'.join(str(dim) for dim in dims) + else: + return '-' + def getProfileToolbar(self): """Profile tools attached to this plot |