From e15f4f26f193289a458a9f0e7c41e1946b746753 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 12 May 2015 15:49:03 +0200 Subject: [PATCH] Added button to change the brightess of the spectrum display grid --- Readme.md | 4 ++-- include-gpl/gui/glspectrum.h | 2 ++ include-gpl/gui/glspectrumgui.h | 2 ++ sdrbase/gui/glspectrum.cpp | 15 +++++++++++++-- sdrbase/gui/glspectrumgui.cpp | 13 +++++++++++++ sdrbase/gui/glspectrumgui.ui | 6 +++--- 6 files changed, 35 insertions(+), 7 deletions(-) diff --git a/Readme.md b/Readme.md index 308ce8fb6..74a50db21 100644 --- a/Readme.md +++ b/Readme.md @@ -78,12 +78,12 @@ Done since the fork - SSB bandwidth can now be tuned in steps of 100 Hz - NFM and SSB receiver in focus trigger the display of the central frequency line on the spectrum frequency scale thus facilitating its identification - Added AM demod so now you can listen to air traffic! - + - Added the possibility to change the brightness and/or color of the grid. + ===== To Do ===== - - Add the possibility to change the brightness and/or color of the grid. Sometimes it is barely visible yet useful - Fix and possibly enhance (stereo, RDS?) WFM. Maybe into two plugins one for plain WFM and the other for Broadcast FM - Make the the SSB filter frequency bounds tunable so that it can be used for CW. Change marker overlay accordingly. - Possibility to completely undock the receiver in a separate window. Useful when there are many receivers diff --git a/include-gpl/gui/glspectrum.h b/include-gpl/gui/glspectrum.h index 2feab86df..918cbb642 100644 --- a/include-gpl/gui/glspectrum.h +++ b/include-gpl/gui/glspectrum.h @@ -43,6 +43,7 @@ public: void setDisplayMaxHold(bool display); void setDisplayHistogram(bool display); void setDisplayGrid(bool display); + void setDisplayGridIntensity(int intensity); void addChannelMarker(ChannelMarker* channelMarker); void removeChannelMarker(ChannelMarker* channelMarker); @@ -87,6 +88,7 @@ private: int m_fftSize; bool m_displayGrid; + int m_displayGridIntensity; bool m_invertedWaterfall; std::vector m_maxHold; diff --git a/include-gpl/gui/glspectrumgui.h b/include-gpl/gui/glspectrumgui.h index b515aed27..5e3ce0a72 100644 --- a/include-gpl/gui/glspectrumgui.h +++ b/include-gpl/gui/glspectrumgui.h @@ -39,6 +39,7 @@ private: Real m_refLevel; Real m_powerRange; int m_decay; + int m_displayGridIntensity; bool m_displayWaterfall; bool m_invertedWaterfall; bool m_displayMaxHold; @@ -54,6 +55,7 @@ private slots: void on_refLevel_currentIndexChanged(int index); void on_levelRange_currentIndexChanged(int index); void on_decay_currentIndexChanged(int index); + void on_gridIntensity_valueChanged(int index); void on_waterfall_toggled(bool checked); void on_histogram_toggled(bool checked); diff --git a/sdrbase/gui/glspectrum.cpp b/sdrbase/gui/glspectrum.cpp index 7e0a0a683..6d44a594a 100644 --- a/sdrbase/gui/glspectrum.cpp +++ b/sdrbase/gui/glspectrum.cpp @@ -33,6 +33,7 @@ GLSpectrum::GLSpectrum(QWidget* parent) : m_sampleRate(500000), m_fftSize(512), m_displayGrid(true), + m_displayGridIntensity(5), m_invertedWaterfall(false), m_displayMaxHold(false), m_leftMarginTextureAllocated(false), @@ -217,6 +218,15 @@ void GLSpectrum::setDisplayGrid(bool display) update(); } +void GLSpectrum::setDisplayGridIntensity(int intensity) +{ + m_displayGridIntensity = intensity; + if (m_displayGridIntensity > 100) { + m_displayGridIntensity = 100; + } + update(); +} + void GLSpectrum::addChannelMarker(ChannelMarker* channelMarker) { QMutexLocker mutexLocker(&m_mutex); @@ -727,7 +737,8 @@ void GLSpectrum::paintGL() glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glLineWidth(1.0f); - glColor4f(1, 1, 1, 0.05f); + //glColor4f(1, 1, 1, 0.05f); + glColor4f(1, 1, 1, m_displayGridIntensity / 100.0); glPushMatrix(); glTranslatef(m_glWaterfallRect.x(), m_glWaterfallRect.y(), 0); @@ -772,7 +783,7 @@ void GLSpectrum::paintGL() glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glLineWidth(1.0f); - glColor4f(1, 1, 1, 0.05f); + glColor4f(1, 1, 1, m_displayGridIntensity / 100.0); glPushMatrix(); glTranslatef(m_glHistogramRect.x(), m_glHistogramRect.y(), 0); diff --git a/sdrbase/gui/glspectrumgui.cpp b/sdrbase/gui/glspectrumgui.cpp index f44abdd2b..a750e8fff 100644 --- a/sdrbase/gui/glspectrumgui.cpp +++ b/sdrbase/gui/glspectrumgui.cpp @@ -17,6 +17,7 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) : m_refLevel(0), m_powerRange(100), m_decay(0), + m_displayGridIntensity(1), m_displayWaterfall(true), m_invertedWaterfall(false), m_displayMaxHold(false), @@ -52,6 +53,7 @@ void GLSpectrumGUI::resetToDefaults() m_refLevel = 0; m_powerRange = 100; m_decay = 0; + m_displayGridIntensity = 5, m_displayWaterfall = true; m_invertedWaterfall = false; m_displayMaxHold = false; @@ -74,6 +76,7 @@ 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); return s.final(); @@ -99,6 +102,7 @@ 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); applySettings(); @@ -126,6 +130,7 @@ void GLSpectrumGUI::applySettings() ui->histogram->setChecked(m_displayHistogram); ui->invert->setChecked(m_invert); ui->grid->setChecked(m_displayGrid); + ui->gridIntensity->setSliderPosition(m_displayGridIntensity); m_glSpectrum->setDisplayWaterfall(m_displayWaterfall); m_glSpectrum->setInvertedWaterfall(m_invertedWaterfall); @@ -134,6 +139,7 @@ void GLSpectrumGUI::applySettings() m_glSpectrum->setDecay(m_decay); m_glSpectrum->setInvertedWaterfall(m_invert); m_glSpectrum->setDisplayGrid(m_displayGrid); + m_glSpectrum->setDisplayGridIntensity(m_displayGridIntensity); m_spectrumVis->configure(m_messageQueue, m_fftSize, m_fftOverlap, (FFTWindow::Function)m_fftWindow); } @@ -208,3 +214,10 @@ void GLSpectrumGUI::on_grid_toggled(bool checked) if(m_glSpectrum != NULL) m_glSpectrum->setDisplayGrid(m_displayGrid); } + +void GLSpectrumGUI::on_gridIntensity_valueChanged(int index) +{ + m_displayGridIntensity = index; + if(m_glSpectrum != NULL) + m_glSpectrum->setDisplayGridIntensity(m_displayGridIntensity); +} diff --git a/sdrbase/gui/glspectrumgui.ui b/sdrbase/gui/glspectrumgui.ui index 9f2033fb4..c74654a0a 100644 --- a/sdrbase/gui/glspectrumgui.ui +++ b/sdrbase/gui/glspectrumgui.ui @@ -457,13 +457,13 @@ Grid intensity - 255 + 100 - 16 + 1 - 64 + 5