Skip to content

Commit

Permalink
Fix/sc builder hydro auto reframe entry (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
guilpier-code authored Jan 26, 2021
1 parent 708ada0 commit 667d864
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/libs/antares/study/scenario-builder/hydroLevelsData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <sstream>
#include <iomanip>
#include "hydroLevelsData.h"
#include "scBuilderUtils.h"

namespace Antares
{
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/libs/antares/study/scenario-builder/scBuilderUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/libs/antares/study/scenario-builder/scBuilderUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ namespace Data
{
namespace ScenarioBuilder
{

string fromHydroLevelToString(double d);
double fromStringToHydroLevel(const Yuni::String& value, const double maxLevel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 667d864

Please sign in to comment.