comparison base/LogRange.cpp @ 464:9525c9d7e54d

* Add vertical zoom and pan to time-value layer. Still some defects, particularly in logarithmic mode. Now need to get this in note layer as well! * Some fixes to log colouring in segmentation mode of time-value layer.
author Chris Cannam
date Fri, 24 Oct 2008 14:52:40 +0000
parents 2268963dabd1
children 1405f4a2caf3
comparison
equal deleted inserted replaced
463:93806ad9481e 464:9525c9d7e54d
14 */ 14 */
15 15
16 #include "LogRange.h" 16 #include "LogRange.h"
17 17
18 #include <algorithm> 18 #include <algorithm>
19 #include <iostream>
19 #include <cmath> 20 #include <cmath>
20 21
21 void 22 void
22 LogRange::mapRange(float &min, float &max, float logthresh) 23 LogRange::mapRange(float &min, float &max, float logthresh)
23 { 24 {
24 if (min > max) std::swap(min, max); 25 if (min > max) std::swap(min, max);
25 if (max == min) max = min + 1; 26 if (max == min) max = min + 1;
26 27
28 // std::cerr << "LogRange::mapRange: min = " << min << ", max = " << max << std::endl;
29
27 if (min >= 0.f) { 30 if (min >= 0.f) {
28 31
29 max = log10f(max); // we know max != 0 32 max = log10f(max); // we know max != 0
30 33
31 if (min == 0.f) min = std::min(logthresh, max); 34 if (min == 0.f) min = std::min(logthresh, max);
32 else min = log10f(min); 35 else min = log10f(min);
36
37 // std::cerr << "LogRange::mapRange: positive: min = " << min << ", max = " << max << std::endl;
33 38
34 } else if (max <= 0.f) { 39 } else if (max <= 0.f) {
35 40
36 min = log10f(-min); // we know min != 0 41 min = log10f(-min); // we know min != 0
37 42
38 if (max == 0.f) max = std::min(logthresh, min); 43 if (max == 0.f) max = std::min(logthresh, min);
39 else max = log10f(-max); 44 else max = log10f(-max);
40 45
41 std::swap(min, max); 46 std::swap(min, max);
42 47
48 // std::cerr << "LogRange::mapRange: negative: min = " << min << ", max = " << max << std::endl;
49
43 } else { 50 } else {
44 51
45 // min < 0 and max > 0 52 // min < 0 and max > 0
46 53
47 max = log10f(std::max(max, -min)); 54 max = log10f(std::max(max, -min));
48 min = std::min(logthresh, max); 55 min = std::min(logthresh, max);
56
57 // std::cerr << "LogRange::mapRange: spanning: min = " << min << ", max = " << max << std::endl;
49 } 58 }
50 59
51 if (min == max) min = max - 1; 60 if (min == max) min = max - 1;
52 } 61 }
53 62