mirror of https://github.com/m-labs/artiq.git
waveform: reset cursor onDataChange
This commit is contained in:
parent
6ed6fb0bce
commit
1749fa661f
|
@ -198,11 +198,13 @@ class _BaseWaveform(pg.PlotWidget):
|
||||||
def setTimescale(self, timescale):
|
def setTimescale(self, timescale):
|
||||||
self.timescale = timescale
|
self.timescale = timescale
|
||||||
|
|
||||||
|
def setData(self, data):
|
||||||
|
if len(data) == 0:
|
||||||
|
raise ValueError("no timeseries data to display for this channel")
|
||||||
|
self.x_data, self.y_data = zip(*data)
|
||||||
|
|
||||||
def onDataChange(self, data):
|
def onDataChange(self, data):
|
||||||
try:
|
raise NotImplementedError
|
||||||
self.x_data, self.y_data = zip(*data)
|
|
||||||
except:
|
|
||||||
logger.error("Error getting data for waveform: %s", self.name, exc_info=True)
|
|
||||||
|
|
||||||
def onCursorMove(self, x):
|
def onCursorMove(self, x):
|
||||||
self.cursor.setValue(x)
|
self.cursor.setValue(x)
|
||||||
|
@ -242,8 +244,8 @@ class BitWaveform(_BaseWaveform):
|
||||||
self._arrows = []
|
self._arrows = []
|
||||||
|
|
||||||
def onDataChange(self, data):
|
def onDataChange(self, data):
|
||||||
_BaseWaveform.onDataChange(self, data)
|
|
||||||
try:
|
try:
|
||||||
|
self.setData(data)
|
||||||
for arw in self._arrows:
|
for arw in self._arrows:
|
||||||
self.removeItem(arw)
|
self.removeItem(arw)
|
||||||
self._arrows = []
|
self._arrows = []
|
||||||
|
@ -285,8 +287,8 @@ class AnalogWaveform(_BaseWaveform):
|
||||||
self._format_string = "{:." + str(ndecimals) + "f}"
|
self._format_string = "{:." + str(ndecimals) + "f}"
|
||||||
|
|
||||||
def onDataChange(self, data):
|
def onDataChange(self, data):
|
||||||
_BaseWaveform.onDataChange(self, data)
|
|
||||||
try:
|
try:
|
||||||
|
self.setData(data)
|
||||||
self.plot_data_item.setData(x=self.x_data, y=self.y_data)
|
self.plot_data_item.setData(x=self.x_data, y=self.y_data)
|
||||||
max_y = max(self.y_data)
|
max_y = max(self.y_data)
|
||||||
min_y = min(self.y_data)
|
min_y = min(self.y_data)
|
||||||
|
@ -326,8 +328,8 @@ class BitVectorWaveform(_BaseWaveform):
|
||||||
self.addItem(lbl)
|
self.addItem(lbl)
|
||||||
|
|
||||||
def onDataChange(self, data):
|
def onDataChange(self, data):
|
||||||
_BaseWaveform.onDataChange(self, data)
|
|
||||||
try:
|
try:
|
||||||
|
self.setData(data)
|
||||||
for lbl in self._labels:
|
for lbl in self._labels:
|
||||||
self.plot_item.removeItem(lbl)
|
self.plot_item.removeItem(lbl)
|
||||||
self._labels = []
|
self._labels = []
|
||||||
|
@ -368,8 +370,8 @@ class LogWaveform(_BaseWaveform):
|
||||||
self._labels = []
|
self._labels = []
|
||||||
|
|
||||||
def onDataChange(self, data):
|
def onDataChange(self, data):
|
||||||
_BaseWaveform.onDataChange(self, data)
|
|
||||||
try:
|
try:
|
||||||
|
self.setData(data)
|
||||||
for lbl in self._labels:
|
for lbl in self._labels:
|
||||||
self.plot_item.removeItem(lbl)
|
self.plot_item.removeItem(lbl)
|
||||||
self._labels = []
|
self._labels = []
|
||||||
|
@ -397,9 +399,6 @@ class LogWaveform(_BaseWaveform):
|
||||||
self.plot_item.removeItem(lbl)
|
self.plot_item.removeItem(lbl)
|
||||||
self.plot_data_item.setData(x=[], y=[])
|
self.plot_data_item.setData(x=[], y=[])
|
||||||
|
|
||||||
def onCursorMove(self, x):
|
|
||||||
_BaseWaveform.onCursorMove(self, x)
|
|
||||||
|
|
||||||
|
|
||||||
class _WaveformView(QtWidgets.QWidget):
|
class _WaveformView(QtWidgets.QWidget):
|
||||||
cursorMove = QtCore.pyqtSignal(float)
|
cursorMove = QtCore.pyqtSignal(float)
|
||||||
|
@ -468,6 +467,7 @@ class _WaveformView(QtWidgets.QWidget):
|
||||||
self._splitter.widget(i).setStoppedX(stopped_x)
|
self._splitter.widget(i).setStoppedX(stopped_x)
|
||||||
|
|
||||||
def onDataChange(self, top, bottom, roles):
|
def onDataChange(self, top, bottom, roles):
|
||||||
|
self.cursorMove.emit(0)
|
||||||
first = top.row()
|
first = top.row()
|
||||||
last = bottom.row()
|
last = bottom.row()
|
||||||
data_row = self._model.headers.index("data")
|
data_row = self._model.headers.index("data")
|
||||||
|
|
Loading…
Reference in New Issue