Commit 8862464d authored by Damien Naudet's avatar Damien Naudet

Merge branch 'master' of gitlab.esrf.fr:kmap/kmap into fitview

parents 55782f89 04985a1d
......@@ -332,6 +332,9 @@ class QSpaceView(Qt.QMainWindow):
# setting up the plot3D and its param tree
self.__view3d = view3d = ScalarFieldView()
view3d.addIsosurface(
lambda data: np.mean(data) + np.std(data),
'#FF0000FF')
view3d.setMinimumSize(400, 400)
view3d.setAxesLabels('qx', 'qy', 'qz')
self.setCentralWidget(view3d)
......@@ -341,6 +344,8 @@ class QSpaceView(Qt.QMainWindow):
# Register ROIPlotIntensity
view3d.sigSelectedRegionChanged.connect(roiPlotWindow.roiChanged)
# Store the cut plane signals connection state
self.__connectedToCutPlane = False
view3d.getCutPlanes()[0].sigPlaneChanged.connect(self.__cutPlaneChanged)
view3d.getCutPlanes()[0].sigDataChanged.connect(self.__cutPlaneChanged)
......@@ -536,60 +541,31 @@ class QSpaceView(Qt.QMainWindow):
def __planePlotDockVisibilityChanged(self, visible):
cutPlane = self.__view3d.getCutPlanes()[0]
if visible:
cutPlane.sigPlaneChanged.connect(self.__cutPlaneChanged)
cutPlane.sigDataChanged.connect(self.__cutPlaneChanged)
self.__cutPlaneChanged() # To sync
if not self.__connectedToCutPlane: # Prevent multiple connect
self.__connectedToCutPlane = True
cutPlane.sigPlaneChanged.connect(self.__cutPlaneChanged)
cutPlane.sigDataChanged.connect(self.__cutPlaneChanged)
self.__cutPlaneChanged() # To sync
else:
cutPlane.sigPlaneChanged.disconnect(self.__cutPlaneChanged)
cutPlane.sigDataChanged.disconnect(self.__cutPlaneChanged)
if self.__connectedToCutPlane: # Prevent multiple disconnect
self.__connectedToCutPlane = False
cutPlane.sigPlaneChanged.disconnect(self.__cutPlaneChanged)
cutPlane.sigDataChanged.disconnect(self.__cutPlaneChanged)
def __cutPlaneChanged(self):
plane = self.__view3d.getCutPlanes()[0]
if plane.isVisible() and plane.isValid():
data = self.__view3d.getData(copy=False)
if data is not None:
normal = plane.getNormal()
point = np.array(plane.getPoint(), dtype=np.int)
labels = self.__view3d.getAxesLabels()
scale = self.__view3d.getScale()
translation = self.__view3d.getTranslation()
if np.all(np.equal(normal, (1., 0., 0.))):
index = max(0, min(point[0], data.shape[2] - 1))
slice_ = data[:, :, index]
xlabel, ylabel = labels.getYLabel(), labels.getZLabel()
imageScale = scale[1], scale[2]
imageTranslation = translation[1], translation[2]
title = labels.getXLabel() + ' = %f' % \
(index * scale[0] + translation[0])
elif np.all(np.equal(normal, (0., 1., 0.))):
index = max(0, min(point[1], data.shape[1] - 1))
slice_ = data[:, index, :]
xlabel, ylabel = labels.getXLabel(), labels.getZLabel()
imageScale = scale[0], scale[2]
imageTranslation = translation[0], translation[2]
title = labels.getYLabel() + ' = %f' % \
(index * scale[1] + translation[1])
elif np.all(np.equal(normal, (0., 0., 1.))):
index = max(0, min(point[2], data.shape[0] - 1))
slice_ = data[index, :, :]
xlabel, ylabel = labels.getXLabel(), labels.getYLabel()
imageScale = scale[0], scale[1]
imageTranslation = translation[0], translation[1]
title = labels.getZLabel() + ' = %f' % \
(index * scale[2] + translation[2])
slice_ = np.array(slice_, copy=True)
self.__planePlotWindow.setGraphXLabel(xlabel)
self.__planePlotWindow.setGraphYLabel(ylabel)
self.__planePlotWindow.setGraphTitle(title)
self.__planePlotWindow.addImage(
slice_,
legend='cutting plane',
origin=imageTranslation,
scale=imageScale,
resetzoom=True)
planeImage = plane.getImageData()
if planeImage.isValid():
self.__planePlotWindow.setGraphXLabel(planeImage.getXLabel())
self.__planePlotWindow.setGraphYLabel(planeImage.getYLabel())
title = (planeImage.getNormalLabel() +
' = %f' % planeImage.getPosition())
self.__planePlotWindow.setGraphTitle(title)
self.__planePlotWindow.addImage(
planeImage.getData(copy=False),
legend='cutting plane',
origin=planeImage.getTranslation(),
scale=planeImage.getScale(),
resetzoom=True)
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