forked from M-Labs/artiq
waveform: cleanups
This commit is contained in:
parent
248af51e45
commit
68f71b7479
@ -29,6 +29,37 @@ DISPLAY_HIGH = 1
|
||||
DISPLAY_MID = 0.5
|
||||
|
||||
|
||||
class _CursorTimeControl(QtWidgets.QLineEdit):
|
||||
submit = QtCore.pyqtSignal(float)
|
||||
PRECISION = 15
|
||||
|
||||
def __init__(self, parent, state):
|
||||
QtWidgets.QLineEdit.__init__(self, parent=parent)
|
||||
self._value = 0
|
||||
self._state = state
|
||||
self.display_value(0)
|
||||
self.textChanged.connect(self._on_text_change)
|
||||
self.returnPressed.connect(self._on_return_press)
|
||||
|
||||
def _on_text_change(self, text):
|
||||
try:
|
||||
self._value = pg.siEval(text) * (1e12 / self._state["timescale"])
|
||||
except Exception:
|
||||
# invalid text entry is ignored, resets to valid value on return pressed
|
||||
pass
|
||||
|
||||
def display_value(self, val):
|
||||
t = pg.siFormat(val * 1e-12 * self._state["timescale"], suffix="s",
|
||||
allowUnicode=False,
|
||||
precision=self.PRECISION)
|
||||
self.setText(t)
|
||||
|
||||
def _on_return_press(self):
|
||||
self.submit.emit(self._value)
|
||||
self.display_value(self._value)
|
||||
self.clearFocus()
|
||||
|
||||
|
||||
class Model(DictSyncTreeSepModel):
|
||||
def __init__(self, init):
|
||||
DictSyncTreeSepModel.__init__(self, "/", ["Channels"], init)
|
||||
@ -87,6 +118,7 @@ class _AddChannelDialog(QtWidgets.QDialog):
|
||||
self.accepted.emit(channels)
|
||||
self.close()
|
||||
|
||||
|
||||
# TODO: make private
|
||||
class BackgroundItem(pg.GraphicsWidgetAnchor, pg.GraphicsWidget):
|
||||
def __init__(self, parent, rect):
|
||||
@ -459,7 +491,8 @@ class WaveformArea(QtWidgets.QWidget):
|
||||
action = QtWidgets.QAction("Reset waveform heights", cw)
|
||||
action.triggered.connect(self._splitter.resetSizes)
|
||||
cw.addAction(action)
|
||||
|
||||
|
||||
# TODO: is the lambda necessary here
|
||||
cw.cursorMoved.connect(lambda x: self.on_cursor_move(x))
|
||||
cw.cursorMoved.connect(self.cursorMoved.emit)
|
||||
|
||||
@ -539,38 +572,6 @@ class WaveformArea(QtWidgets.QWidget):
|
||||
cw.set_cursor_visible(self._cursor_visible)
|
||||
|
||||
|
||||
# TODO: move elsewhere -> this can be a late addition
|
||||
class _CursorTimeControl(QtWidgets.QLineEdit):
|
||||
submit = QtCore.pyqtSignal(float)
|
||||
PRECISION = 15
|
||||
|
||||
def __init__(self, parent, state):
|
||||
QtWidgets.QLineEdit.__init__(self, parent=parent)
|
||||
self._value = 0
|
||||
self._state = state
|
||||
self.display_value(0)
|
||||
self.textChanged.connect(self._on_text_change)
|
||||
self.returnPressed.connect(self._on_return_press)
|
||||
|
||||
def _on_text_change(self, text):
|
||||
try:
|
||||
self._value = pg.siEval(text) * (1e12 / self._state["timescale"])
|
||||
except Exception:
|
||||
# invalid text entry is ignored, resets to valid value on return pressed
|
||||
pass
|
||||
|
||||
def display_value(self, val):
|
||||
t = pg.siFormat(val * 1e-12 * self._state["timescale"], suffix="s",
|
||||
allowUnicode=False,
|
||||
precision=self.PRECISION)
|
||||
self.setText(t)
|
||||
|
||||
def _on_return_press(self):
|
||||
self.submit.emit(self._value)
|
||||
self.display_value(self._value)
|
||||
self.clearFocus()
|
||||
|
||||
|
||||
class _BaseProxyClient:
|
||||
def __init__(self):
|
||||
self.addr = None
|
||||
@ -627,8 +628,8 @@ class RPCProxyClient(_BaseProxyClient):
|
||||
|
||||
async def reconnect_cr(self):
|
||||
await self.client.connect_rpc(self.addr,
|
||||
self.port,
|
||||
"coreanalyzer_proxy_control")
|
||||
self.port,
|
||||
"coreanalyzer_proxy_control")
|
||||
|
||||
async def disconnect_cr(self):
|
||||
self.client.close_rpc()
|
||||
@ -645,6 +646,7 @@ class ReceiverProxyClient(_BaseProxyClient):
|
||||
async def disconnect_cr(self):
|
||||
await self.receiver.close()
|
||||
|
||||
|
||||
class WaveformDock(QtWidgets.QDockWidget):
|
||||
traceDataChanged = QtCore.pyqtSignal()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user