diff options
author | f4exb <f4exb06@gmail.com> | 2016-08-26 21:22:40 +0200 |
---|---|---|
committer | f4exb <f4exb06@gmail.com> | 2016-08-26 21:22:40 +0200 |
commit | 5174fcdff7ca0534c7d2b9fc27cb6531a6e98da3 (patch) | |
tree | c91cb66287bc8c77393256b9cced1f6b4e61740f | |
parent | d4070e2941a8c44807673ac3b75650c2de33b7d3 (diff) |
Limit scope time span display to two decimalsv2.1.2
-rw-r--r-- | sdrbase/gui/glscopegui.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/sdrbase/gui/glscopegui.cpp b/sdrbase/gui/glscopegui.cpp index 1d9fcfac4..40715445f 100644 --- a/sdrbase/gui/glscopegui.cpp +++ b/sdrbase/gui/glscopegui.cpp @@ -512,15 +512,28 @@ void GLScopeGUI::on_scope_sampleRateChanged(int) void GLScopeGUI::setTimeScaleDisplay() { m_sampleRate = m_glScope->getSampleRate(); - qreal t = (m_glScope->getTraceSize() * 1.0 / m_sampleRate) / (qreal)m_timeBase; - if(t < 0.000001) - ui->timeText->setText(tr("%1\nns").arg(t * 1000000000.0)); + double t = (m_glScope->getTraceSize() * 1.0 / m_sampleRate) / (qreal)m_timeBase; + + if(t < 0.000001) + { + t = round(t * 100000000000.0) / 100.0; + ui->timeText->setText(tr("%1\nns").arg(t)); + } else if(t < 0.001) - ui->timeText->setText(tr("%1\nµs").arg(t * 1000000.0)); + { + t = round(t * 100000000.0) / 100.0; + ui->timeText->setText(tr("%1\nµs").arg(t)); + } else if(t < 1.0) - ui->timeText->setText(tr("%1\nms").arg(t * 1000.0)); + { + t = round(t * 100000.0) / 100.0; + ui->timeText->setText(tr("%1\nms").arg(t)); + } else - ui->timeText->setText(tr("%1\ns").arg(t * 1.0)); + { + t = round(t * 100.0) / 100.0; + ui->timeText->setText(tr("%1\ns").arg(t)); + } } void GLScopeGUI::setTraceLenDisplay() |