diff --git a/sdrgui/dsp/scopevis.cpp b/sdrgui/dsp/scopevis.cpp index 3751edf4d..a0d5c7a40 100644 --- a/sdrgui/dsp/scopevis.cpp +++ b/sdrgui/dsp/scopevis.cpp @@ -47,13 +47,13 @@ ScopeVis::ScopeVis(GLScope* glScope) : m_triggerState(TriggerUntriggered), m_focusedTraceIndex(0), m_traceSize(m_traceChunkSize), + m_liveTraceSize(m_traceChunkSize), m_nbSamples(0), m_timeBase(1), m_timeOfsProMill(0), m_traceStart(true), m_sampleRate(0), - m_liveRate(0), - m_memoryRate(0), + m_liveSampleRate(0), m_traceDiscreteMemory(m_nbTraceMemories), m_freeRun(true), m_maxTraceDelay(0), @@ -78,10 +78,10 @@ ScopeVis::~ScopeVis() void ScopeVis::setLiveRate(int sampleRate) { - m_liveRate = sampleRate; + m_liveSampleRate = sampleRate; if (m_currentTraceMemoryIndex == 0) { // update only in live mode - setSampleRate(m_liveRate); + setSampleRate(m_liveSampleRate); } } @@ -94,6 +94,18 @@ void ScopeVis::setSampleRate(int sampleRate) } } +void ScopeVis::setTraceSize(uint32_t traceSize) +{ + m_traceSize = traceSize; + m_traces.resize(m_traceSize); + m_traceDiscreteMemory.resize(m_traceSize); + initTraceBuffers(); + + if (m_glScope) { + m_glScope->setTraceSize(m_traceSize); + } +} + void ScopeVis::configure(uint32_t traceSize, uint32_t timeBase, uint32_t timeOfsProMill, uint32_t triggerPre, bool freeRun) { Message* cmd = MsgConfigureScopeVisNG::create(traceSize, timeBase, timeOfsProMill, triggerPre, freeRun); @@ -617,14 +629,7 @@ bool ScopeVis::handleMessage(const Message& message) if (m_traceSize != traceSize) { - m_traceSize = traceSize; - m_traces.resize(m_traceSize); - m_traceDiscreteMemory.resize(m_traceSize); - initTraceBuffers(); - - if (m_glScope) { - m_glScope->setTraceSize(m_traceSize); - } + setTraceSize(traceSize); } if (m_timeBase != timeBase) @@ -838,16 +843,20 @@ bool ScopeVis::handleMessage(const Message& message) if (memoryIndex != m_currentTraceMemoryIndex) { - // on transition from live rate initialize memory rate to live rate + // transition from live mode if (memoryIndex == 0) { - m_memoryRate = m_liveRate; + m_liveTraceSize = m_traceSize; } m_currentTraceMemoryIndex = memoryIndex; - if (m_currentTraceMemoryIndex == 0) { // transition to live mode - setSampleRate(m_liveRate); // reset to live rate - } else { + if (m_currentTraceMemoryIndex == 0) // transition to live mode + { + setSampleRate(m_liveSampleRate); // reset to live rate + setTraceSize(m_liveTraceSize); // reset to live trace size + } + else + { processMemoryTrace(); } } diff --git a/sdrgui/dsp/scopevis.h b/sdrgui/dsp/scopevis.h index a7a90aabf..a45c95d20 100644 --- a/sdrgui/dsp/scopevis.h +++ b/sdrgui/dsp/scopevis.h @@ -748,9 +748,13 @@ private: { d.readU32(1, &m_memSize, 0); d.readU32(2, &m_currentMemIndex, 0); - d.readU32(3, &m_traceSize, 0); + uint32_t traceSize; + d.readU32(3, &traceSize, 0); m_traceBackBuffers.resize(m_memSize); - resize(m_traceSize); + + if (traceSize != m_traceSize) { + resize(traceSize); + } for (unsigned int i = 0; i < m_memSize; i++) { @@ -1044,14 +1048,14 @@ private: Traces m_traces; //!< Displayable traces int m_focusedTraceIndex; //!< Index of the trace that has focus uint32_t m_traceSize; //!< Size of traces in number of samples + uint32_t m_liveTraceSize; //!< Size of traces in number of samples in live mode int m_nbSamples; //!< Number of samples yet to process in one complex trace uint32_t m_timeBase; //!< Trace display time divisor uint32_t m_timeOfsProMill; //!< Start trace shift in 1/1000 trace size bool m_traceStart; //!< Trace is at start point SampleVector::const_iterator m_triggerPoint; //!< Trigger start location in the samples vector int m_sampleRate; //!< Actual sample rate being used - int m_liveRate; //!< Sample rate in live mode - int m_memoryRate; //!< Sample rate in memory mode + int m_liveSampleRate; //!< Sample rate in live mode TraceBackDiscreteMemory m_traceDiscreteMemory; //!< Complex trace memory for triggered states TODO: vectorize when more than on input is allowed bool m_freeRun; //!< True if free running (trigger globally disabled) int m_maxTraceDelay; //!< Maximum trace delay @@ -1116,6 +1120,11 @@ private: * Set the actual sample rate */ void setSampleRate(int sampleRate); + + /** + * Set the traces size + */ + void setTraceSize(uint32_t traceSize); };