From ccb76331541605c822085f9244e9fb8998977de0 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 5 Jun 2021 19:26:26 +0200 Subject: [PATCH] GLScope redesign: removed SpectrumScopeComboVis --- plugins/channelrx/chanalyzer/chanalyzer.h | 2 +- .../channelrx/chanalyzer/chanalyzerbaseband.h | 4 +- .../channelrx/chanalyzer/chanalyzergui.cpp | 6 +-- plugins/channelrx/chanalyzer/chanalyzergui.h | 2 - .../channelrx/chanalyzer/chanalyzersink.cpp | 13 +++-- plugins/channelrx/chanalyzer/chanalyzersink.h | 6 +-- .../feature/demodanalyzer/demodanalyzer.cpp | 6 +-- plugins/feature/demodanalyzer/demodanalyzer.h | 1 - .../demodanalyzer/demodanalyzergui.cpp | 5 +- .../feature/demodanalyzer/demodanalyzergui.h | 2 - .../demodanalyzer/demodanalyzerworker.cpp | 9 ++-- .../demodanalyzer/demodanalyzerworker.h | 5 +- sdrbase/dsp/scopevis.cpp | 6 +++ sdrbase/dsp/scopevis.h | 3 ++ sdrgui/CMakeLists.txt | 2 - sdrgui/dsp/spectrumscopecombovis.cpp | 52 ------------------- sdrgui/dsp/spectrumscopecombovis.h | 28 ---------- 17 files changed, 36 insertions(+), 116 deletions(-) delete mode 100644 sdrgui/dsp/spectrumscopecombovis.cpp delete mode 100644 sdrgui/dsp/spectrumscopecombovis.h diff --git a/plugins/channelrx/chanalyzer/chanalyzer.h b/plugins/channelrx/chanalyzer/chanalyzer.h index c9acedaba..dcf4a27d7 100644 --- a/plugins/channelrx/chanalyzer/chanalyzer.h +++ b/plugins/channelrx/chanalyzer/chanalyzer.h @@ -62,7 +62,7 @@ public: virtual void destroy() { delete this; } SpectrumVis *getSpectrumVis() { return &m_spectrumVis; } ScopeVis *getScopeVis() { return &m_scopeVis; } - void setSampleSink(BasebandSampleSink *sink) { m_basebandSink->setSampleSink(sink); } + void setScopeVis(ScopeVis *scopeVis) { m_basebandSink->setScopeVis(scopeVis); } int getChannelSampleRate() const { return m_basebandSink->getChannelSampleRate(); } int getDecimation() const { return 1< #include "device/deviceuiset.h" -#include "dsp/spectrumscopecombovis.h" #include "dsp/spectrumvis.h" #include "dsp/dspengine.h" #include "dsp/dspcommands.h" @@ -475,9 +474,9 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceUISet *device m_spectrumVis->setGLSpectrum(ui->glSpectrum); m_scopeVis = m_channelAnalyzer->getScopeVis(); m_scopeVis->setGLScope(ui->glScope); - m_spectrumScopeComboVis = new SpectrumScopeComboVis(m_spectrumVis, m_scopeVis); m_basebandSampleRate = m_channelAnalyzer->getChannelSampleRate(); - m_channelAnalyzer->setSampleSink(m_spectrumScopeComboVis); + m_scopeVis->setSpectrumVis(m_spectrumVis); + m_channelAnalyzer->setScopeVis(m_scopeVis); m_channelAnalyzer->setMessageQueueToGUI(getInputMessageQueue()); ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03))); @@ -529,7 +528,6 @@ ChannelAnalyzerGUI::~ChannelAnalyzerGUI() qDebug("ChannelAnalyzerGUI::~ChannelAnalyzerGUI"); ui->glScope->disconnectTimer(); delete ui; - delete m_spectrumScopeComboVis; qDebug("ChannelAnalyzerGUI::~ChannelAnalyzerGUI: done"); } diff --git a/plugins/channelrx/chanalyzer/chanalyzergui.h b/plugins/channelrx/chanalyzer/chanalyzergui.h index 9a6987f9e..ab088f13a 100644 --- a/plugins/channelrx/chanalyzer/chanalyzergui.h +++ b/plugins/channelrx/chanalyzer/chanalyzergui.h @@ -30,7 +30,6 @@ class PluginAPI; class DeviceUISet; class BasebandSampleSink; class ChannelAnalyzer; -class SpectrumScopeComboVis; class SpectrumVis; class ScopeVis; @@ -65,7 +64,6 @@ private: MovingAverageUtil m_channelPowerAvg; ChannelAnalyzer* m_channelAnalyzer; - SpectrumScopeComboVis* m_spectrumScopeComboVis; SpectrumVis* m_spectrumVis; ScopeVis* m_scopeVis; MessageQueue m_inputMessageQueue; diff --git a/plugins/channelrx/chanalyzer/chanalyzersink.cpp b/plugins/channelrx/chanalyzer/chanalyzersink.cpp index 15a80ac14..18e31d8c4 100644 --- a/plugins/channelrx/chanalyzer/chanalyzersink.cpp +++ b/plugins/channelrx/chanalyzer/chanalyzersink.cpp @@ -21,7 +21,7 @@ #include #include -#include "dsp/basebandsamplesink.h" +#include "dsp/scopevis.h" const unsigned int ChannelAnalyzerSink::m_ssbFftLen = 1024; const unsigned int ChannelAnalyzerSink::m_corrFFTLen = 4*m_ssbFftLen; @@ -31,7 +31,7 @@ ChannelAnalyzerSink::ChannelAnalyzerSink() : m_channelFrequencyOffset(0), m_sinkSampleRate(48000), m_costasLoop(0.002, 2), - m_sampleSink(nullptr) + m_scopeVis(nullptr) { m_usb = true; m_magsq = 0; @@ -90,9 +90,12 @@ void ChannelAnalyzerSink::feed(const SampleVector::const_iterator& begin, const } } - if (m_sampleSink) { - m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), m_settings.m_ssb); // m_ssb = positive only - } + if (m_scopeVis) + { + std::vector vbegin; + vbegin.push_back(m_sampleBuffer.begin()); + m_scopeVis->feed(vbegin, m_sampleBuffer.end() - m_sampleBuffer.begin()); + } m_sampleBuffer.clear(); } diff --git a/plugins/channelrx/chanalyzer/chanalyzersink.h b/plugins/channelrx/chanalyzer/chanalyzersink.h index 21f5cf156..081fffafe 100644 --- a/plugins/channelrx/chanalyzer/chanalyzersink.h +++ b/plugins/channelrx/chanalyzer/chanalyzersink.h @@ -33,7 +33,7 @@ #include "chanalyzersettings.h" -class BasebandSampleSink; +class ScopeVis; class ChannelAnalyzerSink : public ChannelSampleSink { public: @@ -51,7 +51,7 @@ public: Real getPllFrequency() const; Real getPllDeltaPhase() const; Real getPllPhase() const; - void setSampleSink(BasebandSampleSink* sampleSink) { m_sampleSink = sampleSink; } + void setScopeVis(ScopeVis* scopeVis) { m_scopeVis = scopeVis; } static const unsigned int m_corrFFTLen; static const unsigned int m_ssbFftLen; @@ -82,7 +82,7 @@ private: SampleVector m_sampleBuffer; MovingAverageUtil m_channelPowerAvg; - BasebandSampleSink* m_sampleSink; + ScopeVis* m_scopeVis; void setFilters(int sampleRate, float bandwidth, float lowCutoff); void processOneSample(Complex& c, fftfilt::cmplx *sideband); diff --git a/plugins/feature/demodanalyzer/demodanalyzer.cpp b/plugins/feature/demodanalyzer/demodanalyzer.cpp index 35d45d47b..962bcbc42 100644 --- a/plugins/feature/demodanalyzer/demodanalyzer.cpp +++ b/plugins/feature/demodanalyzer/demodanalyzer.cpp @@ -54,6 +54,7 @@ DemodAnalyzer::DemodAnalyzer(WebAPIAdapterInterface *webAPIAdapterInterface) : qDebug("DemodAnalyzer::DemodAnalyzer: webAPIAdapterInterface: %p", webAPIAdapterInterface); setObjectName(m_featureId); m_worker = new DemodAnalyzerWorker(); + m_worker->setScopeVis(&m_scopeVis); m_state = StIdle; m_errorMessage = "DemodAnalyzer error"; m_networkManager = new QNetworkAccessManager(); @@ -108,11 +109,6 @@ void DemodAnalyzer::stop() m_thread.wait(); } -void DemodAnalyzer::setSampleSink(BasebandSampleSink *sink) -{ - m_worker->setSampleSink(sink); -} - double DemodAnalyzer::getMagSqAvg() const { return m_worker->getMagSqAvg(); diff --git a/plugins/feature/demodanalyzer/demodanalyzer.h b/plugins/feature/demodanalyzer/demodanalyzer.h index a616ed93c..d69a10ec0 100644 --- a/plugins/feature/demodanalyzer/demodanalyzer.h +++ b/plugins/feature/demodanalyzer/demodanalyzer.h @@ -158,7 +158,6 @@ public: virtual void destroy() { delete this; } SpectrumVis *getSpectrumVis() { return &m_spectrumVis; } ScopeVis *getScopeVis() { return &m_scopeVis; } - void setSampleSink(BasebandSampleSink *sink); double getMagSqAvg() const; virtual bool handleMessage(const Message& cmd); diff --git a/plugins/feature/demodanalyzer/demodanalyzergui.cpp b/plugins/feature/demodanalyzer/demodanalyzergui.cpp index bdda2b757..4e913de65 100644 --- a/plugins/feature/demodanalyzer/demodanalyzergui.cpp +++ b/plugins/feature/demodanalyzer/demodanalyzergui.cpp @@ -18,7 +18,6 @@ #include #include "feature/featureuiset.h" -#include "dsp/spectrumscopecombovis.h" #include "dsp/spectrumvis.h" #include "gui/basicfeaturesettingsdialog.h" #include "gui/glspectrum.h" @@ -146,8 +145,7 @@ DemodAnalyzerGUI::DemodAnalyzerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUI m_scopeVis->setGLScope(ui->glScope); m_spectrumVis = m_demodAnalyzer->getSpectrumVis(); m_spectrumVis->setGLSpectrum(ui->glSpectrum); - m_spectrumScopeComboVis = new SpectrumScopeComboVis(m_spectrumVis, m_scopeVis); - m_demodAnalyzer->setSampleSink(m_spectrumScopeComboVis); + m_scopeVis->setSpectrumVis(m_spectrumVis); m_featureUISet->addRollupWidget(this); @@ -180,7 +178,6 @@ DemodAnalyzerGUI::DemodAnalyzerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUI DemodAnalyzerGUI::~DemodAnalyzerGUI() { delete ui; - delete m_spectrumScopeComboVis; } void DemodAnalyzerGUI::blockApplySettings(bool block) diff --git a/plugins/feature/demodanalyzer/demodanalyzergui.h b/plugins/feature/demodanalyzer/demodanalyzergui.h index 7d7b90960..bdaa19236 100644 --- a/plugins/feature/demodanalyzer/demodanalyzergui.h +++ b/plugins/feature/demodanalyzer/demodanalyzergui.h @@ -30,7 +30,6 @@ class PluginAPI; class FeatureUISet; class DemodAnalyzer; class Feature; -class SpectrumScopeComboVis; class SpectrumVis; class ScopeVis; @@ -58,7 +57,6 @@ private: bool m_doApplySettings; DemodAnalyzer* m_demodAnalyzer; - SpectrumScopeComboVis* m_spectrumScopeComboVis; SpectrumVis* m_spectrumVis; ScopeVis* m_scopeVis; MessageQueue m_inputMessageQueue; diff --git a/plugins/feature/demodanalyzer/demodanalyzerworker.cpp b/plugins/feature/demodanalyzer/demodanalyzerworker.cpp index c83019825..f8597ddd1 100644 --- a/plugins/feature/demodanalyzer/demodanalyzerworker.cpp +++ b/plugins/feature/demodanalyzer/demodanalyzerworker.cpp @@ -17,7 +17,7 @@ #include -#include "dsp/basebandsamplesink.h" +#include "dsp/scopevis.h" #include "dsp/datafifo.h" #include "demodanalyzerworker.h" @@ -95,8 +95,11 @@ void DemodAnalyzerWorker::feedPart(const QByteArray::const_iterator& begin, cons } } - if (m_sampleSink) { - m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.begin() + countSamples/(1< vbegin; + vbegin.push_back(m_sampleBuffer.begin()); + m_scopeVis->feed(vbegin, countSamples/(1< m_decimators; int m_sampleBufferSize; MovingAverageUtil m_channelPowerAvg; - BasebandSampleSink* m_sampleSink; + ScopeVis* m_scopeVis; bool m_running; QMutex m_mutex; diff --git a/sdrbase/dsp/scopevis.cpp b/sdrbase/dsp/scopevis.cpp index bc8dc73aa..4b8aa314e 100644 --- a/sdrbase/dsp/scopevis.cpp +++ b/sdrbase/dsp/scopevis.cpp @@ -21,6 +21,7 @@ #include #include "scopevis.h" +#include "spectrumvis.h" #include "dsp/dspcommands.h" #include "dsp/glscopeinterface.h" @@ -41,6 +42,7 @@ MESSAGE_CLASS_DEFINITION(ScopeVis::MsgScopeVisNGMemoryTrace, Message) ScopeVis::ScopeVis() : m_glScope(nullptr), + m_spectrumVis(nullptr), m_messageQueueToGUI(nullptr), m_preTriggerDelay(0), m_livePreTriggerDelay(0), @@ -524,6 +526,10 @@ int ScopeVis::processTraces(const SampleVector::const_iterator& cbegin, int ilen uint32_t length = m_traceSize / m_timeBase; int remainder = ilength; + if (m_spectrumVis) { + m_spectrumVis->feed(cbegin, cbegin + ilength, false); + } + while ((remainder > 0) && (m_nbSamples > 0)) { std::vector::iterator itCtl = m_traces.m_tracesControl.begin(); diff --git a/sdrbase/dsp/scopevis.h b/sdrbase/dsp/scopevis.h index 4db848487..ed52befc3 100644 --- a/sdrbase/dsp/scopevis.h +++ b/sdrbase/dsp/scopevis.h @@ -40,6 +40,7 @@ class GLScopeInterface; +class SpectrumVis; class SDRBASE_API ScopeVis : public QObject { Q_OBJECT @@ -48,6 +49,7 @@ public: virtual ~ScopeVis(); void setGLScope(GLScopeInterface* glScope); + void setSpectrumVis(SpectrumVis *spectrumVis) { m_spectrumVis = spectrumVis; } void setMessageQueueToGUI(MessageQueue* messageQueue) { m_messageQueueToGUI = messageQueue; } MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication @@ -1040,6 +1042,7 @@ private: }; GLScopeInterface* m_glScope; + SpectrumVis *m_spectrumVis; MessageQueue m_inputMessageQueue; MessageQueue *m_messageQueueToGUI; uint32_t m_preTriggerDelay; //!< Pre-trigger delay in number of samples diff --git a/sdrgui/CMakeLists.txt b/sdrgui/CMakeLists.txt index a88402c5f..bb807f9b6 100644 --- a/sdrgui/CMakeLists.txt +++ b/sdrgui/CMakeLists.txt @@ -69,7 +69,6 @@ set(sdrgui_SOURCES gui/wrappingdatetimeedit.cpp dsp/scopevisxy.cpp - dsp/spectrumscopecombovis.cpp device/deviceuiset.cpp @@ -157,7 +156,6 @@ set(sdrgui_HEADERS gui/wrappingdatetimeedit.h dsp/scopevisxy.h - dsp/spectrumscopecombovis.h device/deviceuiset.h diff --git a/sdrgui/dsp/spectrumscopecombovis.cpp b/sdrgui/dsp/spectrumscopecombovis.cpp deleted file mode 100644 index 984b0134a..000000000 --- a/sdrgui/dsp/spectrumscopecombovis.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "dsp/spectrumscopecombovis.h" -#include "dsp/dspcommands.h" -#include "dsp/scopevis.h" -#include "util/messagequeue.h" - -SpectrumScopeComboVis::SpectrumScopeComboVis(SpectrumVis* spectrumVis, ScopeVis* scopeVis) : - m_spectrumVis(spectrumVis), - m_scopeVis(scopeVis) -{ - setObjectName("SpectrumScopeComboVis"); -} - -SpectrumScopeComboVis::~SpectrumScopeComboVis() -{ -} - -void SpectrumScopeComboVis::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly) -{ - (void) positiveOnly; - std::vector vbegin; - vbegin.push_back(begin); - m_scopeVis->feed(vbegin, end - begin); - //SampleVector::const_iterator triggerPoint = m_scopeVis->getTriggerPoint(); - //m_spectrumVis->feedTriggered(triggerPoint, end, positiveOnly); - int triggerPointLocation = m_scopeVis->getTriggerLocation(); - - if (m_scopeVis->getFreeRun()) { - m_spectrumVis->feed(begin, end, positiveOnly); - } else if ((triggerPointLocation >= 0) && (triggerPointLocation <= end - begin)) { - m_spectrumVis->feedTriggered(end - triggerPointLocation, end, positiveOnly); - } else { - m_spectrumVis->feedTriggered(begin, end, positiveOnly); - } -} - -void SpectrumScopeComboVis::start() -{ - m_spectrumVis->start(); -} - -void SpectrumScopeComboVis::stop() -{ - m_spectrumVis->stop(); -} - -bool SpectrumScopeComboVis::handleMessage(const Message& message) -{ - bool spectDone = m_spectrumVis->handleMessage(message); - bool scopeDone = m_scopeVis->handleMessage(message); - - return (spectDone || scopeDone); -} diff --git a/sdrgui/dsp/spectrumscopecombovis.h b/sdrgui/dsp/spectrumscopecombovis.h deleted file mode 100644 index d5ba4d46e..000000000 --- a/sdrgui/dsp/spectrumscopecombovis.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef INCLUDE_SPECTRUMSCOPENGCOMBOVIS_H -#define INCLUDE_SPECTRUMSCOPENGCOMBOVIS_H - -#include -#include "dsp/spectrumvis.h" -#include "export.h" - -class Message; -class ScopeVis; - -class SDRGUI_API SpectrumScopeComboVis : public BasebandSampleSink { -public: - - SpectrumScopeComboVis(SpectrumVis* spectrumVis, ScopeVis* scopeVis); - virtual ~SpectrumScopeComboVis(); - - using BasebandSampleSink::feed; - virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); - virtual void start(); - virtual void stop(); - virtual bool handleMessage(const Message& message); - -private: - SpectrumVis* m_spectrumVis; - ScopeVis* m_scopeVis; -}; - -#endif // INCLUDE_SPECTRUMSCOPENGCOMBOVIS_H