Commit 41d273fc authored by Thomas Vincent's avatar Thomas Vincent

update QSpaceView to use new range slider and use bin edges rather than

centers
parent 2462b59a
......@@ -453,6 +453,7 @@ class QSpaceView(Qt.QMainWindow):
histo = self.__histo
mask = self.__mask
qspace[mask] /= histo[mask]
# TODO what is that (__minVal?)? + not updated when changing qspace
if not hasattr(self, "__minVal"):
self.__minVal = qspace[mask*(qspace>0)].min()
qspace /= self.__minVal
......@@ -468,34 +469,27 @@ class QSpaceView(Qt.QMainWindow):
qyScale = (qyMax - qyMin) / (qyLen - 1)
qzScale = (qzMax - qzMin) / (qzLen - 1)
self.__view3d.setScale(qxScale, qyScale, qzScale)
self.__view3d.setTranslation(qxMin, qyMin, qzMin)
self.__view3d.setTranslation(qxMin - qxScale/2.,
qyMin - qyScale/2.,
qzMin - qzScale/2.)
self.__defaultIsoLevels = None # Reset default isosurface levels
swapedQSpace = qspace.swapaxes(0, 2)
self.__view3d.setData(swapedQSpace)
swappedQSpace = qspace.swapaxes(0, 2)
self.__view3d.setData(swappedQSpace)
wasStack = self.__stackView.getStack(copy=False) is not None
self.__stackView.setStack(swapedQSpace,
reset=False,
calibrations=((qzMin, qzScale),
(qyMin, qyScale),
(qxMin, qxScale)))
self.__stackView.setStack(
swappedQSpace,
reset=False,
calibrations=((qzMin - qzScale/2., qzScale),
(qyMin - qyScale/2., qyScale),
(qxMin - qxScale/2., qxScale)))
if not wasStack:
self.__stackView.resetZoom()
z_sum = qspace.sum(axis=0).sum(axis=0)
cube_sum_z = qspace.sum(axis=2)
y_sum = cube_sum_z.sum(axis=0)
x_sum = cube_sum_z.sum(axis=1)
colors = cm.jet(np.arange(255))
cmap = [Qt.QColor.fromRgbF(*c).rgba() for c in colors]
roiWidget = self.__fitWidget.roiWidget()
roiWidget.xSlider().setSliderProfile(x_sum, colormap=cmap)
roiWidget.ySlider().setSliderProfile(y_sum, colormap=cmap)
roiWidget.zSlider().setSliderProfile(z_sum, colormap=cmap)
# Update sliders histograms
self.__fitWidget.setQSpaceIndex(idx)
def __nextFitFile(self):
"""
......@@ -580,14 +574,14 @@ class QSpaceView(Qt.QMainWindow):
zLabel, yLabel, xLabel = self.__getStackViewCurrentLabels()
frame = self.__stackView.getFrameNumber()
begin, end = roiSliders[zLabel].getSliderIndices()
begin, end = roiSliders[zLabel].getPositions()
if begin <= frame <= end:
# Fill for edges of the ROI
fill = (frame == begin) or (frame == end)
xRange = roiSliders[xLabel].getSliderValues()
yRange = roiSliders[yLabel].getSliderValues()
xRange = roiSliders[xLabel].getValues()
yRange = roiSliders[yLabel].getValues()
self.__stackView.addItem(
xRange, yRange,
......@@ -633,10 +627,11 @@ class QSpaceView(Qt.QMainWindow):
[yLeft, yRight],
[xLeft, xRight]) = ([None, None], [None, None], [None, None])
# TODO would be better to do that in fit widget
roiWidget = self.__fitWidget.roiWidget()
roiWidget.xSlider().setSliderValues(xLeft, xRight)
roiWidget.ySlider().setSliderValues(yLeft, yRight)
roiWidget.zSlider().setSliderValues(zLeft, zRight)
roiWidget.xSlider().setValues(xLeft, xRight)
roiWidget.ySlider().setValues(yLeft, yRight)
roiWidget.zSlider().setValues(zLeft, zRight)
self.__updateStackViewROI()
......@@ -651,14 +646,13 @@ class QSpaceView(Qt.QMainWindow):
if region is None:
return
xState = event['x']
yState = event['y']
zState = event['z']
xRoi = xState.leftIndex, xState.rightIndex + 1
yRoi = yState.leftIndex, yState.rightIndex + 1
zRoi = zState.leftIndex, zState.rightIndex + 1
roiRanges = {}
for axis, state in event.items():
roiRanges[axis] = state.leftIndex, state.rightIndex
self.__view3d.setSelectedRegion(zrange=zRoi, yrange=yRoi, xrange_=xRoi)
self.__view3d.setSelectedRegion(zrange=roiRanges['z'],
yrange=roiRanges['y'],
xrange_=roiRanges['x'])
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