mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
This commit is contained in:
parent
6270dd3bc9
commit
bb033eb561
@ -19,6 +19,7 @@
|
||||
#include "RicNewSummaryEnsembleCurveSetFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaColorTables.h"
|
||||
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimOilField.h"
|
||||
@ -30,6 +31,7 @@
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
#include "RimEnsembleCurveSetColorManager.h"
|
||||
|
||||
#include "RiuPlotMainWindow.h"
|
||||
|
||||
@ -65,6 +67,10 @@ void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet();
|
||||
|
||||
size_t colorIndex = plot->ensembleCurveSets()->curveSetCount();
|
||||
curveSet->setColor(RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f(colorIndex));
|
||||
curveSet->legendConfig()->setColorRange(RimEnsembleCurveSetColorManager::cycledEnsembleColorRange(static_cast<int>(colorIndex)));
|
||||
|
||||
if (!project->summaryGroups().empty())
|
||||
{
|
||||
curveSet->setSummaryCaseCollection(project->summaryGroups().back());
|
||||
|
@ -209,7 +209,7 @@ void RimEclipseCellColors::updateLegendCategorySettings()
|
||||
if (this->hasCategoryResult())
|
||||
{
|
||||
legendConfig()->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER);
|
||||
legendConfig()->setColorRangeMode(RimRegularLegendConfig::CATEGORY);
|
||||
legendConfig()->setColorRange(RimRegularLegendConfig::CATEGORY);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -218,9 +218,9 @@ void RimEclipseCellColors::updateLegendCategorySettings()
|
||||
legendConfig()->setMappingMode(RimRegularLegendConfig::LINEAR_CONTINUOUS);
|
||||
}
|
||||
|
||||
if (legendConfig()->colorRangeMode() == RimRegularLegendConfig::CATEGORY)
|
||||
if (legendConfig()->colorRange() == RimRegularLegendConfig::CATEGORY)
|
||||
{
|
||||
legendConfig()->setColorRangeMode(RimRegularLegendConfig::NORMAL);
|
||||
legendConfig()->setColorRange(RimRegularLegendConfig::NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ RimEclipseView::RimEclipseView()
|
||||
this->cellResult()->setReservoirView(this);
|
||||
|
||||
this->cellEdgeResult()->setReservoirView(this);
|
||||
this->cellEdgeResult()->legendConfig()->setColorRangeMode(RimRegularLegendConfig::PINK_WHITE);
|
||||
this->cellEdgeResult()->legendConfig()->setColorRange(RimRegularLegendConfig::PINK_WHITE);
|
||||
|
||||
this->faultResultSettings()->setReservoirView(this);
|
||||
|
||||
|
@ -88,7 +88,7 @@ void RimGeoMechCellColors::updateLegendCategorySettings()
|
||||
if(this->hasCategoryResult())
|
||||
{
|
||||
legendConfig->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER);
|
||||
legendConfig->setColorRangeMode(RimRegularLegendConfig::CATEGORY);
|
||||
legendConfig->setColorRange(RimRegularLegendConfig::CATEGORY);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -97,9 +97,9 @@ void RimGeoMechCellColors::updateLegendCategorySettings()
|
||||
legendConfig->setMappingMode(RimRegularLegendConfig::LINEAR_CONTINUOUS);
|
||||
}
|
||||
|
||||
if(legendConfig->colorRangeMode() == RimRegularLegendConfig::CATEGORY)
|
||||
if(legendConfig->colorRange() == RimRegularLegendConfig::CATEGORY)
|
||||
{
|
||||
legendConfig->setColorRangeMode(RimRegularLegendConfig::NORMAL);
|
||||
legendConfig->setColorRange(RimRegularLegendConfig::NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -513,7 +513,7 @@ void RimRegularLegendConfig::updateFieldVisibility()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimRegularLegendConfig::setColorRangeMode(ColorRangesType colorMode)
|
||||
void RimRegularLegendConfig::setColorRange(ColorRangesType colorMode)
|
||||
{
|
||||
m_colorRangeMode = colorMode;
|
||||
updateLegend();
|
||||
@ -744,15 +744,6 @@ const caf::TitledOverlayFrame* RimRegularLegendConfig::titledOverlayFrame() cons
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimRegularLegendConfig::initForEnsembleCurveSet(RimEnsembleCurveSet* curveSet)
|
||||
{
|
||||
// Set default color palette for ensemble curve sets
|
||||
setColorRangeMode(ColorManager::nextColorRange(curveSet));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -804,7 +795,7 @@ cvf::Color3ubArray RimRegularLegendConfig::colorArrayFromColorType(ColorRangesTy
|
||||
return RiaColorTables::stimPlanPaletteColors().color3ubArray();
|
||||
break;
|
||||
default:
|
||||
if (ColorManager::isEnsembleColorRange(colorType)) return ColorManager::ENSEMBLE_COLOR_RANGES.at(colorType);
|
||||
if (ColorManager::isEnsembleColorRange(colorType)) return ColorManager::EnsembleColorRanges.at(colorType);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -906,7 +897,7 @@ QList<caf::PdmOptionItemInfo> RimRegularLegendConfig::calculateValueOptions(cons
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const auto& col : ColorManager::ENSEMBLE_COLOR_RANGES)
|
||||
for (const auto& col : ColorManager::EnsembleColorRanges)
|
||||
{
|
||||
rangeTypes.push_back(col.first);
|
||||
}
|
||||
|
@ -99,8 +99,8 @@ public:
|
||||
typedef caf::AppEnum<MappingType> MappingEnum;
|
||||
void recreateLegend();
|
||||
|
||||
void setColorRangeMode(ColorRangesType colorMode);
|
||||
ColorRangesType colorRangeMode() { return m_colorRangeMode();}
|
||||
void setColorRange(ColorRangesType colorMode);
|
||||
ColorRangesType colorRange() { return m_colorRangeMode();}
|
||||
void setMappingMode(MappingType mappingType);
|
||||
MappingType mappingMode() { return m_mappingMode();}
|
||||
void disableAllTimeStepsRange(bool doDisable);
|
||||
@ -125,8 +125,6 @@ public:
|
||||
const caf::TitledOverlayFrame* titledOverlayFrame() const override;
|
||||
caf::TitledOverlayFrame* titledOverlayFrame() override;
|
||||
|
||||
void initForEnsembleCurveSet(RimEnsembleCurveSet* curveSet);
|
||||
|
||||
private:
|
||||
void setNamedCategories(const std::vector<QString>& categoryNames, bool inverse);
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
@ -152,7 +152,7 @@ void RimStimPlanColors::loadDataAndUpdate()
|
||||
RimRegularLegendConfig* legendConfig = new RimRegularLegendConfig();
|
||||
legendConfig->resultVariableName = resultNameUnitString;
|
||||
legendConfig->setMappingMode(RimRegularLegendConfig::LINEAR_DISCRETE);
|
||||
legendConfig->setColorRangeMode(RimRegularLegendConfig::STIMPLAN);
|
||||
legendConfig->setColorRange(RimRegularLegendConfig::STIMPLAN);
|
||||
|
||||
|
||||
m_legendConfigurations.push_back(legendConfig);
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "RifReaderEclipseSummary.h"
|
||||
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
#include "RimEnsembleCurveSetColorManager.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
#include "RimSummaryAddress.h"
|
||||
@ -126,6 +127,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendConfig", "", "", "", "");
|
||||
m_legendConfig = new RimRegularLegendConfig();
|
||||
m_legendConfig->setColorRange( RimEnsembleCurveSetColorManager::DEFAULT_ENSEMBLE_COLOR_RANGE );
|
||||
|
||||
CAF_PDM_InitField(&m_userDefinedName, "UserDefinedName", QString("Ensemble Curve Set"), "Curve Set Name", "", "", "");
|
||||
|
||||
@ -186,7 +188,6 @@ void RimEnsembleCurveSet::loadDataAndUpdate(bool updateParentPlot)
|
||||
m_yValuesSelectedVariableDisplayField = QString::fromStdString(m_yValuesCurveVariable->address().uiText());
|
||||
m_yValuesUiFilterResultSelection = m_yValuesCurveVariable->address();
|
||||
|
||||
m_legendConfig->initForEnsembleCurveSet(this);
|
||||
updateAllCurves();
|
||||
}
|
||||
|
||||
|
@ -140,15 +140,13 @@ RimEnsembleCurveSet* RimEnsembleCurveSetCollection::findRimCurveSetFromQwtCurve(
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleCurveSetCollection::addCurveSet(RimEnsembleCurveSet* curveSet)
|
||||
{
|
||||
static int nextAutoColorIndex = 1;
|
||||
static int numberOfColors = (int)RiaColorTables::summaryCurveDefaultPaletteColors().size();
|
||||
|
||||
if (curveSet)
|
||||
{
|
||||
curveSet->setColor(RimSummaryCurveAppearanceCalculator::cycledPaletteColor(nextAutoColorIndex));
|
||||
|
||||
m_curveSets.push_back(curveSet);
|
||||
|
||||
nextAutoColorIndex = (++nextAutoColorIndex) % numberOfColors;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,6 +191,14 @@ std::vector<RimEnsembleCurveSet*> RimEnsembleCurveSetCollection::visibleCurveSet
|
||||
return visible;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RimEnsembleCurveSetCollection::curveSetCount() const
|
||||
{
|
||||
return m_curveSets.size();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
|
||||
std::vector<RimEnsembleCurveSet*> curveSets() const;
|
||||
std::vector<RimEnsembleCurveSet*> visibleCurveSets() const;
|
||||
size_t curveSetCount() const;
|
||||
|
||||
void deleteAllCurveSets();
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::map<RimRegularLegendConfig::ColorRangesType, cvf::Color3ubArray> RimEnsembleCurveSetColorManager::ENSEMBLE_COLOR_RANGES(
|
||||
const std::map<RimRegularLegendConfig::ColorRangesType, cvf::Color3ubArray> RimEnsembleCurveSetColorManager::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) }) },
|
||||
@ -39,49 +39,14 @@ const RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::D
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::nextColorRange(RimEnsembleCurveSet* curveSet)
|
||||
RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::cycledEnsembleColorRange(int index)
|
||||
{
|
||||
CVF_ASSERT(curveSet);
|
||||
size_t modIndex = index % EnsembleColorRanges.size();
|
||||
|
||||
RimEnsembleCurveSetCollection* coll;
|
||||
curveSet->firstAncestorOrThisOfType(coll);
|
||||
auto crIt = EnsembleColorRanges.begin();
|
||||
for (int i = 0; i < modIndex; ++i) ++crIt;
|
||||
|
||||
if (coll)
|
||||
{
|
||||
if (m_colorCache.find(coll) != m_colorCache.end())
|
||||
{
|
||||
if (m_colorCache[coll].find(curveSet) != m_colorCache[coll].end())
|
||||
{
|
||||
// CurveSet found in cache, use same color range as last time
|
||||
return m_colorCache[coll][curveSet];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_colorCache.insert(std::make_pair(coll, std::map<RimEnsembleCurveSet*, RimRegularLegendConfig::ColorRangesType>()));
|
||||
m_nextColorIndexes.insert(std::make_pair(coll, 0));
|
||||
}
|
||||
|
||||
int currColorIndex = m_nextColorIndexes[coll];
|
||||
RimRegularLegendConfig::ColorRangesType resultColorRange = colorRangeByIndex(currColorIndex);
|
||||
m_nextColorIndexes[coll] = (currColorIndex < (int)ENSEMBLE_COLOR_RANGES.size() - 1) ? currColorIndex + 1 : 0;
|
||||
m_colorCache[coll][curveSet] = resultColorRange;
|
||||
return resultColorRange;
|
||||
}
|
||||
return DEFAULT_ENSEMBLE_COLOR_RANGE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::colorRangeByIndex(int index)
|
||||
{
|
||||
int i = 0;
|
||||
for (auto item : ENSEMBLE_COLOR_RANGES)
|
||||
{
|
||||
if (i++ == index) return item.first;
|
||||
}
|
||||
return DEFAULT_ENSEMBLE_COLOR_RANGE;
|
||||
return crIt->first;
|
||||
}
|
||||
|
||||
std::map<RimEnsembleCurveSetCollection*, int> RimEnsembleCurveSetColorManager::m_nextColorIndexes;
|
||||
|
@ -35,19 +35,19 @@ class RimEnsembleCurveSetCollection;
|
||||
class RimEnsembleCurveSetColorManager
|
||||
{
|
||||
public:
|
||||
static const std::map<RimRegularLegendConfig::ColorRangesType, cvf::Color3ubArray> ENSEMBLE_COLOR_RANGES;
|
||||
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 ENSEMBLE_COLOR_RANGES.find(colorRange) != ENSEMBLE_COLOR_RANGES.end();
|
||||
return EnsembleColorRanges.find(colorRange) != EnsembleColorRanges.end();
|
||||
}
|
||||
|
||||
static RimRegularLegendConfig::ColorRangesType nextColorRange(RimEnsembleCurveSet* curveSet);
|
||||
|
||||
private:
|
||||
static RimRegularLegendConfig::ColorRangesType colorRangeByIndex(int index);
|
||||
|
||||
static std::map<RimEnsembleCurveSetCollection*, int> m_nextColorIndexes;
|
||||
static std::map<RimEnsembleCurveSetCollection*, std::map<RimEnsembleCurveSet*, RimRegularLegendConfig::ColorRangesType>> m_colorCache;
|
||||
|
Loading…
Reference in New Issue
Block a user