Commit f9d357cd authored by Thomas Vincent's avatar Thomas Vincent

Update stack view management

parent 8447b401
...@@ -35,6 +35,7 @@ import numpy as np ...@@ -35,6 +35,7 @@ import numpy as np
from matplotlib import cm from matplotlib import cm
from silx.utils.weakref import WeakMethodProxy
from silx.gui import qt as Qt from silx.gui import qt as Qt
from silx.gui.plot import actions, PlotToolButtons, PlotWidget from silx.gui.plot import actions, PlotToolButtons, PlotWidget
from silx.gui.icons import getQIcon from silx.gui.icons import getQIcon
...@@ -272,14 +273,17 @@ class QSpaceView(Qt.QMainWindow): ...@@ -272,14 +273,17 @@ class QSpaceView(Qt.QMainWindow):
# Create StackView # Create StackView
self.__stackView = StackView() self.__stackView = StackView()
self.__stackView.setLabels(('qz', 'qy', 'qx')) self.__stackView.setLabels(('qz', 'qy', 'qx'))
self.__stackView.setColormap('viridis') self.__stackView.setColormap('viridis')
self.__stackView.setKeepDataAspectRatio(True) self.__stackView.setKeepDataAspectRatio(True)
self.__stackView.getProfileToolbar().setVisible(False) self.__stackView.getProfileToolbar().setVisible(False)
self.__stackView.getColorBarAction().setVisible(False) self.__stackView.getColorBarAction().setVisible(False)
self.__stackView.getPlot().getMaskAction().setVisible(False) self.__stackView.getPlot().getMaskAction().setVisible(False)
self.__stackView.sigInteractiveModeChanged.connect( self.__stackView.sigPlaneSelectionChanged.connect(
self.__updateStackViewROI) self.__updateStackViewROI)
self.__stackView.sigStackChanged.connect(self.__updateStackViewROI) self.__stackView.sigStackChanged.connect(self.__updateStackViewROI)
# setting up the plot3D and its param tree # setting up the plot3D and its param tree
self.__view3d = ScalarFieldView() self.__view3d = ScalarFieldView()
...@@ -534,33 +538,69 @@ class QSpaceView(Qt.QMainWindow): ...@@ -534,33 +538,69 @@ class QSpaceView(Qt.QMainWindow):
for widget in self.__lockWidgets: for widget in self.__lockWidgets:
widget.setEnabled(True) widget.setEnabled(True)
def __getStackViewCurrentLabels(self):
"""Retrieves StackView axis labels ordered as currently viewed
(Frame axis label, Y axis, X axis)
:rtype: List[str]
plot = self.__stackView.getPlot()
xLabel = plot.getXAxis().getLabel()
yLabel = plot.getYAxis().getLabel()
zLabel = ['qx', 'qy', 'qz']
zLabel = zLabel[0]
return zLabel, yLabel, xLabel
def __stackViewTitle(self, index):
"""Returns StackView title
:param ind index: Frame index
:rtype: str
labels = self.__getStackViewCurrentLabels()
# TODO apply calibration
return '%s = %d' % (labels[0], index)
def __updateStackViewROI(self, *args, **kwargs): def __updateStackViewROI(self, *args, **kwargs):
"""Update display of ROI on StackView""" """Update display of ROI on StackView"""
roiWidget = self.__fitWidget.roiWidget() roiWidget = self.__fitWidget.roiWidget()
plot = self.__stackView.getPlot()
legend = "__QSpaceView_ROI__" legend = "__QSpaceView_ROI__"
if roiWidget.isActive(): if roiWidget.isActive():
# Get ROI range for currently displayed axes # Get ROI range for currently displayed axes
ranges = { roiSliders = {
'qx': roiWidget.xSlider().getSliderValues(), 'qx': roiWidget.xSlider(),
'qy': roiWidget.ySlider().getSliderValues(), 'qy': roiWidget.ySlider(),
'qz': roiWidget.zSlider().getSliderValues() 'qz': roiWidget.zSlider()
} }
zLabel, yLabel, xLabel = self.__getStackViewCurrentLabels()
frame = self.__stackView.getFrameNumber()
begin, end = roiSliders[zLabel].getSliderIndices()
if begin <= frame <= end:
# Fill for edges of the ROI
fill = (frame == begin) or (frame == end)
xRange = ranges[plot.getXAxis().getLabel()] xRange = roiSliders[xLabel].getSliderValues()
yRange = ranges[plot.getYAxis().getLabel()] yRange = roiSliders[yLabel].getSliderValues()
plot.addItem( self.__stackView.addItem(
xRange, yRange, xRange, yRange,
legend="__QSpaceView_ROI__", legend="__QSpaceView_ROI__",
shape='rectangle', shape='rectangle',
color='pink', color='pink',
fill=False, fill=fill,
overlay=True) overlay=True)
self.__stackView.remove(legend, kind='item')
else: else:
plot.remove(legend, kind='item') self.__stackView.remove(legend, kind='item')
def __slotRoiToggled(self, on): def __slotRoiToggled(self, on):
""" """
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment