Commit 2199911a authored by Damien Naudet's avatar Damien Naudet
Browse files

Temporary link fit to qspace.

parent c1960275
......@@ -26,6 +26,7 @@
from __future__ import absolute_import
import os
from collections import OrderedDict
from silx.gui import qt as Qt
......@@ -95,8 +96,8 @@ class XsocsGui(Qt.QMainWindow):
self.__project = None
self.__intensityView = None
self.__qspaceViews = {}
self.__fitViews = {}
self.__qspaceViews = OrderedDict()
self.__fitViews = OrderedDict()
self.__createViews()
self.__createActions()
......@@ -214,7 +215,7 @@ class XsocsGui(Qt.QMainWindow):
tree = property(lambda self: self.centralWidget())
def __showQSpace(self, node):
def __showQSpace(self, node, bringToFront=True):
view = self.__qspaceViews.get(node)
if not view:
view = QSpaceView(self, model=node.model, node=node)
......@@ -227,7 +228,9 @@ class XsocsGui(Qt.QMainWindow):
view.resize(size)
view.sigProcessApplied.connect(self.__qspaceRoiApplied)
view.show()
view.raise_()
if bringToFront:
view.raise_()
return view
def __qspaceRoiApplied(self, node, roi):
item = h5NodeToProjectItem(node)
......@@ -257,7 +260,26 @@ class XsocsGui(Qt.QMainWindow):
# TODO : unmaintainable and FUGLY!!!!! node.parent().parent()
view = FitView(self, node.model, node, node.parent().parent())
self.__fitViews[node] = view
view.sigPointSelected.connect(self.__fitViewPointSelected)
view.show()
return view
def __fitViewPointSelected(self, point):
sender = self.sender()
if not isinstance(sender, FitView):
return
views = self.__fitViews.values()
try:
viewIdx = views.index(sender)
except ValueError:
# TODO
return
fitNode = self.__fitViews.keys()[viewIdx]
qspaceNode = fitNode.parent().parent()
qspaceView = self.__showQSpace(qspaceNode, bringToFront=False)
qspaceView.selectPoint(point.x, point.y)
def model(self):
return self.tree.model()
......
......@@ -333,7 +333,7 @@ class DropPlotWidget(XsocsPlot2D):
class FitView(Qt.QMainWindow):
sigProcessApplied = Qt.Signal(object)
sigPointSelected = Qt.Signal(object)
def __init__(self,
parent,
......@@ -343,6 +343,8 @@ class FitView(Qt.QMainWindow):
**kwargs):
super(FitView, self).__init__(parent)
self.__firstShow = True
self.setWindowTitle('[XSOCS] {0}'.format(node.h5Path))
item = h5NodeToProjectItem(node)
......@@ -425,24 +427,24 @@ class FitView(Qt.QMainWindow):
grpLayout.addWidget(plot)
self.__fitPlots.append(plot)
plot.setGraphTitle('Qx fit')
self.setShowMousePosition(True)
self.setShowSelectedCoordinates(True)
plot.setShowMousePosition(True)
plot.setShowSelectedCoordinates(True)
plot = XsocsPlot2D()
plot.setKeepDataAspectRatio(False)
grpLayout.addWidget(plot)
self.__fitPlots.append(plot)
plot.setGraphTitle('Qy fit')
self.setShowMousePosition(True)
self.setShowSelectedCoordinates(True)
plot.setShowMousePosition(True)
plot.setShowSelectedCoordinates(True)
plot = XsocsPlot2D()
plot.setKeepDataAspectRatio(False)
grpLayout.addWidget(plot)
self.__fitPlots.append(plot)
plot.setGraphTitle('Qz fit')
self.setShowMousePosition(True)
self.setShowSelectedCoordinates(True)
plot.setShowMousePosition(True)
plot.setShowSelectedCoordinates(True)
layout.addWidget(grpBox, 0, 2)
......@@ -451,7 +453,16 @@ class FitView(Qt.QMainWindow):
self.setCentralWidget(centralWid)
self.__initPlots()
# self.__initPlots()
def showEvent(self, event):
# TODO : this is a workaround to the fact that
# plot ranges aren't set correctly when adding data when the plot
# widget hasn't been shown yet.
super(FitView, self).showEvent(event)
if self.__firstShow:
self.__firstShow = False
self.__initPlots()
def __initPlots(self):
......@@ -473,8 +484,8 @@ class FitView(Qt.QMainWindow):
_initCentroid(self.__plots, fitH5.filename, entry, process)
def __plotSignal(self, point):
# x, y = point.x, point.y
self.__plotFitResults(point.xIdx)
self.sigPointSelected.emit(point)
def __plotFitResults(self, xIdx):
# TODO : the values could/should be loaded when the widget is shown for the
......@@ -643,9 +654,12 @@ def _initLeastSq(plots, fitH5Name, entry, process):
"""
# hard coded result name, this isn't satisfactory but I can't think
# of any other way right now.
plots[0].plotFitResult(fitH5Name, entry, process, 'position', FitH5.qx_axis)
plots[1].plotFitResult(fitH5Name, entry, process, 'position', FitH5.qy_axis)
plots[2].plotFitResult(fitH5Name, entry, process, 'position', FitH5.qz_axis)
plots[0].plotFitResult(fitH5Name, entry, process,
'position', FitH5.qx_axis)
plots[1].plotFitResult(fitH5Name, entry, process,
'position', FitH5.qy_axis)
plots[2].plotFitResult(fitH5Name, entry, process,
'position', FitH5.qz_axis)
def _initCentroid(plots, fitH5Name, entry, process):
......
......@@ -396,6 +396,9 @@ class QSpaceView(Qt.QMainWindow):
self.sigProcessApplied.emit(self.__node, roi)
def selectPoint(self, x, y):
self.__showIsoView(x, y)
def __pointSelected(self, point):
xIdx = point.xIdx
x = point.x
......
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