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