2014-05-18 11:52:39 -04:00
|
|
|
#include "gui/glspectrumgui.h"
|
|
|
|
#include "dsp/fftwindow.h"
|
|
|
|
#include "dsp/spectrumvis.h"
|
|
|
|
#include "gui/glspectrum.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "ui_glspectrumgui.h"
|
|
|
|
|
|
|
|
GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) :
|
|
|
|
QWidget(parent),
|
|
|
|
ui(new Ui::GLSpectrumGUI),
|
2018-07-01 14:48:30 -04:00
|
|
|
m_messageQueueToVis(0),
|
2018-06-30 16:30:42 -04:00
|
|
|
m_spectrumVis(0),
|
|
|
|
m_glSpectrum(0),
|
2014-05-18 11:52:39 -04:00
|
|
|
m_fftSize(1024),
|
2014-06-10 07:24:52 -04:00
|
|
|
m_fftOverlap(0),
|
2014-05-18 11:52:39 -04:00
|
|
|
m_fftWindow(FFTWindow::Hamming),
|
|
|
|
m_refLevel(0),
|
|
|
|
m_powerRange(100),
|
2018-10-18 18:40:14 -04:00
|
|
|
m_decay(1),
|
|
|
|
m_decayDivisor(1),
|
|
|
|
m_histogramStroke(30),
|
2015-07-18 11:53:57 -04:00
|
|
|
m_displayGridIntensity(5),
|
|
|
|
m_displayTraceIntensity(50),
|
2014-06-30 16:53:59 -04:00
|
|
|
m_displayWaterfall(true),
|
2014-05-18 11:52:39 -04:00
|
|
|
m_invertedWaterfall(false),
|
2014-06-30 16:53:59 -04:00
|
|
|
m_displayMaxHold(false),
|
2015-07-15 22:55:14 -04:00
|
|
|
m_displayCurrent(false),
|
2014-06-30 16:53:59 -04:00
|
|
|
m_displayHistogram(false),
|
|
|
|
m_displayGrid(false),
|
2018-06-30 16:30:42 -04:00
|
|
|
m_invert(true),
|
2018-07-01 16:36:36 -04:00
|
|
|
m_averagingMode(AvgModeNone),
|
2018-06-30 16:30:42 -04:00
|
|
|
m_averagingIndex(0),
|
2018-10-13 00:29:43 -04:00
|
|
|
m_averagingMaxScale(5),
|
2018-06-30 16:30:42 -04:00
|
|
|
m_averagingNb(0)
|
2014-05-18 11:52:39 -04:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2018-08-15 04:30:12 -04:00
|
|
|
on_linscale_toggled(false);
|
2018-06-30 22:10:36 -04:00
|
|
|
ui->refLevel->clear();
|
2015-06-11 20:58:25 -04:00
|
|
|
for(int ref = 0; ref >= -110; ref -= 5)
|
2014-05-18 11:52:39 -04:00
|
|
|
ui->refLevel->addItem(QString("%1").arg(ref));
|
2018-06-30 22:10:36 -04:00
|
|
|
ui->levelRange->clear();
|
2014-05-18 11:52:39 -04:00
|
|
|
for(int range = 100; range >= 5; range -= 5)
|
|
|
|
ui->levelRange->addItem(QString("%1").arg(range));
|
2018-06-30 18:55:30 -04:00
|
|
|
setAveragingCombo();
|
2018-07-01 14:48:30 -04:00
|
|
|
connect(&m_messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
GLSpectrumGUI::~GLSpectrumGUI()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLSpectrumGUI::setBuddies(MessageQueue* messageQueue, SpectrumVis* spectrumVis, GLSpectrum* glSpectrum)
|
|
|
|
{
|
2018-07-01 14:48:30 -04:00
|
|
|
m_messageQueueToVis = messageQueue;
|
2014-05-18 11:52:39 -04:00
|
|
|
m_spectrumVis = spectrumVis;
|
|
|
|
m_glSpectrum = glSpectrum;
|
2018-07-01 14:48:30 -04:00
|
|
|
m_glSpectrum->setMessageQueueToGUI(&m_messageQueue);
|
2014-05-18 11:52:39 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLSpectrumGUI::resetToDefaults()
|
|
|
|
{
|
|
|
|
m_fftSize = 1024;
|
2014-06-10 07:24:52 -04:00
|
|
|
m_fftOverlap = 0;
|
2014-05-18 11:52:39 -04:00
|
|
|
m_fftWindow = FFTWindow::Hamming;
|
|
|
|
m_refLevel = 0;
|
|
|
|
m_powerRange = 100;
|
2018-10-18 18:40:14 -04:00
|
|
|
m_decay = 1;
|
|
|
|
m_decayDivisor = 1;
|
|
|
|
m_histogramStroke = 30;
|
2015-05-12 09:49:03 -04:00
|
|
|
m_displayGridIntensity = 5,
|
2014-06-30 16:53:59 -04:00
|
|
|
m_displayWaterfall = true;
|
2014-05-18 11:52:39 -04:00
|
|
|
m_invertedWaterfall = false;
|
2014-06-30 16:53:59 -04:00
|
|
|
m_displayMaxHold = false;
|
|
|
|
m_displayHistogram = false;
|
|
|
|
m_displayGrid = false;
|
|
|
|
m_invert = true;
|
2018-07-01 16:36:36 -04:00
|
|
|
m_averagingMode = AvgModeNone;
|
2018-06-30 16:30:42 -04:00
|
|
|
m_averagingIndex = 0;
|
2018-07-05 19:34:05 -04:00
|
|
|
m_linear = false;
|
2014-05-18 11:52:39 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray GLSpectrumGUI::serialize() const
|
|
|
|
{
|
|
|
|
SimpleSerializer s(1);
|
|
|
|
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);
|
2015-07-15 02:48:02 -04:00
|
|
|
s.writeS32(13, m_displayGridIntensity);
|
2018-10-18 18:40:14 -04:00
|
|
|
s.writeS32(14, m_decayDivisor);
|
2015-07-15 02:48:02 -04:00
|
|
|
s.writeS32(15, m_histogramStroke);
|
2015-07-15 22:55:14 -04:00
|
|
|
s.writeBool(16, m_displayCurrent);
|
2015-07-18 11:53:57 -04:00
|
|
|
s.writeS32(17, m_displayTraceIntensity);
|
2015-07-23 19:30:00 -04:00
|
|
|
s.writeReal(18, m_glSpectrum->getWaterfallShare());
|
2018-06-30 16:30:42 -04:00
|
|
|
s.writeS32(19, (int) m_averagingMode);
|
|
|
|
s.writeS32(20, (qint32) getAveragingValue(m_averagingIndex));
|
2018-07-05 19:34:05 -04:00
|
|
|
s.writeBool(21, m_linear);
|
2014-05-18 11:52:39 -04:00
|
|
|
return s.final();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GLSpectrumGUI::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
SimpleDeserializer d(data);
|
|
|
|
|
|
|
|
if(!d.isValid()) {
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-06-30 16:30:42 -04:00
|
|
|
int tmp;
|
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
if(d.getVersion() == 1) {
|
|
|
|
d.readS32(1, &m_fftSize, 1024);
|
2014-06-10 07:24:52 -04:00
|
|
|
d.readS32(2, &m_fftOverlap, 0);
|
2014-05-18 11:52:39 -04:00
|
|
|
d.readS32(3, &m_fftWindow, FFTWindow::Hamming);
|
|
|
|
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);
|
2014-06-30 16:53:59 -04:00
|
|
|
d.readBool(9, &m_displayHistogram, false);
|
2018-10-18 18:40:14 -04:00
|
|
|
d.readS32(10, &m_decay, 1);
|
2014-06-30 16:53:59 -04:00
|
|
|
d.readBool(11, &m_displayGrid, false);
|
|
|
|
d.readBool(12, &m_invert, true);
|
2015-07-18 11:53:57 -04:00
|
|
|
d.readS32(13, &m_displayGridIntensity, 5);
|
2018-10-18 18:40:14 -04:00
|
|
|
d.readS32(14, &m_decayDivisor, 1);
|
|
|
|
d.readS32(15, &m_histogramStroke, 30);
|
2015-07-15 22:55:14 -04:00
|
|
|
d.readBool(16, &m_displayCurrent, false);
|
2015-07-18 11:53:57 -04:00
|
|
|
d.readS32(17, &m_displayTraceIntensity, 50);
|
2015-07-23 19:30:00 -04:00
|
|
|
Real waterfallShare;
|
|
|
|
d.readReal(18, &waterfallShare, 0.66);
|
2018-06-30 16:30:42 -04:00
|
|
|
d.readS32(19, &tmp, 0);
|
2018-10-12 02:47:14 -04:00
|
|
|
m_averagingMode = tmp < 0 ? AvgModeNone : tmp > 3 ? AvgModeMax : (AveragingMode) tmp;
|
2018-06-30 16:30:42 -04:00
|
|
|
d.readS32(20, &tmp, 0);
|
2018-06-30 22:14:06 -04:00
|
|
|
m_averagingIndex = getAveragingIndex(tmp);
|
2018-06-30 16:30:42 -04:00
|
|
|
m_averagingNb = getAveragingValue(m_averagingIndex);
|
2018-07-05 19:34:05 -04:00
|
|
|
d.readBool(21, &m_linear, false);
|
2018-06-30 16:30:42 -04:00
|
|
|
|
2015-07-23 19:30:00 -04:00
|
|
|
m_glSpectrum->setWaterfallShare(waterfallShare);
|
2014-05-18 11:52:39 -04:00
|
|
|
applySettings();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLSpectrumGUI::applySettings()
|
|
|
|
{
|
|
|
|
ui->fftWindow->setCurrentIndex(m_fftWindow);
|
|
|
|
for(int i = 0; i < 6; i++) {
|
|
|
|
if(m_fftSize == (1 << (i + 7))) {
|
|
|
|
ui->fftSize->setCurrentIndex(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ui->refLevel->setCurrentIndex(-m_refLevel / 5);
|
|
|
|
ui->levelRange->setCurrentIndex((100 - m_powerRange) / 5);
|
2018-06-30 16:30:42 -04:00
|
|
|
ui->averaging->setCurrentIndex(m_averagingIndex);
|
|
|
|
ui->averagingMode->setCurrentIndex((int) m_averagingMode);
|
2018-07-05 19:34:05 -04:00
|
|
|
ui->linscale->setChecked(m_linear);
|
2015-07-15 02:48:02 -04:00
|
|
|
ui->decay->setSliderPosition(m_decay);
|
2018-10-18 18:40:14 -04:00
|
|
|
ui->decayDivisor->setSliderPosition(m_decayDivisor);
|
2015-07-15 02:48:02 -04:00
|
|
|
ui->stroke->setSliderPosition(m_histogramStroke);
|
2014-05-18 11:52:39 -04:00
|
|
|
ui->waterfall->setChecked(m_displayWaterfall);
|
|
|
|
ui->maxHold->setChecked(m_displayMaxHold);
|
2015-07-15 22:55:14 -04:00
|
|
|
ui->current->setChecked(m_displayCurrent);
|
2014-05-18 11:52:39 -04:00
|
|
|
ui->histogram->setChecked(m_displayHistogram);
|
|
|
|
ui->invert->setChecked(m_invert);
|
|
|
|
ui->grid->setChecked(m_displayGrid);
|
2015-05-12 09:49:03 -04:00
|
|
|
ui->gridIntensity->setSliderPosition(m_displayGridIntensity);
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2015-07-15 02:48:02 -04:00
|
|
|
ui->decay->setToolTip(QString("Decay: %1").arg(m_decay));
|
2018-10-18 18:40:14 -04:00
|
|
|
ui->decayDivisor->setToolTip(QString("Decay divisor: %1").arg(m_decayDivisor));
|
2015-07-15 02:48:02 -04:00
|
|
|
ui->stroke->setToolTip(QString("Stroke: %1").arg(m_histogramStroke));
|
|
|
|
ui->gridIntensity->setToolTip(QString("Grid intensity: %1").arg(m_displayGridIntensity));
|
2015-07-18 11:53:57 -04:00
|
|
|
ui->traceIntensity->setToolTip(QString("Trace intensity: %1").arg(m_displayTraceIntensity));
|
2015-07-15 02:48:02 -04:00
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
m_glSpectrum->setDisplayWaterfall(m_displayWaterfall);
|
|
|
|
m_glSpectrum->setInvertedWaterfall(m_invertedWaterfall);
|
|
|
|
m_glSpectrum->setDisplayMaxHold(m_displayMaxHold);
|
2015-07-15 22:55:14 -04:00
|
|
|
m_glSpectrum->setDisplayCurrent(m_displayCurrent);
|
2014-05-18 11:52:39 -04:00
|
|
|
m_glSpectrum->setDisplayHistogram(m_displayHistogram);
|
|
|
|
m_glSpectrum->setDecay(m_decay);
|
2018-10-18 18:40:14 -04:00
|
|
|
m_glSpectrum->setDecayDivisor(m_decayDivisor);
|
2015-07-15 22:55:14 -04:00
|
|
|
m_glSpectrum->setHistoStroke(m_histogramStroke);
|
2014-05-18 11:52:39 -04:00
|
|
|
m_glSpectrum->setInvertedWaterfall(m_invert);
|
|
|
|
m_glSpectrum->setDisplayGrid(m_displayGrid);
|
2015-05-12 09:49:03 -04:00
|
|
|
m_glSpectrum->setDisplayGridIntensity(m_displayGridIntensity);
|
2018-07-05 19:34:05 -04:00
|
|
|
m_glSpectrum->setLinear(m_linear);
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2018-06-30 16:30:42 -04:00
|
|
|
if (m_spectrumVis) {
|
2018-07-01 14:48:30 -04:00
|
|
|
m_spectrumVis->configure(m_messageQueueToVis,
|
2018-06-30 20:16:59 -04:00
|
|
|
m_fftSize,
|
|
|
|
m_fftOverlap,
|
|
|
|
m_averagingNb,
|
|
|
|
m_averagingMode,
|
2018-07-04 17:11:28 -04:00
|
|
|
(FFTWindow::Function)m_fftWindow,
|
|
|
|
m_linear);
|
2018-06-30 16:30:42 -04:00
|
|
|
}
|
2018-07-01 14:48:30 -04:00
|
|
|
|
|
|
|
setAveragingToolitp();
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GLSpectrumGUI::on_fftWindow_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
m_fftWindow = index;
|
2018-06-30 16:30:42 -04:00
|
|
|
if(m_spectrumVis != 0) {
|
2018-07-01 14:48:30 -04:00
|
|
|
m_spectrumVis->configure(m_messageQueueToVis,
|
2018-06-30 20:16:59 -04:00
|
|
|
m_fftSize,
|
|
|
|
m_fftOverlap,
|
|
|
|
m_averagingNb,
|
|
|
|
m_averagingMode,
|
2018-07-04 17:11:28 -04:00
|
|
|
(FFTWindow::Function)m_fftWindow,
|
|
|
|
m_linear);
|
2018-06-30 16:30:42 -04:00
|
|
|
}
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GLSpectrumGUI::on_fftSize_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
m_fftSize = 1 << (7 + index);
|
2018-06-30 16:30:42 -04:00
|
|
|
if(m_spectrumVis != 0) {
|
2018-07-01 14:48:30 -04:00
|
|
|
m_spectrumVis->configure(m_messageQueueToVis,
|
2018-06-30 20:16:59 -04:00
|
|
|
m_fftSize,
|
|
|
|
m_fftOverlap,
|
|
|
|
m_averagingNb,
|
|
|
|
m_averagingMode,
|
2018-07-04 17:11:28 -04:00
|
|
|
(FFTWindow::Function)m_fftWindow,
|
|
|
|
m_linear);
|
2018-06-30 16:30:42 -04:00
|
|
|
}
|
2018-07-01 14:48:30 -04:00
|
|
|
setAveragingToolitp();
|
2018-06-30 16:30:42 -04:00
|
|
|
}
|
|
|
|
|
2018-06-30 20:16:59 -04:00
|
|
|
void GLSpectrumGUI::on_averagingMode_currentIndexChanged(int index)
|
2018-06-30 16:30:42 -04:00
|
|
|
{
|
2018-10-12 02:47:14 -04:00
|
|
|
m_averagingMode = index < 0 ? AvgModeNone : index > 3 ? AvgModeMax : (AveragingMode) index;
|
2018-06-30 21:11:36 -04:00
|
|
|
|
2018-10-16 17:56:09 -04:00
|
|
|
if (m_averagingMode == AvgModeMoving)
|
|
|
|
{
|
|
|
|
m_averagingMaxScale = 2;
|
|
|
|
setAveragingCombo();
|
|
|
|
m_averagingNb = m_averagingNb > 1000 ? 1000 : m_averagingNb;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_averagingMaxScale = 5;
|
|
|
|
setAveragingCombo();
|
|
|
|
}
|
|
|
|
|
2018-06-30 20:16:59 -04:00
|
|
|
if(m_spectrumVis != 0) {
|
2018-07-01 14:48:30 -04:00
|
|
|
m_spectrumVis->configure(m_messageQueueToVis,
|
2018-06-30 20:16:59 -04:00
|
|
|
m_fftSize,
|
|
|
|
m_fftOverlap,
|
|
|
|
m_averagingNb,
|
|
|
|
m_averagingMode,
|
2018-07-04 17:11:28 -04:00
|
|
|
(FFTWindow::Function)m_fftWindow,
|
|
|
|
m_linear);
|
2018-06-30 20:16:59 -04:00
|
|
|
}
|
2018-06-30 21:11:36 -04:00
|
|
|
|
|
|
|
if (m_glSpectrum != 0)
|
|
|
|
{
|
2018-10-12 02:47:14 -04:00
|
|
|
if ((m_averagingMode == AvgModeFixed) || (m_averagingMode == AvgModeMax)) {
|
2018-06-30 21:11:36 -04:00
|
|
|
m_glSpectrum->setTimingRate(m_averagingNb == 0 ? 1 : m_averagingNb);
|
|
|
|
} else {
|
|
|
|
m_glSpectrum->setTimingRate(1);
|
|
|
|
}
|
|
|
|
}
|
2018-06-30 16:30:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GLSpectrumGUI::on_averaging_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
m_averagingIndex = index;
|
|
|
|
m_averagingNb = getAveragingValue(index);
|
2018-06-30 21:11:36 -04:00
|
|
|
|
2018-06-30 16:30:42 -04:00
|
|
|
if(m_spectrumVis != 0) {
|
2018-07-01 14:48:30 -04:00
|
|
|
m_spectrumVis->configure(m_messageQueueToVis,
|
2018-06-30 20:16:59 -04:00
|
|
|
m_fftSize,
|
|
|
|
m_fftOverlap,
|
|
|
|
m_averagingNb,
|
|
|
|
m_averagingMode,
|
2018-07-04 17:11:28 -04:00
|
|
|
(FFTWindow::Function)m_fftWindow,
|
|
|
|
m_linear);
|
2018-06-30 16:30:42 -04:00
|
|
|
}
|
2018-06-30 21:11:36 -04:00
|
|
|
|
|
|
|
if (m_glSpectrum != 0)
|
|
|
|
{
|
2018-10-12 02:47:14 -04:00
|
|
|
if ((m_averagingMode == AvgModeFixed) || (m_averagingMode == AvgModeMax)) {
|
2018-06-30 21:11:36 -04:00
|
|
|
m_glSpectrum->setTimingRate(m_averagingNb == 0 ? 1 : m_averagingNb);
|
2018-10-12 02:47:14 -04:00
|
|
|
} else {
|
|
|
|
m_glSpectrum->setTimingRate(1);
|
2018-06-30 21:11:36 -04:00
|
|
|
}
|
|
|
|
}
|
2018-07-01 14:48:30 -04:00
|
|
|
|
|
|
|
setAveragingToolitp();
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
|
2018-07-04 17:11:28 -04:00
|
|
|
void GLSpectrumGUI::on_linscale_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_linear = checked;
|
|
|
|
|
|
|
|
if(m_spectrumVis != 0) {
|
|
|
|
m_spectrumVis->configure(m_messageQueueToVis,
|
|
|
|
m_fftSize,
|
|
|
|
m_fftOverlap,
|
|
|
|
m_averagingNb,
|
|
|
|
m_averagingMode,
|
|
|
|
(FFTWindow::Function)m_fftWindow,
|
|
|
|
m_linear);
|
|
|
|
}
|
2018-07-05 19:34:05 -04:00
|
|
|
|
|
|
|
if(m_glSpectrum != 0)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2018-07-04 17:11:28 -04:00
|
|
|
}
|
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
void GLSpectrumGUI::on_refLevel_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
m_refLevel = 0 - index * 5;
|
2018-07-05 19:34:05 -04:00
|
|
|
|
|
|
|
if(m_glSpectrum != 0)
|
|
|
|
{
|
|
|
|
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);
|
2018-06-30 16:30:42 -04:00
|
|
|
}
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GLSpectrumGUI::on_levelRange_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
m_powerRange = 100 - index * 5;
|
2018-07-05 19:34:05 -04:00
|
|
|
|
|
|
|
if(m_glSpectrum != 0)
|
|
|
|
{
|
|
|
|
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);
|
2018-06-30 16:30:42 -04:00
|
|
|
}
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
|
2015-07-15 02:48:02 -04:00
|
|
|
void GLSpectrumGUI::on_decay_valueChanged(int index)
|
|
|
|
{
|
|
|
|
m_decay = index;
|
|
|
|
ui->decay->setToolTip(QString("Decay: %1").arg(m_decay));
|
2018-06-30 16:30:42 -04:00
|
|
|
if(m_glSpectrum != 0) {
|
|
|
|
m_glSpectrum->setDecay(m_decay);
|
|
|
|
}
|
2015-07-15 02:48:02 -04:00
|
|
|
}
|
|
|
|
|
2018-10-18 18:40:14 -04:00
|
|
|
void GLSpectrumGUI::on_decayDivisor_valueChanged(int index)
|
2014-05-18 11:52:39 -04:00
|
|
|
{
|
2018-10-18 18:40:14 -04:00
|
|
|
m_decayDivisor = index;
|
|
|
|
//ui->decayDivisor->setToolTip(QString("Decay divisor: %1").arg(m_decayDivisor));
|
2018-06-30 16:30:42 -04:00
|
|
|
if(m_glSpectrum != 0) {
|
2015-07-15 22:55:14 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
2015-07-15 02:48:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GLSpectrumGUI::on_stroke_valueChanged(int index)
|
|
|
|
{
|
|
|
|
m_histogramStroke = index;
|
2015-07-15 22:55:14 -04:00
|
|
|
//ui->stroke->setToolTip(QString("Stroke: %1").arg(m_histogramStroke));
|
2018-06-30 16:30:42 -04:00
|
|
|
if(m_glSpectrum != 0) {
|
2015-07-15 22:55:14 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GLSpectrumGUI::on_waterfall_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_displayWaterfall = checked;
|
2018-06-30 16:30:42 -04:00
|
|
|
if(m_glSpectrum != 0) {
|
|
|
|
m_glSpectrum->setDisplayWaterfall(m_displayWaterfall);
|
|
|
|
}
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GLSpectrumGUI::on_histogram_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_displayHistogram = checked;
|
2018-06-30 16:30:42 -04:00
|
|
|
if(m_glSpectrum != 0) {
|
|
|
|
m_glSpectrum->setDisplayHistogram(m_displayHistogram);
|
|
|
|
}
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GLSpectrumGUI::on_maxHold_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_displayMaxHold = checked;
|
2018-06-30 16:30:42 -04:00
|
|
|
if(m_glSpectrum != 0) {
|
|
|
|
m_glSpectrum->setDisplayMaxHold(m_displayMaxHold);
|
|
|
|
}
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
|
2015-07-15 22:55:14 -04:00
|
|
|
void GLSpectrumGUI::on_current_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_displayCurrent = checked;
|
2018-06-30 16:30:42 -04:00
|
|
|
if(m_glSpectrum != 0) {
|
|
|
|
m_glSpectrum->setDisplayCurrent(m_displayCurrent);
|
|
|
|
}
|
2015-07-15 22:55:14 -04:00
|
|
|
}
|
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
void GLSpectrumGUI::on_invert_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_invert = checked;
|
2018-06-30 16:30:42 -04:00
|
|
|
if(m_glSpectrum != 0) {
|
|
|
|
m_glSpectrum->setInvertedWaterfall(m_invert);
|
|
|
|
}
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GLSpectrumGUI::on_grid_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_displayGrid = checked;
|
2018-06-30 16:30:42 -04:00
|
|
|
if(m_glSpectrum != 0) {
|
|
|
|
m_glSpectrum->setDisplayGrid(m_displayGrid);
|
|
|
|
}
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
2015-05-12 09:49:03 -04:00
|
|
|
|
|
|
|
void GLSpectrumGUI::on_gridIntensity_valueChanged(int index)
|
|
|
|
{
|
|
|
|
m_displayGridIntensity = index;
|
2015-07-15 02:48:02 -04:00
|
|
|
ui->gridIntensity->setToolTip(QString("Grid intensity: %1").arg(m_displayGridIntensity));
|
2018-06-30 16:30:42 -04:00
|
|
|
if(m_glSpectrum != 0) {
|
|
|
|
m_glSpectrum->setDisplayGridIntensity(m_displayGridIntensity);
|
|
|
|
}
|
2015-05-12 09:49:03 -04:00
|
|
|
}
|
2015-07-18 11:53:57 -04:00
|
|
|
|
|
|
|
void GLSpectrumGUI::on_traceIntensity_valueChanged(int index)
|
|
|
|
{
|
|
|
|
m_displayTraceIntensity = index;
|
|
|
|
ui->traceIntensity->setToolTip(QString("Trace intensity: %1").arg(m_displayTraceIntensity));
|
2018-06-30 16:30:42 -04:00
|
|
|
if(m_glSpectrum != 0) {
|
|
|
|
m_glSpectrum->setDisplayTraceIntensity(m_displayTraceIntensity);
|
|
|
|
}
|
2015-07-18 11:53:57 -04:00
|
|
|
}
|
2015-07-23 19:09:03 -04:00
|
|
|
|
2018-11-12 12:36:27 -05:00
|
|
|
void GLSpectrumGUI::on_clearSpectrum_clicked(bool checked)
|
2015-07-23 19:09:03 -04:00
|
|
|
{
|
2018-11-12 12:36:27 -05:00
|
|
|
(void) checked;
|
2018-06-30 16:30:42 -04:00
|
|
|
if(m_glSpectrum != 0) {
|
|
|
|
m_glSpectrum->clearSpectrumHistogram();
|
|
|
|
}
|
2015-07-23 19:09:03 -04:00
|
|
|
}
|
2018-06-30 16:30:42 -04:00
|
|
|
|
|
|
|
int GLSpectrumGUI::getAveragingIndex(int averagingValue) const
|
|
|
|
{
|
2018-10-13 19:16:39 -04:00
|
|
|
if (averagingValue <= 1) {
|
2018-06-30 16:30:42 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int v = averagingValue;
|
|
|
|
int j = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i <= m_averagingMaxScale; i++)
|
|
|
|
{
|
|
|
|
if (v < 20)
|
|
|
|
{
|
|
|
|
if (v < 2) {
|
|
|
|
j = 0;
|
|
|
|
} else if (v < 5) {
|
|
|
|
j = 1;
|
|
|
|
} else if (v < 10) {
|
|
|
|
j = 2;
|
|
|
|
} else {
|
|
|
|
j = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 3*i + j;
|
|
|
|
}
|
|
|
|
|
|
|
|
v /= 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 3*m_averagingMaxScale + 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GLSpectrumGUI::getAveragingValue(int averagingIndex) const
|
|
|
|
{
|
|
|
|
if (averagingIndex <= 0) {
|
2018-10-13 19:16:39 -04:00
|
|
|
return 1;
|
2018-06-30 16:30:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int v = averagingIndex - 1;
|
|
|
|
int m = pow(10.0, v/3 > m_averagingMaxScale ? m_averagingMaxScale : v/3);
|
2018-11-18 05:06:41 -05:00
|
|
|
int x = 1;
|
2018-06-30 16:30:42 -04:00
|
|
|
|
|
|
|
if (v % 3 == 0) {
|
|
|
|
x = 2;
|
|
|
|
} else if (v % 3 == 1) {
|
|
|
|
x = 5;
|
|
|
|
} else if (v % 3 == 2) {
|
|
|
|
x = 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
return x * m;
|
|
|
|
}
|
|
|
|
|
2018-06-30 18:55:30 -04:00
|
|
|
void GLSpectrumGUI::setAveragingCombo()
|
|
|
|
{
|
2018-10-16 17:56:09 -04:00
|
|
|
int index = ui->averaging->currentIndex();
|
2018-06-30 18:55:30 -04:00
|
|
|
ui->averaging->clear();
|
2018-10-13 19:16:39 -04:00
|
|
|
ui->averaging->addItem(QString("1"));
|
2018-06-30 18:55:30 -04:00
|
|
|
|
|
|
|
for (int i = 0; i <= m_averagingMaxScale; i++)
|
|
|
|
{
|
|
|
|
QString s;
|
|
|
|
int m = pow(10.0, i);
|
|
|
|
int x = 2*m;
|
|
|
|
setNumberStr(x, s);
|
|
|
|
ui->averaging->addItem(s);
|
|
|
|
x = 5*m;
|
|
|
|
setNumberStr(x, s);
|
|
|
|
ui->averaging->addItem(s);
|
|
|
|
x = 10*m;
|
|
|
|
setNumberStr(x, s);
|
|
|
|
ui->averaging->addItem(s);
|
|
|
|
}
|
2018-10-16 17:56:09 -04:00
|
|
|
|
|
|
|
ui->averaging->setCurrentIndex(index >= ui->averaging->count() ? ui->averaging->count() - 1 : index);
|
2018-06-30 18:55:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GLSpectrumGUI::setNumberStr(int n, QString& s)
|
|
|
|
{
|
|
|
|
if (n < 1000) {
|
|
|
|
s = tr("%1").arg(n);
|
2018-10-13 19:16:39 -04:00
|
|
|
} else if (n < 100000) {
|
2018-06-30 18:55:30 -04:00
|
|
|
s = tr("%1k").arg(n/1000);
|
2018-10-13 19:16:39 -04:00
|
|
|
} else if (n < 1000000) {
|
|
|
|
s = tr("%1e5").arg(n/100000);
|
2018-06-30 18:55:30 -04:00
|
|
|
} else if (n < 1000000000) {
|
|
|
|
s = tr("%1M").arg(n/1000000);
|
|
|
|
} else {
|
|
|
|
s = tr("%1G").arg(n/1000000000);
|
|
|
|
}
|
|
|
|
}
|
2018-07-01 14:48:30 -04:00
|
|
|
|
|
|
|
void GLSpectrumGUI::setNumberStr(float v, int decimalPlaces, QString& s)
|
|
|
|
{
|
|
|
|
if (v < 1e-6) {
|
|
|
|
s = tr("%1n").arg(v*1e9, 0, 'f', decimalPlaces);
|
|
|
|
} else if (v < 1e-3) {
|
|
|
|
s = tr("%1µ").arg(v*1e6, 0, 'f', decimalPlaces);
|
|
|
|
} else if (v < 1.0) {
|
|
|
|
s = tr("%1m").arg(v*1e3, 0, 'f', decimalPlaces);
|
|
|
|
} else if (v < 1e3) {
|
|
|
|
s = tr("%1").arg(v, 0, 'f', decimalPlaces);
|
|
|
|
} else if (v < 1e6) {
|
|
|
|
s = tr("%1k").arg(v*1e-3, 0, 'f', decimalPlaces);
|
|
|
|
} else if (v < 1e9) {
|
|
|
|
s = tr("%1M").arg(v*1e-6, 0, 'f', decimalPlaces);
|
|
|
|
} else {
|
|
|
|
s = tr("%1G").arg(v*1e-9, 0, 'f', decimalPlaces);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLSpectrumGUI::setAveragingToolitp()
|
|
|
|
{
|
|
|
|
if (m_glSpectrum)
|
|
|
|
{
|
|
|
|
QString s;
|
2018-07-01 18:15:28 -04:00
|
|
|
float averagingTime = (m_fftSize * (m_averagingNb == 0 ? 1 : m_averagingNb)) / (float) m_glSpectrum->getSampleRate();
|
2018-07-01 14:48:30 -04:00
|
|
|
setNumberStr(averagingTime, 2, s);
|
|
|
|
ui->averaging->setToolTip(QString("Number of averaging samples (avg time: %1s)").arg(s));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->averaging->setToolTip(QString("Number of averaging samples"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GLSpectrumGUI::handleMessage(const Message& message)
|
|
|
|
{
|
|
|
|
if (GLSpectrum::MsgReportSampleRate::match(message))
|
|
|
|
{
|
|
|
|
setAveragingToolitp();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLSpectrumGUI::handleInputMessages()
|
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
|
|
|
while ((message = m_messageQueue.pop()) != 0)
|
|
|
|
{
|
|
|
|
qDebug("GLSpectrumGUI::handleInputMessages: message: %s", message->getIdentifier());
|
|
|
|
|
|
|
|
if (handleMessage(*message))
|
|
|
|
{
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|