diff --git a/dive.h b/dive.h index e4c4e354c..c56d569ad 100644 --- a/dive.h +++ b/dive.h @@ -20,6 +20,8 @@ (void) (&_max1 == &_max2); \ _max1 > _max2 ? _max1 : _max2; }) +#define IS_FP_SAME(_a,_b) (abs((_a) - (_b)) < 0.000001) + #include #include diff --git a/dives/test9a.xml b/dives/test9a.xml new file mode 100644 index 000000000..ac9fa8582 --- /dev/null +++ b/dives/test9a.xml @@ -0,0 +1,42 @@ + + + + + + 9Ath test dive, with temperature in single sample + Test collapse of temperature axis due to max_temp == min_temp. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp index fdcfff3c6..505b60d7e 100644 --- a/qt-ui/profile/divecartesianaxis.cpp +++ b/qt-ui/profile/divecartesianaxis.cpp @@ -184,7 +184,8 @@ qreal DiveCartesianAxis::posAtValue(qreal value) double size = max - min; // unused for now: // double distanceFromOrigin = value - min; - double percent = (value - min) / size; + double percent = IS_FP_SAME(min,max) ? 0.0 : (value - min) / size; + double realSize = orientation == LeftToRight || orientation == RightToLeft? m.x2() - m.x1() :