From ecb4a0871852f8132804b351fd00838316dcb28e Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 30 May 2019 18:38:10 +0200 Subject: [PATCH] MIMO: channel marker affinity with the stream being displayed on the main spectrum. Implemented in demod AM --- plugins/channelrx/demodam/amdemodgui.cpp | 1 + .../channeltx/localsource/localsourcegui.cpp | 1 + plugins/channeltx/modam/ammodgui.cpp | 1 + plugins/channeltx/modatv/atvmodgui.cpp | 1 + plugins/channeltx/modfreedv/freedvmodgui.cpp | 1 + plugins/channeltx/modnfm/nfmmodgui.cpp | 1 + plugins/channeltx/modssb/ssbmodgui.cpp | 1 + plugins/channeltx/modwfm/wfmmodgui.cpp | 1 + .../remotesource/remotesourcegui.cpp | 1 + plugins/channeltx/udpsource/udpsourcegui.cpp | 1 + plugins/samplemimo/testmi/testmigui.cpp | 2 + sdrbase/dsp/channelmarker.cpp | 4 +- sdrbase/dsp/channelmarker.h | 7 ++++ sdrgui/gui/glspectrum.cpp | 41 ++++++++++++++++--- sdrgui/gui/glspectrum.h | 9 +++- sdrgui/mainwindow.cpp | 1 + 16 files changed, 66 insertions(+), 8 deletions(-) diff --git a/plugins/channelrx/demodam/amdemodgui.cpp b/plugins/channelrx/demodam/amdemodgui.cpp index 756a0a608..654a5cc65 100644 --- a/plugins/channelrx/demodam/amdemodgui.cpp +++ b/plugins/channelrx/demodam/amdemodgui.cpp @@ -240,6 +240,7 @@ void AMDemodGUI::onMenuDialogCalled(const QPoint &p) dialog.exec(); m_settings.m_streamIndex = dialog.getSelectedStreamIndex(); + m_channelMarker.setStreamIndex(m_settings.m_streamIndex); displayStreamIndex(); applySettings(); } diff --git a/plugins/channeltx/localsource/localsourcegui.cpp b/plugins/channeltx/localsource/localsourcegui.cpp index 2f495a644..31cf92009 100644 --- a/plugins/channeltx/localsource/localsourcegui.cpp +++ b/plugins/channeltx/localsource/localsourcegui.cpp @@ -125,6 +125,7 @@ LocalSourceGUI::LocalSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, B m_channelMarker.setColor(m_settings.m_rgbColor); m_channelMarker.setCenterFrequency(0); m_channelMarker.setTitle("Local Source"); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); // activate signal on the last setting only diff --git a/plugins/channeltx/modam/ammodgui.cpp b/plugins/channeltx/modam/ammodgui.cpp index 83e96be0a..999c988b2 100644 --- a/plugins/channeltx/modam/ammodgui.cpp +++ b/plugins/channeltx/modam/ammodgui.cpp @@ -342,6 +342,7 @@ AMModGUI::AMModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampl m_channelMarker.setBandwidth(5000); m_channelMarker.setCenterFrequency(0); m_channelMarker.setTitle("AM Modulator"); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); // activate signal on the last setting only diff --git a/plugins/channeltx/modatv/atvmodgui.cpp b/plugins/channeltx/modatv/atvmodgui.cpp index 8c6a32863..04f1f9a0f 100644 --- a/plugins/channeltx/modatv/atvmodgui.cpp +++ b/plugins/channeltx/modatv/atvmodgui.cpp @@ -678,6 +678,7 @@ ATVModGUI::ATVModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam m_channelMarker.setBandwidth(5000); m_channelMarker.setCenterFrequency(0); m_channelMarker.setTitle("ATV Modulator"); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); // activate signal on the last setting only diff --git a/plugins/channeltx/modfreedv/freedvmodgui.cpp b/plugins/channeltx/modfreedv/freedvmodgui.cpp index d61571894..e35326859 100644 --- a/plugins/channeltx/modfreedv/freedvmodgui.cpp +++ b/plugins/channeltx/modfreedv/freedvmodgui.cpp @@ -375,6 +375,7 @@ FreeDVModGUI::FreeDVModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.setVisible(true); m_deviceUISet->registerTxChannelInstance(FreeDVMod::m_channelIdURI, this); diff --git a/plugins/channeltx/modnfm/nfmmodgui.cpp b/plugins/channeltx/modnfm/nfmmodgui.cpp index 403de44b8..9187414ad 100644 --- a/plugins/channeltx/modnfm/nfmmodgui.cpp +++ b/plugins/channeltx/modnfm/nfmmodgui.cpp @@ -370,6 +370,7 @@ NFMModGUI::NFMModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam m_channelMarker.setBandwidth(12500); m_channelMarker.setCenterFrequency(0); m_channelMarker.setTitle("NFM Modulator"); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); // activate signal on the last setting only diff --git a/plugins/channeltx/modssb/ssbmodgui.cpp b/plugins/channeltx/modssb/ssbmodgui.cpp index 316616ef2..a709b02e4 100644 --- a/plugins/channeltx/modssb/ssbmodgui.cpp +++ b/plugins/channeltx/modssb/ssbmodgui.cpp @@ -455,6 +455,7 @@ SSBModGUI::SSBModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam m_channelMarker.setSidebands(ChannelMarker::usb); m_channelMarker.setCenterFrequency(0); m_channelMarker.setTitle("SSB Modulator"); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); diff --git a/plugins/channeltx/modwfm/wfmmodgui.cpp b/plugins/channeltx/modwfm/wfmmodgui.cpp index 408c306bf..65e3e0466 100644 --- a/plugins/channeltx/modwfm/wfmmodgui.cpp +++ b/plugins/channeltx/modwfm/wfmmodgui.cpp @@ -360,6 +360,7 @@ WFMModGUI::WFMModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam m_channelMarker.setBandwidth(125000); m_channelMarker.setCenterFrequency(0); m_channelMarker.setTitle("WFM Modulator"); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); // activate signal on the last setting only diff --git a/plugins/channeltx/remotesource/remotesourcegui.cpp b/plugins/channeltx/remotesource/remotesourcegui.cpp index 1058e0ce4..26433ea69 100644 --- a/plugins/channeltx/remotesource/remotesourcegui.cpp +++ b/plugins/channeltx/remotesource/remotesourcegui.cpp @@ -184,6 +184,7 @@ RemoteSourceGUI::RemoteSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, m_channelMarker.setColor(m_settings.m_rgbColor); m_channelMarker.setCenterFrequency(0); m_channelMarker.setTitle("Remote source"); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); // activate signal on the last setting only diff --git a/plugins/channeltx/udpsource/udpsourcegui.cpp b/plugins/channeltx/udpsource/udpsourcegui.cpp index eb7d220d2..c57aeed74 100644 --- a/plugins/channeltx/udpsource/udpsourcegui.cpp +++ b/plugins/channeltx/udpsource/udpsourcegui.cpp @@ -159,6 +159,7 @@ UDPSourceGUI::UDPSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb m_channelMarker.setCenterFrequency(0); m_channelMarker.setColor(m_settings.m_rgbColor); m_channelMarker.setTitle("UDP Sample Sink"); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); // activate signal on the last setting only diff --git a/plugins/samplemimo/testmi/testmigui.cpp b/plugins/samplemimo/testmi/testmigui.cpp index 745369ee5..6433621bb 100644 --- a/plugins/samplemimo/testmi/testmigui.cpp +++ b/plugins/samplemimo/testmi/testmigui.cpp @@ -153,6 +153,7 @@ void TestMIGui::on_streamIndex_currentIndexChanged(int index) if (ui->streamLock->isChecked()) { m_spectrumStreamIndex = index; + m_deviceUISet->m_spectrum->setDisplayedStream(true, index); m_deviceUISet->m_deviceAPI->setSpectrumSinkInput(true, m_spectrumStreamIndex); ui->spectrumSource->blockSignals(true); ui->spectrumSource->setCurrentIndex(index); @@ -168,6 +169,7 @@ void TestMIGui::on_streamIndex_currentIndexChanged(int index) void TestMIGui::on_spectrumSource_currentIndexChanged(int index) { m_spectrumStreamIndex = index; + m_deviceUISet->m_spectrum->setDisplayedStream(true, index); m_deviceUISet->m_deviceAPI->setSpectrumSinkInput(true, m_spectrumStreamIndex); updateSampleRateAndFrequency(); diff --git a/sdrbase/dsp/channelmarker.cpp b/sdrbase/dsp/channelmarker.cpp index 1b242caf2..b106471b5 100644 --- a/sdrbase/dsp/channelmarker.cpp +++ b/sdrbase/dsp/channelmarker.cpp @@ -37,7 +37,9 @@ ChannelMarker::ChannelMarker(QObject* parent) : m_highlighted(false), m_color(m_colorTable[m_nextColor]), m_movable(true), - m_fScaleDisplayType(FScaleDisplay_freq) + m_fScaleDisplayType(FScaleDisplay_freq), + m_sourceOrSinkStream(true), + m_streamIndex(0) { ++m_nextColor; if(m_colorTable[m_nextColor] == 0) diff --git a/sdrbase/dsp/channelmarker.h b/sdrbase/dsp/channelmarker.h index 125a4cf58..4e93d720b 100644 --- a/sdrbase/dsp/channelmarker.h +++ b/sdrbase/dsp/channelmarker.h @@ -72,6 +72,11 @@ public: const QString& getDisplayAddressSend() const { return m_displayAddressSend; } const QString& getDisplayAddressReceive() const { return m_displayAddressReceive; } + void setSourceOrSinkStream(bool sourceOrSinkStream) { m_sourceOrSinkStream = sourceOrSinkStream; } + bool getSourceOrSinkStream() const { return m_sourceOrSinkStream; } + void setStreamIndex(int streamIndex) { m_streamIndex = streamIndex; } + int getStreamIndex() const { return m_streamIndex; } + virtual QByteArray serialize() const; virtual bool deserialize(const QByteArray& data); @@ -92,6 +97,8 @@ protected: QColor m_color; bool m_movable; frequencyScaleDisplay_t m_fScaleDisplayType; + bool m_sourceOrSinkStream; + int m_streamIndex; void resetToDefaults(); diff --git a/sdrgui/gui/glspectrum.cpp b/sdrgui/gui/glspectrum.cpp index 94e686129..9638ab13f 100644 --- a/sdrgui/gui/glspectrum.cpp +++ b/sdrgui/gui/glspectrum.cpp @@ -64,6 +64,8 @@ GLSpectrum::GLSpectrum(QWidget* parent) : m_histogram(0), m_displayHistogram(true), m_displayChanged(false), + m_displaySourceOrSink(true), + m_displayStreamIndex(0), m_matrixLoc(0), m_colorLoc(0), m_messageQueueToGUI(0) @@ -605,7 +607,10 @@ void GLSpectrum::paintGL() for (int i = 0; i < m_channelMarkerStates.size(); ++i) { ChannelMarkerState* dv = m_channelMarkerStates[i]; - if (dv->m_channelMarker->getVisible()) + + if (dv->m_channelMarker->getVisible() + && (dv->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink) + && (dv->m_channelMarker->getStreamIndex() == m_displayStreamIndex)) { { GLfloat q3[] { @@ -693,7 +698,10 @@ void GLSpectrum::paintGL() for(int i = 0; i < m_channelMarkerStates.size(); ++i) { ChannelMarkerState* dv = m_channelMarkerStates[i]; - if(dv->m_channelMarker->getVisible()) + + if (dv->m_channelMarker->getVisible() + && (dv->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink) + && (dv->m_channelMarker->getStreamIndex() == m_displayStreamIndex)) { { GLfloat q3[] { @@ -784,7 +792,9 @@ void GLSpectrum::paintGL() ChannelMarkerState* dv = m_channelMarkerStates[i]; // frequency scale channel overlay - if(dv->m_channelMarker->getVisible()) + if (dv->m_channelMarker->getVisible() + && (dv->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink) + && (dv->m_channelMarker->getStreamIndex() == m_displayStreamIndex)) { { GLfloat q3[] { @@ -1506,7 +1516,10 @@ void GLSpectrum::applyChanges() // Frequency overlay on highlighted marker for(int i = 0; i < m_channelMarkerStates.size(); ++i) { ChannelMarkerState* dv = m_channelMarkerStates[i]; - if (dv->m_channelMarker->getHighlighted()) + + if (dv->m_channelMarker->getVisible() + && (dv->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink) + && (dv->m_channelMarker->getStreamIndex() == m_displayStreamIndex)) { qreal xc; int shift; @@ -1651,7 +1664,9 @@ void GLSpectrum::mouseMoveEvent(QMouseEvent* event) { Real freq = m_frequencyScale.getValueFromPos(event->x() - m_leftMarginPixmap.width() - 1) - m_centerFrequency; - if (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getMovable()) + if (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getMovable() + && (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink) + && (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getStreamIndex() == m_displayStreamIndex)) { m_channelMarkerStates[m_cursorChannel]->m_channelMarker->setCenterFrequencyByCursor(freq); channelMarkerChanged(); @@ -1662,6 +1677,12 @@ void GLSpectrum::mouseMoveEvent(QMouseEvent* event) { for (int i = 0; i < m_channelMarkerStates.size(); ++i) { + if ((m_channelMarkerStates[i]->m_channelMarker->getSourceOrSinkStream() != m_displaySourceOrSink) + || (m_channelMarkerStates[i]->m_channelMarker->getStreamIndex() != m_displayStreamIndex)) + { + continue; + } + if (m_channelMarkerStates[i]->m_rect.contains(event->pos())) { if (m_cursorState == CSNormal) @@ -1721,7 +1742,9 @@ void GLSpectrum::mousePressEvent(QMouseEvent* event) m_cursorChannel = 0; Real freq = m_frequencyScale.getValueFromPos(event->x() - m_leftMarginPixmap.width() - 1) - m_centerFrequency; - if(m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getMovable()) + if (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getMovable() + && (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink) + && (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getStreamIndex() == m_displayStreamIndex)) { m_channelMarkerStates[m_cursorChannel]->m_channelMarker->setCenterFrequencyByCursor(freq); channelMarkerChanged(); @@ -1756,6 +1779,12 @@ void GLSpectrum::wheelEvent(QWheelEvent *event) for (int i = 0; i < m_channelMarkerStates.size(); ++i) { + if ((m_channelMarkerStates[i]->m_channelMarker->getSourceOrSinkStream() != m_displaySourceOrSink) + || (m_channelMarkerStates[i]->m_channelMarker->getStreamIndex() != m_displayStreamIndex)) + { + continue; + } + if (m_channelMarkerStates[i]->m_rect.contains(event->pos())) { int freq = m_channelMarkerStates[i]->m_channelMarker->getCenterFrequency(); diff --git a/sdrgui/gui/glspectrum.h b/sdrgui/gui/glspectrum.h index 053a173e4..75940813e 100644 --- a/sdrgui/gui/glspectrum.h +++ b/sdrgui/gui/glspectrum.h @@ -96,6 +96,12 @@ public: void setWaterfallShare(Real waterfallShare); void connectTimer(const QTimer& timer); + void setDisplayedStream(bool sourceOrSink, int streamIndex) + { + m_displaySourceOrSink = sourceOrSink; + m_displayStreamIndex = streamIndex; + } + private: struct ChannelMarkerState { ChannelMarker* m_channelMarker; @@ -180,8 +186,9 @@ private: QMatrix4x4 m_glHistogramSpectrumMatrix; QMatrix4x4 m_glHistogramBoxMatrix; bool m_displayHistogram; - bool m_displayChanged; + bool m_displaySourceOrSink; + int m_displayStreamIndex; GLShaderSimple m_glShaderSimple; GLShaderTextured m_glShaderLeftScale; diff --git a/sdrgui/mainwindow.cpp b/sdrgui/mainwindow.cpp index b62ce1e17..5e359105c 100644 --- a/sdrgui/mainwindow.cpp +++ b/sdrgui/mainwindow.cpp @@ -362,6 +362,7 @@ void MainWindow::addSinkDevice() connect(m_deviceUIs.back()->m_samplingDeviceControl->getAddChannelButton(), SIGNAL(clicked(bool)), this, SLOT(channelAddClicked(bool))); dspDeviceSinkEngine->addSpectrumSink(m_deviceUIs.back()->m_spectrumVis); + m_deviceUIs.back()->m_spectrum->setDisplayedStream(false, 0); ui->tabSpectra->addTab(m_deviceUIs.back()->m_spectrum, tabNameCStr); ui->tabSpectraGUI->addTab(m_deviceUIs.back()->m_spectrumGUI, tabNameCStr); ui->tabChannels->addTab(m_deviceUIs.back()->m_channelWindow, tabNameCStr);