# HG changeset patch # User Chris Cannam # Date 1453290196 0 # Node ID 9c890b7dfa836bf6999df4601ae8974a6888284b # Parent 6a8084c72e7a8fd663089269f6af2b250aea0835 Add default spectrogram colours to prefs diff -r 6a8084c72e7a -r 9c890b7dfa83 layer/ColourMapper.cpp --- a/layer/ColourMapper.cpp Tue Jan 19 17:18:38 2016 +0000 +++ b/layer/ColourMapper.cpp Wed Jan 20 11:43:16 2016 +0000 @@ -33,13 +33,13 @@ return converted; } -static vector xRay = convertStrings({ +static vector ice = convertStrings({ // Based on ColorBrewer ylGnBu "#ffffff", "#ffff00", "#f7fcf0", "#e0f3db", "#ccebc5", "#a8ddb5", "#7bccc4", "#4eb3d3", "#2b8cbe", "#0868ac", "#084081", "#042040" }); -static vector cherryPie = convertStrings({ +static vector cherry = convertStrings({ "#f7f7f7", "#fddbc7", "#f4a582", "#d6604d", "#b2182b", "#dd3497", "#ae017e", "#7a0177", "#49006a" }); @@ -89,12 +89,12 @@ StandardMap map = (StandardMap)n; switch (map) { - case DefaultColours: return tr("Green"); + case Green: return tr("Green"); case WhiteOnBlack: return tr("White on Black"); case BlackOnWhite: return tr("Black on White"); - case CherryPie: return tr("Cherry"); - case YellowOnBlack: return tr("Wasp"); - case XRay: return tr("X-Ray"); + case Cherry: return tr("Cherry"); + case Wasp: return tr("Wasp"); + case Ice: return tr("Ice"); case Sunset: return tr("Sunset"); case FruitSalad: return tr("Fruit Salad"); case Banded: return tr("Banded"); @@ -123,7 +123,7 @@ switch (map) { - case DefaultColours: + case Green: h = blue - norm * 2.0 * pieslice; s = 0.5f + norm/2.0; v = norm; @@ -139,12 +139,12 @@ hsv = false; break; - case CherryPie: + case Cherry: hsv = false; - mapDiscrete(norm, cherryPie, r, g, b); + mapDiscrete(norm, cherry, r, g, b); break; - case YellowOnBlack: + case Wasp: h = 0.15; s = 1.0; v = norm; @@ -233,9 +233,9 @@ */ break; - case XRay: + case Ice: hsv = false; - mapDiscrete(norm, xRay, r, g, b); + mapDiscrete(norm, ice, r, g, b); } if (hsv) { @@ -253,7 +253,7 @@ switch (map) { - case DefaultColours: + case Green: return QColor(255, 150, 50); case WhiteOnBlack: @@ -262,13 +262,13 @@ case BlackOnWhite: return Qt::darkGreen; - case CherryPie: + case Cherry: return Qt::green; - case YellowOnBlack: + case Wasp: return QColor::fromHsv(240, 255, 255); - case XRay: + case Ice: return Qt::red; case Sunset: @@ -306,12 +306,12 @@ case HighGain: return true; - case DefaultColours: + case Green: case Sunset: case WhiteOnBlack: - case CherryPie: - case YellowOnBlack: - case XRay: + case Cherry: + case Wasp: + case Ice: case FruitSalad: case Banded: case Highlight: diff -r 6a8084c72e7a -r 9c890b7dfa83 layer/ColourMapper.h --- a/layer/ColourMapper.h Tue Jan 19 17:18:38 2016 +0000 +++ b/layer/ColourMapper.h Wed Jan 20 11:43:16 2016 +0000 @@ -33,13 +33,13 @@ virtual ~ColourMapper(); enum StandardMap { - DefaultColours, + Green, Sunset, WhiteOnBlack, BlackOnWhite, - CherryPie, - YellowOnBlack, - XRay, + Cherry, + Wasp, + Ice, FruitSalad, Banded, Highlight, diff -r 6a8084c72e7a -r 9c890b7dfa83 layer/SpectrogramLayer.cpp --- a/layer/SpectrogramLayer.cpp Tue Jan 19 17:18:38 2016 +0000 +++ b/layer/SpectrogramLayer.cpp Wed Jan 20 11:43:16 2016 +0000 @@ -38,6 +38,7 @@ #include #include #include +#include #include @@ -81,6 +82,9 @@ m_exiting(false), m_sliceableModel(0) { + QString colourConfigName = "spectrogram-colour"; + int colourConfigDefault = int(ColourMapper::Green); + if (config == FullRangeDb) { m_initialMaxFrequency = 0; setMaxFrequency(0); @@ -93,6 +97,8 @@ setColourScale(LinearColourScale); setColourMap(ColourMapper::Sunset); setFrequencyScale(LogFrequencyScale); + colourConfigName = "spectrogram-melodic-colour"; + colourConfigDefault = int(ColourMapper::Sunset); // setGain(20); } else if (config == MelodicPeaks) { setWindowSize(4096); @@ -104,8 +110,15 @@ setColourScale(LinearColourScale); setBinDisplay(PeakFrequencies); setNormalization(NormalizeColumns); + colourConfigName = "spectrogram-melodic-colour"; + colourConfigDefault = int(ColourMapper::Sunset); } + QSettings settings; + settings.beginGroup("Preferences"); + setColourMap(settings.value(colourConfigName, colourConfigDefault).toInt()); + settings.endGroup(); + Preferences *prefs = Preferences::getInstance(); connect(prefs, SIGNAL(propertyChanged(PropertyContainer::PropertyName)), this, SLOT(preferenceChanged(PropertyContainer::PropertyName)));