Commit c208f45b authored by Valentin Valls's avatar Valentin Valls
Browse files

Add isAvailableInScan to check item with other scans

parent d0a82f59
......@@ -148,6 +148,21 @@ class CurveItem(plot_model.Item, CurveMixIn):
def isValid(self):
return self.__x is not None and self.__y is not None
def isAvailableInScan(self, scan: scan_model.Scan) -> bool:
"""Returns true if this item is available in this scan.
This only imply that the data source is available.
"""
if not self.isValid():
return False
channel = self.xChannel()
if channel.channel(scan) is None:
return False
channel = self.yChannel()
if channel.channel(scan) is None:
return False
return True
def getScanValidation(self, scan: scan_model.Scan) -> Optional[str]:
"""
Returns None if everything is fine, else a message to explain the problem.
......@@ -229,6 +244,18 @@ class XIndexCurveItem(CurveItem):
channel = self.yChannel()
return channel is not None
def isAvailableInScan(self, scan: scan_model.Scan) -> bool:
"""Returns true if this item is available in this scan.
This only imply that the data source is available.
"""
if not self.isValid():
return False
channel = self.yChannel()
if channel.channel(scan) is None:
return False
return True
def xData(self, scan: scan_model.Scan) -> Optional[scan_model.Data]:
yData = self.yData(scan)
if yData is None:
......
......@@ -381,6 +381,13 @@ class Item(qt.QObject):
"""
return None
def isAvailableInScan(self, scan: scan_model.Scan) -> bool:
"""Returns true if this item is available in this scan.
This only imply that the data source is available.
"""
return True
def isValidInScan(self, scan: scan_model.Scan) -> bool:
"""Returns true if this item do not have any messages associated with
the data of this scan."""
......@@ -511,6 +518,19 @@ class ChildItem(Item):
def source(self) -> Optional[Item]:
return self.__source
def isAvailableInScan(self, scan: scan_model.Scan) -> bool:
"""Returns true if this item is available in this scan.
This only imply that the data source is available.
"""
if not self.isValid():
return False
source = self.source()
if source is not None:
if not source.isAvailableInScan(scan):
return False
return True
class ComputableMixIn:
"""This item use the scan data to process result before displaying it."""
......
......@@ -595,6 +595,19 @@ class NormalizedCurveItem(plot_model.ChildItem, plot_item_model.CurveMixIn):
if eventType == plot_model.ChangeEventType.X_CHANNEL:
self._emitValueChanged(plot_model.ChangeEventType.X_CHANNEL)
def isAvailableInScan(self, scan: scan_model.Scan) -> bool:
"""Returns true if this item is available in this scan.
This only imply that the data source is available.
"""
if not plot_model.ChildItem.isAvailableInScan(self, scan):
return False
monitor = self.monitorChannel()
if monitor is not None:
if monitor.channel(scan) is None:
return False
return True
def displayName(self, axisName, scan: scan_model.Scan) -> str:
"""Helper to reach the axis display name"""
sourceItem = self.source()
......
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