Commit ce344bdc authored by Valentin Valls's avatar Valentin Valls

Synchronize properties with the real scan displayed by the plot

parent 51ef348a
......@@ -44,9 +44,10 @@ class CurvePlotWidget(ExtendedDockWidget):
widgetActivated = qt.Signal(object)
plotModelUpdated = qt.Signal(object)
"""Emitted when the plot model displayed by the plot was changed"""
scanModelUpdated = qt.Signal(object)
"""Emitted when the scan model displayed by the plot is changed"""
"""Emitted when the scan model displayed by the plot was changed"""
plotItemSelected = qt.Signal(object)
"""Emitted when a flint plot item was selected by the plot"""
......
......@@ -46,6 +46,12 @@ class ImagePlotWidget(ExtendedDockWidget):
widgetActivated = qt.Signal(object)
plotModelUpdated = qt.Signal(object)
"""Emitted when the plot model displayed by the plot was changed"""
scanModelUpdated = qt.Signal(object)
"""Emitted when the scan model displayed by the plot was changed"""
plotModelUpdated = qt.Signal(object)
def __init__(self, parent=None):
......@@ -264,6 +270,7 @@ class ImagePlotWidget(ExtendedDockWidget):
)
if self.__scan.state() != scan_model.ScanState.INITIALIZED:
self.__updateTitle(self.__scan)
self.scanModelUpdated.emit(scan)
self.__redrawAll()
def __clear(self):
......
......@@ -156,13 +156,7 @@ class ImagePlotPropertyWidget(qt.QWidget):
layout.addWidget(self.__tree)
def setFlintModel(self, flintModel: flint_model.FlintState = None):
if self.__flintModel is not None:
self.__flintModel.currentScanChanged.disconnect(self.__currentScanChanged)
self.__setScan(None)
self.__flintModel = flintModel
if self.__flintModel is not None:
self.__flintModel.currentScanChanged.connect(self.__currentScanChanged)
self.__setScan(self.__flintModel.currentScan())
def focusWidget(self):
return self.__focusWidget
......@@ -170,13 +164,18 @@ class ImagePlotPropertyWidget(qt.QWidget):
def setFocusWidget(self, widget):
if self.__focusWidget is not None:
widget.plotModelUpdated.disconnect(self.__plotModelUpdated)
widget.scanModelUpdated.disconnect(self.__currentScanChanged)
self.__focusWidget = widget
if self.__focusWidget is not None:
widget.plotModelUpdated.connect(self.__plotModelUpdated)
widget.scanModelUpdated.connect(self.__currentScanChanged)
plotModel = widget.plotModel()
scanModel = widget.scan()
else:
plotModel = None
scanModel = None
self.__plotModelUpdated(plotModel)
self.__currentScanChanged(scanModel)
def __plotModelUpdated(self, plotModel):
self.setPlotModel(plotModel)
......@@ -191,8 +190,8 @@ class ImagePlotPropertyWidget(qt.QWidget):
self.__plotModel.itemValueChanged.connect(self.__itemValueChanged)
self.__updateTree()
def __currentScanChanged(self):
self.__setScan(self.__flintModel.currentScan())
def __currentScanChanged(self, scanModel):
self.__setScan(scanModel)
def __structureChanged(self):
self.__updateTree()
......
......@@ -37,6 +37,10 @@ class McaPlotWidget(ExtendedDockWidget):
widgetActivated = qt.Signal(object)
plotModelUpdated = qt.Signal(object)
"""Emitted when the plot model displayed by the plot was changed"""
scanModelUpdated = qt.Signal(object)
"""Emitted when the scan model displayed by the plot was changed"""
def __init__(self, parent=None):
super(McaPlotWidget, self).__init__(parent=parent)
......@@ -259,6 +263,7 @@ class McaPlotWidget(ExtendedDockWidget):
)
if self.__scan.state() != scan_model.ScanState.INITIALIZED:
self.__updateTitle(self.__scan)
self.scanModelUpdated.emit(scan)
self.__redrawAll()
def __clear(self):
......
......@@ -151,13 +151,7 @@ class McaPlotPropertyWidget(qt.QWidget):
layout.addWidget(self.__tree)
def setFlintModel(self, flintModel: flint_model.FlintState = None):
if self.__flintModel is not None:
self.__flintModel.currentScanChanged.disconnect(self.__currentScanChanged)
self.__setScan(None)
self.__flintModel = flintModel
if self.__flintModel is not None:
self.__flintModel.currentScanChanged.connect(self.__currentScanChanged)
self.__setScan(self.__flintModel.currentScan())
def focusWidget(self):
return self.__focusWidget
......@@ -165,13 +159,18 @@ class McaPlotPropertyWidget(qt.QWidget):
def setFocusWidget(self, widget):
if self.__focusWidget is not None:
widget.plotModelUpdated.disconnect(self.__plotModelUpdated)
widget.scanModelUpdated.disconnect(self.__currentScanChanged)
self.__focusWidget = widget
if self.__focusWidget is not None:
widget.plotModelUpdated.connect(self.__plotModelUpdated)
widget.scanModelUpdated.connect(self.__currentScanChanged)
plotModel = widget.plotModel()
scanModel = widget.scan()
else:
plotModel = None
scanModel = None
self.__plotModelUpdated(plotModel)
self.__currentScanChanged(scanModel)
def __plotModelUpdated(self, plotModel):
self.setPlotModel(plotModel)
......@@ -186,8 +185,8 @@ class McaPlotPropertyWidget(qt.QWidget):
self.__plotModel.itemValueChanged.connect(self.__itemValueChanged)
self.__updateTree()
def __currentScanChanged(self):
self.__setScan(self.__flintModel.currentScan())
def __currentScanChanged(self, scanModel):
self.__setScan(scanModel)
def __structureChanged(self):
self.__updateTree()
......
......@@ -42,6 +42,10 @@ class ScatterPlotWidget(ExtendedDockWidget):
widgetActivated = qt.Signal(object)
plotModelUpdated = qt.Signal(object)
"""Emitted when the plot model displayed by the plot was changed"""
scanModelUpdated = qt.Signal(object)
"""Emitted when the scan model displayed by the plot was changed"""
def __init__(self, parent=None):
super(ScatterPlotWidget, self).__init__(parent=parent)
......@@ -355,6 +359,7 @@ class ScatterPlotWidget(ExtendedDockWidget):
)
if self.__scan.state() != scan_model.ScanState.INITIALIZED:
self.__updateTitle(self.__scan)
self.scanModelUpdated.emit(scan)
self.__redrawAll()
def __clear(self):
......
......@@ -299,13 +299,7 @@ class ScatterPlotPropertyWidget(qt.QWidget):
layout.addWidget(self.__tree)
def setFlintModel(self, flintModel: flint_model.FlintState = None):
if self.__flintModel is not None:
self.__flintModel.currentScanChanged.disconnect(self.__currentScanChanged)
self.__setScan(None)
self.__flintModel = flintModel
if self.__flintModel is not None:
self.__flintModel.currentScanChanged.connect(self.__currentScanChanged)
self.__setScan(self.__flintModel.currentScan())
def focusWidget(self):
return self.__focusWidget
......@@ -313,13 +307,18 @@ class ScatterPlotPropertyWidget(qt.QWidget):
def setFocusWidget(self, widget):
if self.__focusWidget is not None:
widget.plotModelUpdated.disconnect(self.__plotModelUpdated)
widget.scanModelUpdated.disconnect(self.__currentScanChanged)
self.__focusWidget = widget
if self.__focusWidget is not None:
widget.plotModelUpdated.connect(self.__plotModelUpdated)
widget.scanModelUpdated.connect(self.__currentScanChanged)
plotModel = widget.plotModel()
scanModel = widget.scan()
else:
plotModel = None
scanModel = None
self.__plotModelUpdated(plotModel)
self.__currentScanChanged(scanModel)
def __plotModelUpdated(self, plotModel):
self.setPlotModel(plotModel)
......@@ -336,8 +335,8 @@ class ScatterPlotPropertyWidget(qt.QWidget):
self.__plotModel.transactionFinished.connect(self.__transactionFinished)
self.__updateTree()
def __currentScanChanged(self):
self.__setScan(self.__flintModel.currentScan())
def __currentScanChanged(self, scanModel):
self.__setScan(scanModel)
def __structureChanged(self):
self.__updateTree()
......
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