From c8aa0dc4b8128a4fc00ba99555583bf1264c5c65 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 11 Feb 2017 10:36:10 +0100 Subject: [PATCH] New scope: focused trigger change --- sdrbase/dsp/scopevisng.cpp | 26 +++++++++++++++++++++++++- sdrbase/dsp/scopevisng.h | 22 ++++++++++++++++++++++ sdrbase/gui/glscopenggui.cpp | 12 +++++++----- 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/sdrbase/dsp/scopevisng.cpp b/sdrbase/dsp/scopevisng.cpp index 4655bc4a4..255d10f33 100644 --- a/sdrbase/dsp/scopevisng.cpp +++ b/sdrbase/dsp/scopevisng.cpp @@ -24,6 +24,7 @@ MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgConfigureScopeVisNG, Message) MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGAddTrigger, Message) MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGChangeTrigger, Message) MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGRemoveTrigger, Message) +MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGFocusOnTrigger, Message) MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGAddTrace, Message) MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGChangeTrace, Message) MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGRemoveTrace, Message) @@ -113,6 +114,12 @@ void ScopeVisNG::removeTrigger(uint32_t triggerIndex) getInputMessageQueue()->push(cmd); } +void ScopeVisNG::focusOnTrigger(uint32_t triggerIndex) +{ + Message* cmd = MsgScopeVisNGFocusOnTrigger::create(triggerIndex); + getInputMessageQueue()->push(cmd); +} + void ScopeVisNG::feed(const SampleVector::const_iterator& cbegin, const SampleVector::const_iterator& end, bool positiveOnly) { @@ -512,12 +519,27 @@ bool ScopeVisNG::handleMessage(const Message& message) return true; } + else if (MsgScopeVisNGFocusOnTrigger::match(message)) + { + MsgScopeVisNGFocusOnTrigger& conf = (MsgScopeVisNGFocusOnTrigger&) message; + int triggerIndex = conf.getTriggerIndex(); + + if (triggerIndex < m_triggerConditions.size()) + { + m_focusedTriggerIndex = triggerIndex; + computeDisplayTriggerLevels(); + m_glScope->updateDisplay(); + } + + return true; + } else if (MsgScopeVisNGAddTrace::match(message)) { MsgScopeVisNGAddTrace& conf = (MsgScopeVisNGAddTrace&) message; m_traces.addTrace(conf.getTraceData(), m_traceSize); initTraceBuffers(); updateMaxTraceDelay(); + computeDisplayTriggerLevels(); m_glScope->updateDisplay(); return true; } @@ -527,6 +549,7 @@ bool ScopeVisNG::handleMessage(const Message& message) bool doComputeTriggerLevelsOnDisplay = m_traces.isVerticalDisplayChange(conf.getTraceData(), conf.getTraceIndex()); m_traces.changeTrace(conf.getTraceData(), conf.getTraceIndex()); updateMaxTraceDelay(); + if (doComputeTriggerLevelsOnDisplay) computeDisplayTriggerLevels(); m_glScope->updateDisplay(); return true; } @@ -535,6 +558,7 @@ bool ScopeVisNG::handleMessage(const Message& message) MsgScopeVisNGRemoveTrace& conf = (MsgScopeVisNGRemoveTrace&) message; m_traces.removeTrace(conf.getTraceIndex()); updateMaxTraceDelay(); + computeDisplayTriggerLevels(); m_glScope->updateDisplay(); return true; } @@ -585,7 +609,7 @@ void ScopeVisNG::computeDisplayTriggerLevels() for (; itData != m_traces.m_tracesData.end(); ++itData) { - if (m_triggerConditions[m_focusedTriggerIndex].m_projector->getProjectionType() == itData->m_projectionType) + if ((m_focusedTriggerIndex < m_triggerConditions.size()) && (m_triggerConditions[m_focusedTriggerIndex].m_projector->getProjectionType() == itData->m_projectionType)) { float level = m_triggerConditions[m_focusedTriggerIndex].m_triggerData.m_triggerLevel; float levelPowerLin = level + 1.0f; diff --git a/sdrbase/dsp/scopevisng.h b/sdrbase/dsp/scopevisng.h index a7ca9cfc3..c731d5522 100644 --- a/sdrbase/dsp/scopevisng.h +++ b/sdrbase/dsp/scopevisng.h @@ -108,6 +108,7 @@ public: void addTrigger(const TriggerData& triggerData); void changeTrigger(const TriggerData& triggerData, uint32_t triggerIndex); void removeTrigger(uint32_t triggerIndex); + void focusOnTrigger(uint32_t triggerIndex); void getTriggerData(TriggerData& triggerData, uint32_t triggerIndex) { @@ -230,6 +231,27 @@ private: {} }; + // --------------------------------------------- + class MsgScopeVisNGFocusOnTrigger : public Message { + MESSAGE_CLASS_DECLARATION + + public: + static MsgScopeVisNGFocusOnTrigger* create( + uint32_t triggerIndex) + { + return new MsgScopeVisNGFocusOnTrigger(triggerIndex); + } + + uint32_t getTriggerIndex() const { return m_triggerIndex; } + + private: + uint32_t m_triggerIndex; + + MsgScopeVisNGFocusOnTrigger(uint32_t triggerIndex) : + m_triggerIndex(triggerIndex) + {} + }; + // --------------------------------------------- class MsgScopeVisNGAddTrace : public Message { MESSAGE_CLASS_DECLARATION diff --git a/sdrbase/gui/glscopenggui.cpp b/sdrbase/gui/glscopenggui.cpp index efe8fa452..8299a8ab8 100644 --- a/sdrbase/gui/glscopenggui.cpp +++ b/sdrbase/gui/glscopenggui.cpp @@ -67,16 +67,16 @@ void GLScopeNGGUI::setBuddies(MessageQueue* messageQueue, ScopeVisNG* scopeVis, ui->trigOneShot->setEnabled(false); ui->freerun->setChecked(true); - // Add a trace - ScopeVisNG::TraceData traceData; - fillTraceData(traceData); - m_scopeVis->addTrace(traceData); - // Add a trigger ScopeVisNG::TriggerData triggerData; fillTriggerData(triggerData); m_scopeVis->addTrigger(triggerData); + // Add a trace + ScopeVisNG::TraceData traceData; + fillTraceData(traceData); + m_scopeVis->addTrace(traceData); + setEnabled(true); connect(m_glScope, SIGNAL(sampleRateChanged(int)), this, SLOT(on_scope_sampleRateChanged(int))); @@ -272,6 +272,8 @@ void GLScopeNGGUI::on_trig_valueChanged(int value) << " m_triggerLevel" << triggerData.m_triggerLevel; setTriggerUI(triggerData); + + m_scopeVis->focusOnTrigger(value); } void GLScopeNGGUI::on_trigAdd_clicked(bool checked)