diff --git a/src/libs/antares/study/scenario-builder/hydroLevelsData.cpp b/src/libs/antares/study/scenario-builder/hydroLevelsData.cpp index 4521bf3c1d..93da18dd55 100644 --- a/src/libs/antares/study/scenario-builder/hydroLevelsData.cpp +++ b/src/libs/antares/study/scenario-builder/hydroLevelsData.cpp @@ -28,6 +28,7 @@ #include #include #include "hydroLevelsData.h" +#include "scBuilderUtils.h" namespace Antares { @@ -43,7 +44,7 @@ namespace ScenarioBuilder const uint nbYears = study.parameters.nbYears; pHydroLevelsRules.reset(study.areas.size(), nbYears); - pHydroLevelsRules.fill(-1.); + pHydroLevelsRules.fill(std::nan("")); return true; } @@ -70,7 +71,7 @@ namespace ScenarioBuilder { const MatrixType::Type value = col[y]; // Equals to zero means 'auto', which is the default mode - if (value < 0.) + if (std::isnan(value)) continue; assert(index < study.areas.size()); value_into_string << value; diff --git a/src/libs/antares/study/scenario-builder/scBuilderUtils.cpp b/src/libs/antares/study/scenario-builder/scBuilderUtils.cpp index eadd53dc7d..44a2781fb9 100644 --- a/src/libs/antares/study/scenario-builder/scBuilderUtils.cpp +++ b/src/libs/antares/study/scenario-builder/scBuilderUtils.cpp @@ -59,11 +59,11 @@ namespace ScenarioBuilder } catch (std::invalid_argument&) { - return -1.; + return std::nan(""); } if (result_tmp < 0.) - result = -1.; + result = 0.; else { if (result_tmp > maxLevel) diff --git a/src/libs/antares/study/scenario-builder/scBuilderUtils.h b/src/libs/antares/study/scenario-builder/scBuilderUtils.h index 2872660ab7..75150f44f3 100644 --- a/src/libs/antares/study/scenario-builder/scBuilderUtils.h +++ b/src/libs/antares/study/scenario-builder/scBuilderUtils.h @@ -39,7 +39,6 @@ namespace Data { namespace ScenarioBuilder { - string fromHydroLevelToString(double d); double fromStringToHydroLevel(const Yuni::String& value, const double maxLevel); diff --git a/src/ui/simulator/toolbox/components/datagrid/renderer/scenario-builder-hydro-levels-renderer.cpp b/src/ui/simulator/toolbox/components/datagrid/renderer/scenario-builder-hydro-levels-renderer.cpp index 1a8c5e2e4f..80de6a4ca7 100644 --- a/src/ui/simulator/toolbox/components/datagrid/renderer/scenario-builder-hydro-levels-renderer.cpp +++ b/src/ui/simulator/toolbox/components/datagrid/renderer/scenario-builder-hydro-levels-renderer.cpp @@ -47,7 +47,7 @@ namespace Renderer { const double d = cellNumericValue(x, y); - return (d < 0.) + return (std::isnan(d)) ? wxString() << wxT("rand") : wxString() << fromHydroLevelToString(d); } @@ -82,6 +82,14 @@ namespace Renderer return 0.; } + IRenderer::CellStyle hydroLevelsScBuilderRenderer::cellStyle(int x, int y) const + { + bool valid = (!(!study) && !(!pRules) && std::isnan(cellNumericValue(x, y))); + return (valid) + ? cellStyleDefaultCenterDisabled + : cellStyleDefaultCenter; + } + } // namespace Renderer } // namespace Datagrid } // namespace Component diff --git a/src/ui/simulator/toolbox/components/datagrid/renderer/scenario-builder-hydro-levels-renderer.h b/src/ui/simulator/toolbox/components/datagrid/renderer/scenario-builder-hydro-levels-renderer.h index 09b4d91d49..cff2807936 100644 --- a/src/ui/simulator/toolbox/components/datagrid/renderer/scenario-builder-hydro-levels-renderer.h +++ b/src/ui/simulator/toolbox/components/datagrid/renderer/scenario-builder-hydro-levels-renderer.h @@ -46,6 +46,7 @@ namespace Renderer wxString cellValue(int x, int y) const; bool cellValue(int x, int y, const Yuni::String& value); double cellNumericValue(int x, int y) const; + IRenderer::CellStyle cellStyle(int x, int y) const; }; // class hydroLevelsScBuilderRenderer