From bd04ee5a5e096003d84943a30c916e68df2ca467 Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 24 Jun 2021 22:52:20 +0200 Subject: [PATCH] GLScopeGUI: effective implementation of stream input selection. Fixes #872 --- sdrgui/gui/glscopegui.cpp | 57 +++++++++++++++++++++++++++++++++++++++ sdrgui/gui/glscopegui.h | 4 +++ 2 files changed, 61 insertions(+) diff --git a/sdrgui/gui/glscopegui.cpp b/sdrgui/gui/glscopegui.cpp index 1700dd439..970735a16 100644 --- a/sdrgui/gui/glscopegui.cpp +++ b/sdrgui/gui/glscopegui.cpp @@ -435,6 +435,51 @@ bool GLScopeGUI::deserialize(const QByteArray& data) } } +void GLScopeGUI::setNbStreams(unsigned int nbStreams) +{ + QStringList streamNames; + + for (unsigned int s = 0; s < nbStreams; s++) { + streamNames.append(tr("%1").arg(s)); + } + + setStreams(streamNames); +} + +void GLScopeGUI::setStreams(const QStringList& streamNames) +{ + int traceStreamIndex = ui->traceStream->currentIndex(); + int triggerStreamIndex = ui->trigStream->currentIndex(); + ui->traceStream->blockSignals(true); + ui->trigStream->blockSignals(true); + ui->traceStream->clear(); + ui->trigStream->clear(); + + for (QString s : streamNames) + { + ui->traceStream->addItem(s); + ui->trigStream->addItem(s); + } + + int newTraceStreamIndex = traceStreamIndex < streamNames.size() ? traceStreamIndex : streamNames.size() - 1; + int newTriggerStreamIndex = triggerStreamIndex < streamNames.size() ? triggerStreamIndex: streamNames.size() - 1; + + ui->traceStream->setCurrentIndex(newTraceStreamIndex); + + if (newTraceStreamIndex != traceStreamIndex) { + changeCurrentTrace(); + } + + ui->trigStream->setCurrentIndex(newTriggerStreamIndex); + + if (newTriggerStreamIndex != triggerStreamIndex) { + changeCurrentTrigger(); + } + + ui->traceStream->blockSignals(false); + ui->trigStream->blockSignals(false); +} + void GLScopeGUI::on_onlyX_toggled(bool checked) { if (checked) @@ -806,6 +851,12 @@ void GLScopeGUI::on_trigDown_clicked(bool checked) } } +void GLScopeGUI::on_traceStream_currentIndexChanged(int index) +{ + (void) index; + changeCurrentTrace(); +} + void GLScopeGUI::on_traceMode_currentIndexChanged(int index) { (void) index; @@ -936,6 +987,12 @@ void GLScopeGUI::on_mem_valueChanged(int value) m_scopeVis->setMemoryIndex(value); } +void GLScopeGUI::on_trigStream_currentIndexChanged(int index) +{ + (void) index; + changeCurrentTrigger(); +} + void GLScopeGUI::on_trigMode_currentIndexChanged(int index) { (void) index; diff --git a/sdrgui/gui/glscopegui.h b/sdrgui/gui/glscopegui.h index db7550bb9..8bb420fdf 100644 --- a/sdrgui/gui/glscopegui.h +++ b/sdrgui/gui/glscopegui.h @@ -53,6 +53,8 @@ public: bool handleMessage(Message* message); unsigned int getNbTraces() const { return m_settings.m_tracesData.size(); } unsigned int getNbTriggers() const { return m_settings.m_triggersData.size(); } + void setNbStreams(unsigned int nbStreams); //!< Set number of streams with default names (indexes) + void setStreams(const QStringList& streamNames); //!< Give streans by their names in a list // preconfiguration methods // global (first line): @@ -217,6 +219,7 @@ private slots: void on_traceDel_clicked(bool checked); void on_traceUp_clicked(bool checked); void on_traceDown_clicked(bool checked); + void on_traceStream_currentIndexChanged(int index); void on_traceMode_currentIndexChanged(int index); void on_amp_valueChanged(int value); void on_ofsCoarse_valueChanged(int value); @@ -234,6 +237,7 @@ private slots: void on_trigDel_clicked(bool checked); void on_trigUp_clicked(bool checked); void on_trigDown_clicked(bool checked); + void on_trigStream_currentIndexChanged(int index); void on_trigMode_currentIndexChanged(int index); void on_trigCount_valueChanged(int value); void on_trigPos_toggled(bool checked);