mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Legend: Fixed legend numbers being completely wrong.
The abs() function is only integer on linux RH5. Caused legend numbers to be truncated (0 typically)
This commit is contained in:
@@ -367,13 +367,13 @@ void RimLegendConfig::updateLegend()
|
||||
if (m_mappingMode == LOG10_CONTINUOUS || m_mappingMode == LOG10_DISCRETE)
|
||||
{
|
||||
// For log mapping, use the min value as reference for num valid digits
|
||||
decadesInRange = abs(adjustedMin) < abs(adjustedMax) ? abs(adjustedMin) : abs(adjustedMax);
|
||||
decadesInRange = cvf::Math::abs(adjustedMin) < cvf::Math::abs(adjustedMax) ? cvf::Math::abs(adjustedMin) : cvf::Math::abs(adjustedMax);
|
||||
decadesInRange = log10(decadesInRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
// For linear mapping, use the max value as reference for num valid digits
|
||||
double absRange = CVF_MAX(abs(adjustedMax), abs(adjustedMin));
|
||||
double absRange = CVF_MAX(cvf::Math::abs(adjustedMax), cvf::Math::abs(adjustedMin));
|
||||
decadesInRange = log10(absRange);
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ void RimLegendConfig::updateLegend()
|
||||
int numDecimalDigits = m_precision();
|
||||
if (nft != SCIENTIFIC)
|
||||
{
|
||||
numDecimalDigits -= decadesInRange;
|
||||
numDecimalDigits -= static_cast<int>(decadesInRange);
|
||||
}
|
||||
m_legend->setTickPrecision(cvf::Math::clamp(numDecimalDigits, 0, 20));
|
||||
|
||||
@@ -550,7 +550,7 @@ double RimLegendConfig::roundToNumSignificantDigits(double domainValue, double n
|
||||
double integerPart;
|
||||
double fraction = modf(tmp, &integerPart);
|
||||
|
||||
if (abs(fraction)>= 0.5) (integerPart >= 0) ? integerPart++: integerPart-- ;
|
||||
if (cvf::Math::abs(fraction)>= 0.5) (integerPart >= 0) ? integerPart++: integerPart-- ;
|
||||
|
||||
double newDomainValue = integerPart / factor;
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include "cvfMath.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// A function to do basic statistical calculations
|
||||
@@ -103,7 +104,7 @@ std::vector<double> RigStatisticsMath::calculateNearestRankPercentiles(const std
|
||||
{
|
||||
double pVal = HUGE_VAL;
|
||||
|
||||
size_t pValIndex = static_cast<size_t>(sortedValues.size() * fabs(pValPositions[i]) / 100);
|
||||
size_t pValIndex = static_cast<size_t>(sortedValues.size() * cvf::Math::abs(pValPositions[i]) / 100);
|
||||
|
||||
if (pValIndex >= sortedValues.size() ) pValIndex = sortedValues.size() - 1;
|
||||
|
||||
@@ -142,7 +143,7 @@ std::vector<double> RigStatisticsMath::calculateInterpolatedPercentiles(const st
|
||||
{
|
||||
double pVal = HUGE_VAL;
|
||||
|
||||
double doubleIndex = (sortedValues.size() - 1) * fabs(pValPositions[i]) / 100.0;
|
||||
double doubleIndex = (sortedValues.size() - 1) * cvf::Math::abs(pValPositions[i]) / 100.0;
|
||||
|
||||
size_t lowerValueIndex = static_cast<size_t>(floor(doubleIndex));
|
||||
size_t upperValueIndex = lowerValueIndex + 1;
|
||||
|
||||
Reference in New Issue
Block a user