summaryrefslogtreecommitdiff
path: root/silx/gui/plot/Profile.py
diff options
context:
space:
mode:
authorPicca Frédéric-Emmanuel <picca@debian.org>2017-10-07 07:59:01 +0200
committerPicca Frédéric-Emmanuel <picca@debian.org>2017-10-07 07:59:01 +0200
commitbfa4dba15485b4192f8bbe13345e9658c97ecf76 (patch)
treefb9c6e5860881fbde902f7cbdbd41dc4a3a9fb5d /silx/gui/plot/Profile.py
parentf7bdc2acff3c13a6d632c28c4569690ab106eed7 (diff)
New upstream version 0.6.0+dfsg
Diffstat (limited to 'silx/gui/plot/Profile.py')
-rw-r--r--silx/gui/plot/Profile.py77
1 files changed, 42 insertions, 35 deletions
diff --git a/silx/gui/plot/Profile.py b/silx/gui/plot/Profile.py
index a11b3f0..ff85695 100644
--- a/silx/gui/plot/Profile.py
+++ b/silx/gui/plot/Profile.py
@@ -28,7 +28,7 @@ and stacks of images"""
__authors__ = ["V.A. Sole", "T. Vincent", "P. Knobel", "H. Payno"]
__license__ = "MIT"
-__date__ = "24/04/2017"
+__date__ = "17/08/2017"
import numpy
@@ -39,11 +39,11 @@ from .. import icons
from .. import qt
from . import items
from .Colors import cursorColorForColormap
-from .PlotActions import PlotAction
+from . import actions
from .PlotToolButtons import ProfileToolButton
from .ProfileMainWindow import ProfileMainWindow
-from silx.utils.decorators import deprecated
+from silx.utils.deprecation import deprecated
def _alignedFullProfile(data, origin, scale, position, roiWidth, axis):
@@ -372,13 +372,8 @@ class ProfileToolBar(qt.QToolBar):
self._profileMainWindow = ProfileMainWindow(self)
# Actions
- self.browseAction = qt.QAction(
- icons.getQIcon('normal'),
- 'Browsing Mode', None)
- self.browseAction.setToolTip(
- 'Enables zooming interaction mode')
- self.browseAction.setCheckable(True)
- self.browseAction.triggered[bool].connect(self._browseActionTriggered)
+ self._browseAction = actions.mode.ZoomModeAction(self.plot, parent=self)
+ self._browseAction.setVisible(False)
self.hLineAction = qt.QAction(
icons.getQIcon('shape-horizontal'),
@@ -414,15 +409,13 @@ class ProfileToolBar(qt.QToolBar):
# ActionGroup
self.actionGroup = qt.QActionGroup(self)
- self.actionGroup.addAction(self.browseAction)
+ self.actionGroup.addAction(self._browseAction)
self.actionGroup.addAction(self.hLineAction)
self.actionGroup.addAction(self.vLineAction)
self.actionGroup.addAction(self.lineAction)
- self.browseAction.setChecked(True)
-
# Add actions to ToolBar
- self.addAction(self.browseAction)
+ self.addAction(self._browseAction)
self.addAction(self.hLineAction)
self.addAction(self.vLineAction)
self.addAction(self.lineAction)
@@ -450,6 +443,11 @@ class ProfileToolBar(qt.QToolBar):
self.getProfileMainWindow().sigClose.connect(self.clearProfile)
@property
+ @deprecated(since_version="0.6.0")
+ def browseAction(self):
+ return self._browseAction
+
+ @property
@deprecated(replacement="getProfilePlot", since_version="0.5.0")
def profileWindow(self):
return self.getProfilePlot()
@@ -473,10 +471,15 @@ class ProfileToolBar(qt.QToolBar):
def _activeImageChanged(self, previous, legend):
"""Handle active image change: toggle enabled toolbar, update curve"""
- self.setEnabled(legend is not None)
- if legend is not None:
- # Update default profile color
+ if legend is None:
+ self.setEnabled(False)
+ else:
activeImage = self.plot.getActiveImage()
+
+ # Disable for empty image
+ self.setEnabled(activeImage.getData(copy=False).size > 0)
+
+ # Update default profile color
if isinstance(activeImage, items.ColormapMixIn):
self._defaultOverlayColor = cursorColorForColormap(
activeImage.getColormap()['name'])
@@ -495,7 +498,15 @@ class ProfileToolBar(qt.QToolBar):
If changed from elsewhere, disable drawing tool
"""
if source is not self:
- self.browseAction.setChecked(True)
+ self.clearProfile()
+
+ # Uncheck all drawing profile modes
+ self.hLineAction.setChecked(False)
+ self.vLineAction.setChecked(False)
+ self.lineAction.setChecked(False)
+
+ if self.getProfileMainWindow() is not None:
+ self.getProfileMainWindow().hide()
def _hLineActionToggled(self, checked):
"""Handle horizontal line profile action toggle"""
@@ -524,14 +535,6 @@ class ProfileToolBar(qt.QToolBar):
else:
self.plot.sigPlotSignal.disconnect(self._plotWindowSlot)
- def _browseActionTriggered(self, checked):
- """Handle browse action mode triggered by user."""
- if checked:
- self.clearProfile()
- self.plot.setInteractiveMode('zoom', source=self)
- if self.getProfileMainWindow() is not None:
- self.getProfileMainWindow().hide()
-
def _plotWindowSlot(self, event):
"""Listen to Plot to handle drawing events to refresh ROI and profile.
"""
@@ -585,8 +588,8 @@ class ProfileToolBar(qt.QToolBar):
self.plot.remove(self._POLYGON_LEGEND, kind='item')
self.getProfilePlot().clear()
self.getProfilePlot().setGraphTitle('')
- self.getProfilePlot().setGraphXLabel('X')
- self.getProfilePlot().setGraphYLabel('Y')
+ self.getProfilePlot().getXAxis().setLabel('X')
+ self.getProfilePlot().getYAxis().setLabel('Y')
self._createProfile(currentData=image.getData(copy=False),
origin=image.getOrigin(),
@@ -678,17 +681,21 @@ class ProfileToolBar(qt.QToolBar):
class Profile3DToolBar(ProfileToolBar):
- def __init__(self, parent=None, plot=None, title='Profile Selection'):
+ def __init__(self, parent=None, stackview=None,
+ title='Profile Selection'):
"""QToolBar providing profile tools for an image or a stack of images.
:param parent: the parent QWidget
- :param plot: :class:`PlotWindow` instance on which to operate.
+ :param stackview: :class:`StackView` instance on which to operate.
:param str title: See :class:`QToolBar`.
:param parent: See :class:`QToolBar`.
"""
# TODO: add param profileWindow (specify the plot used for profiles)
- super(Profile3DToolBar, self).__init__(parent=parent, plot=plot,
+ super(Profile3DToolBar, self).__init__(parent=parent,
+ plot=stackview.getPlot(),
title=title)
+ self.stackView = stackview
+ """:class:`StackView` instance"""
self.profile3dAction = ProfileToolButton(
parent=self, plot=self.plot)
@@ -721,15 +728,15 @@ class Profile3DToolBar(ProfileToolBar):
if self._profileType == "1D":
super(Profile3DToolBar, self).updateProfile()
elif self._profileType == "2D":
- stackData = self.plot.getCurrentView(copy=False,
- returnNumpyArray=True)
+ stackData = self.stackView.getCurrentView(copy=False,
+ returnNumpyArray=True)
if stackData is None:
return
self.plot.remove(self._POLYGON_LEGEND, kind='item')
self.getProfilePlot().clear()
self.getProfilePlot().setGraphTitle('')
- self.getProfilePlot().setGraphXLabel('X')
- self.getProfilePlot().setGraphYLabel('Y')
+ self.getProfilePlot().getXAxis().setLabel('X')
+ self.getProfilePlot().getYAxis().setLabel('Y')
self._createProfile(currentData=stackData[0],
origin=stackData[1]['origin'],