diff --git a/sdrgui/gui/glscope.cpp b/sdrgui/gui/glscope.cpp index 115979de2..91b0fada2 100644 --- a/sdrgui/gui/glscope.cpp +++ b/sdrgui/gui/glscope.cpp @@ -2314,7 +2314,11 @@ QString GLScope::displayScaled(float value, char type, int precision) { float posValue = (value < 0) ? -value : value; - if (posValue < 1) + if (posValue == 0) + { + return tr("%1").arg(QString::number(value, 'f', precision)); + } + else if (posValue < 1) { if (posValue > 0.001) { return tr("%1m").arg(QString::number(value * 1000.0, type, precision)); diff --git a/sdrgui/gui/glspectrum.cpp b/sdrgui/gui/glspectrum.cpp index 44bc2a133..19fa055d8 100644 --- a/sdrgui/gui/glspectrum.cpp +++ b/sdrgui/gui/glspectrum.cpp @@ -2094,7 +2094,7 @@ void GLSpectrum::mousePressEvent(QMouseEvent* event) getPrecision(m_centerFrequency/m_sampleRate), false); m_waterfallMarkers.back().m_time = time; - m_waterfallMarkers.back().m_timeStr = displayScaledM( + m_waterfallMarkers.back().m_timeStr = displayScaledF( time, 'f', 3, @@ -2108,7 +2108,7 @@ void GLSpectrum::mousePressEvent(QMouseEvent* event) 'f', getPrecision(deltaFrequency/m_sampleRate), true); - m_waterfallMarkers.back().m_deltaTimeStr = displayScaledM( + m_waterfallMarkers.back().m_deltaTimeStr = displayScaledF( time - m_waterfallMarkers.at(0).m_time, 'f', 3, @@ -2312,33 +2312,37 @@ QString GLSpectrum::displayScaledF(float value, char type, int precision, bool s { float posValue = (value < 0) ? -value : value; - if (posValue < 1000) { - return tr("%1").arg(QString::number(value, type, precision)); - } else if (posValue < 1000000) { - return tr("%1%2").arg(QString::number(value / 1000.0, type, precision)).arg(showMult ? "k" : ""); - } else if (posValue < 1000000000) { - return tr("%1%2").arg(QString::number(value / 1000000.0, type, precision)).arg(showMult ? "M" : ""); - } else if (posValue < 1000000000000) { - return tr("%1%2").arg(QString::number(value / 1000000000.0, type, precision)).arg(showMult ? "G" : ""); + if (posValue == 0) + { + return tr("%1").arg(QString::number(value, 'f', precision)); } -} - -QString GLSpectrum::displayScaledM(float value, char type, int precision, bool showMult) -{ - float posValue = (value < 0) ? -value : value; - - if (posValue > 1) { - return tr("%1").arg(QString::number(value, type, precision)); - } else if (posValue > 0.001) { - return tr("%1%2").arg(QString::number(value * 1000.0, type, precision)).arg(showMult ? "m" : ""); - } else if (posValue > 0.000001) { - return tr("%1%2").arg(QString::number(value * 1000000.0, type, precision)).arg(showMult ? "u" : ""); - } else if (posValue > 1e-9) { - return tr("%1%2").arg(QString::number(value * 1e9, type, precision)).arg(showMult ? "n" : ""); - } else if (posValue > 1e-12) { - return tr("%1%2").arg(QString::number(value * 1e12, type, precision)).arg(showMult ? "p" : ""); - } else { - return tr("%1").arg(QString::number(value, 'e', precision)); + else if (posValue < 1) + { + if (posValue > 0.001) { + return tr("%1%2").arg(QString::number(value * 1000.0, type, precision)).arg(showMult ? "m" : ""); + } else if (posValue > 0.000001) { + return tr("%1%2").arg(QString::number(value * 1000000.0, type, precision)).arg(showMult ? "u" : ""); + } else if (posValue > 1e-9) { + return tr("%1%2").arg(QString::number(value * 1e9, type, precision)).arg(showMult ? "n" : ""); + } else if (posValue > 1e-12) { + return tr("%1%2").arg(QString::number(value * 1e12, type, precision)).arg(showMult ? "p" : ""); + } else { + return tr("%1").arg(QString::number(value, 'e', precision)); + } + } + else + { + if (posValue < 1000) { + return tr("%1").arg(QString::number(value, type, precision)); + } else if (posValue < 1000000) { + return tr("%1%2").arg(QString::number(value / 1000.0, type, precision)).arg(showMult ? "k" : ""); + } else if (posValue < 1000000000) { + return tr("%1%2").arg(QString::number(value / 1000000.0, type, precision)).arg(showMult ? "M" : ""); + } else if (posValue < 1000000000000) { + return tr("%1%2").arg(QString::number(value / 1000000000.0, type, precision)).arg(showMult ? "G" : ""); + } else { + return tr("%1").arg(QString::number(value, 'e', precision)); + } } } diff --git a/sdrgui/gui/glspectrum.h b/sdrgui/gui/glspectrum.h index 0189a10ef..1934673ef 100644 --- a/sdrgui/gui/glspectrum.h +++ b/sdrgui/gui/glspectrum.h @@ -334,7 +334,6 @@ private: QString displayScaled(int64_t value, char type, int precision, bool showMult); QString displayScaledF(float value, char type, int precision, bool showMult); - QString displayScaledM(float value, char type, int precision, bool showMult); int getPrecision(int value); void drawTextOverlay( //!< Draws a text overlay const QString& text,