Commit 66ab9ba8 authored by Thomas Vincent's avatar Thomas Vincent

update stack view control to make it use public API in future silx

and add fallback code for silx 0.8
parent 7e4c98a1
......@@ -468,9 +468,15 @@ class QSpaceView(Qt.QMainWindow):
swappedQSpace = qspace.swapaxes(0, 2)
self.__view3d.setData(swappedQSpace)
if hasattr(self.__stackView, 'getPerspective'): # silx 0.9
perspective = self.__stackView.getPerspective()
else:
perspective = self.__stackView._perspective
wasStack = self.__stackView.getStack(copy=False) is not None
self.__stackView.setStack(
swappedQSpace,
perspective=perspective,
reset=False,
calibrations=((qzMinBinEdge, qzBinStep),
(qyMinBinEdge, qyBinStep),
......@@ -522,32 +528,27 @@ class QSpaceView(Qt.QMainWindow):
for widget in self.__lockWidgets:
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.remove(xLabel)
zLabel.remove(yLabel)
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 frame = %d' % (labels[0], index)
if hasattr(self.__stackView, 'getPrespective'): # silx 0.9
perspective = self.__stackView.getPerspective()
else:
perspective = self.__stackView._perspective
label = self.__stackView.getLabels()[perspective]
if hasattr(self.__stackView, 'getCalibrations'): # silx 0.9
calibration = self.__stackView.getCalibrations(order='axes')[-1]
else: # silx 0.8 fallback
if hasattr(self.__stackView, 'calibrations3D'):
calibration = self.__stackView._getXYZCalibs()[-1]
else:
calibration = lambda i: i
return '%s = %f' % (label, calibration(index))
def __updateStackViewROI(self, *args, **kwargs):
"""Update display of ROI on StackView"""
......@@ -556,22 +557,28 @@ class QSpaceView(Qt.QMainWindow):
if roiWidget.isActive():
# Get ROI range for currently displayed axes
roiSliders = {
'qx': roiWidget.xSlider(),
'qy': roiWidget.ySlider(),
'qz': roiWidget.zSlider()
}
zLabel, yLabel, xLabel = self.__getStackViewCurrentLabels()
roiSliders = [roiWidget.zSlider(),
roiWidget.ySlider(),
roiWidget.xSlider()]
if hasattr(self.__stackView, 'getPerspective'): # silx 0.9
perspective = self.__stackView.getPerspective()
else:
perspective = self.__stackView._perspective
# Get image axes indices
image_dimensions = [d for d in (0, 1, 2) if d != perspective]
yIndex, xIndex = min(image_dimensions), max(image_dimensions)
frame = self.__stackView.getFrameNumber()
begin, end = roiSliders[zLabel].getPositions()
begin, end = roiSliders[perspective].getPositions()
if begin <= frame < end:
# Fill for edges of the ROI
fill = (frame == begin) or (frame == end - 1)
xRange = roiSliders[xLabel].getValues()
yRange = roiSliders[yLabel].getValues()
xRange = roiSliders[xIndex].getValues()
yRange = roiSliders[yIndex].getValues()
self.__stackView.addItem(
xRange, yRange,
......
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