mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-17 13:51:47 -05:00
GLSpectrum: factorized displayScaledF and displayScaledM
This commit is contained in:
parent
f540fa0536
commit
aea72786b6
@ -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));
|
||||
|
@ -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,24 +2312,13 @@ 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) {
|
||||
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" : "");
|
||||
@ -2340,6 +2329,21 @@ QString GLSpectrum::displayScaledM(float value, char type, int precision, bool s
|
||||
} 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int GLSpectrum::getPrecision(int value)
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user