From acede8c347e1bef2913311b6e903d3bd3d87ec91 Mon Sep 17 00:00:00 2001 From: Uwe Date: Tue, 5 Apr 2022 03:40:10 +0200 Subject: [PATCH] [Gui] Color Gradient: handle case of min = 0 When the minimum is zero, we don't want scientific notation, for example for a range [0, 12.57] --- src/Gui/SoFCColorGradient.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Gui/SoFCColorGradient.cpp b/src/Gui/SoFCColorGradient.cpp index 6e7c709617..048cc481d4 100644 --- a/src/Gui/SoFCColorGradient.cpp +++ b/src/Gui/SoFCColorGradient.cpp @@ -161,14 +161,12 @@ void SoFCColorGradient::setRange(float fMin, float fMax, int prec) // otherwise output "normal" (fixed notation) SoMFString label; - std::ios::fmtflags flags = 0; + std::ios::fmtflags flags = (std::ios::fixed | std::ios::showpoint | std::ios::showpos); float eps = std::pow(10.0f, static_cast(-prec)); - if ((std::min(fabs(fMin), fabs(fMax)) < eps) - || (std::max(fabs(fMin), fabs(fMax)) > 1e4)) + if ( ( (std::min(fabs(fMin), fabs(fMax)) < eps) && (std::min(fabs(fMin), fabs(fMax)) != 0.0f) ) + || (std::max(fabs(fMin), fabs(fMax)) > 1e4) ) flags = (std::ios::scientific | std::ios::showpoint | std::ios::showpos); - else - flags = (std::ios::fixed | std::ios::showpoint | std::ios::showpos); // write the labels int i = 0;