Mercurial > hg > svgui
comparison layer/WaveformLayer.cpp @ 1147:1badacff7ab2 3.0-integration
Introduce labels in RangeMapper and use them in AudioDial, though only for tooltip at present. Make use of this for spectrogram magic -81dB/-Inf threshold. Also introduce static strings for inf/pi and use where appropriate.
author | Chris Cannam |
---|---|
date | Fri, 05 Aug 2016 17:48:52 +0100 |
parents | ee01a4062747 |
children | a34a2a25907c |
comparison
equal
deleted
inserted
replaced
1146:74f2706995b7 | 1147:1badacff7ab2 |
---|---|
17 | 17 |
18 #include "base/AudioLevel.h" | 18 #include "base/AudioLevel.h" |
19 #include "view/View.h" | 19 #include "view/View.h" |
20 #include "base/Profiler.h" | 20 #include "base/Profiler.h" |
21 #include "base/RangeMapper.h" | 21 #include "base/RangeMapper.h" |
22 #include "base/Strings.h" | |
22 | 23 |
23 #include "ColourDatabase.h" | 24 #include "ColourDatabase.h" |
24 #include "PaintAssistant.h" | 25 #include "PaintAssistant.h" |
25 | 26 |
26 #include <QPainter> | 27 #include <QPainter> |
1201 { | 1202 { |
1202 if (m_scale == LinearScale) { | 1203 if (m_scale == LinearScale) { |
1203 return paint.fontMetrics().width("0.0") + 13; | 1204 return paint.fontMetrics().width("0.0") + 13; |
1204 } else { | 1205 } else { |
1205 return std::max(paint.fontMetrics().width(tr("0dB")), | 1206 return std::max(paint.fontMetrics().width(tr("0dB")), |
1206 paint.fontMetrics().width(tr("-Inf"))) + 13; | 1207 paint.fontMetrics().width(Strings::minus_infinity)) + 13; |
1207 } | 1208 } |
1208 } | 1209 } |
1209 | 1210 |
1210 void | 1211 void |
1211 WaveformLayer::paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect rect) const | 1212 WaveformLayer::paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect rect) const |
1255 case MeterScale: | 1256 case MeterScale: |
1256 val = AudioLevel::dB_to_multiplier(meterdbs[i]) * gain; | 1257 val = AudioLevel::dB_to_multiplier(meterdbs[i]) * gain; |
1257 text = QString("%1").arg(meterdbs[i]); | 1258 text = QString("%1").arg(meterdbs[i]); |
1258 if (i == n) text = tr("0dB"); | 1259 if (i == n) text = tr("0dB"); |
1259 if (i == 0) { | 1260 if (i == 0) { |
1260 text = tr("-Inf"); | 1261 text = Strings::minus_infinity; |
1261 val = 0.0; | 1262 val = 0.0; |
1262 } | 1263 } |
1263 break; | 1264 break; |
1264 | 1265 |
1265 case dBScale: | 1266 case dBScale: |
1266 val = AudioLevel::dB_to_multiplier(-(10*n) + i * 10) * gain; | 1267 val = AudioLevel::dB_to_multiplier(-(10*n) + i * 10) * gain; |
1267 text = QString("%1").arg(-(10*n) + i * 10); | 1268 text = QString("%1").arg(-(10*n) + i * 10); |
1268 if (i == n) text = tr("0dB"); | 1269 if (i == n) text = tr("0dB"); |
1269 if (i == 0) { | 1270 if (i == 0) { |
1270 text = tr("-Inf"); | 1271 text = Strings::minus_infinity; |
1271 val = 0.0; | 1272 val = 0.0; |
1272 } | 1273 } |
1273 break; | 1274 break; |
1274 } | 1275 } |
1275 | 1276 |