From 97efda734ff422fb9b0a00f6ef4ea47467d8ac2c Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 29 Aug 2020 11:10:11 +0200 Subject: [PATCH] GLSpectrum: fixed settings and waterfall share serialization. Fixes #609 --- sdrbase/dsp/glspectrumsettings.cpp | 8 +++++--- sdrgui/gui/glspectrum.cpp | 5 +++++ sdrgui/gui/glspectrum.h | 19 ++++++++++++++++--- sdrgui/gui/glspectrumgui.cpp | 8 +++++++- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/sdrbase/dsp/glspectrumsettings.cpp b/sdrbase/dsp/glspectrumsettings.cpp index 08750fc49..310828b60 100644 --- a/sdrbase/dsp/glspectrumsettings.cpp +++ b/sdrbase/dsp/glspectrumsettings.cpp @@ -39,8 +39,10 @@ void GLSpectrumSettings::resetToDefaults() m_histogramStroke = 30; m_displayGridIntensity = 5; m_displayTraceIntensity = 50; + m_displayCurrent = true; m_displayWaterfall = true; - m_invertedWaterfall = false; + m_invertedWaterfall = true; + m_waterfallShare = 0.66; m_displayMaxHold = false; m_displayHistogram = false; m_displayGrid = false; @@ -99,7 +101,7 @@ bool GLSpectrumSettings::deserialize(const QByteArray& data) 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(7, &m_invertedWaterfall, true); d.readBool(8, &m_displayMaxHold, false); d.readBool(9, &m_displayHistogram, false); d.readS32(10, &m_decay, 1); @@ -108,7 +110,7 @@ bool GLSpectrumSettings::deserialize(const QByteArray& data) 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.readBool(16, &m_displayCurrent, true); d.readS32(17, &m_displayTraceIntensity, 50); d.readReal(18, &m_waterfallShare, 0.66); d.readS32(19, &tmp, 0); diff --git a/sdrgui/gui/glspectrum.cpp b/sdrgui/gui/glspectrum.cpp index 5a410f991..e0df70ed1 100644 --- a/sdrgui/gui/glspectrum.cpp +++ b/sdrgui/gui/glspectrum.cpp @@ -31,6 +31,7 @@ #include MESSAGE_CLASS_DEFINITION(GLSpectrum::MsgReportSampleRate, Message) +MESSAGE_CLASS_DEFINITION(GLSpectrum::MsgReportWaterfallShare, Message) GLSpectrum::GLSpectrum(QWidget* parent) : QGLWidget(parent), @@ -1909,6 +1910,10 @@ void GLSpectrum::mouseMoveEvent(QMouseEvent* event) m_waterfallShare = newShare; m_changesPending = true; + if (m_messageQueueToGUI) { + m_messageQueueToGUI->push(new MsgReportWaterfallShare(m_waterfallShare)); + } + update(); return; } diff --git a/sdrgui/gui/glspectrum.h b/sdrgui/gui/glspectrum.h index 64323a3e1..2d6369ccc 100644 --- a/sdrgui/gui/glspectrum.h +++ b/sdrgui/gui/glspectrum.h @@ -51,9 +51,7 @@ public: MsgReportSampleRate(quint32 sampleRate) : Message(), m_sampleRate(sampleRate) - { - m_sampleRate = sampleRate; - } + {} quint32 getSampleRate() const { return m_sampleRate; } @@ -61,6 +59,21 @@ public: quint32 m_sampleRate; }; + class MsgReportWaterfallShare : public Message { + MESSAGE_CLASS_DECLARATION + + public: + MsgReportWaterfallShare(Real waterfallShare) : + Message(), + m_waterfallShare(waterfallShare) + {} + + Real getWaterfallShare() const { return m_waterfallShare; } + + private: + Real m_waterfallShare; + }; + GLSpectrum(QWidget* parent = nullptr); virtual ~GLSpectrum(); diff --git a/sdrgui/gui/glspectrumgui.cpp b/sdrgui/gui/glspectrumgui.cpp index 4318cc7ac..2894f8adb 100644 --- a/sdrgui/gui/glspectrumgui.cpp +++ b/sdrgui/gui/glspectrumgui.cpp @@ -87,7 +87,7 @@ bool GLSpectrumGUI::deserialize(const QByteArray& data) { if (m_settings.deserialize(data)) { - displaySettings(); + displaySettings(); // ends with blockApplySettings(false) applySettings(); return true; } @@ -173,6 +173,7 @@ void GLSpectrumGUI::applySettings() m_glSpectrum->setDisplayGrid(m_settings.m_displayGrid); m_glSpectrum->setDisplayGridIntensity(m_settings.m_displayGridIntensity); m_glSpectrum->setDisplayTraceIntensity(m_settings.m_displayTraceIntensity); + m_glSpectrum->setWaterfallShare(m_settings.m_waterfallShare); if ((m_settings.m_averagingMode == GLSpectrumSettings::AvgModeFixed) || (m_settings.m_averagingMode == GLSpectrumSettings::AvgModeMax)) { m_glSpectrum->setTimingRate(getAveragingValue(m_settings.m_averagingIndex, m_settings.m_averagingMode) == 0 ? @@ -492,6 +493,11 @@ bool GLSpectrumGUI::handleMessage(const Message& message) setAveragingToolitp(); return true; } + else if (GLSpectrum::MsgReportWaterfallShare::match(message)) + { + const GLSpectrum::MsgReportWaterfallShare& report = (const GLSpectrum::MsgReportWaterfallShare&) message; + m_settings.m_waterfallShare = report.getWaterfallShare(); + } else if (SpectrumVis::MsgStartStop::match(message)) { const SpectrumVis::MsgStartStop& msg = (SpectrumVis::MsgStartStop&) message;