mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-11-03 21:20:31 -05:00 
			
		
		
		
	GLSpectrum: use GLSpectrumSettings
This commit is contained in:
		
							parent
							
								
									68fcdff6d1
								
							
						
					
					
						commit
						578ac1db00
					
				@ -1,3 +1,24 @@
 | 
				
			|||||||
 | 
					///////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// Copyright (C) 2016-2020 F4EXB                                                 //
 | 
				
			||||||
 | 
					// written by Edouard Griffiths                                                  //
 | 
				
			||||||
 | 
					//                                                                               //
 | 
				
			||||||
 | 
					// OpenGL interface modernization.                                               //
 | 
				
			||||||
 | 
					// See: http://doc.qt.io/qt-5/qopenglshaderprogram.html                          //
 | 
				
			||||||
 | 
					//                                                                               //
 | 
				
			||||||
 | 
					// This program is free software; you can redistribute it and/or modify          //
 | 
				
			||||||
 | 
					// it under the terms of the GNU General Public License as published by          //
 | 
				
			||||||
 | 
					// the Free Software Foundation as version 3 of the License, or                  //
 | 
				
			||||||
 | 
					// (at your option) any later version.                                           //
 | 
				
			||||||
 | 
					//                                                                               //
 | 
				
			||||||
 | 
					// This program is distributed in the hope that it will be useful,               //
 | 
				
			||||||
 | 
					// but WITHOUT ANY WARRANTY; without even the implied warranty of                //
 | 
				
			||||||
 | 
					// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
 | 
				
			||||||
 | 
					// GNU General Public License V3 for more details.                               //
 | 
				
			||||||
 | 
					//                                                                               //
 | 
				
			||||||
 | 
					// You should have received a copy of the GNU General Public License             //
 | 
				
			||||||
 | 
					// along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "gui/glspectrumgui.h"
 | 
					#include "gui/glspectrumgui.h"
 | 
				
			||||||
#include "dsp/fftwindow.h"
 | 
					#include "dsp/fftwindow.h"
 | 
				
			||||||
#include "dsp/spectrumvis.h"
 | 
					#include "dsp/spectrumvis.h"
 | 
				
			||||||
@ -10,38 +31,25 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) :
 | 
				
			|||||||
	ui(new Ui::GLSpectrumGUI),
 | 
						ui(new Ui::GLSpectrumGUI),
 | 
				
			||||||
	m_spectrumVis(nullptr),
 | 
						m_spectrumVis(nullptr),
 | 
				
			||||||
	m_glSpectrum(nullptr),
 | 
						m_glSpectrum(nullptr),
 | 
				
			||||||
	m_fftSize(1024),
 | 
					    m_doApplySettings(true)
 | 
				
			||||||
	m_fftOverlap(0),
 | 
					 | 
				
			||||||
	m_fftWindow(FFTWindow::Hanning),
 | 
					 | 
				
			||||||
	m_refLevel(0),
 | 
					 | 
				
			||||||
	m_powerRange(100),
 | 
					 | 
				
			||||||
	m_decay(1),
 | 
					 | 
				
			||||||
	m_decayDivisor(1),
 | 
					 | 
				
			||||||
	m_histogramStroke(30),
 | 
					 | 
				
			||||||
	m_displayGridIntensity(5),
 | 
					 | 
				
			||||||
	m_displayTraceIntensity(50),
 | 
					 | 
				
			||||||
	m_displayWaterfall(true),
 | 
					 | 
				
			||||||
	m_invertedWaterfall(false),
 | 
					 | 
				
			||||||
	m_displayMaxHold(false),
 | 
					 | 
				
			||||||
	m_displayCurrent(false),
 | 
					 | 
				
			||||||
	m_displayHistogram(false),
 | 
					 | 
				
			||||||
	m_displayGrid(false),
 | 
					 | 
				
			||||||
	m_invert(true),
 | 
					 | 
				
			||||||
	m_averagingMode(AvgModeNone),
 | 
					 | 
				
			||||||
	m_averagingIndex(0),
 | 
					 | 
				
			||||||
	m_averagingMaxScale(5),
 | 
					 | 
				
			||||||
	m_averagingNb(0)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	ui->setupUi(this);
 | 
						ui->setupUi(this);
 | 
				
			||||||
	on_linscale_toggled(false);
 | 
						on_linscale_toggled(false);
 | 
				
			||||||
	ui->refLevel->clear();
 | 
					
 | 
				
			||||||
	for(int ref = 0; ref >= -110; ref -= 5)
 | 
					    ui->refLevel->clear();
 | 
				
			||||||
 | 
						for(int ref = 0; ref >= -110; ref -= 5) {
 | 
				
			||||||
		ui->refLevel->addItem(QString("%1").arg(ref));
 | 
							ui->refLevel->addItem(QString("%1").arg(ref));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ui->levelRange->clear();
 | 
						ui->levelRange->clear();
 | 
				
			||||||
	for(int range = 100; range >= 5; range -= 5)
 | 
						for(int range = 100; range >= 5; range -= 5) {
 | 
				
			||||||
		ui->levelRange->addItem(QString("%1").arg(range));
 | 
							ui->levelRange->addItem(QString("%1").arg(range));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	setAveragingCombo();
 | 
						setAveragingCombo();
 | 
				
			||||||
	connect(&m_messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
 | 
						connect(&m_messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
 | 
				
			||||||
 | 
					    displaySettings();
 | 
				
			||||||
 | 
					    applySettings();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
GLSpectrumGUI::~GLSpectrumGUI()
 | 
					GLSpectrumGUI::~GLSpectrumGUI()
 | 
				
			||||||
@ -54,410 +62,275 @@ void GLSpectrumGUI::setBuddies(SpectrumVis* spectrumVis, GLSpectrum* glSpectrum)
 | 
				
			|||||||
	m_spectrumVis = spectrumVis;
 | 
						m_spectrumVis = spectrumVis;
 | 
				
			||||||
	m_glSpectrum = glSpectrum;
 | 
						m_glSpectrum = glSpectrum;
 | 
				
			||||||
	m_glSpectrum->setMessageQueueToGUI(&m_messageQueue);
 | 
						m_glSpectrum->setMessageQueueToGUI(&m_messageQueue);
 | 
				
			||||||
	applySettings();
 | 
					    m_spectrumVis->setMessageQueueToGUI(&m_messageQueue);
 | 
				
			||||||
	applySettingsVis();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::resetToDefaults()
 | 
					void GLSpectrumGUI::resetToDefaults()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	m_fftSize = 1024;
 | 
					    m_settings.resetToDefaults();
 | 
				
			||||||
	m_fftOverlap = 0;
 | 
					    displaySettings();
 | 
				
			||||||
	m_fftWindow = FFTWindow::Hanning;
 | 
					 | 
				
			||||||
	m_refLevel = 0;
 | 
					 | 
				
			||||||
	m_powerRange = 100;
 | 
					 | 
				
			||||||
	m_decay = 1;
 | 
					 | 
				
			||||||
	m_decayDivisor = 1;
 | 
					 | 
				
			||||||
	m_histogramStroke = 30;
 | 
					 | 
				
			||||||
	m_displayGridIntensity = 5,
 | 
					 | 
				
			||||||
	m_displayWaterfall = true;
 | 
					 | 
				
			||||||
	m_invertedWaterfall = false;
 | 
					 | 
				
			||||||
	m_displayMaxHold = false;
 | 
					 | 
				
			||||||
	m_displayHistogram = false;
 | 
					 | 
				
			||||||
	m_displayGrid = false;
 | 
					 | 
				
			||||||
	m_invert = true;
 | 
					 | 
				
			||||||
	m_averagingMode = AvgModeNone;
 | 
					 | 
				
			||||||
	m_averagingIndex = 0;
 | 
					 | 
				
			||||||
	m_linear = false;
 | 
					 | 
				
			||||||
	applySettings();
 | 
						applySettings();
 | 
				
			||||||
	applySettingsVis();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QByteArray GLSpectrumGUI::serialize() const
 | 
					QByteArray GLSpectrumGUI::serialize() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	SimpleSerializer s(1);
 | 
					    return m_settings.serialize();
 | 
				
			||||||
 | 
					 | 
				
			||||||
	s.writeS32(1, m_fftSize);
 | 
					 | 
				
			||||||
	s.writeS32(2, m_fftOverlap);
 | 
					 | 
				
			||||||
	s.writeS32(3, m_fftWindow);
 | 
					 | 
				
			||||||
	s.writeReal(4, m_refLevel);
 | 
					 | 
				
			||||||
	s.writeReal(5, m_powerRange);
 | 
					 | 
				
			||||||
	s.writeBool(6, m_displayWaterfall);
 | 
					 | 
				
			||||||
	s.writeBool(7, m_invertedWaterfall);
 | 
					 | 
				
			||||||
	s.writeBool(8, m_displayMaxHold);
 | 
					 | 
				
			||||||
	s.writeBool(9, m_displayHistogram);
 | 
					 | 
				
			||||||
	s.writeS32(10, m_decay);
 | 
					 | 
				
			||||||
	s.writeBool(11, m_displayGrid);
 | 
					 | 
				
			||||||
	s.writeBool(12, m_invert);
 | 
					 | 
				
			||||||
	s.writeS32(13, m_displayGridIntensity);
 | 
					 | 
				
			||||||
	s.writeS32(14, m_decayDivisor);
 | 
					 | 
				
			||||||
	s.writeS32(15, m_histogramStroke);
 | 
					 | 
				
			||||||
	s.writeBool(16, m_displayCurrent);
 | 
					 | 
				
			||||||
	s.writeS32(17, m_displayTraceIntensity);
 | 
					 | 
				
			||||||
	s.writeReal(18, m_glSpectrum->getWaterfallShare());
 | 
					 | 
				
			||||||
	s.writeS32(19, (int) m_averagingMode);
 | 
					 | 
				
			||||||
	s.writeS32(20, (qint32) getAveragingValue(m_averagingIndex));
 | 
					 | 
				
			||||||
	s.writeBool(21, m_linear);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return s.final();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool GLSpectrumGUI::deserialize(const QByteArray& data)
 | 
					bool GLSpectrumGUI::deserialize(const QByteArray& data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	SimpleDeserializer d(data);
 | 
					    if (m_settings.deserialize(data))
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(!d.isValid()) {
 | 
					 | 
				
			||||||
		resetToDefaults();
 | 
					 | 
				
			||||||
		return false;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int tmp;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (d.getVersion() == 1)
 | 
					 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
		d.readS32(1, &m_fftSize, 1024);
 | 
					        displaySettings();
 | 
				
			||||||
		d.readS32(2, &m_fftOverlap, 0);
 | 
					        applySettings();
 | 
				
			||||||
		d.readS32(3, &m_fftWindow, FFTWindow::Hanning);
 | 
					        return true;
 | 
				
			||||||
		d.readReal(4, &m_refLevel, 0);
 | 
					    }
 | 
				
			||||||
		d.readReal(5, &m_powerRange, 100);
 | 
					 | 
				
			||||||
		d.readBool(6, &m_displayWaterfall, true);
 | 
					 | 
				
			||||||
		d.readBool(7, &m_invertedWaterfall, false);
 | 
					 | 
				
			||||||
		d.readBool(8, &m_displayMaxHold, false);
 | 
					 | 
				
			||||||
		d.readBool(9, &m_displayHistogram, false);
 | 
					 | 
				
			||||||
		d.readS32(10, &m_decay, 1);
 | 
					 | 
				
			||||||
		d.readBool(11, &m_displayGrid, false);
 | 
					 | 
				
			||||||
		d.readBool(12, &m_invert, true);
 | 
					 | 
				
			||||||
		d.readS32(13, &m_displayGridIntensity, 5);
 | 
					 | 
				
			||||||
		d.readS32(14, &m_decayDivisor, 1);
 | 
					 | 
				
			||||||
		d.readS32(15, &m_histogramStroke, 30);
 | 
					 | 
				
			||||||
		d.readBool(16, &m_displayCurrent, false);
 | 
					 | 
				
			||||||
		d.readS32(17, &m_displayTraceIntensity, 50);
 | 
					 | 
				
			||||||
		Real waterfallShare;
 | 
					 | 
				
			||||||
		d.readReal(18, &waterfallShare, 0.66);
 | 
					 | 
				
			||||||
		d.readS32(19, &tmp, 0);
 | 
					 | 
				
			||||||
		m_averagingMode = tmp < 0 ? AvgModeNone : tmp > 3 ? AvgModeMax : (AveragingMode) tmp;
 | 
					 | 
				
			||||||
		d.readS32(20, &tmp, 0);
 | 
					 | 
				
			||||||
		m_averagingIndex = getAveragingIndex(tmp);
 | 
					 | 
				
			||||||
	    m_averagingNb = getAveragingValue(m_averagingIndex);
 | 
					 | 
				
			||||||
	    d.readBool(21, &m_linear, false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        m_glSpectrum->setWaterfallShare(waterfallShare);
 | 
					 | 
				
			||||||
    	applySettings();
 | 
					 | 
				
			||||||
		applySettingsVis();
 | 
					 | 
				
			||||||
		return true;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
		resetToDefaults();
 | 
					        resetToDefaults();
 | 
				
			||||||
		return false;
 | 
					        return false;
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::applySettings()
 | 
					void GLSpectrumGUI::displaySettings()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	ui->refLevel->setCurrentIndex(-m_refLevel / 5);
 | 
					    blockApplySettings(true);
 | 
				
			||||||
	ui->levelRange->setCurrentIndex((100 - m_powerRange) / 5);
 | 
						ui->refLevel->setCurrentIndex(-m_settings.m_refLevel / 5);
 | 
				
			||||||
	ui->decay->setSliderPosition(m_decay);
 | 
						ui->levelRange->setCurrentIndex((100 - m_settings.m_powerRange) / 5);
 | 
				
			||||||
	ui->decayDivisor->setSliderPosition(m_decayDivisor);
 | 
						ui->decay->setSliderPosition(m_settings.m_decay);
 | 
				
			||||||
	ui->stroke->setSliderPosition(m_histogramStroke);
 | 
						ui->decayDivisor->setSliderPosition(m_settings.m_decayDivisor);
 | 
				
			||||||
	ui->waterfall->setChecked(m_displayWaterfall);
 | 
						ui->stroke->setSliderPosition(m_settings.m_histogramStroke);
 | 
				
			||||||
	ui->maxHold->setChecked(m_displayMaxHold);
 | 
						ui->waterfall->setChecked(m_settings.m_displayWaterfall);
 | 
				
			||||||
	ui->current->setChecked(m_displayCurrent);
 | 
						ui->maxHold->setChecked(m_settings.m_displayMaxHold);
 | 
				
			||||||
	ui->histogram->setChecked(m_displayHistogram);
 | 
						ui->current->setChecked(m_settings.m_displayCurrent);
 | 
				
			||||||
	ui->invert->setChecked(m_invert);
 | 
						ui->histogram->setChecked(m_settings.m_displayHistogram);
 | 
				
			||||||
	ui->grid->setChecked(m_displayGrid);
 | 
						ui->invert->setChecked(m_settings.m_invert);
 | 
				
			||||||
	ui->gridIntensity->setSliderPosition(m_displayGridIntensity);
 | 
						ui->grid->setChecked(m_settings.m_displayGrid);
 | 
				
			||||||
 | 
						ui->gridIntensity->setSliderPosition(m_settings.m_displayGridIntensity);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ui->decay->setToolTip(QString("Decay: %1").arg(m_decay));
 | 
						ui->decay->setToolTip(QString("Decay: %1").arg(m_settings.m_decay));
 | 
				
			||||||
	ui->decayDivisor->setToolTip(QString("Decay divisor: %1").arg(m_decayDivisor));
 | 
						ui->decayDivisor->setToolTip(QString("Decay divisor: %1").arg(m_settings.m_decayDivisor));
 | 
				
			||||||
	ui->stroke->setToolTip(QString("Stroke: %1").arg(m_histogramStroke));
 | 
						ui->stroke->setToolTip(QString("Stroke: %1").arg(m_settings.m_histogramStroke));
 | 
				
			||||||
	ui->gridIntensity->setToolTip(QString("Grid intensity: %1").arg(m_displayGridIntensity));
 | 
						ui->gridIntensity->setToolTip(QString("Grid intensity: %1").arg(m_settings.m_displayGridIntensity));
 | 
				
			||||||
	ui->traceIntensity->setToolTip(QString("Trace intensity: %1").arg(m_displayTraceIntensity));
 | 
						ui->traceIntensity->setToolTip(QString("Trace intensity: %1").arg(m_settings.m_displayTraceIntensity));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	m_glSpectrum->setDisplayWaterfall(m_displayWaterfall);
 | 
					 | 
				
			||||||
	m_glSpectrum->setInvertedWaterfall(m_invertedWaterfall);
 | 
					 | 
				
			||||||
	m_glSpectrum->setDisplayMaxHold(m_displayMaxHold);
 | 
					 | 
				
			||||||
	m_glSpectrum->setDisplayCurrent(m_displayCurrent);
 | 
					 | 
				
			||||||
	m_glSpectrum->setDisplayHistogram(m_displayHistogram);
 | 
					 | 
				
			||||||
	m_glSpectrum->setDecay(m_decay);
 | 
					 | 
				
			||||||
	m_glSpectrum->setDecayDivisor(m_decayDivisor);
 | 
					 | 
				
			||||||
	m_glSpectrum->setHistoStroke(m_histogramStroke);
 | 
					 | 
				
			||||||
	m_glSpectrum->setInvertedWaterfall(m_invert);
 | 
					 | 
				
			||||||
	m_glSpectrum->setDisplayGrid(m_displayGrid);
 | 
					 | 
				
			||||||
	m_glSpectrum->setDisplayGridIntensity(m_displayGridIntensity);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	setAveragingToolitp();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void GLSpectrumGUI::applySettingsVis()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	ui->fftWindow->blockSignals(true);
 | 
						ui->fftWindow->blockSignals(true);
 | 
				
			||||||
	ui->averaging->blockSignals(true);
 | 
						ui->averaging->blockSignals(true);
 | 
				
			||||||
	ui->averagingMode->blockSignals(true);
 | 
						ui->averagingMode->blockSignals(true);
 | 
				
			||||||
	ui->linscale->blockSignals(true);
 | 
						ui->linscale->blockSignals(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ui->fftWindow->setCurrentIndex(m_fftWindow);
 | 
						ui->fftWindow->setCurrentIndex(m_settings.m_fftWindow);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (int i = 0; i < 6; i++)
 | 
						for (int i = 0; i < 6; i++)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if (m_fftSize == (1 << (i + 7)))
 | 
							if (m_settings.m_fftSize == (1 << (i + 7)))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			ui->fftSize->setCurrentIndex(i);
 | 
								ui->fftSize->setCurrentIndex(i);
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ui->averaging->setCurrentIndex(m_averagingIndex);
 | 
						ui->averaging->setCurrentIndex(m_settings.m_averagingIndex);
 | 
				
			||||||
    m_averagingNb = getAveragingValue(m_averagingIndex);
 | 
						ui->averagingMode->setCurrentIndex((int) m_settings.m_averagingMode);
 | 
				
			||||||
	ui->averagingMode->setCurrentIndex((int) m_averagingMode);
 | 
						ui->linscale->setChecked(m_settings.m_linear);
 | 
				
			||||||
	ui->linscale->setChecked(m_linear);
 | 
						setAveragingToolitp();
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (m_glSpectrum) {
 | 
					 | 
				
			||||||
		m_glSpectrum->setLinear(m_linear);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (m_spectrumVis)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	    m_spectrumVis->configure(
 | 
					 | 
				
			||||||
            m_fftSize,
 | 
					 | 
				
			||||||
            m_refLevel,
 | 
					 | 
				
			||||||
            m_powerRange,
 | 
					 | 
				
			||||||
            m_fftOverlap,
 | 
					 | 
				
			||||||
            m_averagingNb,
 | 
					 | 
				
			||||||
            (SpectrumVis::AvgMode) m_averagingMode,
 | 
					 | 
				
			||||||
            (FFTWindow::Function) m_fftWindow,
 | 
					 | 
				
			||||||
            m_linear
 | 
					 | 
				
			||||||
		);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ui->fftWindow->blockSignals(false);
 | 
						ui->fftWindow->blockSignals(false);
 | 
				
			||||||
	ui->averaging->blockSignals(false);
 | 
						ui->averaging->blockSignals(false);
 | 
				
			||||||
	ui->averagingMode->blockSignals(false);
 | 
						ui->averagingMode->blockSignals(false);
 | 
				
			||||||
	ui->linscale->blockSignals(false);
 | 
						ui->linscale->blockSignals(false);
 | 
				
			||||||
 | 
					    blockApplySettings(false);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void GLSpectrumGUI::blockApplySettings(bool block)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    m_doApplySettings = !block;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void GLSpectrumGUI::applySettings()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (!m_doApplySettings) {
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (m_glSpectrum)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        m_glSpectrum->setDisplayWaterfall(m_settings.m_displayWaterfall);
 | 
				
			||||||
 | 
					        m_glSpectrum->setInvertedWaterfall(m_settings.m_invertedWaterfall);
 | 
				
			||||||
 | 
					        m_glSpectrum->setDisplayMaxHold(m_settings.m_displayMaxHold);
 | 
				
			||||||
 | 
					        m_glSpectrum->setDisplayCurrent(m_settings.m_displayCurrent);
 | 
				
			||||||
 | 
					        m_glSpectrum->setDisplayHistogram(m_settings.m_displayHistogram);
 | 
				
			||||||
 | 
					        m_glSpectrum->setDecay(m_settings.m_decay);
 | 
				
			||||||
 | 
					        m_glSpectrum->setDecayDivisor(m_settings.m_decayDivisor);
 | 
				
			||||||
 | 
					        m_glSpectrum->setHistoStroke(m_settings.m_histogramStroke);
 | 
				
			||||||
 | 
					        m_glSpectrum->setInvertedWaterfall(m_settings.m_invert);
 | 
				
			||||||
 | 
					        m_glSpectrum->setDisplayGrid(m_settings.m_displayGrid);
 | 
				
			||||||
 | 
					        m_glSpectrum->setDisplayGridIntensity(m_settings.m_displayGridIntensity);
 | 
				
			||||||
 | 
					        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));
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            m_glSpectrum->setTimingRate(1);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Real refLevel = m_settings.m_linear ? pow(10.0, m_settings.m_refLevel/10.0) : m_settings.m_refLevel;
 | 
				
			||||||
 | 
					        Real powerRange = m_settings.m_linear ? pow(10.0, m_settings.m_refLevel/10.0) :  m_settings.m_powerRange;
 | 
				
			||||||
 | 
					        qDebug("GLSpectrumGUI::applySettings: refLevel: %e powerRange: %e", refLevel, powerRange);
 | 
				
			||||||
 | 
					        m_glSpectrum->setReferenceLevel(refLevel);
 | 
				
			||||||
 | 
					        m_glSpectrum->setPowerRange(powerRange);
 | 
				
			||||||
 | 
					        m_glSpectrum->setLinear(m_settings.m_linear);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (m_spectrumVis)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
						    m_spectrumVis->configure(
 | 
				
			||||||
 | 
					            m_settings.m_fftSize,
 | 
				
			||||||
 | 
					            m_settings.m_refLevel,
 | 
				
			||||||
 | 
					            m_settings.m_powerRange,
 | 
				
			||||||
 | 
					            m_settings.m_fftOverlap,
 | 
				
			||||||
 | 
					            getAveragingValue(m_settings.m_averagingIndex),
 | 
				
			||||||
 | 
					            (SpectrumVis::AvgMode) m_settings.m_averagingMode,
 | 
				
			||||||
 | 
					            (FFTWindow::Function) m_settings.m_fftWindow,
 | 
				
			||||||
 | 
					            m_settings.m_linear
 | 
				
			||||||
 | 
							);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_fftWindow_currentIndexChanged(int index)
 | 
					void GLSpectrumGUI::on_fftWindow_currentIndexChanged(int index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	qDebug("GLSpectrumGUI::on_fftWindow_currentIndexChanged: %d", index);
 | 
						qDebug("GLSpectrumGUI::on_fftWindow_currentIndexChanged: %d", index);
 | 
				
			||||||
	m_fftWindow = index;
 | 
						m_settings.m_fftWindow = (FFTWindow::Function) index;
 | 
				
			||||||
	applySettingsVis();
 | 
						applySettings();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_fftSize_currentIndexChanged(int index)
 | 
					void GLSpectrumGUI::on_fftSize_currentIndexChanged(int index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	qDebug("GLSpectrumGUI::on_fftSize_currentIndexChanged: %d", index);
 | 
						qDebug("GLSpectrumGUI::on_fftSize_currentIndexChanged: %d", index);
 | 
				
			||||||
	m_fftSize = 1 << (7 + index);
 | 
						m_settings.m_fftSize = 1 << (7 + index);
 | 
				
			||||||
	applySettingsVis();
 | 
						applySettings();
 | 
				
			||||||
	setAveragingToolitp();
 | 
						setAveragingToolitp();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_averagingMode_currentIndexChanged(int index)
 | 
					void GLSpectrumGUI::on_averagingMode_currentIndexChanged(int index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	qDebug("GLSpectrumGUI::on_averagingMode_currentIndexChanged: %d", index);
 | 
						qDebug("GLSpectrumGUI::on_averagingMode_currentIndexChanged: %d", index);
 | 
				
			||||||
    m_averagingMode = index < 0 ? AvgModeNone : index > 3 ? AvgModeMax : (AveragingMode) index;
 | 
					    m_settings.m_averagingMode = index < 0 ?
 | 
				
			||||||
 | 
					        GLSpectrumSettings::AvgModeNone :
 | 
				
			||||||
 | 
					        index > 3 ?
 | 
				
			||||||
 | 
					            GLSpectrumSettings::AvgModeMax :
 | 
				
			||||||
 | 
					            (GLSpectrumSettings::AveragingMode) index;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (m_averagingMode == AvgModeMoving)
 | 
					    if (m_settings.m_averagingMode == GLSpectrumSettings::AvgModeMoving)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        m_averagingMaxScale = 2;
 | 
					        m_settings.m_averagingMaxScale = 2;
 | 
				
			||||||
        setAveragingCombo();
 | 
					        setAveragingCombo();
 | 
				
			||||||
        m_averagingNb = m_averagingNb > 1000 ? 1000 : m_averagingNb;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        m_averagingMaxScale = 5;
 | 
					        m_settings.m_averagingMaxScale = 5;
 | 
				
			||||||
        setAveragingCombo();
 | 
					        setAveragingCombo();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	applySettingsVis();
 | 
						applySettings();
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (m_glSpectrum)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        if ((m_averagingMode == AvgModeFixed) || (m_averagingMode == AvgModeMax)) {
 | 
					 | 
				
			||||||
            m_glSpectrum->setTimingRate(m_averagingNb == 0 ? 1 : m_averagingNb);
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            m_glSpectrum->setTimingRate(1);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_averaging_currentIndexChanged(int index)
 | 
					void GLSpectrumGUI::on_averaging_currentIndexChanged(int index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	qDebug("GLSpectrumGUI::on_averaging_currentIndexChanged: %d", index);
 | 
						qDebug("GLSpectrumGUI::on_averaging_currentIndexChanged: %d", index);
 | 
				
			||||||
    m_averagingIndex = index;
 | 
					    m_settings.m_averagingIndex = index;
 | 
				
			||||||
 | 
						applySettings();
 | 
				
			||||||
	applySettingsVis();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (m_glSpectrum)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        if ((m_averagingMode == AvgModeFixed) || (m_averagingMode == AvgModeMax)) {
 | 
					 | 
				
			||||||
            m_glSpectrum->setTimingRate(m_averagingNb == 0 ? 1 : m_averagingNb);
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            m_glSpectrum->setTimingRate(1);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    setAveragingToolitp();
 | 
					    setAveragingToolitp();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_linscale_toggled(bool checked)
 | 
					void GLSpectrumGUI::on_linscale_toggled(bool checked)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	qDebug("GLSpectrumGUI::on_averaging_currentIndexChanged: %s", checked ? "lin" : "log");
 | 
						qDebug("GLSpectrumGUI::on_averaging_currentIndexChanged: %s", checked ? "lin" : "log");
 | 
				
			||||||
    m_linear = checked;
 | 
					    m_settings.m_linear = checked;
 | 
				
			||||||
 | 
						applySettings();
 | 
				
			||||||
	applySettingsVis();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (m_glSpectrum)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        Real refLevel = m_linear ? pow(10.0, m_refLevel/10.0) : m_refLevel;
 | 
					 | 
				
			||||||
        Real powerRange = m_linear ? pow(10.0, m_refLevel/10.0) :  m_powerRange;
 | 
					 | 
				
			||||||
        qDebug("GLSpectrumGUI::on_linscale_toggled: refLevel: %e powerRange: %e", refLevel, powerRange);
 | 
					 | 
				
			||||||
        m_glSpectrum->setReferenceLevel(refLevel);
 | 
					 | 
				
			||||||
        m_glSpectrum->setPowerRange(powerRange);
 | 
					 | 
				
			||||||
        m_glSpectrum->setLinear(m_linear);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_refLevel_currentIndexChanged(int index)
 | 
					void GLSpectrumGUI::on_refLevel_currentIndexChanged(int index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	m_refLevel = 0 - index * 5;
 | 
						m_settings.m_refLevel = 0 - index * 5;
 | 
				
			||||||
 | 
					    applySettings();
 | 
				
			||||||
	if (m_glSpectrum)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	    Real refLevel = m_linear ? pow(10.0, m_refLevel/10.0) : m_refLevel;
 | 
					 | 
				
			||||||
        Real powerRange = m_linear ? pow(10.0, m_refLevel/10.0) :  m_powerRange;
 | 
					 | 
				
			||||||
	    qDebug("GLSpectrumGUI::on_refLevel_currentIndexChanged: refLevel: %e ", refLevel);
 | 
					 | 
				
			||||||
	    m_glSpectrum->setReferenceLevel(refLevel);
 | 
					 | 
				
			||||||
        m_glSpectrum->setPowerRange(powerRange);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    applySettingsVis();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_levelRange_currentIndexChanged(int index)
 | 
					void GLSpectrumGUI::on_levelRange_currentIndexChanged(int index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	m_powerRange = 100 - index * 5;
 | 
						m_settings.m_powerRange = 100 - index * 5;
 | 
				
			||||||
 | 
					    applySettings();
 | 
				
			||||||
	if (m_glSpectrum)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
        Real refLevel = m_linear ? pow(10.0, m_refLevel/10.0) : m_refLevel;
 | 
					 | 
				
			||||||
	    Real powerRange = m_linear ? pow(10.0, m_refLevel/10.0) :  m_powerRange;
 | 
					 | 
				
			||||||
	    qDebug("GLSpectrumGUI::on_levelRange_currentIndexChanged: powerRange: %e", powerRange);
 | 
					 | 
				
			||||||
        m_glSpectrum->setReferenceLevel(refLevel);
 | 
					 | 
				
			||||||
	    m_glSpectrum->setPowerRange(powerRange);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    applySettingsVis();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_decay_valueChanged(int index)
 | 
					void GLSpectrumGUI::on_decay_valueChanged(int index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	m_decay = index;
 | 
						m_settings.m_decay = index;
 | 
				
			||||||
	ui->decay->setToolTip(QString("Decay: %1").arg(m_decay));
 | 
						ui->decay->setToolTip(QString("Decay: %1").arg(m_settings.m_decay));
 | 
				
			||||||
 | 
					    applySettings();
 | 
				
			||||||
	if (m_glSpectrum) {
 | 
					 | 
				
			||||||
	    m_glSpectrum->setDecay(m_decay);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_decayDivisor_valueChanged(int index)
 | 
					void GLSpectrumGUI::on_decayDivisor_valueChanged(int index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	m_decayDivisor = index;
 | 
						m_settings.m_decayDivisor = index;
 | 
				
			||||||
	//ui->decayDivisor->setToolTip(QString("Decay divisor: %1").arg(m_decayDivisor));
 | 
						ui->decayDivisor->setToolTip(QString("Decay divisor: %1").arg(m_settings.m_decayDivisor));
 | 
				
			||||||
	if(m_glSpectrum != 0) {
 | 
					    applySettings();
 | 
				
			||||||
		applySettings();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_stroke_valueChanged(int index)
 | 
					void GLSpectrumGUI::on_stroke_valueChanged(int index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	m_histogramStroke = index;
 | 
						m_settings.m_histogramStroke = index;
 | 
				
			||||||
	//ui->stroke->setToolTip(QString("Stroke: %1").arg(m_histogramStroke));
 | 
						ui->stroke->setToolTip(QString("Stroke: %1").arg(m_settings.m_histogramStroke));
 | 
				
			||||||
	if (m_glSpectrum) {
 | 
					    applySettings();
 | 
				
			||||||
		applySettings();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_waterfall_toggled(bool checked)
 | 
					void GLSpectrumGUI::on_waterfall_toggled(bool checked)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	m_displayWaterfall = checked;
 | 
						m_settings.m_displayWaterfall = checked;
 | 
				
			||||||
 | 
					    applySettings();
 | 
				
			||||||
	if (m_glSpectrum) {
 | 
					 | 
				
			||||||
	    m_glSpectrum->setDisplayWaterfall(m_displayWaterfall);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_histogram_toggled(bool checked)
 | 
					void GLSpectrumGUI::on_histogram_toggled(bool checked)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	m_displayHistogram = checked;
 | 
						m_settings.m_displayHistogram = checked;
 | 
				
			||||||
 | 
					    applySettings();
 | 
				
			||||||
	if (m_glSpectrum) {
 | 
					 | 
				
			||||||
	    m_glSpectrum->setDisplayHistogram(m_displayHistogram);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_maxHold_toggled(bool checked)
 | 
					void GLSpectrumGUI::on_maxHold_toggled(bool checked)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	m_displayMaxHold = checked;
 | 
						m_settings.m_displayMaxHold = checked;
 | 
				
			||||||
 | 
					    applySettings();
 | 
				
			||||||
	if (m_glSpectrum) {
 | 
					 | 
				
			||||||
	    m_glSpectrum->setDisplayMaxHold(m_displayMaxHold);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_current_toggled(bool checked)
 | 
					void GLSpectrumGUI::on_current_toggled(bool checked)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	m_displayCurrent = checked;
 | 
						m_settings.m_displayCurrent = checked;
 | 
				
			||||||
 | 
					    applySettings();
 | 
				
			||||||
	if (m_glSpectrum) {
 | 
					 | 
				
			||||||
	    m_glSpectrum->setDisplayCurrent(m_displayCurrent);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_invert_toggled(bool checked)
 | 
					void GLSpectrumGUI::on_invert_toggled(bool checked)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	m_invert = checked;
 | 
						m_settings.m_invert = checked;
 | 
				
			||||||
 | 
					    applySettings();
 | 
				
			||||||
	if (m_glSpectrum) {
 | 
					 | 
				
			||||||
	    m_glSpectrum->setInvertedWaterfall(m_invert);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_grid_toggled(bool checked)
 | 
					void GLSpectrumGUI::on_grid_toggled(bool checked)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	m_displayGrid = checked;
 | 
						m_settings.m_displayGrid = checked;
 | 
				
			||||||
 | 
					    applySettings();
 | 
				
			||||||
	if (m_glSpectrum) {
 | 
					 | 
				
			||||||
	    m_glSpectrum->setDisplayGrid(m_displayGrid);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_gridIntensity_valueChanged(int index)
 | 
					void GLSpectrumGUI::on_gridIntensity_valueChanged(int index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	m_displayGridIntensity = index;
 | 
						m_settings.m_displayGridIntensity = index;
 | 
				
			||||||
	ui->gridIntensity->setToolTip(QString("Grid intensity: %1").arg(m_displayGridIntensity));
 | 
						ui->gridIntensity->setToolTip(QString("Grid intensity: %1").arg(m_settings.m_displayGridIntensity));
 | 
				
			||||||
 | 
					    applySettings();
 | 
				
			||||||
	if (m_glSpectrum) {
 | 
					 | 
				
			||||||
	    m_glSpectrum->setDisplayGridIntensity(m_displayGridIntensity);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_traceIntensity_valueChanged(int index)
 | 
					void GLSpectrumGUI::on_traceIntensity_valueChanged(int index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	m_displayTraceIntensity = index;
 | 
						m_settings.m_displayTraceIntensity = index;
 | 
				
			||||||
	ui->traceIntensity->setToolTip(QString("Trace intensity: %1").arg(m_displayTraceIntensity));
 | 
						ui->traceIntensity->setToolTip(QString("Trace intensity: %1").arg(m_settings.m_displayTraceIntensity));
 | 
				
			||||||
 | 
					    applySettings();
 | 
				
			||||||
	if (m_glSpectrum) {
 | 
					 | 
				
			||||||
	    m_glSpectrum->setDisplayTraceIntensity(m_displayTraceIntensity);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GLSpectrumGUI::on_clearSpectrum_clicked(bool checked)
 | 
					void GLSpectrumGUI::on_clearSpectrum_clicked(bool checked)
 | 
				
			||||||
@ -478,7 +351,7 @@ int GLSpectrumGUI::getAveragingIndex(int averagingValue) const
 | 
				
			|||||||
    int v = averagingValue;
 | 
					    int v = averagingValue;
 | 
				
			||||||
    int j = 0;
 | 
					    int j = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (int i = 0; i <= m_averagingMaxScale; i++)
 | 
					    for (int i = 0; i <= m_settings.m_averagingMaxScale; i++)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (v < 20)
 | 
					        if (v < 20)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@ -498,7 +371,7 @@ int GLSpectrumGUI::getAveragingIndex(int averagingValue) const
 | 
				
			|||||||
        v /= 10;
 | 
					        v /= 10;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return 3*m_averagingMaxScale + 3;
 | 
					    return 3*m_settings.m_averagingMaxScale + 3;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int GLSpectrumGUI::getAveragingValue(int averagingIndex) const
 | 
					int GLSpectrumGUI::getAveragingValue(int averagingIndex) const
 | 
				
			||||||
@ -508,7 +381,7 @@ int GLSpectrumGUI::getAveragingValue(int averagingIndex) const
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int v = averagingIndex - 1;
 | 
					    int v = averagingIndex - 1;
 | 
				
			||||||
    int m = pow(10.0, v/3 > m_averagingMaxScale ? m_averagingMaxScale : v/3);
 | 
					    int m = pow(10.0, v/3 > m_settings.m_averagingMaxScale ? m_settings.m_averagingMaxScale : v/3);
 | 
				
			||||||
    int x = 1;
 | 
					    int x = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (v % 3 == 0) {
 | 
					    if (v % 3 == 0) {
 | 
				
			||||||
@ -529,7 +402,7 @@ void GLSpectrumGUI::setAveragingCombo()
 | 
				
			|||||||
    ui->averaging->clear();
 | 
					    ui->averaging->clear();
 | 
				
			||||||
    ui->averaging->addItem(QString("1"));
 | 
					    ui->averaging->addItem(QString("1"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (int i = 0; i <= m_averagingMaxScale; i++)
 | 
					    for (int i = 0; i <= m_settings.m_averagingMaxScale; i++)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        QString s;
 | 
					        QString s;
 | 
				
			||||||
        int m = pow(10.0, i);
 | 
					        int m = pow(10.0, i);
 | 
				
			||||||
@ -587,7 +460,9 @@ void GLSpectrumGUI::setAveragingToolitp()
 | 
				
			|||||||
    if (m_glSpectrum)
 | 
					    if (m_glSpectrum)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        QString s;
 | 
					        QString s;
 | 
				
			||||||
        float averagingTime = (m_fftSize * (m_averagingNb == 0 ? 1 : m_averagingNb)) / (float) m_glSpectrum->getSampleRate();
 | 
					        float averagingTime = (m_settings.m_fftSize * (getAveragingValue(m_settings.m_averagingIndex) == 0 ?
 | 
				
			||||||
 | 
					            1 :
 | 
				
			||||||
 | 
					            getAveragingValue(m_settings.m_averagingIndex))) / (float) m_glSpectrum->getSampleRate();
 | 
				
			||||||
        setNumberStr(averagingTime, 2, s);
 | 
					        setNumberStr(averagingTime, 2, s);
 | 
				
			||||||
        ui->averaging->setToolTip(QString("Number of averaging samples (avg time: %1s)").arg(s));
 | 
					        ui->averaging->setToolTip(QString("Number of averaging samples (avg time: %1s)").arg(s));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -1,8 +1,31 @@
 | 
				
			|||||||
 | 
					///////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// Copyright (C) 2016-2020 F4EXB                                                 //
 | 
				
			||||||
 | 
					// written by Edouard Griffiths                                                  //
 | 
				
			||||||
 | 
					//                                                                               //
 | 
				
			||||||
 | 
					// OpenGL interface modernization.                                               //
 | 
				
			||||||
 | 
					// See: http://doc.qt.io/qt-5/qopenglshaderprogram.html                          //
 | 
				
			||||||
 | 
					//                                                                               //
 | 
				
			||||||
 | 
					// This program is free software; you can redistribute it and/or modify          //
 | 
				
			||||||
 | 
					// it under the terms of the GNU General Public License as published by          //
 | 
				
			||||||
 | 
					// the Free Software Foundation as version 3 of the License, or                  //
 | 
				
			||||||
 | 
					// (at your option) any later version.                                           //
 | 
				
			||||||
 | 
					//                                                                               //
 | 
				
			||||||
 | 
					// This program is distributed in the hope that it will be useful,               //
 | 
				
			||||||
 | 
					// but WITHOUT ANY WARRANTY; without even the implied warranty of                //
 | 
				
			||||||
 | 
					// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
 | 
				
			||||||
 | 
					// GNU General Public License V3 for more details.                               //
 | 
				
			||||||
 | 
					//                                                                               //
 | 
				
			||||||
 | 
					// You should have received a copy of the GNU General Public License             //
 | 
				
			||||||
 | 
					// along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef INCLUDE_GLSPECTRUMGUI_H
 | 
					#ifndef INCLUDE_GLSPECTRUMGUI_H
 | 
				
			||||||
#define INCLUDE_GLSPECTRUMGUI_H
 | 
					#define INCLUDE_GLSPECTRUMGUI_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QWidget>
 | 
					#include <QWidget>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "dsp/dsptypes.h"
 | 
					#include "dsp/dsptypes.h"
 | 
				
			||||||
 | 
					#include "dsp/glspectrumsettings.h"
 | 
				
			||||||
#include "export.h"
 | 
					#include "export.h"
 | 
				
			||||||
#include "settings/serializable.h"
 | 
					#include "settings/serializable.h"
 | 
				
			||||||
#include "util/messagequeue.h"
 | 
					#include "util/messagequeue.h"
 | 
				
			||||||
@ -42,32 +65,12 @@ private:
 | 
				
			|||||||
	SpectrumVis* m_spectrumVis;
 | 
						SpectrumVis* m_spectrumVis;
 | 
				
			||||||
	GLSpectrum* m_glSpectrum;
 | 
						GLSpectrum* m_glSpectrum;
 | 
				
			||||||
	MessageQueue m_messageQueue;
 | 
						MessageQueue m_messageQueue;
 | 
				
			||||||
 | 
					    GLSpectrumSettings m_settings;
 | 
				
			||||||
 | 
					    bool m_doApplySettings;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	qint32 m_fftSize;
 | 
					    void blockApplySettings(bool block);
 | 
				
			||||||
	qint32 m_fftOverlap;
 | 
					 | 
				
			||||||
	qint32 m_fftWindow;
 | 
					 | 
				
			||||||
	Real m_refLevel;
 | 
					 | 
				
			||||||
	Real m_powerRange;
 | 
					 | 
				
			||||||
	int m_decay;
 | 
					 | 
				
			||||||
	int m_decayDivisor;
 | 
					 | 
				
			||||||
	int m_histogramStroke;
 | 
					 | 
				
			||||||
	int m_displayGridIntensity;
 | 
					 | 
				
			||||||
	int m_displayTraceIntensity;
 | 
					 | 
				
			||||||
	bool m_displayWaterfall;
 | 
					 | 
				
			||||||
	bool m_invertedWaterfall;
 | 
					 | 
				
			||||||
	bool m_displayMaxHold;
 | 
					 | 
				
			||||||
	bool m_displayCurrent;
 | 
					 | 
				
			||||||
	bool m_displayHistogram;
 | 
					 | 
				
			||||||
	bool m_displayGrid;
 | 
					 | 
				
			||||||
	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
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void applySettings();
 | 
						void applySettings();
 | 
				
			||||||
	void applySettingsVis();
 | 
					    void displaySettings();
 | 
				
			||||||
	int getAveragingIndex(int averaging) const;
 | 
						int getAveragingIndex(int averaging) const;
 | 
				
			||||||
	int getAveragingValue(int averagingIndex) const;
 | 
						int getAveragingValue(int averagingIndex) const;
 | 
				
			||||||
	void setAveragingCombo();
 | 
						void setAveragingCombo();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user