comparison 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
comparison
equal deleted inserted replaced
1412:b7a9edee85e0 1413:c6fa111b4553
18 18
19 #include <string> 19 #include <string>
20 #include <vector> 20 #include <vector>
21 #include <cmath> 21 #include <cmath>
22 22
23 #define DEBUG_SCALE_TICK_INTERVALS 1 23 //#define DEBUG_SCALE_TICK_INTERVALS 1
24 24
25 #ifdef DEBUG_SCALE_TICK_INTERVALS 25 #ifdef DEBUG_SCALE_TICK_INTERVALS
26 #include <iostream> 26 #include <iostream>
27 #endif 27 #endif
28 28
120 if (inc < roundTo) inc = roundTo; 120 if (inc < roundTo) inc = roundTo;
121 121
122 double min = ceil(r.min / roundTo) * roundTo; 122 double min = ceil(r.min / roundTo) * roundTo;
123 if (min > r.max) min = r.max; 123 if (min > r.max) min = r.max;
124 124
125 if (!fixed && min != 0.0) {
126 double digNewMin = log10(fabs(min));
127 if (digNewMin < digInc) {
128 prec = int(ceil(digMax - digNewMin));
129 #ifdef DEBUG_SCALE_TICK_INTERVALS
130 std::cerr << "min is smaller than increment, adjusting prec to "
131 << prec << std::endl;
132 #endif
133 }
134 }
135
125 Ticks t { min, inc, roundTo, fixed, prec, {} }; 136 Ticks t { min, inc, roundTo, fixed, prec, {} };
126 explode(r, t); 137 explode(r, t);
127 return t; 138 return t;
128 } 139 }
129 140