From: vsv Date: Mon, 11 Nov 2019 14:27:24 +0000 (+0300) Subject: Issue #2185: Fix bug with negative values for color scale X-Git-Tag: V9_5_0a1~173 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=34723ac370da1f3cb2d3a53f957c1fa40f0188e3;p=modules%2Fshaper.git Issue #2185: Fix bug with negative values for color scale --- 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;