Mercurial > hg > svcore
diff base/ScaleTickIntervals.h @ 1413:c6fa111b4553 scale-ticks
Tests now passing
author | Chris Cannam |
---|---|
date | Thu, 04 May 2017 08:53:00 +0100 |
parents | b7a9edee85e0 |
children | c57994e1edd7 |
line wrap: on
line diff
--- a/base/ScaleTickIntervals.h Thu May 04 08:32:41 2017 +0100 +++ b/base/ScaleTickIntervals.h Thu May 04 08:53:00 2017 +0100 @@ -20,7 +20,7 @@ #include <vector> #include <cmath> -#define DEBUG_SCALE_TICK_INTERVALS 1 +//#define DEBUG_SCALE_TICK_INTERVALS 1 #ifdef DEBUG_SCALE_TICK_INTERVALS #include <iostream> @@ -122,6 +122,17 @@ double min = ceil(r.min / roundTo) * roundTo; if (min > r.max) min = r.max; + if (!fixed && min != 0.0) { + double digNewMin = log10(fabs(min)); + if (digNewMin < digInc) { + prec = int(ceil(digMax - digNewMin)); +#ifdef DEBUG_SCALE_TICK_INTERVALS + std::cerr << "min is smaller than increment, adjusting prec to " + << prec << std::endl; +#endif + } + } + Ticks t { min, inc, roundTo, fixed, prec, {} }; explode(r, t); return t;