Commit 65eeb17d authored by Thomas Vincent's avatar Thomas Vincent

rework swap qspace and update to FitWidget API changes

parent 3ad708de
......@@ -42,7 +42,6 @@ from silx.gui.plot.StackView import StackView
from silx.math.combo import min_max
from ... import config
from ...io import QSpaceH5
from ...util import bin_centers_to_range_step
from ..widgets.XsocsPlot2D import XsocsPlot2D
from ..process.FitWidget import FitWidget
......@@ -495,23 +494,16 @@ class QSpaceView(Qt.QMainWindow):
axisNames = list(qspaceH5.qspace_dimension_names)
# For cartesian coordinates swap axes as it is stored as qx, qy, qz
# Would need to change how it is stored in the file to avoid this...
if axisNames == list(QSpaceH5.QSpaceCoordinates.axesNames(
QSpaceH5.QSpaceCoordinates.CARTESIAN)):
# Swap qspace dataset to be qz, qy, qx (was qx, qy, qz)
qspace = qspace.swapaxes(0, 2)
# in-place operations
minBinEdge.reverse()
binSteps.reverse()
axisNames.reverse()
# Swap qspace dataset to be qz, qy, qx (was qx, qy, qz)
# For spherical, swap from (qr, qincl, qazim) to (qazim, qincl, qr).
qspace = qspace.swapaxes(0, 2)
if self.__view3d is not None:
# swap scale, transition, labels as it is follows x, y, z convention
self.__view3d.setScale(*tuple(reversed(binSteps)))
self.__view3d.setTranslation(*tuple(reversed(minBinEdge)))
self.__view3d.setScale(*binSteps)
self.__view3d.setTranslation(*minBinEdge)
self.__view3d.setAxesLabels(*tuple(reversed(axisNames)))
self.__view3d.setAxesLabels(*axisNames)
self.__defaultIsoLevels = None # Reset default isosurface levels
......@@ -525,7 +517,7 @@ class QSpaceView(Qt.QMainWindow):
qspace,
perspective=perspective,
reset=False,
calibrations=tuple(zip(minBinEdge, binSteps)))
calibrations=tuple(reversed(tuple(zip(minBinEdge, binSteps)))))
if not wasStack:
self.__stackView.resetZoom()
......@@ -589,14 +581,11 @@ class QSpaceView(Qt.QMainWindow):
def __updateStackViewROI(self, *args, **kwargs):
"""Update display of ROI on StackView"""
roiWidget = self.__fitWidget.roiWidget()
legend = "__QSpaceView_ROI__"
if roiWidget.isActive():
if self.__fitWidget.roiWidget().isActive():
# Get ROI range for currently displayed axes
roiSliders = [roiWidget.zSlider(),
roiWidget.ySlider(),
roiWidget.xSlider()]
roiSliders = tuple(reversed(self.__fitWidget.roiWidget().sliders()))
perspective = self.__stackView.getPerspective()
......@@ -658,10 +647,8 @@ class QSpaceView(Qt.QMainWindow):
xRange, yRange, zRange = None, None, None
# TODO would be better to do that in fit widget
roiWidget = self.__fitWidget.roiWidget()
for slider, range_ in ((roiWidget.xSlider(), xRange),
(roiWidget.ySlider(), yRange),
(roiWidget.zSlider(), zRange)):
for slider, range_ in zip(self.__fitWidget.roiWidget().sliders(),
(xRange, yRange, zRange)):
if range_ is None:
range_ = slider.getRange()
slider.setValues(*range_)
......@@ -680,13 +667,11 @@ class QSpaceView(Qt.QMainWindow):
if region is None:
return
roiRanges = {}
for axis, state in event.items():
roiRanges[axis] = state.leftIndex, state.rightIndex
roiRanges = [(state.leftIndex, state.rightIndex) for state in event]
self.__view3d.setSelectedRegion(zrange=roiRanges['z'],
yrange=roiRanges['y'],
xrange_=roiRanges['x'])
self.__view3d.setSelectedRegion(zrange=roiRanges[2],
yrange=roiRanges[1],
xrange_=roiRanges[0])
self.__updateStackViewROI()
......
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