Commit ef921011 authored by Thomas Vincent's avatar Thomas Vincent

change default isolevels

parent 77140371
......@@ -40,6 +40,7 @@ from silx.gui.plot import actions, PlotToolButtons, PlotWidget
from silx.gui.icons import getQIcon
from silx.gui.plot3d.ScalarFieldView import ScalarFieldView
from silx.gui.plot3d.SFViewParamTree import TreeView as SFViewParamTree
from silx.math.combo import min_max
from ..model.TreeView import TreeView
from ..widgets.XsocsPlot2D import XsocsPlot2D
......@@ -238,6 +239,8 @@ class QSpaceView(Qt.QMainWindow):
self.__qspaceH5 = item.qspaceH5
self.__defaultIsoLevels = None
# plot window displaying the intensity map
self.__plotWindow = plotWindow = PlotIntensityMap(parent=self)
plotWindow.setToolTip('Intensity Map integrated on whole QSpaces')
......@@ -266,29 +269,25 @@ class QSpaceView(Qt.QMainWindow):
firstY = sampleY[0]
# setting up the plot3D and its param tree
self.__view3d = view3d = ScalarFieldView()
view3d.addIsosurface(
lambda data: np.max(data)/25.,
'#FF000060')
view3d.addIsosurface(
lambda data: np.max(data)/5.,
'#00FF00FF')
view3d.setMinimumSize(400, 400)
view3d.setAxesLabels('qx', 'qy', 'qz')
self.setCentralWidget(view3d)
self.__view3d = ScalarFieldView()
self.__view3d.addIsosurface(self.__defaultIsoLevel1, '#FF000060')
self.__view3d.addIsosurface(self.__defaultIsoLevel2, '#00FF00FF')
self.__view3d.setMinimumSize(400, 400)
self.__view3d.setAxesLabels('qx', 'qy', 'qz')
self.setCentralWidget(self.__view3d)
sfTree = SFViewParamTree()
sfTree.setSfView(view3d)
sfTree.setSfView(self.__view3d)
# Register ROIPlotIntensity
view3d.sigSelectedRegionChanged.connect(roiPlotWindow.roiChanged)
self.__view3d.sigSelectedRegionChanged.connect(roiPlotWindow.roiChanged)
# Store the cut plane signals connection state
self.__connectedToCutPlane = True
view3d.getCutPlanes()[0].sigPlaneChanged.connect(
self.__view3d.getCutPlanes()[0].sigPlaneChanged.connect(
self.__cutPlaneChanged)
view3d.getCutPlanes()[0].sigColormapChanged.connect(
self.__view3d.getCutPlanes()[0].sigColormapChanged.connect(
self.__cutPlaneChanged)
view3d.getCutPlanes()[0].sigDataChanged.connect(self.__cutPlaneChanged)
self.__view3d.getCutPlanes()[0].sigDataChanged.connect(self.__cutPlaneChanged)
self.__fitWidget = fitWidget = FitWidget(self.__qspaceH5.filename)
fitWidget.roiWidget().sigRoiChanged.connect(self.__slotRoiChanged)
......@@ -302,7 +301,7 @@ class QSpaceView(Qt.QMainWindow):
fitDock.setWidget(fitWidget)
features = fitDock.features() ^ Qt.QDockWidget.DockWidgetClosable
fitDock.setFeatures(features)
view3d.addDockWidget(Qt.Qt.RightDockWidgetArea, fitDock)
self.__view3d.addDockWidget(Qt.Qt.RightDockWidgetArea, fitDock)
# widget that are to be disabled when the fit is running
self.__lockWidgets = lockWidgets = []
......@@ -341,6 +340,28 @@ class QSpaceView(Qt.QMainWindow):
self.__showIsoView(firstX, firstY)
def __getDefaultIsoLevels(self, data):
"""Returns array of default isosurface levels, computing them if needed
:param numpy.ndarray data: Data from which to compute iso levels
:return: array of default isosurface levels
"""
if self.__defaultIsoLevels is None:
result = min_max(data, min_positive=True, finite=True)
min_ = result.min_positive
max_ = result.maximum
self.__defaultIsoLevels = np.logspace(np.log10(min_), np.log10(max_), 4)[1:-1]
return self.__defaultIsoLevels
def __defaultIsoLevel1(self, data):
"""Return first isosurface default level"""
return self.__getDefaultIsoLevels(data)[0]
def __defaultIsoLevel2(self, data):
"""Returns second isosurface default level"""
return self.__getDefaultIsoLevels(data)[1]
def __setPlotData(self, x, y, data):
"""
Sets the intensity maps data.
......@@ -387,8 +408,6 @@ class QSpaceView(Qt.QMainWindow):
coordinates.
:return:
"""
isoView = self.__view3d
if self.sender() == self.__roiPlotWindow:
self.__plotWindow.selectPoint(x, y)
elif self.sender() == self.__roiPlotWindow:
......@@ -420,12 +439,13 @@ class QSpaceView(Qt.QMainWindow):
qxMin, qxMax = min(self.__qx), max(self.__qx)
qyMin, qyMax = min(self.__qy), max(self.__qy)
qzMin, qzMax = min(self.__qz), max(self.__qz)
isoView.setScale((qxMax - qxMin) / (qxLen - 1),
(qyMax - qyMin) / (qyLen - 1),
(qzMax - qzMin) / (qzLen - 1))
isoView.setTranslation(qxMin, qyMin, qzMin)
self.__view3d.setScale((qxMax - qxMin) / (qxLen - 1),
(qyMax - qyMin) / (qyLen - 1),
(qzMax - qzMin) / (qzLen - 1))
self.__view3d.setTranslation(qxMin, qyMin, qzMin)
isoView.setData(qspace.swapaxes(0, 2))
self.__defaultIsoLevels = None # Reset default isosurface levels
self.__view3d.setData(qspace.swapaxes(0, 2))
z_sum = qspace.sum(axis=0).sum(axis=0)
cube_sum_z = qspace.sum(axis=2)
......@@ -487,22 +507,21 @@ class QSpaceView(Qt.QMainWindow):
:param on:
:return:
"""
view3d = self.__view3d
region = view3d.getSelectedRegion()
region = self.__view3d.getSelectedRegion()
if not on:
# Reset selection region
view3d.setSelectedRegion()
self.__view3d.setSelectedRegion()
else:
if region is None: # Init region
data = view3d.getData(copy=False)
data = self.__view3d.getData(copy=False)
if data is not None:
depth, height, width = data.shape
view3d.setSelectedRegion(zrange=(0, depth),
yrange=(0, height),
xrange_=(0, width))
region = view3d.getSelectedRegion()
self.__view3d.setSelectedRegion(zrange=(0, depth),
yrange=(0, height),
xrange_=(0, width))
region = self.__view3d.getSelectedRegion()
if on and region:
([xLeft, xRight],
......
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