From 34723ac370da1f3cb2d3a53f957c1fa40f0188e3 Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 11 Nov 2019 17:27:24 +0300 Subject: [PATCH] Issue #2185: Fix bug with negative values for color scale --- src/PartSet/PartSet_FieldStepPrs.cpp | 32 ++++++++++++++++++---------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/PartSet/PartSet_FieldStepPrs.cpp b/src/PartSet/PartSet_FieldStepPrs.cpp index 20dd7ca98..8bf365e67 100644 --- a/src/PartSet/PartSet_FieldStepPrs.cpp +++ b/src/PartSet/PartSet_FieldStepPrs.cpp @@ -123,18 +123,28 @@ QList PartSet_FieldStepPrs::range(double& theMin, double& theMax) const } QList aShapeData; double aRangeMin = aFieldStepData.first(), aRangeMax = aFieldStepData.last(); - for (int aRow = 0; aRow < aRows - aStart; aRow++) { - double aNorm = 0; - int aBaseIndex = aRow * aCols; - for (int aCol = 0; aCol < aCols; aCol++) { - int anIndex = aCol + aBaseIndex; - double aValue = aFieldStepData.at(anIndex); - aNorm += aValue * aValue; + if (aCols == 1) { + for (int aRow = 0; aRow < aRows - aStart; aRow++) { + double aValue = aFieldStepData.at(aRow); + aRangeMin = Min(aRangeMin, aValue); + aRangeMax = Max(aRangeMax, aValue); + aShapeData << aValue; + } + } + else { + for (int aRow = 0; aRow < aRows - aStart; aRow++) { + double aNorm = 0; + int aBaseIndex = aRow * aCols; + for (int aCol = 0; aCol < aCols; aCol++) { + int anIndex = aCol + aBaseIndex; + double aValue = aFieldStepData.at(anIndex); + aNorm += aValue * aValue; + } + aNorm = pow(aNorm, 0.5); + aRangeMin = Min(aRangeMin, aNorm); + aRangeMax = Max(aRangeMax, aNorm); + aShapeData << aNorm; } - aNorm = pow(aNorm, 0.5); - aRangeMin = Min(aRangeMin, aNorm); - aRangeMax = Max(aRangeMax, aNorm); - aShapeData << aNorm; } theMin = aRangeMin; theMax = aRangeMax; -- 2.39.2