From 94e376346ef0518d2148c94917f93d8855ebda99 Mon Sep 17 00:00:00 2001 From: Uwe Date: Sun, 12 Jun 2022 01:05:26 +0200 Subject: [PATCH] [FEM] fix display of point filter - results of 1e8 or 1e-7 in fixed notation are almost unreadable, therefore use scientific notation if necessary --- src/Mod/Fem/Gui/TaskPostBoxes.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Mod/Fem/Gui/TaskPostBoxes.cpp b/src/Mod/Fem/Gui/TaskPostBoxes.cpp index 3d8bc53a1e..77a659d23f 100644 --- a/src/Mod/Fem/Gui/TaskPostBoxes.cpp +++ b/src/Mod/Fem/Gui/TaskPostBoxes.cpp @@ -967,8 +967,20 @@ void TaskPostDataAtPoint::on_Field_activated(int i) { static_cast(getObject())->Unit.setValue(""); } - std::string PointData = " The value at that location is " - + std::to_string(static_cast(getObject())->PointData[0]) + auto pointValue = static_cast(getObject())->PointData[0]; + + // for display we must therefore convert large and small numbers to scientific notation + // if pointValue is in the range [1e-2, 1e+4] -> fixed notation, else scientific + bool scientific = (pointValue < 1e-2) || (pointValue > 1e4); + std::ios::fmtflags flags = scientific ? (std::ios::scientific | std::ios::showpoint | std::ios::showpos) + : (std::ios::fixed | std::ios::showpoint | std::ios::showpos); + int UserDecimals = Base::UnitsApi::getDecimals(); + std::stringstream valueStream; + valueStream.precision(UserDecimals); + valueStream.setf(flags); + valueStream << pointValue; + + std::string PointData = " The value at that location is " + valueStream.str() + " " + static_cast(getObject())->Unit.getValue() + "\n"; QMessageBox::information(Gui::getMainWindow(), qApp->translate("CmdFemPostCreateDataAtPointFilter", "Data At Point"),