Mercurial > hg > svgui
changeset 1017:9c890b7dfa83 colourschemes
Add default spectrogram colours to prefs
author | Chris Cannam |
---|---|
date | Wed, 20 Jan 2016 11:43:16 +0000 |
parents | 6a8084c72e7a |
children | 072f0db59081 |
files | layer/ColourMapper.cpp layer/ColourMapper.h layer/SpectrogramLayer.cpp |
diffstat | 3 files changed, 37 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- 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<QColor> xRay = convertStrings({ +static vector<QColor> ice = convertStrings({ // Based on ColorBrewer ylGnBu "#ffffff", "#ffff00", "#f7fcf0", "#e0f3db", "#ccebc5", "#a8ddb5", "#7bccc4", "#4eb3d3", "#2b8cbe", "#0868ac", "#084081", "#042040" }); -static vector<QColor> cherryPie = convertStrings({ +static vector<QColor> 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:
--- 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,
--- 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 <QMessageBox> #include <QMouseEvent> #include <QTextStream> +#include <QSettings> #include <iostream> @@ -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)));