Mercurial > hg > svgui
diff layer/SpectrogramLayer.cpp @ 1374:631897ba9fca zoom
Merge from default branch
author | Chris Cannam |
---|---|
date | Tue, 06 Nov 2018 08:59:03 +0000 |
parents | d79e21855aef |
children | b6cca362bbf4 |
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp Fri Oct 05 10:25:52 2018 +0100 +++ b/layer/SpectrogramLayer.cpp Tue Nov 06 08:59:03 2018 +0000 @@ -73,6 +73,7 @@ m_colourScale(ColourScaleType::Log), m_colourScaleMultiple(1.0), m_colourMap(0), + m_colourInverted(false), m_binScale(BinScale::Linear), m_binDisplay(BinDisplay::AllBins), m_normalization(ColumnNormalization::None), @@ -448,7 +449,7 @@ int value) const { if (name == "Colour") { - return ColourMapper::getColourMapName(value); + return ColourMapper::getColourMapLabel(value); } if (name == "Colour Scale") { switch (value) { @@ -1081,7 +1082,8 @@ bool SpectrogramLayer::hasLightBackground() const { - return ColourMapper(m_colourMap, 1.f, 255.f).hasLightBackground(); + return ColourMapper(m_colourMap, m_colourInverted, 1.f, 255.f) + .hasLightBackground(); } double @@ -1530,7 +1532,8 @@ m_renderers[viewId] = new Colour3DPlotRenderer(sources, params); m_crosshairColour = - ColourMapper(m_colourMap, 1.f, 255.f).getContrastingColour(); + ColourMapper(m_colourMap, m_colourInverted, 1.f, 255.f) + .getContrastingColour(); } return m_renderers[viewId]; @@ -2508,18 +2511,27 @@ s += QString("minFrequency=\"%1\" " "maxFrequency=\"%2\" " "colourScale=\"%3\" " - "colourScheme=\"%4\" " - "colourRotation=\"%5\" " - "frequencyScale=\"%6\" " - "binDisplay=\"%7\" ") + "colourRotation=\"%4\" " + "frequencyScale=\"%5\" " + "binDisplay=\"%6\" ") .arg(m_minFrequency) .arg(m_maxFrequency) .arg(convertFromColourScale(m_colourScale, m_colourScaleMultiple)) - .arg(m_colourMap) .arg(m_colourRotation) .arg(int(m_binScale)) .arg(int(m_binDisplay)); + // New-style colour map attribute, by string id rather than by + // number + + s += QString("colourMap=\"%1\" ") + .arg(ColourMapper::getColourMapId(m_colourMap)); + + // Old-style colour map attribute + + s += QString("colourScheme=\"%1\" ") + .arg(ColourMapper::getBackwardCompatibilityColourMap(m_colourMap)); + // New-style normalization attributes, allowing for more types of // normalization in future: write out the column normalization // type separately, and then whether we are normalizing visible @@ -2596,8 +2608,16 @@ setColourScaleMultiple(colourScale.second); } - int colourMap = attributes.value("colourScheme").toInt(&ok); - if (ok) setColourMap(colourMap); + QString colourMapId = attributes.value("colourMap"); + int colourMap = ColourMapper::getColourMapById(colourMapId); + if (colourMap >= 0) { + setColourMap(colourMap); + } else { + colourMap = attributes.value("colourScheme").toInt(&ok); + if (ok && colourMap < ColourMapper::getColourMapCount()) { + setColourMap(colourMap); + } + } int colourRotation = attributes.value("colourRotation").toInt(&ok); if (ok) setColourRotation(colourRotation);