From ad73a3e9d28df3eeeb6d5176ffa13c044e9118ba Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Tue, 8 Jun 2021 09:58:30 -0700 Subject: [PATCH] Adjustable waterfall length is now non-destructive. --- wfmain.cpp | 18 +++++++++++------- wfmain.h | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index a20bf11..df8ab9a 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -1494,6 +1494,8 @@ void wfmain::prepareWf(unsigned int wfLength) spectrumDrawLock = true; spectWidth = rigCaps.spectLenMax; + wfLengthMax = 1024; + this->wfLength = wfLength; // fixed for now, time-length of waterfall // Initialize before use! @@ -1501,17 +1503,21 @@ void wfmain::prepareWf(unsigned int wfLength) QByteArray empty((int)spectWidth, '\x01'); spectrumPeaks = QByteArray( (int)spectWidth, '\x01' ); - if((unsigned int)wfimage.size() < wfLength) + //wfimage.resize(wfLengthMax); + + if((unsigned int)wfimage.size() < wfLengthMax) { unsigned int i=0; unsigned int oldSize = wfimage.size(); - for(i=oldSize; i<(wfLength); i++) + for(i=oldSize; i<(wfLengthMax); i++) { wfimage.append(empty); } } else { - wfimage.remove(wfLength, wfimage.size()-wfLength); + // Keep wfimage, do not trim, no performance impact. + //wfimage.remove(wfLength, wfimage.size()-wfLength); } + wfimage.squeeze(); //colorMap->clearData(); colorMap->data()->clear(); @@ -2675,10 +2681,8 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e if(specLen == spectWidth) { wfimage.prepend(spectrum); - if(wfimage.length() > wfLength) - { - wfimage.remove(wfLength); - } + wfimage.resize(wfLengthMax); + wfimage.squeeze(); // Waterfall: for(int row = 0; row < wfLength; row++) diff --git a/wfmain.h b/wfmain.h index a5a1db8..9439ba7 100644 --- a/wfmain.h +++ b/wfmain.h @@ -557,6 +557,7 @@ private: int smeterPos=0; QVector wfimage; + unsigned int wfLengthMax; bool onFullscreen; bool drawPeaks;