From 2ccb866c79bf6c3c3357355e293819472c30ae6d Mon Sep 17 00:00:00 2001 From: f4exb Date: Fri, 1 May 2020 05:33:44 +0200 Subject: [PATCH] GLSpectrum GUI: removed m_averagingMaxScale from settings --- sdrbase/dsp/glspectrumsettings.h | 1 - sdrgui/gui/glspectrumgui.cpp | 45 ++++++++++++++++---------------- sdrgui/gui/glspectrumgui.h | 5 ++-- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/sdrbase/dsp/glspectrumsettings.h b/sdrbase/dsp/glspectrumsettings.h index e20a35b37..a269ca75e 100644 --- a/sdrbase/dsp/glspectrumsettings.h +++ b/sdrbase/dsp/glspectrumsettings.h @@ -56,7 +56,6 @@ public: bool m_invert; AveragingMode m_averagingMode; int m_averagingIndex; - int m_averagingMaxScale; //!< Max power of 10 multiplier to 2,5,10 base ex: 2 -> 2,5,10,20,50,100,200,500,1000 unsigned int m_averagingNb; bool m_linear; //!< linear else logarithmic scale diff --git a/sdrgui/gui/glspectrumgui.cpp b/sdrgui/gui/glspectrumgui.cpp index 35457979c..3e748f876 100644 --- a/sdrgui/gui/glspectrumgui.cpp +++ b/sdrgui/gui/glspectrumgui.cpp @@ -46,9 +46,9 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) : ui->levelRange->addItem(QString("%1").arg(range)); } - setAveragingCombo(); connect(&m_messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); displaySettings(); + setAveragingCombo(); applySettings(); } @@ -169,7 +169,9 @@ void GLSpectrumGUI::applySettings() m_glSpectrum->setDisplayTraceIntensity(m_settings.m_displayTraceIntensity); if ((m_settings.m_averagingMode == GLSpectrumSettings::AvgModeFixed) || (m_settings.m_averagingMode == GLSpectrumSettings::AvgModeMax)) { - m_glSpectrum->setTimingRate(getAveragingValue(m_settings.m_averagingIndex) == 0 ? 1 : getAveragingValue(m_settings.m_averagingIndex)); + m_glSpectrum->setTimingRate(getAveragingValue(m_settings.m_averagingIndex, m_settings.m_averagingMode) == 0 ? + 1 : + getAveragingValue(m_settings.m_averagingIndex, m_settings.m_averagingMode)); } else { m_glSpectrum->setTimingRate(1); } @@ -189,7 +191,7 @@ void GLSpectrumGUI::applySettings() m_settings.m_refLevel, m_settings.m_powerRange, m_settings.m_fftOverlap, - getAveragingValue(m_settings.m_averagingIndex), + getAveragingValue(m_settings.m_averagingIndex, m_settings.m_averagingMode), (SpectrumVis::AvgMode) m_settings.m_averagingMode, (FFTWindow::Function) m_settings.m_fftWindow, m_settings.m_linear @@ -221,17 +223,7 @@ void GLSpectrumGUI::on_averagingMode_currentIndexChanged(int index) GLSpectrumSettings::AvgModeMax : (GLSpectrumSettings::AveragingMode) index; - if (m_settings.m_averagingMode == GLSpectrumSettings::AvgModeMoving) - { - m_settings.m_averagingMaxScale = 2; - setAveragingCombo(); - } - else - { - m_settings.m_averagingMaxScale = 5; - setAveragingCombo(); - } - + setAveragingCombo(); applySettings(); } @@ -342,7 +334,16 @@ void GLSpectrumGUI::on_clearSpectrum_clicked(bool checked) } } -int GLSpectrumGUI::getAveragingIndex(int averagingValue) const +int GLSpectrumGUI::getAveragingMaxScale(GLSpectrumSettings::AveragingMode averagingMode) +{ + if (averagingMode == GLSpectrumSettings::AvgModeMoving) { + return 2; + } else { + return 5; + } +} + +int GLSpectrumGUI::getAveragingIndex(int averagingValue, GLSpectrumSettings::AveragingMode averagingMode) { if (averagingValue <= 1) { return 0; @@ -351,7 +352,7 @@ int GLSpectrumGUI::getAveragingIndex(int averagingValue) const int v = averagingValue; int j = 0; - for (int i = 0; i <= m_settings.m_averagingMaxScale; i++) + for (int i = 0; i <= getAveragingMaxScale(averagingMode); i++) { if (v < 20) { @@ -371,17 +372,17 @@ int GLSpectrumGUI::getAveragingIndex(int averagingValue) const v /= 10; } - return 3*m_settings.m_averagingMaxScale + 3; + return 3 * getAveragingMaxScale(averagingMode) + 3; } -int GLSpectrumGUI::getAveragingValue(int averagingIndex) const +int GLSpectrumGUI::getAveragingValue(int averagingIndex, GLSpectrumSettings::AveragingMode averagingMode) { if (averagingIndex <= 0) { return 1; } int v = averagingIndex - 1; - int m = pow(10.0, v/3 > m_settings.m_averagingMaxScale ? m_settings.m_averagingMaxScale : v/3); + int m = pow(10.0, v/3 > getAveragingMaxScale(averagingMode) ? getAveragingMaxScale(averagingMode) : v/3); int x = 1; if (v % 3 == 0) { @@ -402,7 +403,7 @@ void GLSpectrumGUI::setAveragingCombo() ui->averaging->clear(); ui->averaging->addItem(QString("1")); - for (int i = 0; i <= m_settings.m_averagingMaxScale; i++) + for (int i = 0; i <= getAveragingMaxScale(m_settings.m_averagingMode); i++) { QString s; int m = pow(10.0, i); @@ -460,9 +461,9 @@ void GLSpectrumGUI::setAveragingToolitp() if (m_glSpectrum) { QString s; - float averagingTime = (m_settings.m_fftSize * (getAveragingValue(m_settings.m_averagingIndex) == 0 ? + float averagingTime = (m_settings.m_fftSize * (getAveragingValue(m_settings.m_averagingIndex, m_settings.m_averagingMode) == 0 ? 1 : - getAveragingValue(m_settings.m_averagingIndex))) / (float) m_glSpectrum->getSampleRate(); + getAveragingValue(m_settings.m_averagingIndex, m_settings.m_averagingMode))) / (float) m_glSpectrum->getSampleRate(); setNumberStr(averagingTime, 2, s); ui->averaging->setToolTip(QString("Number of averaging samples (avg time: %1s)").arg(s)); } diff --git a/sdrgui/gui/glspectrumgui.h b/sdrgui/gui/glspectrumgui.h index 3f66a6f15..40474b2ce 100644 --- a/sdrgui/gui/glspectrumgui.h +++ b/sdrgui/gui/glspectrumgui.h @@ -71,8 +71,9 @@ private: void blockApplySettings(bool block); void applySettings(); void displaySettings(); - int getAveragingIndex(int averaging) const; - int getAveragingValue(int averagingIndex) const; + static int getAveragingMaxScale(GLSpectrumSettings::AveragingMode averagingMode); //!< Max power of 10 multiplier to 2,5,10 base ex: 2 -> 2,5,10,20,50,100,200,500,1000 + static int getAveragingIndex(int averaging, GLSpectrumSettings::AveragingMode averagingMode); + static int getAveragingValue(int averagingIndex, GLSpectrumSettings::AveragingMode averagingMode); void setAveragingCombo(); void setNumberStr(int n, QString& s); void setNumberStr(float v, int decimalPlaces, QString& s);