From 8b503c3b4f1ed9adff03c1eab6de495a3c5f39a1 Mon Sep 17 00:00:00 2001 From: Simon Renblad Date: Thu, 1 Feb 2024 17:15:23 +0800 Subject: [PATCH] waveform: add remove, clear waveform actions --- artiq/dashboard/waveform.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/artiq/dashboard/waveform.py b/artiq/dashboard/waveform.py index 256de1504..b309ee229 100644 --- a/artiq/dashboard/waveform.py +++ b/artiq/dashboard/waveform.py @@ -434,8 +434,18 @@ class _WaveformView(QtWidgets.QWidget): w.setXLink(self._ref_vb) w.setStoppedX(self._stopped_x) w.setTimescale(self._timescale) + action = QtWidgets.QAction("Delete waveform", w) + action.triggered.connect(lambda: self._delete_waveform(w)) + w.addAction(action) + action = QtWidgets.QAction("Clear waveforms", w) + action.triggered.connect(self._model.clear) + w.addAction(action) return w + def _delete_waveform(self, waveform): + row = self._splitter.indexOf(waveform) + self._model.pop(row) + def _resize(self): self._splitter.setFixedHeight( int((WAVEFORM_MIN_HEIGHT + WAVEFORM_MAX_HEIGHT) * self._model.rowCount() / 2)) @@ -479,6 +489,11 @@ class _WaveformModel(QtCore.QAbstractTableModel): self.backing_struct.insert(dest, self.backing_struct.pop(src)) self.endMoveRows() + def clear(self): + self.beginRemoveRows(QtCore.QModelIndex(), 0, len(self.backing_struct) - 1) + self.backing_struct.clear() + self.endRemoveRows() + def update_data(self, waveform_data, top, bottom): name_col = self.headers.index("name") data_col = self.headers.index("data")