[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]
This commit is contained in:
Uwe
2022-04-05 03:40:10 +02:00
parent e34ecb0c5e
commit bc017a7c03

View File

@@ -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<float>(-prec));
if ((std::min<float>(fabs(fMin), fabs(fMax)) < eps)
|| (std::max<float>(fabs(fMin), fabs(fMax)) > 1e4))
if ( ( (std::min<float>(fabs(fMin), fabs(fMax)) < eps) && (std::min<float>(fabs(fMin), fabs(fMax)) != 0.0f) )
|| (std::max<float>(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;