From bba7a481ad093a7814cce2f90f78bef709f28b02 Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 6 Jun 2021 15:21:41 +0200 Subject: [PATCH] automatic scale for the color based on the max power values --- displayarea.cpp | 16 ++++++++++++++++ displayarea.h | 3 +++ inputparser.cpp | 13 ++++++++++++- inputparser.h | 3 +++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/displayarea.cpp b/displayarea.cpp index 9b6239b..4ec171b 100644 --- a/displayarea.cpp +++ b/displayarea.cpp @@ -45,3 +45,19 @@ bool DisplayArea::saveImage(const QString &fileName, const char *fileFormat) { return image.save(fileName, fileFormat); } + +void DisplayArea::updateColorMap(float oldMin, float oldMax, float newMin, float newMax) +{ + QRgb* imagePixels=(QRgb*)image.bits(); + for(unsigned long long i=0;imaxPow){ + float newMin=qMin(currentPowerValue,minPow); + float newMax=qMax(currentPowerValue,maxPow); + + display->updateColorMap(minPow,maxPow,newMin,newMax); + + minPow=newMin; + maxPow=newMax; + } + + int col=qRound(currentPowerValue-minPow)*255/(maxPow-minPow); display->setPixel(currentX,currentY,qRgba(col,col,col,255)); currentX++; currentPowerValue=0; diff --git a/inputparser.h b/inputparser.h index a01fd23..7bdcbaf 100644 --- a/inputparser.h +++ b/inputparser.h @@ -28,6 +28,9 @@ private: unsigned long minFreq=-1; unsigned long maxFreq=0; + float minPow=__FLT_MAX__; + float maxPow=0; + unsigned long lastMaxFreq=0; unsigned long index=0;