Commit 4874e4b1 authored by Valentin Valls's avatar Valentin Valls
Browse files

Update the curve plot property with the user edit time

parent b9ca3313
...@@ -149,6 +149,9 @@ class YAxesEditor(qt.QWidget): ...@@ -149,6 +149,9 @@ class YAxesEditor(qt.QWidget):
assert False assert False
if self.__plotItem is not None: if self.__plotItem is not None:
self.__plotItem.setYAxis(axis) self.__plotItem.setYAxis(axis)
plotModel = self.__plotItem.plot()
# FIXME: It would be better to make it part of the model
plotModel.tagUserEditTime()
self.valueChanged.emit() self.valueChanged.emit()
def __plotItemChanged(self, eventType): def __plotItemChanged(self, eventType):
...@@ -331,11 +334,13 @@ class _AddItemAction(qt.QWidgetAction): ...@@ -331,11 +334,13 @@ class _AddItemAction(qt.QWidgetAction):
def __createChildItem(self, itemClass): def __createChildItem(self, itemClass):
parentItem = self.parent().selectedPlotItem() parentItem = self.parent().selectedPlotItem()
if parentItem is not None: if parentItem is not None:
plot = parentItem.plot() plotModel = parentItem.plot()
newItem = itemClass(plot) newItem = itemClass(plotModel)
newItem.setSource(parentItem) newItem.setSource(parentItem)
with plot.transaction(): with plotModel.transaction():
plot.addItem(newItem) plotModel.addItem(newItem)
# FIXME: It would be better to make it part of the model
plotModel.tagUserEditTime()
def __createNormalized(self): def __createNormalized(self):
parentItem = self.parent().selectedPlotItem() parentItem = self.parent().selectedPlotItem()
...@@ -350,13 +355,15 @@ class _AddItemAction(qt.QWidgetAction): ...@@ -350,13 +355,15 @@ class _AddItemAction(qt.QWidgetAction):
monitorName = dialog.selectedChannelName() monitorName = dialog.selectedChannelName()
if monitorName is None: if monitorName is None:
return return
plot = parentItem.plot() plotModel = parentItem.plot()
newItem = plot_state_model.NormalizedCurveItem(plot) newItem = plot_state_model.NormalizedCurveItem(plotModel)
channel = plot_model.ChannelRef(plot, monitorName) channel = plot_model.ChannelRef(plotModel, monitorName)
newItem.setMonitorChannel(channel) newItem.setMonitorChannel(channel)
newItem.setSource(parentItem) newItem.setSource(parentItem)
with plot.transaction(): with plotModel.transaction():
plot.addItem(newItem) plotModel.addItem(newItem)
# FIXME: It would be better to make it part of the model
plotModel.tagUserEditTime()
class _DataItem(_property_tree_helper.ScanRowItem): class _DataItem(_property_tree_helper.ScanRowItem):
...@@ -440,18 +447,23 @@ class _DataItem(_property_tree_helper.ScanRowItem): ...@@ -440,18 +447,23 @@ class _DataItem(_property_tree_helper.ScanRowItem):
else: else:
assert self.__channel is not None assert self.__channel is not None
assert self.__plotModel is not None assert self.__plotModel is not None
plot = self.__plotModel plotModel = self.__plotModel
yAxis = item.data(role=YAxesPropertyItemDelegate.YAxesRole) yAxis = item.data(role=YAxesPropertyItemDelegate.YAxesRole)
assert yAxis in ["left", "right"] assert yAxis in ["left", "right"]
_curve, _wasUpdated = model_helper.createCurveItem( _curve, _wasUpdated = model_helper.createCurveItem(
plot, self.__channel, yAxis, allowIndexed=True plotModel, self.__channel, yAxis, allowIndexed=True
) )
# FIXME: It would be better to make it part of the model
plotModel.tagUserEditTime()
def __visibilityViewChanged(self, item: qt.QStandardItem): def __visibilityViewChanged(self, item: qt.QStandardItem):
if self.__plotItem is not None: if self.__plotItem is not None:
state = item.data(delegates.VisibilityRole) state = item.data(delegates.VisibilityRole)
self.__plotItem.setVisible(state == qt.Qt.Checked) self.__plotItem.setVisible(state == qt.Qt.Checked)
plotModel = self.__plotItem.plot()
# FIXME: It would be better to make it part of the model
plotModel.tagUserEditTime()
def setSelectedXAxis(self): def setSelectedXAxis(self):
if self.__xAxisSelected: if self.__xAxisSelected:
...@@ -485,6 +497,8 @@ class _DataItem(_property_tree_helper.ScanRowItem): ...@@ -485,6 +497,8 @@ class _DataItem(_property_tree_helper.ScanRowItem):
model_helper.updateXAxis(plotModel, scan, topMaster, xIndex=True) model_helper.updateXAxis(plotModel, scan, topMaster, xIndex=True)
else: else:
assert False assert False
# FIXME: It would be better to make it part of the model
plotModel.tagUserEditTime()
def setDevice(self, device: scan_model.Device): def setDevice(self, device: scan_model.Device):
self.setDeviceLookAndFeel(device) self.setDeviceLookAndFeel(device)
...@@ -676,14 +690,17 @@ class CurvePlotPropertyWidget(qt.QWidget): ...@@ -676,14 +690,17 @@ class CurvePlotPropertyWidget(qt.QWidget):
def __removeAllItems(self): def __removeAllItems(self):
if self.__plotModel is None: if self.__plotModel is None:
return return
with self.__plotModel.transaction(): plotModel = self.__plotModel
items = list(self.__plotModel.items()) with plotModel.transaction():
items = list(plotModel.items())
for item in items: for item in items:
try: try:
self.__plotModel.removeItem(item) plotModel.removeItem(item)
except IndexError: except IndexError:
# Item was maybe already removed # Item was maybe already removed
pass pass
# FIXME: It would be better to make it part of the model
plotModel.tagUserEditTime()
def __createToolBar(self): def __createToolBar(self):
toolBar = qt.QToolBar(self) toolBar = qt.QToolBar(self)
......
...@@ -191,9 +191,11 @@ class RemovePlotItemButton(qt.QToolButton): ...@@ -191,9 +191,11 @@ class RemovePlotItemButton(qt.QToolButton):
def __requestRemoveItem(self): def __requestRemoveItem(self):
plotItem = self.__plotItem plotItem = self.__plotItem
plot = plotItem.plot() plotModel = plotItem.plot()
if plot is not None: if plotModel is not None:
model_helper.removeItemAndKeepAxes(plot, plotItem) model_helper.removeItemAndKeepAxes(plotModel, plotItem)
# FIXME: It would be better to make it part of the model
plotModel.tagUserEditTime()
def setPlotItem(self, plotItem: plot_model.Item): def setPlotItem(self, plotItem: plot_model.Item):
self.__plotItem = plotItem self.__plotItem = plotItem
......
Supports Markdown
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