diff --git a/plugins/channelmimo/interferometer/interferometer.cpp b/plugins/channelmimo/interferometer/interferometer.cpp index d75bcf59f..2700c5547 100644 --- a/plugins/channelmimo/interferometer/interferometer.cpp +++ b/plugins/channelmimo/interferometer/interferometer.cpp @@ -43,7 +43,6 @@ Interferometer::Interferometer(DeviceAPI *deviceAPI) : ChannelAPI(m_channelIdURI, ChannelAPI::StreamMIMO), m_deviceAPI(deviceAPI), m_spectrumVis(SDR_RX_SCALEF), - m_scopeSink(nullptr), m_guiMessageQueue(nullptr), m_frequencyOffset(0), m_deviceSampleRate(48000) @@ -73,12 +72,6 @@ Interferometer::~Interferometer() delete m_thread; } -void Interferometer::setScopeSink(ScopeVis *scopeSink) -{ - m_scopeSink = scopeSink; - m_basebandSink->setScopeSink(scopeSink); -} - void Interferometer::startSinks() { if (m_deviceSampleRate != 0) { diff --git a/plugins/channelmimo/interferometer/interferometer.h b/plugins/channelmimo/interferometer/interferometer.h index 7b09bf24f..c6dbf3968 100644 --- a/plugins/channelmimo/interferometer/interferometer.h +++ b/plugins/channelmimo/interferometer/interferometer.h @@ -23,6 +23,7 @@ #include "dsp/mimochannel.h" #include "dsp/spectrumvis.h" +#include "dsp/scopevis.h" #include "channel/channelapi.h" #include "util/messagequeue.h" #include "util/message.h" @@ -34,7 +35,6 @@ class DeviceAPI; class InterferometerBaseband; class QNetworkReply; class QNetworkAccessManager; -class ScopeVis; class Interferometer: public MIMOChannel, public ChannelAPI { @@ -121,7 +121,7 @@ public: MessageQueue *getMessageQueueToGUI() { return m_guiMessageQueue; } SpectrumVis *getSpectrumVis() { return &m_spectrumVis; } - void setScopeSink(ScopeVis *scopeSink); + ScopeVis *getScopeVis() { return &m_scopeSink; } void applyChannelSettings(uint32_t log2Decim, uint32_t filterChainHash); virtual int webapiSettingsGet( @@ -151,8 +151,8 @@ private: DeviceAPI *m_deviceAPI; QThread *m_thread; SpectrumVis m_spectrumVis; + ScopeVis m_scopeSink; InterferometerBaseband* m_basebandSink; - ScopeVis* m_scopeSink; InterferometerSettings m_settings; MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication MessageQueue *m_guiMessageQueue; //!< Input message queue to the GUI diff --git a/plugins/channelmimo/interferometer/interferometergui.cpp b/plugins/channelmimo/interferometer/interferometergui.cpp index 35d66e50c..713df6de3 100644 --- a/plugins/channelmimo/interferometer/interferometergui.cpp +++ b/plugins/channelmimo/interferometer/interferometergui.cpp @@ -110,11 +110,11 @@ InterferometerGUI::InterferometerGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUI connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &))); - m_scopeVis = new ScopeVis(ui->glScope); - m_interferometer = (Interferometer*) channelMIMO; m_spectrumVis = m_interferometer->getSpectrumVis(); - m_interferometer->setScopeSink(m_scopeVis); + m_spectrumVis->setGLSpectrum(ui->glSpectrum); + m_scopeVis = m_interferometer->getScopeVis(); + m_scopeVis->setGLScope(ui->glScope); m_interferometer->setMessageQueueToGUI(getInputMessageQueue()); m_sampleRate = m_interferometer->getDeviceSampleRate(); @@ -159,7 +159,6 @@ InterferometerGUI::InterferometerGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUI InterferometerGUI::~InterferometerGUI() { - delete m_scopeVis; delete ui; } diff --git a/plugins/channelrx/chanalyzer/chanalyzer.h b/plugins/channelrx/chanalyzer/chanalyzer.h index 73044ea64..c9acedaba 100644 --- a/plugins/channelrx/chanalyzer/chanalyzer.h +++ b/plugins/channelrx/chanalyzer/chanalyzer.h @@ -24,6 +24,7 @@ #include "dsp/basebandsamplesink.h" #include "dsp/spectrumvis.h" +#include "dsp/scopevis.h" #include "channel/channelapi.h" #include "util/message.h" #include "util/movingaverage.h" @@ -60,6 +61,7 @@ public: virtual ~ChannelAnalyzer(); virtual void destroy() { delete this; } SpectrumVis *getSpectrumVis() { return &m_spectrumVis; } + ScopeVis *getScopeVis() { return &m_scopeVis; } void setSampleSink(BasebandSampleSink *sink) { m_basebandSink->setSampleSink(sink); } int getChannelSampleRate() const { return m_basebandSink->getChannelSampleRate(); } @@ -103,6 +105,7 @@ private: ChannelAnalyzerBaseband *m_basebandSink; ChannelAnalyzerSettings m_settings; SpectrumVis m_spectrumVis; + ScopeVis m_scopeVis; int m_basebandSampleRate; //!< stored from device message used when starting baseband sink qint64 m_centerFrequency; //!< stored from device message used when starting baseband sink diff --git a/plugins/channelrx/chanalyzer/chanalyzergui.cpp b/plugins/channelrx/chanalyzer/chanalyzergui.cpp index c30f308ab..1394c4d8f 100644 --- a/plugins/channelrx/chanalyzer/chanalyzergui.cpp +++ b/plugins/channelrx/chanalyzer/chanalyzergui.cpp @@ -467,13 +467,14 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceUISet *device ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose, true); connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); - m_scopeVis = new ScopeVis(ui->glScope); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &))); m_channelAnalyzer = (ChannelAnalyzer*) rxChannel; m_spectrumVis = m_channelAnalyzer->getSpectrumVis(); 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); @@ -529,7 +530,6 @@ ChannelAnalyzerGUI::~ChannelAnalyzerGUI() ui->glScope->disconnectTimer(); delete ui; delete m_spectrumScopeComboVis; - delete m_scopeVis; qDebug("ChannelAnalyzerGUI::~ChannelAnalyzerGUI: done"); } diff --git a/plugins/channelrx/demodais/aisdemod.cpp b/plugins/channelrx/demodais/aisdemod.cpp index e8c733398..9ff21f792 100644 --- a/plugins/channelrx/demodais/aisdemod.cpp +++ b/plugins/channelrx/demodais/aisdemod.cpp @@ -186,9 +186,9 @@ bool AISDemod::handleMessage(const Message& cmd) } } -void AISDemod::setScopeSink(ScopeVis* scopeSink) +ScopeVis *AISDemod::getScopeSink() { - m_basebandSink->setScopeSink(scopeSink); + return m_basebandSink->getScopeSink(); } void AISDemod::applySettings(const AISDemodSettings& settings, bool force) diff --git a/plugins/channelrx/demodais/aisdemod.h b/plugins/channelrx/demodais/aisdemod.h index 937807ac7..8739f9331 100644 --- a/plugins/channelrx/demodais/aisdemod.h +++ b/plugins/channelrx/demodais/aisdemod.h @@ -136,7 +136,7 @@ public: const QStringList& channelSettingsKeys, SWGSDRangel::SWGChannelSettings& response); - void setScopeSink(ScopeVis* scopeSink); + ScopeVis *getScopeSink(); double getMagSq() const { return m_basebandSink->getMagSq(); } void getMagSqLevels(double& avg, double& peak, int& nbSamples) { diff --git a/plugins/channelrx/demodais/aisdemodbaseband.cpp b/plugins/channelrx/demodais/aisdemodbaseband.cpp index c92bf67cf..f4d6971dc 100644 --- a/plugins/channelrx/demodais/aisdemodbaseband.cpp +++ b/plugins/channelrx/demodais/aisdemodbaseband.cpp @@ -33,6 +33,7 @@ AISDemodBaseband::AISDemodBaseband(AISDemod *aisDemod) : { qDebug("AISDemodBaseband::AISDemodBaseband"); + m_sink.setScopeSink(&m_scopeSink); m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(48000)); m_channelizer = new DownChannelizer(&m_sink); } diff --git a/plugins/channelrx/demodais/aisdemodbaseband.h b/plugins/channelrx/demodais/aisdemodbaseband.h index c2ceb9eb7..ce1766cc4 100644 --- a/plugins/channelrx/demodais/aisdemodbaseband.h +++ b/plugins/channelrx/demodais/aisdemodbaseband.h @@ -23,6 +23,7 @@ #include #include "dsp/samplesinkfifo.h" +#include "dsp/scopevis.h" #include "util/message.h" #include "util/messagequeue.h" @@ -72,7 +73,7 @@ public: } void setMessageQueueToChannel(MessageQueue *messageQueue) { m_sink.setMessageQueueToChannel(messageQueue); } void setBasebandSampleRate(int sampleRate); - void setScopeSink(ScopeVis* scopeSink) { m_sink.setScopeSink(scopeSink); } + ScopeVis *getScopeSink() { return &m_scopeSink; } void setChannel(ChannelAPI *channel); double getMagSq() const { return m_sink.getMagSq(); } bool isRunning() const { return m_running; } @@ -83,6 +84,7 @@ private: AISDemodSink m_sink; MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication AISDemodSettings m_settings; + ScopeVis m_scopeSink; bool m_running; QMutex m_mutex; diff --git a/plugins/channelrx/demodais/aisdemodgui.cpp b/plugins/channelrx/demodais/aisdemodgui.cpp index 923d5b4da..7df76db0f 100644 --- a/plugins/channelrx/demodais/aisdemodgui.cpp +++ b/plugins/channelrx/demodais/aisdemodgui.cpp @@ -415,8 +415,8 @@ AISDemodGUI::AISDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban connect(&MainCore::instance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); // 50 ms - m_scopeVis = new ScopeVis(ui->glScope); - m_aisDemod->setScopeSink(m_scopeVis); + m_scopeVis = m_aisDemod->getScopeSink(); + m_scopeVis->setGLScope(ui->glScope); ui->glScope->connectTimer(MainCore::instance()->getMasterTimer()); ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope); diff --git a/plugins/channelrx/demodatv/atvdemod.h b/plugins/channelrx/demodatv/atvdemod.h index afec5fecd..719c1a29b 100644 --- a/plugins/channelrx/demodatv/atvdemod.h +++ b/plugins/channelrx/demodatv/atvdemod.h @@ -88,7 +88,7 @@ public: return m_settings.m_inputFrequencyOffset; } - void setScopeSink(ScopeVis* scopeSink) { m_basebandSink->setScopeSink(scopeSink); } + ScopeVis *getScopeSink() { return m_basebandSink->getScopeSink(); } void setTVScreen(TVScreenAnalog *tvScreen) { m_basebandSink->setTVScreen(tvScreen); }; //!< set by the GUI double getMagSq() const { return m_basebandSink->getMagSq(); } //!< Beware this is scaled to 2^30 bool getBFOLocked() { return m_basebandSink->getBFOLocked(); } diff --git a/plugins/channelrx/demodatv/atvdemodbaseband.cpp b/plugins/channelrx/demodatv/atvdemodbaseband.cpp index b310c557d..2fe3f102c 100644 --- a/plugins/channelrx/demodatv/atvdemodbaseband.cpp +++ b/plugins/channelrx/demodatv/atvdemodbaseband.cpp @@ -30,6 +30,7 @@ ATVDemodBaseband::ATVDemodBaseband() : m_mutex(QMutex::Recursive) { qDebug("ATVDemodBaseband::ATVDemodBaseband"); + m_sink.setScopeSink(&m_scopeSink); m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(48000)); m_channelizer = new DownChannelizer(&m_sink); } diff --git a/plugins/channelrx/demodatv/atvdemodbaseband.h b/plugins/channelrx/demodatv/atvdemodbaseband.h index 81144e23a..01b658482 100644 --- a/plugins/channelrx/demodatv/atvdemodbaseband.h +++ b/plugins/channelrx/demodatv/atvdemodbaseband.h @@ -22,6 +22,7 @@ #include #include "dsp/samplesinkfifo.h" +#include "dsp/scopevis.h" #include "util/message.h" #include "util/messagequeue.h" @@ -65,7 +66,7 @@ public: MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication int getChannelSampleRate() const; double getMagSq() const { return m_sink.getMagSq(); } - void setScopeSink(ScopeVis* scopeSink) { m_sink.setScopeSink(scopeSink); } + ScopeVis *getScopeSink() { return &m_scopeSink; } void setTVScreen(TVScreenAnalog *tvScreen) { m_sink.setTVScreen(tvScreen); } bool getBFOLocked() { return m_sink.getBFOLocked(); } void setVideoTabIndex(int videoTabIndex) { m_sink.setVideoTabIndex(videoTabIndex); } @@ -78,6 +79,7 @@ private: ATVDemodSink m_sink; MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication ATVDemodSettings m_settings; + ScopeVis m_scopeSink; bool m_running; QMutex m_mutex; diff --git a/plugins/channelrx/demodatv/atvdemodgui.cpp b/plugins/channelrx/demodatv/atvdemodgui.cpp index fdc94e4a6..497a167ba 100644 --- a/plugins/channelrx/demodatv/atvdemodgui.cpp +++ b/plugins/channelrx/demodatv/atvdemodgui.cpp @@ -222,10 +222,10 @@ ATVDemodGUI::ATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, Base setAttribute(Qt::WA_DeleteOnClose, true); connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); - m_scopeVis = new ScopeVis(ui->glScope); m_atvDemod = (ATVDemod*) rxChannel; m_atvDemod->setMessageQueueToGUI(getInputMessageQueue()); - m_atvDemod->setScopeSink(m_scopeVis); + m_scopeVis = m_atvDemod->getScopeSink(); + m_scopeVis->setGLScope(ui->glScope); m_atvDemod->setTVScreen(ui->screenTV); ui->glScope->connectTimer(MainCore::instance()->getMasterTimer()); @@ -276,7 +276,6 @@ ATVDemodGUI::ATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, Base ATVDemodGUI::~ATVDemodGUI() { - delete m_scopeVis; delete ui; } diff --git a/plugins/channelrx/demoddsd/dsddemodgui.h b/plugins/channelrx/demoddsd/dsddemodgui.h index 0bb115aa5..31809e6d1 100644 --- a/plugins/channelrx/demoddsd/dsddemodgui.h +++ b/plugins/channelrx/demoddsd/dsddemodgui.h @@ -33,7 +33,6 @@ class PluginAPI; class DeviceUISet; class BasebandSampleSink; -class ScopeVis; class ScopeVisXY; class DSDDemod; diff --git a/plugins/channeltx/mod802.15.4/ieee_802_15_4_mod.cpp b/plugins/channeltx/mod802.15.4/ieee_802_15_4_mod.cpp index 41269015e..4a38eefbe 100644 --- a/plugins/channeltx/mod802.15.4/ieee_802_15_4_mod.cpp +++ b/plugins/channeltx/mod802.15.4/ieee_802_15_4_mod.cpp @@ -607,9 +607,9 @@ uint32_t IEEE_802_15_4_Mod::getNumberOfDeviceStreams() const return m_deviceAPI->getNbSinkStreams(); } -void IEEE_802_15_4_Mod::setScopeSink(ScopeVis* scopeSink) +ScopeVis *IEEE_802_15_4_Mod::getScopeSink() { - m_basebandSource->setScopeSink(scopeSink); + return m_basebandSource->getScopeSink(); } void IEEE_802_15_4_Mod::openUDP(const IEEE_802_15_4_ModSettings& settings) diff --git a/plugins/channeltx/mod802.15.4/ieee_802_15_4_mod.h b/plugins/channeltx/mod802.15.4/ieee_802_15_4_mod.h index cdf3c9013..7f2f09adb 100644 --- a/plugins/channeltx/mod802.15.4/ieee_802_15_4_mod.h +++ b/plugins/channeltx/mod802.15.4/ieee_802_15_4_mod.h @@ -144,7 +144,7 @@ public: SWGSDRangel::SWGChannelSettings& response); SpectrumVis *getSpectrumVis() { return &m_spectrumVis; } - void setScopeSink(ScopeVis* scopeSink); + ScopeVis *getScopeSink(); double getMagSq() const; void setLevelMeter(QObject *levelMeter); uint32_t getNumberOfDeviceStreams() const; diff --git a/plugins/channeltx/mod802.15.4/ieee_802_15_4_modbaseband.cpp b/plugins/channeltx/mod802.15.4/ieee_802_15_4_modbaseband.cpp index 50fcdf5c5..87d0758e9 100644 --- a/plugins/channeltx/mod802.15.4/ieee_802_15_4_modbaseband.cpp +++ b/plugins/channeltx/mod802.15.4/ieee_802_15_4_modbaseband.cpp @@ -32,6 +32,7 @@ IEEE_802_15_4_ModBaseband::IEEE_802_15_4_ModBaseband() : { m_sampleFifo.resize(SampleSourceFifo::getSizePolicy(48000)); m_channelizer = new UpChannelizer(&m_source); + m_source.setScopeSink(&m_scopeSink); qDebug("IEEE_802_15_4_ModBaseband::IEEE_802_15_4_ModBaseband"); QObject::connect( diff --git a/plugins/channeltx/mod802.15.4/ieee_802_15_4_modbaseband.h b/plugins/channeltx/mod802.15.4/ieee_802_15_4_modbaseband.h index c29876a32..39f5240c0 100644 --- a/plugins/channeltx/mod802.15.4/ieee_802_15_4_modbaseband.h +++ b/plugins/channeltx/mod802.15.4/ieee_802_15_4_modbaseband.h @@ -23,6 +23,7 @@ #include #include "dsp/samplesourcefifo.h" +#include "dsp/scopevis.h" #include "util/message.h" #include "util/messagequeue.h" @@ -66,7 +67,7 @@ public: double getMagSq() const { return m_source.getMagSq(); } int getChannelSampleRate() const; void setSpectrumSampleSink(BasebandSampleSink* sampleSink) { m_source.setSpectrumSink(sampleSink); } - void setScopeSink(ScopeVis* scopeSink) { m_source.setScopeSink(scopeSink); } + ScopeVis *getScopeSink() { return &m_scopeSink; } signals: @@ -84,6 +85,7 @@ private: IEEE_802_15_4_ModSource m_source; MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication IEEE_802_15_4_ModSettings m_settings; + ScopeVis m_scopeSink; QMutex m_mutex; void processFifo(SampleVector& data, unsigned int iBegin, unsigned int iEnd); diff --git a/plugins/channeltx/mod802.15.4/ieee_802_15_4_modgui.cpp b/plugins/channeltx/mod802.15.4/ieee_802_15_4_modgui.cpp index e5c10c717..283a5d058 100644 --- a/plugins/channeltx/mod802.15.4/ieee_802_15_4_modgui.cpp +++ b/plugins/channeltx/mod802.15.4/ieee_802_15_4_modgui.cpp @@ -359,8 +359,8 @@ IEEE_802_15_4_ModGUI::IEEE_802_15_4_ModGUI(PluginAPI* pluginAPI, DeviceUISet *de connect(&MainCore::instance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); - m_scopeVis = new ScopeVis(ui->glScope); - m_IEEE_802_15_4_Mod->setScopeSink(m_scopeVis); + m_scopeVis = m_IEEE_802_15_4_Mod->getScopeSink(); + m_scopeVis->setGLScope(ui->glScope); ui->glScope->connectTimer(MainCore::instance()->getMasterTimer()); connect(&MainCore::instance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); // 50 ms ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope); @@ -442,7 +442,6 @@ IEEE_802_15_4_ModGUI::IEEE_802_15_4_ModGUI(PluginAPI* pluginAPI, DeviceUISet *de IEEE_802_15_4_ModGUI::~IEEE_802_15_4_ModGUI() { - delete m_scopeVis; delete ui; } diff --git a/plugins/channeltx/modais/aismod.cpp b/plugins/channeltx/modais/aismod.cpp index 2b469cd51..2e9717671 100644 --- a/plugins/channeltx/modais/aismod.cpp +++ b/plugins/channeltx/modais/aismod.cpp @@ -140,9 +140,9 @@ bool AISMod::handleMessage(const Message& cmd) } } -void AISMod::setScopeSink(ScopeVis* scopeSink) +ScopeVis *AISMod::getScopeSink() { - m_basebandSource->setScopeSink(scopeSink); + return m_basebandSource->getScopeSink(); } void AISMod::applySettings(const AISModSettings& settings, bool force) diff --git a/plugins/channeltx/modais/aismod.h b/plugins/channeltx/modais/aismod.h index d9dd314b7..e93d4ff4c 100644 --- a/plugins/channeltx/modais/aismod.h +++ b/plugins/channeltx/modais/aismod.h @@ -161,7 +161,7 @@ public: SWGSDRangel::SWGChannelSettings& response); SpectrumVis *getSpectrumVis() { return &m_spectrumVis; } - void setScopeSink(ScopeVis* scopeSink); + ScopeVis *getScopeSink(); double getMagSq() const; void setLevelMeter(QObject *levelMeter); uint32_t getNumberOfDeviceStreams() const; diff --git a/plugins/channeltx/modais/aismodbaseband.cpp b/plugins/channeltx/modais/aismodbaseband.cpp index 7cf4bb0d6..0614ec0cb 100644 --- a/plugins/channeltx/modais/aismodbaseband.cpp +++ b/plugins/channeltx/modais/aismodbaseband.cpp @@ -32,6 +32,7 @@ AISModBaseband::AISModBaseband() : { m_sampleFifo.resize(SampleSourceFifo::getSizePolicy(48000)); m_channelizer = new UpChannelizer(&m_source); + m_source.setScopeSink(&m_scopeSink); qDebug("AISModBaseband::AISModBaseband"); QObject::connect( diff --git a/plugins/channeltx/modais/aismodbaseband.h b/plugins/channeltx/modais/aismodbaseband.h index 9c60bfadc..e5aa4090f 100644 --- a/plugins/channeltx/modais/aismodbaseband.h +++ b/plugins/channeltx/modais/aismodbaseband.h @@ -23,6 +23,7 @@ #include #include "dsp/samplesourcefifo.h" +#include "dsp/scopevis.h" #include "util/message.h" #include "util/messagequeue.h" @@ -67,7 +68,7 @@ public: double getMagSq() const { return m_source.getMagSq(); } int getChannelSampleRate() const; void setSpectrumSampleSink(BasebandSampleSink* sampleSink) { m_source.setSpectrumSink(sampleSink); } - void setScopeSink(ScopeVis* scopeSink) { m_source.setScopeSink(scopeSink); } + ScopeVis *getScopeSink() { return &m_scopeSink; } void setChannel(ChannelAPI *channel); signals: @@ -85,6 +86,7 @@ private: AISModSource m_source; MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication AISModSettings m_settings; + ScopeVis m_scopeSink; QMutex m_mutex; void processFifo(SampleVector& data, unsigned int iBegin, unsigned int iEnd); diff --git a/plugins/channeltx/modais/aismodgui.cpp b/plugins/channeltx/modais/aismodgui.cpp index 3c793463e..66917f7d0 100644 --- a/plugins/channeltx/modais/aismodgui.cpp +++ b/plugins/channeltx/modais/aismodgui.cpp @@ -490,8 +490,8 @@ AISModGUI::AISModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam connect(&MainCore::instance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); - m_scopeVis = new ScopeVis(ui->glScope); - m_aisMod->setScopeSink(m_scopeVis); + m_scopeVis = m_aisMod->getScopeSink(); + m_scopeVis->setGLScope(ui->glScope); ui->glScope->connectTimer(MainCore::instance()->getMasterTimer()); ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope); diff --git a/plugins/feature/demodanalyzer/demodanalyzer.h b/plugins/feature/demodanalyzer/demodanalyzer.h index 7f92a7a50..a616ed93c 100644 --- a/plugins/feature/demodanalyzer/demodanalyzer.h +++ b/plugins/feature/demodanalyzer/demodanalyzer.h @@ -25,6 +25,7 @@ #include "feature/feature.h" #include "util/message.h" #include "dsp/spectrumvis.h" +#include "dsp/scopevis.h" #include "demodanalyzersettings.h" @@ -156,6 +157,7 @@ public: virtual ~DemodAnalyzer(); 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); @@ -197,6 +199,7 @@ private: DemodAnalyzerWorker *m_worker; DemodAnalyzerSettings m_settings; SpectrumVis m_spectrumVis; + ScopeVis m_scopeVis; QHash m_availableChannels; ChannelAPI *m_selectedChannel; DataFifo *m_dataFifo; diff --git a/plugins/feature/demodanalyzer/demodanalyzergui.cpp b/plugins/feature/demodanalyzer/demodanalyzergui.cpp index 11960c2da..bdda2b757 100644 --- a/plugins/feature/demodanalyzer/demodanalyzergui.cpp +++ b/plugins/feature/demodanalyzer/demodanalyzergui.cpp @@ -139,10 +139,11 @@ DemodAnalyzerGUI::DemodAnalyzerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUI setAttribute(Qt::WA_DeleteOnClose, true); setChannelWidget(false); connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); - m_scopeVis = new ScopeVis(ui->glScope); m_demodAnalyzer = reinterpret_cast(feature); m_demodAnalyzer->setMessageQueueToGUI(&m_inputMessageQueue); + m_scopeVis = m_demodAnalyzer->getScopeVis(); + m_scopeVis->setGLScope(ui->glScope); m_spectrumVis = m_demodAnalyzer->getSpectrumVis(); m_spectrumVis->setGLSpectrum(ui->glSpectrum); m_spectrumScopeComboVis = new SpectrumScopeComboVis(m_spectrumVis, m_scopeVis); @@ -180,7 +181,6 @@ DemodAnalyzerGUI::~DemodAnalyzerGUI() { delete ui; delete m_spectrumScopeComboVis; - delete m_scopeVis; } void DemodAnalyzerGUI::blockApplySettings(bool block) diff --git a/sdrbase/dsp/glscopemiinterface.h b/sdrbase/dsp/glscopemiinterface.h deleted file mode 100644 index ee623aec3..000000000 --- a/sdrbase/dsp/glscopemiinterface.h +++ /dev/null @@ -1,38 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2021 Edouard Griffiths, F4EXB. // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation as version 3 of the License, or // -// (at your option) any later version. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License V3 for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program. If not, see . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef SDRBASE_DSP_GLSCOPEINTERFACE_H_ -#define SDRBASE_DSP_GLSCOPEINTERFACE_H_ - -#include "dsptypes.h" -#include "scopesettings.h" -#include "physicalunit.h" - -class GLScopeInterface -{ -public: - GLScopeInterface() {} - virtual ~GLScopeInterface() {} - virtual void setTracesData(std::vector* tracesData) = 0; - virtual void setTraces(std::vector>* traces) = 0; - virtual void newTraces(int traceIndex, int traceSize) = 0; - virtual void setTimeScale(float min, float max) = 0; //!< Linear horizontal scales - virtual void setXScale(Unit::Physical unit, float min, float max) = 0; //!< Set X Scale => X for polar, Y1 for linear - virtual void setYScale(Unit::Physical unit, float min, float max) = 0; //!< Set Y Scale => Y for polar, Y2 for linear -}; - -#endif // SDRBASE_DSP_GLSPECTRUMINTERFACE_H_ diff --git a/sdrbase/dsp/scopevis.cpp b/sdrbase/dsp/scopevis.cpp index dccbe3414..ca1ccaa79 100644 --- a/sdrbase/dsp/scopevis.cpp +++ b/sdrbase/dsp/scopevis.cpp @@ -39,8 +39,8 @@ MESSAGE_CLASS_DEFINITION(ScopeVis::MsgScopeVisNGOneShot, Message) MESSAGE_CLASS_DEFINITION(ScopeVis::MsgScopeVisNGMemoryTrace, Message) -ScopeVis::ScopeVis(GLScopeInterface* glScope) : - m_glScope(glScope), +ScopeVis::ScopeVis() : + m_glScope(nullptr), m_messageQueueToGUI(nullptr), m_preTriggerDelay(0), m_livePreTriggerDelay(0), @@ -67,7 +67,6 @@ ScopeVis::ScopeVis(GLScopeInterface* glScope) : { setObjectName("ScopeVis"); m_traceDiscreteMemory.resize(GLScopeSettings::m_traceChunkDefaultSize); // arbitrary - m_glScope->setTraces(&m_traces.m_tracesData, &m_traces.m_traces[0]); for (int i = 0; i < (int) Projector::nbProjectionTypes; i++) { m_projectorCache[i] = 0.0; } @@ -82,6 +81,12 @@ ScopeVis::~ScopeVis() } } +void ScopeVis::setGLScope(GLScopeInterface* glScope) +{ + m_glScope = glScope; + m_glScope->setTraces(&m_traces.m_tracesData, &m_traces.m_traces[0]); +} + void ScopeVis::setLiveRate(int sampleRate) { m_liveSampleRate = sampleRate; @@ -617,11 +622,11 @@ int ScopeVis::processTraces(const SampleVector::const_iterator& cbegin, const Sa float traceTime = ((float) m_traceSize) / m_sampleRate; - if (traceTime >= 1.0f) { // display continuously if trace time is 1 second or more + if (m_glScope && (traceTime >= 1.0f)) { // display continuously if trace time is 1 second or more m_glScope->newTraces(m_traces.m_traces, m_traces.currentBufferIndex(), &m_traces.m_projectionTypes); } - if (m_nbSamples == 0) // finished + if (m_glScope && (m_nbSamples == 0)) // finished { // display only at trace end if trace time is less than 1 second if (traceTime < 1.0f) @@ -756,7 +761,11 @@ bool ScopeVis::handleMessage(const Message& message) if (triggerIndex == m_focusedTriggerIndex) { computeDisplayTriggerLevels(); - m_glScope->setFocusedTriggerData(m_triggerConditions[m_focusedTriggerIndex]->m_triggerData); + + if (m_glScope) { + m_glScope->setFocusedTriggerData(m_triggerConditions[m_focusedTriggerIndex]->m_triggerData); + } + updateGLScopeDisplay(); } } @@ -797,7 +806,11 @@ bool ScopeVis::handleMessage(const Message& message) m_triggerConditions[triggerIndex] = nextTrigger; computeDisplayTriggerLevels(); - m_glScope->setFocusedTriggerData(m_triggerConditions[m_focusedTriggerIndex]->m_triggerData); + + if (m_glScope) { + m_glScope->setFocusedTriggerData(m_triggerConditions[m_focusedTriggerIndex]->m_triggerData); + } + updateGLScopeDisplay(); return true; @@ -812,7 +825,11 @@ bool ScopeVis::handleMessage(const Message& message) { m_focusedTriggerIndex = triggerIndex; computeDisplayTriggerLevels(); - m_glScope->setFocusedTriggerData(m_triggerConditions[m_focusedTriggerIndex]->m_triggerData); + + if (m_glScope) { + m_glScope->setFocusedTriggerData(m_triggerConditions[m_focusedTriggerIndex]->m_triggerData); + } + updateGLScopeDisplay(); } @@ -877,7 +894,11 @@ bool ScopeVis::handleMessage(const Message& message) { m_focusedTraceIndex = traceIndex; computeDisplayTriggerLevels(); - m_glScope->setFocusedTraceIndex(m_focusedTraceIndex); + + if (m_glScope) { + m_glScope->setFocusedTraceIndex(m_focusedTraceIndex); + } + updateGLScopeDisplay(); } @@ -1044,6 +1065,10 @@ void ScopeVis::computeDisplayTriggerLevels() void ScopeVis::updateGLScopeDisplay() { + if (!m_glScope) { + return; + } + if (m_currentTraceMemoryIndex > 0) { m_glScope->setConfigChanged(); diff --git a/sdrbase/dsp/scopevis.h b/sdrbase/dsp/scopevis.h index 6e626dad6..cb17a1c04 100644 --- a/sdrbase/dsp/scopevis.h +++ b/sdrbase/dsp/scopevis.h @@ -43,9 +43,10 @@ class GLScopeInterface; class SDRGUI_API ScopeVis : public QObject { Q_OBJECT public: - ScopeVis(GLScopeInterface* glScope = nullptr); + ScopeVis(); virtual ~ScopeVis(); + void setGLScope(GLScopeInterface* glScope); void setMessageQueueToGUI(MessageQueue* messageQueue) { m_messageQueueToGUI = messageQueue; } MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication