From 528b11ebd137d3e5a6903c470bdd28911c7824df Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 15 Jul 2015 08:48:02 +0200 Subject: [PATCH] Refactoring spectrum histogram display #1 --- include-gpl/gui/glspectrum.h | 1 + include-gpl/gui/glspectrumgui.h | 6 +- sdrbase/gui/glspectrum.cpp | 9 +- sdrbase/gui/glspectrumgui.cpp | 49 +++++++++- sdrbase/gui/glspectrumgui.ui | 162 +++++++++++++------------------- 5 files changed, 119 insertions(+), 108 deletions(-) diff --git a/include-gpl/gui/glspectrum.h b/include-gpl/gui/glspectrum.h index a8824fa1a..41c00c422 100644 --- a/include-gpl/gui/glspectrum.h +++ b/include-gpl/gui/glspectrum.h @@ -132,6 +132,7 @@ private: int m_histogramHoldoffBase; int m_histogramHoldoffCount; int m_histogramLateHoldoff; + int m_histogramStroke; QRectF m_glHistogramRect; bool m_displayHistogram; diff --git a/include-gpl/gui/glspectrumgui.h b/include-gpl/gui/glspectrumgui.h index 5e3ce0a72..24d901105 100644 --- a/include-gpl/gui/glspectrumgui.h +++ b/include-gpl/gui/glspectrumgui.h @@ -39,6 +39,8 @@ private: Real m_refLevel; Real m_powerRange; int m_decay; + int m_histogramLateHoldoff; + int m_histogramStroke; int m_displayGridIntensity; bool m_displayWaterfall; bool m_invertedWaterfall; @@ -54,7 +56,9 @@ private slots: void on_fftSize_currentIndexChanged(int index); void on_refLevel_currentIndexChanged(int index); void on_levelRange_currentIndexChanged(int index); - void on_decay_currentIndexChanged(int index); + void on_decay_valueChanged(int index); + void on_holdoff_valueChanged(int index); + void on_stroke_valueChanged(int index); void on_gridIntensity_valueChanged(int index); void on_waterfall_toggled(bool checked); diff --git a/sdrbase/gui/glspectrum.cpp b/sdrbase/gui/glspectrum.cpp index 21730e7b0..226f46c40 100644 --- a/sdrbase/gui/glspectrum.cpp +++ b/sdrbase/gui/glspectrum.cpp @@ -86,9 +86,10 @@ GLSpectrum::GLSpectrum(QWidget* parent) : ((quint8*)&m_histogramPalette[i])[2] = c.blue(); ((quint8*)&m_histogramPalette[i])[3] = c.alpha(); } - m_histogramHoldoffBase = 4; + m_histogramHoldoffBase = 1; // was 4 m_histogramHoldoffCount = m_histogramHoldoffBase; - m_histogramLateHoldoff = 20; + m_histogramLateHoldoff = 1; // was 20 + m_histogramStroke = 40; // was 4 m_timeScale.setFont(font()); m_timeScale.setOrientation(Qt::Vertical); @@ -332,7 +333,7 @@ void GLSpectrum::updateHistogram(const std::vector& spectrum) m_histogramHoldoffCount = m_histogramHoldoffBase; } -//#define NO_AVX +#define NO_AVX #ifdef NO_AVX for(int i = 0; i < m_fftSize; i++) { int v = (int)((spectrum[i] - m_referenceLevel) * 100.0 / m_powerRange + 100.0); @@ -340,7 +341,7 @@ void GLSpectrum::updateHistogram(const std::vector& spectrum) if((v >= 0) && (v <= 99)) { b = m_histogram + i * 100 + v; if(*b < 220) - *b += 4; + *b += m_histogramStroke; // was 4 else if(*b < 239) *b += 1; } diff --git a/sdrbase/gui/glspectrumgui.cpp b/sdrbase/gui/glspectrumgui.cpp index 65b77acb1..b821e6816 100644 --- a/sdrbase/gui/glspectrumgui.cpp +++ b/sdrbase/gui/glspectrumgui.cpp @@ -17,6 +17,8 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) : m_refLevel(0), m_powerRange(100), m_decay(0), + m_histogramLateHoldoff(1), + m_histogramStroke(40), m_displayGridIntensity(1), m_displayWaterfall(true), m_invertedWaterfall(false), @@ -53,6 +55,8 @@ void GLSpectrumGUI::resetToDefaults() m_refLevel = 0; m_powerRange = 100; m_decay = 0; + m_histogramLateHoldoff = 1; + m_histogramStroke = 40; m_displayGridIntensity = 5, m_displayWaterfall = true; m_invertedWaterfall = false; @@ -76,9 +80,11 @@ QByteArray GLSpectrumGUI::serialize() const s.writeBool(8, m_displayMaxHold); s.writeBool(9, m_displayHistogram); s.writeS32(10, m_decay); - s.writeS32(13, m_displayGridIntensity); s.writeBool(11, m_displayGrid); s.writeBool(12, m_invert); + s.writeS32(13, m_displayGridIntensity); + s.writeS32(14, m_histogramLateHoldoff); + s.writeS32(15, m_histogramStroke); return s.final(); } @@ -102,9 +108,11 @@ bool GLSpectrumGUI::deserialize(const QByteArray& data) d.readBool(8, &m_displayMaxHold, false); d.readBool(9, &m_displayHistogram, false); d.readS32(10, &m_decay, 0); - d.readS32(13, &m_displayGridIntensity, 0); d.readBool(11, &m_displayGrid, false); d.readBool(12, &m_invert, true); + d.readS32(13, &m_displayGridIntensity, 0); + d.readS32(14, &m_histogramLateHoldoff, 1); + d.readS32(15, &m_histogramStroke, 40); applySettings(); return true; } else { @@ -124,7 +132,9 @@ void GLSpectrumGUI::applySettings() } ui->refLevel->setCurrentIndex(-m_refLevel / 5); ui->levelRange->setCurrentIndex((100 - m_powerRange) / 5); - ui->decay->setCurrentIndex(m_decay + 2); + ui->decay->setSliderPosition(m_decay); + ui->holdoff->setSliderPosition(m_histogramLateHoldoff); + ui->stroke->setSliderPosition(m_histogramStroke); ui->waterfall->setChecked(m_displayWaterfall); ui->maxHold->setChecked(m_displayMaxHold); ui->histogram->setChecked(m_displayHistogram); @@ -132,6 +142,11 @@ void GLSpectrumGUI::applySettings() ui->grid->setChecked(m_displayGrid); ui->gridIntensity->setSliderPosition(m_displayGridIntensity); + ui->decay->setToolTip(QString("Decay: %1").arg(m_decay)); + ui->holdoff->setToolTip(QString("Holdoff: %1").arg(m_histogramLateHoldoff)); + ui->stroke->setToolTip(QString("Stroke: %1").arg(m_histogramStroke)); + ui->gridIntensity->setToolTip(QString("Grid intensity: %1").arg(m_displayGridIntensity)); + m_glSpectrum->setDisplayWaterfall(m_displayWaterfall); m_glSpectrum->setInvertedWaterfall(m_invertedWaterfall); m_glSpectrum->setDisplayMaxHold(m_displayMaxHold); @@ -173,9 +188,32 @@ void GLSpectrumGUI::on_levelRange_currentIndexChanged(int index) m_glSpectrum->setPowerRange(m_powerRange); } -void GLSpectrumGUI::on_decay_currentIndexChanged(int index) +void GLSpectrumGUI::on_decay_valueChanged(int index) { - m_decay = index - 2; + m_decay = index; + ui->decay->setToolTip(QString("Decay: %1").arg(m_decay)); + if(m_glSpectrum != NULL) + m_glSpectrum->setDecay(m_decay); +} + +void GLSpectrumGUI::on_holdoff_valueChanged(int index) +{ + if (index < 1) { + return; + } + m_histogramLateHoldoff = index; + ui->holdoff->setToolTip(QString("Holdoff: %1").arg(m_histogramLateHoldoff)); + if(m_glSpectrum != NULL) + m_glSpectrum->setDecay(m_decay); +} + +void GLSpectrumGUI::on_stroke_valueChanged(int index) +{ + if (index < 4) { + return; + } + m_histogramStroke = index; + ui->stroke->setToolTip(QString("Stroke: %1").arg(m_histogramStroke)); if(m_glSpectrum != NULL) m_glSpectrum->setDecay(m_decay); } @@ -218,6 +256,7 @@ void GLSpectrumGUI::on_grid_toggled(bool checked) void GLSpectrumGUI::on_gridIntensity_valueChanged(int index) { m_displayGridIntensity = index; + ui->gridIntensity->setToolTip(QString("Grid intensity: %1").arg(m_displayGridIntensity)); if(m_glSpectrum != NULL) m_glSpectrum->setDisplayGridIntensity(m_displayGridIntensity); } diff --git a/sdrbase/gui/glspectrumgui.ui b/sdrbase/gui/glspectrumgui.ui index ccaba4635..02be5b570 100644 --- a/sdrbase/gui/glspectrumgui.ui +++ b/sdrbase/gui/glspectrumgui.ui @@ -217,107 +217,74 @@ - - - - - 0 - 0 - - - - - 30 - 0 - - - - - 100 - 16777215 - - - - Decay adjust - - - 0 - - - QComboBox::AdjustToContents - - - - -2 - - - - - -1 - - - - - 0 - - - - - +1 - - - - - +2 - - - - - +3 - - - - - +4 - - - - - +5 - - - - - +6 - - - - - +7 - - - - - +8 - - - - - +9 - - - - - +10 - - - - - + 3 + + + + + 24 + 24 + + + + Decay: + + + 10 + + + 1 + + + + + + + + 24 + 24 + + + + Holdoff: + + + 1 + + + 100 + + + 1 + + + + + + + + 24 + 24 + + + + Stroke: + + + 4 + + + 100 + + + 1 + + + @@ -534,7 +501,6 @@ fftSize refLevel levelRange - decay waterfall histogram maxHold