Cleanup in EnsembleColormanager

This commit is contained in:
Jacob Støren 2018-05-11 09:24:42 +02:00
parent d1e55c64d3
commit ca30c58a77
3 changed files with 17 additions and 9 deletions

View File

@ -795,7 +795,7 @@ cvf::Color3ubArray RimRegularLegendConfig::colorArrayFromColorType(ColorRangesTy
return RiaColorTables::stimPlanPaletteColors().color3ubArray();
break;
default:
if (ColorManager::isEnsembleColorRange(colorType)) return ColorManager::EnsembleColorRanges.at(colorType);
if (ColorManager::isEnsembleColorRange(colorType)) return ColorManager::EnsembleColorRanges().at(colorType);
break;
}
@ -897,7 +897,7 @@ QList<caf::PdmOptionItemInfo> RimRegularLegendConfig::calculateValueOptions(cons
}
else
{
for (const auto& col : ColorManager::EnsembleColorRanges)
for (const auto& col : ColorManager::EnsembleColorRanges())
{
rangeTypes.push_back(col.first);
}

View File

@ -22,7 +22,7 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::map<RimRegularLegendConfig::ColorRangesType, cvf::Color3ubArray> RimEnsembleCurveSetColorManager::EnsembleColorRanges(
const std::map<RimRegularLegendConfig::ColorRangesType, cvf::Color3ubArray> RimEnsembleCurveSetColorManager::m_ensembleColorRanges(
{
{ RimRegularLegendConfig::GREEN_RED, cvf::Color3ubArray({ cvf::Color3ub(0x00, 0xff, 0x00), cvf::Color3ub(0xff, 0x00, 0x00) }) },
{ RimRegularLegendConfig::BLUE_MAGENTA, cvf::Color3ubArray({ cvf::Color3ub(0x00, 0x00, 0xff), cvf::Color3ub(0xff, 0x00, 0xff) }) },
@ -31,6 +31,14 @@ const std::map<RimRegularLegendConfig::ColorRangesType, cvf::Color3ubArray> RimE
{ RimRegularLegendConfig::BLUE_LIGHT_DARK, cvf::Color3ubArray({ cvf::Color3ub(0xcc, 0xcc, 0xff), cvf::Color3ub(0x00, 0x00, 0x99) }) }
});
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::map<RimRegularLegendConfig::ColorRangesType, cvf::Color3ubArray>& RimEnsembleCurveSetColorManager::EnsembleColorRanges()
{
return m_ensembleColorRanges;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -41,9 +49,9 @@ const RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::D
//--------------------------------------------------------------------------------------------------
RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::cycledEnsembleColorRange(int index)
{
size_t modIndex = index % EnsembleColorRanges.size();
size_t modIndex = index % m_ensembleColorRanges.size();
auto crIt = EnsembleColorRanges.begin();
auto crIt = m_ensembleColorRanges.begin();
for (int i = 0; i < modIndex; ++i) ++crIt;
return crIt->first;

View File

@ -35,20 +35,20 @@ class RimEnsembleCurveSetCollection;
class RimEnsembleCurveSetColorManager
{
public:
static const std::map<RimRegularLegendConfig::ColorRangesType, cvf::Color3ubArray> EnsembleColorRanges;
static const std::map<RimRegularLegendConfig::ColorRangesType, cvf::Color3ubArray>& EnsembleColorRanges();
static const RimRegularLegendConfig::ColorRangesType DEFAULT_ENSEMBLE_COLOR_RANGE;
static RimRegularLegendConfig::ColorRangesType cycledEnsembleColorRange(int index);
static bool isEnsembleColorRange(RimRegularLegendConfig::ColorRangesType colorRange)
{
return EnsembleColorRanges.find(colorRange) != EnsembleColorRanges.end();
return m_ensembleColorRanges.find(colorRange) != m_ensembleColorRanges.end();
}
static RimRegularLegendConfig::ColorRangesType nextColorRange(RimEnsembleCurveSet* curveSet);
private:
static const std::map<RimRegularLegendConfig::ColorRangesType, cvf::Color3ubArray> m_ensembleColorRanges;
static std::map<RimEnsembleCurveSetCollection*, int> m_nextColorIndexes;
static std::map<RimEnsembleCurveSetCollection*, std::map<RimEnsembleCurveSet*, RimRegularLegendConfig::ColorRangesType>> m_colorCache;
};