Commit 1e2ae767 authored by Valentin Valls's avatar Valentin Valls

Selection remain the same updating plot or tree

parent 1efd3860
......@@ -18,6 +18,7 @@ import logging
from silx.gui import qt
from silx.gui import icons
from silx.gui import utils as qtutils
from silx.gui.plot.items.shape import BoundingRect
from silx.gui.plot.items import Curve
from silx.gui.plot.items import axis as axis_mdl
......@@ -209,6 +210,10 @@ class CurvePlotWidget(ExtendedDockWidget):
def __plotItemSelectedFromProperty(self, selected):
"""Callback executed when the selection from the property view was
changed"""
self.selectPlotItem(selected)
def selectPlotItem(self, selected: plot_model.Item):
"""Select a flint plot item"""
if selected is self.selectedPlotItem():
# Break reentrant signals
return
......@@ -557,20 +562,30 @@ class CurvePlotWidget(ExtendedDockWidget):
if self.__plotModel is None:
return
scanItems = []
plotModel = self.__plotModel
for scanItem in plotModel.items():
if isinstance(scanItem, plot_item_model.ScanItem):
scanItems.append(scanItem)
if len(scanItems) > 0:
for scan in scanItems:
self.__updatePlotItem(item, scan.scan())
selectedPlotItem = self.selectedPlotItem()
if item is selectedPlotItem:
reselect = item
else:
currentScan = self.__scan
if currentScan is None:
return
self.__updatePlotItem(item, currentScan)
reselect = None
with qtutils.blockSignals(self):
scanItems = []
plotModel = self.__plotModel
for scanItem in plotModel.items():
if isinstance(scanItem, plot_item_model.ScanItem):
scanItems.append(scanItem)
if len(scanItems) > 0:
for scan in scanItems:
self.__updatePlotItem(item, scan.scan())
else:
currentScan = self.__scan
if currentScan is None:
return
self.__updatePlotItem(item, currentScan)
if reselect is not None:
self.selectPlotItem(reselect)
def __updatePlotItem(self, item: plot_model.Item, scan: scan_model.Scan):
if not item.isValid():
......
......@@ -15,6 +15,7 @@ import logging
from silx.gui import qt
from silx.gui import icons
from silx.gui import utils as qtutils
from bliss.flint.model import flint_model
from bliss.flint.model import plot_model
......@@ -621,18 +622,21 @@ class CurvePlotPropertyWidget(qt.QWidget):
return None
def __selectionChangedFromPlot(self, current: plot_model.Item):
self.selectPlotItem(current)
def selectPlotItem(self, select: plot_model.Item):
selectionModel = self.__tree.selectionModel()
if current is None:
if select is None:
# Break reentrant signals
indices = selectionModel.selectedRows()
index = indices[0] if len(indices) > 0 else qt.QModelIndex()
if index.isValid():
selectionModel.select(qt.QModelIndex(), qt.QItemSelectionModel.Clear)
return
if current is self.selectedPlotItem():
if select is self.selectedPlotItem():
# Break reentrant signals
return
item = self.__findItemFromPlotItem(current)
item = self.__findItemFromPlotItem(select)
flags = qt.QItemSelectionModel.Rows | qt.QItemSelectionModel.ClearAndSelect
if item is None:
index = qt.QModelIndex()
......@@ -833,6 +837,8 @@ class CurvePlotPropertyWidget(qt.QWidget):
def __updateTree(self):
collapsed = _property_tree_helper.getPathFromCollapsedNodes(self.__tree)
selectedItem = self.selectedPlotItem()
model = self.__tree.model()
model.clear()
......@@ -952,3 +958,6 @@ class CurvePlotPropertyWidget(qt.QWidget):
self.__tree.expandAll()
_property_tree_helper.collapseNodesFromPaths(self.__tree, collapsed)
with qtutils.blockSignals(self):
self.selectPlotItem(selectedItem)
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