Mercurial > hg > svgui
comparison layer/SpectrogramLayer.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 | 17f999cd0a22 |
children | 0edfed2c8482 |
comparison
equal
deleted
inserted
replaced
1146:74f2706995b7 | 1147:1badacff7ab2 |
---|---|
22 #include "base/Pitch.h" | 22 #include "base/Pitch.h" |
23 #include "base/Preferences.h" | 23 #include "base/Preferences.h" |
24 #include "base/RangeMapper.h" | 24 #include "base/RangeMapper.h" |
25 #include "base/LogRange.h" | 25 #include "base/LogRange.h" |
26 #include "base/ColumnOp.h" | 26 #include "base/ColumnOp.h" |
27 #include "base/Strings.h" | |
27 #include "widgets/CommandHistory.h" | 28 #include "widgets/CommandHistory.h" |
28 #include "data/model/Dense3DModelPeakCache.h" | 29 #include "data/model/Dense3DModelPeakCache.h" |
29 | 30 |
30 #include "ColourMapper.h" | 31 #include "ColourMapper.h" |
31 #include "PianoScale.h" | 32 #include "PianoScale.h" |
527 { | 528 { |
528 if (name == "Gain") { | 529 if (name == "Gain") { |
529 return new LinearRangeMapper(-50, 50, -25, 25, tr("dB")); | 530 return new LinearRangeMapper(-50, 50, -25, 25, tr("dB")); |
530 } | 531 } |
531 if (name == "Threshold") { | 532 if (name == "Threshold") { |
532 return new LinearRangeMapper(-81, -1, -81, -1, tr("dB")); | 533 return new LinearRangeMapper(-81, -1, -81, -1, tr("dB"), false, |
534 { { -81, Strings::minus_infinity } }); | |
533 } | 535 } |
534 return 0; | 536 return 0; |
535 } | 537 } |
536 | 538 |
537 void | 539 void |
1954 double dbMin = AudioLevel::multiplier_to_dB(magMin); | 1956 double dbMin = AudioLevel::multiplier_to_dB(magMin); |
1955 double dbMax = AudioLevel::multiplier_to_dB(magMax); | 1957 double dbMax = AudioLevel::multiplier_to_dB(magMax); |
1956 QString dbMinString; | 1958 QString dbMinString; |
1957 QString dbMaxString; | 1959 QString dbMaxString; |
1958 if (dbMin == AudioLevel::DB_FLOOR) { | 1960 if (dbMin == AudioLevel::DB_FLOOR) { |
1959 dbMinString = tr("-Inf"); | 1961 dbMinString = Strings::minus_infinity; |
1960 } else { | 1962 } else { |
1961 dbMinString = QString("%1").arg(lrint(dbMin)); | 1963 dbMinString = QString("%1").arg(lrint(dbMin)); |
1962 } | 1964 } |
1963 if (dbMax == AudioLevel::DB_FLOOR) { | 1965 if (dbMax == AudioLevel::DB_FLOOR) { |
1964 dbMaxString = tr("-Inf"); | 1966 dbMaxString = Strings::minus_infinity; |
1965 } else { | 1967 } else { |
1966 dbMaxString = QString("%1").arg(lrint(dbMax)); | 1968 dbMaxString = QString("%1").arg(lrint(dbMax)); |
1967 } | 1969 } |
1968 if (lrint(dbMin) != lrint(dbMax)) { | 1970 if (lrint(dbMin) != lrint(dbMax)) { |
1969 text += tr("dB:\t%1 - %2").arg(dbMinString).arg(dbMaxString); | 1971 text += tr("dB:\t%1 - %2").arg(dbMinString).arg(dbMaxString); |
2217 int topLines = 1; | 2219 int topLines = 1; |
2218 | 2220 |
2219 int ch = h - textHeight * (topLines + 1) - 8; | 2221 int ch = h - textHeight * (topLines + 1) - 8; |
2220 paint.drawRect(4 + cw - cbw, textHeight * topLines + 4, cbw - 1, ch + 1); | 2222 paint.drawRect(4 + cw - cbw, textHeight * topLines + 4, cbw - 1, ch + 1); |
2221 | 2223 |
2222 QString top, bottom, middle; | 2224 QString top = Strings::pi, bottom = Strings::minus_pi, middle = "0"; |
2223 top = QString("%1").arg(QChar(0x3c0)); // pi | |
2224 bottom = "-" + top; | |
2225 middle = "0"; | |
2226 | 2225 |
2227 double min = -M_PI; | 2226 double min = -M_PI; |
2228 double max = M_PI; | 2227 double max = M_PI; |
2229 | 2228 |
2230 paint.drawText(3 + cw - cbw - paint.fontMetrics().width(top), | 2229 paint.drawText(3 + cw - cbw - paint.fontMetrics().width(top), |