comparison base/ScaleTickIntervals.h @ 1409:21ba60008200 scale-ticks

More fixes, more tests, including some more that now fail
author Chris Cannam
date Wed, 03 May 2017 18:01:25 +0100
parents f89365917d02
children c4af57d59434
comparison
equal deleted inserted replaced
1408:f89365917d02 1409:21ba60008200
64 64
65 double digInc = log10(inc); 65 double digInc = log10(inc);
66 double digMax = log10(fabs(r.max)); 66 double digMax = log10(fabs(r.max));
67 double digMin = log10(fabs(r.min)); 67 double digMin = log10(fabs(r.min));
68 68
69 int precInc = int(trunc(digInc)) - 1; 69 int precInc = int(trunc(digInc));
70 if (double(precInc) != digInc) {
71 precInc -= 1;
72 }
70 73
71 bool fixed = false; 74 bool fixed = false;
72 if (precInc > -4 && precInc < 4) { 75 if (precInc > -4 && precInc < 4) {
73 fixed = true; 76 fixed = true;
74 } else if ((digMax >= -3.0 && digMax <= 2.0) && 77 } else if ((digMax >= -3.0 && digMax <= 2.0) &&
94 std::cerr << "digMax = " << digMax << ", digInc = " << digInc 97 std::cerr << "digMax = " << digMax << ", digInc = " << digInc
95 << std::endl; 98 << std::endl;
96 std::cerr << "fixed = " << fixed << ", inc = " << inc 99 std::cerr << "fixed = " << fixed << ", inc = " << inc
97 << ", precInc = " << precInc << ", precRange = " << precRange 100 << ", precInc = " << precInc << ", precRange = " << precRange
98 << ", prec = " << prec << std::endl; 101 << ", prec = " << prec << std::endl;
99 102
100 // int prec = int((ilg > 0.0) ? round(ilg) : trunc(ilg)) - 1;
101 /*
102 int dp = 0, sf = 0;
103 bool fixed = false;
104 if (prec < 0) {
105 dp = -prec;
106 sf = 1; // was 2, but should probably vary
107 } else {
108 sf = prec;
109 }
110 if (sf == 0) {
111 sf = 1;
112 }
113 if (prec > -4 && prec < 4) {
114 fixed = true;
115 }
116 */
117 /* bool fixed = true;
118 int dp = sig;
119 int sf = prec;
120 */
121 double roundTo = pow(10.0, precInc); 103 double roundTo = pow(10.0, precInc);
122 104
123 std::cerr << "roundTo = " << roundTo << std::endl; 105 std::cerr << "roundTo = " << roundTo << std::endl;
124 106
125 inc = round(inc / roundTo) * roundTo; 107 inc = round(inc / roundTo) * roundTo;