From 2b0f2ae36ea62b406cd0b603786306628bd48fae Mon Sep 17 00:00:00 2001 From: Kizarm Date: Thu, 14 Nov 2024 15:12:23 +0100 Subject: [PATCH] continual indicator --- V203/usb/scope/software/displaywidget.cpp | 13 +++++++++++++ V203/usb/scope/software/displaywidget.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/V203/usb/scope/software/displaywidget.cpp b/V203/usb/scope/software/displaywidget.cpp index 4a6704b..159fd32 100644 --- a/V203/usb/scope/software/displaywidget.cpp +++ b/V203/usb/scope/software/displaywidget.cpp @@ -19,6 +19,7 @@ static const double ChannelsSteps [] = { static constexpr double REF_Y = 3.3; // maximum napětí převodníku static constexpr double MAX_Y = double (1 << 12); // 12. bit rozlišení - 4096 steps static constexpr double HALF_Y = 0.5 * MAX_Y; +static constexpr double QSCL_Y = 0.5 * HALF_Y; static constexpr double STEP_Y = REF_Y / MAX_Y; // jeden krok ve Voltech static constexpr unsigned T_SIZE = 1u << 10; static constexpr unsigned T_MASK = T_SIZE - 1u; @@ -40,6 +41,7 @@ DisplayWidget::DisplayWidget(QWidget * p) : QWidget(p), pcol(), ACopy(), BCopy() for (QPointF & e : ChA) { const QPointF p (n++, 0); e = p; } n = 0; for (QPointF & e : ChB) { const QPointF p (n++, 0); e = p; } + m_continual = false; } DisplayWidget::~DisplayWidget() { } @@ -158,6 +160,7 @@ void DisplayWidget::resizeEvent(QResizeEvent * event) { void DisplayWidget::paintEvent(QPaintEvent * event) { QPainter p (this); p.drawImage(event->rect(), background); + drawCurrent(p); QPen pa (pcol.colA, 2); QPen pb (pcol.colB, 2); p.setPen(pb); @@ -169,6 +172,14 @@ void DisplayWidget::paintEvent(QPaintEvent * event) { ma.translate(0, m_offset.a - HALF_Y); p.drawPolyline (ma.map(ChA)); } +void DisplayWidget::drawCurrent(QPainter & p) { + if (!m_continual) return; + const QPen pen (QColor(192,192,192)); + p.setPen (pen); + QLineF vl (QPointF(m_timeCount, -QSCL_Y), QPointF(m_timeCount, +QSCL_Y)); + p.drawLine (m_forward.map (vl)); // Stávající poloha v kontinuálním módu +} + void DisplayWidget::setTrigger(TrigerSettings * ts) { m_ts = ts; } @@ -184,6 +195,7 @@ void DisplayWidget::reloadData () { const size_t Amin = Alen < T_SIZE ? Alen : T_SIZE; const size_t Bmin = Blen < T_SIZE ? Blen : T_SIZE; if ((Alen == 1u) and (Blen == 1u)) { // kontinuální mód + m_continual = true; const QPointF pta (m_timeCount, ACopy [0]), ptb (m_timeCount, BCopy [0]); ChA[m_timeCount] = pta; ChB[m_timeCount] = ptb; @@ -191,6 +203,7 @@ void DisplayWidget::reloadData () { m_timeCount &= T_MASK; return; } + m_continual = false; for (unsigned n=0u; n