From 710e2b931d00395ca196f3275481e8301ba89baf Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 13 Feb 2017 00:17:59 +0100 Subject: [PATCH] New scope: compute trace in ScopeVis only when required by GLScope. Fixed trace and trigger color dialogs --- plugins/channelrx/CMakeLists.txt | 2 +- sdrbase/dsp/scopevisng.cpp | 6 +++++ sdrbase/gui/glscopeng.cpp | 16 +++++++++++- sdrbase/gui/glscopeng.h | 4 +++ sdrbase/gui/glscopenggui.cpp | 44 ++++++++++++++++++++------------ sdrbase/gui/glscopenggui.ui | 8 +++++- 6 files changed, 61 insertions(+), 19 deletions(-) diff --git a/plugins/channelrx/CMakeLists.txt b/plugins/channelrx/CMakeLists.txt index 3f98bb1b2..1638660a2 100644 --- a/plugins/channelrx/CMakeLists.txt +++ b/plugins/channelrx/CMakeLists.txt @@ -10,7 +10,7 @@ add_subdirectory(udpsrc) add_subdirectory(demodwfm) add_subdirectory(chanalyzer) add_subdirectory(chanalyzerng) -add_subdirectory(demodatv) +#add_subdirectory(demodatv) if(LIBDSDCC_FOUND AND LIBMBE_FOUND) add_subdirectory(demoddsd) diff --git a/sdrbase/dsp/scopevisng.cpp b/sdrbase/dsp/scopevisng.cpp index 578395c82..044d70303 100644 --- a/sdrbase/dsp/scopevisng.cpp +++ b/sdrbase/dsp/scopevisng.cpp @@ -269,6 +269,11 @@ void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const } // trace process + if (m_glScope->getDataChanged()) // optimization: process trace only if required by glScope + { + m_triggerState = TriggerUntriggered; + } + if (m_triggerState == TriggerTriggered) { int remainder = -1; @@ -306,6 +311,7 @@ void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const m_traceDiscreteMemory.current().m_endPoint = mbegin; m_traceDiscreteMemory.store(); // next memory trace m_triggerState = TriggerUntriggered; + //if (m_glScope) m_glScope->incrementTraceCounter(); // process remainder recursively if (remainder != 0) diff --git a/sdrbase/gui/glscopeng.cpp b/sdrbase/gui/glscopeng.cpp index 7f3c891c3..51f596915 100644 --- a/sdrbase/gui/glscopeng.cpp +++ b/sdrbase/gui/glscopeng.cpp @@ -58,6 +58,8 @@ GLScopeNG::GLScopeNG(QWidget* parent) : m_powerOverlayFont.setBold(true); m_powerOverlayFont.setPointSize(font().pointSize()+1); + + //m_traceCounter = 0; } GLScopeNG::~GLScopeNG() @@ -177,6 +179,11 @@ void GLScopeNG::paintGL() if(m_configChanged) applyConfig(); +// qDebug("GLScopeNG::paintGL: m_traceCounter: %d", m_traceCounter); +// m_traceCounter = 0; + + m_dataChanged = false; + QOpenGLFunctions *glFunctions = QOpenGLContext::currentContext()->functions(); glFunctions->glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glFunctions->glClear(GL_COLOR_BUFFER_BIT); @@ -343,7 +350,10 @@ void GLScopeNG::paintGL() } } - m_dataChanged = false; + else if (m_displayMode == DisplayY) // display only traces #1..n + { + } + m_mutex.unlock(); } @@ -425,6 +435,10 @@ void GLScopeNG::applyConfig() { setYScale(m_y2Scale, m_highlightedTraceIndex > 0 ? m_highlightedTraceIndex : 1); // if Highlighted trace is #0 (X trace) set it to first Y trace (trace #1) } + else + { + setYScale(m_y1Scale, 0); // Default to the X trace (trace #0) - If there is only one trace it should not get there (Y displays disabled in the UI) + } if ((m_displayMode == DisplayX) || (m_displayMode == DisplayY)) // unique display { diff --git a/sdrbase/gui/glscopeng.h b/sdrbase/gui/glscopeng.h index 2eacfbc44..75fb3800a 100644 --- a/sdrbase/gui/glscopeng.h +++ b/sdrbase/gui/glscopeng.h @@ -68,6 +68,9 @@ public: void setDisplayGridIntensity(int intensity); void setDisplayTraceIntensity(int intensity); void setFocusedTriggerData(ScopeVisNG::TriggerData& triggerData) { m_focusedTriggerData = triggerData; } + //void incrementTraceCounter() { m_traceCounter++; } + + bool getDataChanged() const { return m_dataChanged; } signals: void sampleRateChanged(int); @@ -76,6 +79,7 @@ private: std::vector *m_tracesData; std::vector *m_traces; ScopeVisNG::TriggerData m_focusedTriggerData; + //int m_traceCounter; uint32_t m_bufferIndex; DisplayMode m_displayMode; QTimer m_timer; diff --git a/sdrbase/gui/glscopenggui.cpp b/sdrbase/gui/glscopenggui.cpp index 343b6840a..350b23525 100644 --- a/sdrbase/gui/glscopenggui.cpp +++ b/sdrbase/gui/glscopenggui.cpp @@ -64,6 +64,10 @@ void GLScopeNGGUI::setBuddies(MessageQueue* messageQueue, ScopeVisNG* scopeVis, ui->horizontalXY->setChecked(false); ui->verticalXY->setChecked(false); ui->polar->setChecked(false); + ui->onlyY->setEnabled(false); + ui->horizontalXY->setEnabled(false); + ui->verticalXY->setEnabled(false); + ui->polar->setEnabled(false); m_glScope->setDisplayMode(GLScopeNG::DisplayX); // initialize trigger combo @@ -337,12 +341,16 @@ void GLScopeNGGUI::on_traceDelay_valueChanged(int value) void GLScopeNGGUI::on_traceColor_clicked() { - QColor newColor = QColorDialog::getColor(); - m_focusedTraceColor = newColor; - int r,g,b,a; - m_focusedTraceColor.getRgb(&r, &g, &b, &a); - ui->traceColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b)); - changeCurrentTrace(); + QColor newColor = QColorDialog::getColor(m_focusedTraceColor); + + if (newColor.isValid()) // user clicked OK and selected a color + { + m_focusedTraceColor = newColor; + int r,g,b,a; + m_focusedTraceColor.getRgb(&r, &g, &b, &a); + ui->traceColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b)); + changeCurrentTrace(); + } } void GLScopeNGGUI::on_trigMode_currentIndexChanged(int index) @@ -422,12 +430,16 @@ void GLScopeNGGUI::on_trigPre_valueChanged(int value) void GLScopeNGGUI::on_trigColor_clicked() { - QColor newColor = QColorDialog::getColor(); - m_focusedTriggerColor = newColor; - int r,g,b,a; - m_focusedTriggerColor.getRgb(&r, &g, &b, &a); - ui->trigColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b)); - changeCurrentTrigger(); + QColor newColor = QColorDialog::getColor(m_focusedTriggerColor); + + if (newColor.isValid()) // user clicked "OK" + { + m_focusedTriggerColor = newColor; + int r,g,b,a; + m_focusedTriggerColor.getRgb(&r, &g, &b, &a); + ui->trigColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b)); + changeCurrentTrigger(); + } } void GLScopeNGGUI::on_trigOneShot_toggled(bool checked) @@ -625,13 +637,13 @@ void GLScopeNGGUI::setTrigLevelDisplay() } if(fabs(a) < 0.000001) - ui->trigLevelText->setText(tr("%1\nn").arg(a * 1000000000.0f)); + ui->trigLevelText->setText(tr("%1\nn").arg(a * 1000000000.0f, 0, 'f', 2)); else if(fabs(a) < 0.001) - ui->trigLevelText->setText(tr("%1\nµ").arg(a * 1000000.0f)); + ui->trigLevelText->setText(tr("%1\nµ").arg(a * 1000000.0f, 0, 'f', 2)); else if(fabs(a) < 1.0) - ui->trigLevelText->setText(tr("%1\nm").arg(a * 1000.0f)); + ui->trigLevelText->setText(tr("%1\nm").arg(a * 1000.0f, 0, 'f', 2)); else - ui->trigLevelText->setText(tr("%1").arg(a * 1.0f)); + ui->trigLevelText->setText(tr("%1").arg(a * 1.0f, 0, 'f', 2)); } } diff --git a/sdrbase/gui/glscopenggui.ui b/sdrbase/gui/glscopenggui.ui index d5c793473..7fe32818c 100644 --- a/sdrbase/gui/glscopenggui.ui +++ b/sdrbase/gui/glscopenggui.ui @@ -917,6 +917,9 @@ kS/s 16 + + Current trace color (click to change) + @@ -1311,7 +1314,7 @@ kS/s - 36 + 40 0 @@ -1529,6 +1532,9 @@ kS/s 16 + + Current trigger color (click to change) +