Mercurial > hg > svcore
comparison base/BaseTypes.h @ 1532:5360f7aba189 zoom
Pull out ZoomLevel, add inexact frame/pixel conversion functions and streaming
author | Chris Cannam |
---|---|
date | Wed, 19 Sep 2018 15:41:44 +0100 |
parents | bf32b26d1dad |
children | 895186c43fce |
comparison
equal
deleted
inserted
replaced
1531:2f3a77472c8c | 1532:5360f7aba189 |
---|---|
53 typedef std::vector<float, breakfastquay::StlAllocator<float>> floatvec_t; | 53 typedef std::vector<float, breakfastquay::StlAllocator<float>> floatvec_t; |
54 | 54 |
55 typedef std::vector<std::complex<float>, | 55 typedef std::vector<std::complex<float>, |
56 breakfastquay::StlAllocator<std::complex<float>>> complexvec_t; | 56 breakfastquay::StlAllocator<std::complex<float>>> complexvec_t; |
57 | 57 |
58 /** Display zoom level. Can be an integer number of samples per pixel, | |
59 * or an integer number of pixels per sample. | |
60 */ | |
61 struct ZoomLevel { | |
62 | |
63 enum Zone { | |
64 FramesPerPixel, // zoomed out (as in classic SV) | |
65 PixelsPerFrame // zoomed in beyond 1-1 (interpolating the waveform) | |
66 }; | |
67 Zone zone; | |
68 int level; | |
69 | |
70 ZoomLevel(Zone z, int l) : zone(z), level(l) { } | |
71 | |
72 bool operator<(const ZoomLevel &other) const { | |
73 if (zone == FramesPerPixel) { | |
74 if (other.zone == zone) { | |
75 return level < other.level; | |
76 } else { | |
77 return false; | |
78 } | |
79 } else { | |
80 if (other.zone == zone) { | |
81 return level > other.level; | |
82 } else { | |
83 return false; | |
84 } | |
85 } | |
86 } | |
87 | |
88 bool operator==(const ZoomLevel &other) const { | |
89 return (zone == other.zone && level == other.level); | |
90 } | |
91 | |
92 ZoomLevel incremented() const { | |
93 if (zone == FramesPerPixel) { | |
94 return { zone, level + 1 }; | |
95 } else if (level == 1) { | |
96 return { FramesPerPixel, 2 }; | |
97 } else if (level == 2) { | |
98 return { FramesPerPixel, 1 }; | |
99 } else { | |
100 return { zone, level - 1 }; | |
101 } | |
102 } | |
103 | |
104 ZoomLevel decremented() const { | |
105 if (zone == PixelsPerFrame) { | |
106 return { zone, level + 1 }; | |
107 } else if (level == 1) { | |
108 return { PixelsPerFrame, 2 }; | |
109 } else { | |
110 return { zone, level - 1 }; | |
111 } | |
112 } | |
113 }; | |
114 | |
115 #endif | 58 #endif |
116 | 59 |