Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 9de075c0 authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Merge branch 'fix-variable-line' into 'master'

Fix display of variable lines with no variation or with invalid values

See merge request !21
parents 177a2251 305ccbc9
No related branches found
No related tags found
1 merge request!21Fix display of variable lines with no variation or with invalid values
Pipeline #140433 passed
...@@ -57,6 +57,11 @@ ...@@ -57,6 +57,11 @@
using namespace std; using namespace std;
bool convert_to_double(const std::string &arg, double *val) { bool convert_to_double(const std::string &arg, double *val) {
if (arg.compare("-nan") == 0 || arg.compare("nan") == 0 || arg.compare("inf") == 0) {
*val = 0;
return true;
}
int nb_read; int nb_read;
// Try to convert first in the current locale // Try to convert first in the current locale
sscanf(arg.c_str(), "%lf%n", val, &nb_read); sscanf(arg.c_str(), "%lf%n", val, &nb_read);
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include <iostream> #include <iostream>
#include <cassert> #include <cassert>
#include <cmath>
/* /*
* Theses constants can not be put as static const float because it is a template and there binary representation is not normed by the C++ langage. * Theses constants can not be put as static const float because it is a template and there binary representation is not normed by the C++ langage.
...@@ -529,7 +530,15 @@ public: ...@@ -529,7 +530,15 @@ public:
/* Call the object state drawing function. /* Call the object state drawing function.
We pass the first value if correspond to the beginning */ We pass the first value if correspond to the beginning */
first_value = variable_value.first.get_value(); first_value = variable_value.first.get_value();
second_value =(variable_value.second.get_value()-min)/(max-min) ;
// min and max can be equal if all values are equal (ie 0) or if there is only one value for the variable
if (fabs(max-min) < std::numeric_limits<double>::epsilon()) {
second_value = 0;
}
else {
second_value =(variable_value.second.get_value()-min)/(max-min);
}
if(!(first_value == 0. && second_value == 0.)) { if(!(first_value == 0. && second_value == 0.)) {
draw_variable_value(draw_object, first_value, second_value, position); draw_variable_value(draw_object, first_value, second_value, position);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment