mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2721 Ensemble curves. Color ranges, cyclic color range assignment. Minor refactoring
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
#include "RimCellEdgeColors.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
#include "RimEnsembleCurveSetColorManager.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGeoMechResultDefinition.h"
|
||||
#include "RimIntersectionCollection.h"
|
||||
@@ -53,6 +55,11 @@
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
using ColorManager = RimEnsembleCurveSetColorManager;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CAF_PDM_SOURCE_INIT(RimRegularLegendConfig, "Legend");
|
||||
|
||||
|
||||
@@ -60,17 +67,22 @@ namespace caf {
|
||||
template<>
|
||||
void RimRegularLegendConfig::ColorRangeEnum::setUp()
|
||||
{
|
||||
addItem(RimRegularLegendConfig::NORMAL, "NORMAL", "Full color, Red on top");
|
||||
addItem(RimRegularLegendConfig::OPPOSITE_NORMAL,"OPPOSITE_NORMAL", "Full color, Blue on top");
|
||||
addItem(RimRegularLegendConfig::WHITE_PINK, "WHITE_PIMK", "White to pink");
|
||||
addItem(RimRegularLegendConfig::PINK_WHITE, "PINK_WHITE", "Pink to white");
|
||||
addItem(RimRegularLegendConfig::BLUE_WHITE_RED, "BLUE_WHITE_RED", "Blue, white, red");
|
||||
addItem(RimRegularLegendConfig::RED_WHITE_BLUE, "RED_WHITE_BLUE", "Red, white, blue");
|
||||
addItem(RimRegularLegendConfig::WHITE_BLACK, "WHITE_BLACK", "White to black");
|
||||
addItem(RimRegularLegendConfig::BLACK_WHITE, "BLACK_WHITE", "Black to white");
|
||||
addItem(RimRegularLegendConfig::CATEGORY, "CATEGORY", "Category colors");
|
||||
addItem(RimRegularLegendConfig::ANGULAR, "ANGULAR", "Full color cyclic");
|
||||
addItem(RimRegularLegendConfig::STIMPLAN, "STIMPLAN", "StimPlan colors");
|
||||
addItem(RimRegularLegendConfig::NORMAL, "NORMAL", "Full color, Red on top");
|
||||
addItem(RimRegularLegendConfig::OPPOSITE_NORMAL, "OPPOSITE_NORMAL", "Full color, Blue on top");
|
||||
addItem(RimRegularLegendConfig::WHITE_PINK, "WHITE_PIMK", "White to pink");
|
||||
addItem(RimRegularLegendConfig::PINK_WHITE, "PINK_WHITE", "Pink to white");
|
||||
addItem(RimRegularLegendConfig::BLUE_WHITE_RED, "BLUE_WHITE_RED", "Blue, white, red");
|
||||
addItem(RimRegularLegendConfig::RED_WHITE_BLUE, "RED_WHITE_BLUE", "Red, white, blue");
|
||||
addItem(RimRegularLegendConfig::WHITE_BLACK, "WHITE_BLACK", "White to black");
|
||||
addItem(RimRegularLegendConfig::BLACK_WHITE, "BLACK_WHITE", "Black to white");
|
||||
addItem(RimRegularLegendConfig::CATEGORY, "CATEGORY", "Category colors");
|
||||
addItem(RimRegularLegendConfig::ANGULAR, "ANGULAR", "Full color cyclic");
|
||||
addItem(RimRegularLegendConfig::STIMPLAN, "STIMPLAN", "StimPlan colors");
|
||||
addItem(RimRegularLegendConfig::RED_LIGHT_DARK, "RED_DARK_LIGHT", "Red Light to Dark");
|
||||
addItem(RimRegularLegendConfig::GREEN_LIGHT_DARK, "GREEN_DARK_LIGHT", "Green Light to Dark");
|
||||
addItem(RimRegularLegendConfig::BLUE_LIGHT_DARK, "BLUE_DARK_LIGHT", "Blue Light to Dark");
|
||||
addItem(RimRegularLegendConfig::GREEN_RED, "GREEN_RED", "Green to Red");
|
||||
addItem(RimRegularLegendConfig::BLUE_MAGENTA, "BLUE_MAGENTA", "Blue to Magenta");
|
||||
setDefault(RimRegularLegendConfig::NORMAL);
|
||||
}
|
||||
}
|
||||
@@ -732,6 +744,15 @@ const caf::TitledOverlayFrame* RimRegularLegendConfig::titledOverlayFrame() cons
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimRegularLegendConfig::initForEnsembleCurveSet(RimEnsembleCurveSet* curveSet)
|
||||
{
|
||||
// Set default color palette for ensemble curve sets
|
||||
setColorRangeMode(ColorManager::nextColorRange(curveSet));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -783,6 +804,7 @@ cvf::Color3ubArray RimRegularLegendConfig::colorArrayFromColorType(ColorRangesTy
|
||||
return RiaColorTables::stimPlanPaletteColors().color3ubArray();
|
||||
break;
|
||||
default:
|
||||
if (ColorManager::isEnsembleColorRange(colorType)) return ColorManager::ENSEMBLE_COLOR_RANGES.at(colorType);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -870,15 +892,26 @@ QList<caf::PdmOptionItemInfo> RimRegularLegendConfig::calculateValueOptions(cons
|
||||
{
|
||||
// This is an app enum field, see cafInternalPdmFieldTypeSpecializations.h for the default specialization of this type
|
||||
std::vector<ColorRangesType> rangeTypes;
|
||||
rangeTypes.push_back(NORMAL);
|
||||
rangeTypes.push_back(OPPOSITE_NORMAL);
|
||||
rangeTypes.push_back(WHITE_PINK);
|
||||
rangeTypes.push_back(PINK_WHITE);
|
||||
rangeTypes.push_back(BLUE_WHITE_RED);
|
||||
rangeTypes.push_back(RED_WHITE_BLUE);
|
||||
rangeTypes.push_back(WHITE_BLACK);
|
||||
rangeTypes.push_back(BLACK_WHITE);
|
||||
rangeTypes.push_back(ANGULAR);
|
||||
if (!hasEnsembleCurveSetParent)
|
||||
{
|
||||
rangeTypes.push_back(NORMAL);
|
||||
rangeTypes.push_back(OPPOSITE_NORMAL);
|
||||
rangeTypes.push_back(WHITE_PINK);
|
||||
rangeTypes.push_back(PINK_WHITE);
|
||||
rangeTypes.push_back(BLUE_WHITE_RED);
|
||||
rangeTypes.push_back(RED_WHITE_BLUE);
|
||||
rangeTypes.push_back(WHITE_BLACK);
|
||||
rangeTypes.push_back(BLACK_WHITE);
|
||||
rangeTypes.push_back(ANGULAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const auto& col : ColorManager::ENSEMBLE_COLOR_RANGES)
|
||||
{
|
||||
rangeTypes.push_back(col.first);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasStimPlanParent) rangeTypes.push_back(STIMPLAN);
|
||||
|
||||
if (isCategoryResult)
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace caf
|
||||
}
|
||||
|
||||
class Rim3dView;
|
||||
class RimEnsembleCurveSet;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -74,7 +75,13 @@ public:
|
||||
RED_WHITE_BLUE,
|
||||
CATEGORY,
|
||||
ANGULAR,
|
||||
STIMPLAN
|
||||
STIMPLAN,
|
||||
|
||||
GREEN_RED,
|
||||
BLUE_MAGENTA,
|
||||
RED_LIGHT_DARK,
|
||||
GREEN_LIGHT_DARK,
|
||||
BLUE_LIGHT_DARK
|
||||
};
|
||||
|
||||
typedef caf::AppEnum<ColorRangesType> ColorRangeEnum;
|
||||
@@ -118,6 +125,8 @@ 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;
|
||||
|
||||
@@ -31,6 +31,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimCsvUserData.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotNameHelper.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSetCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSet.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSetColorManager.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -65,6 +66,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimCsvUserData.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotNameHelper.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSetCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSet.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSetColorManager.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaColorTables.h"
|
||||
|
||||
#include "RifReaderEclipseSummary.h"
|
||||
|
||||
@@ -46,6 +47,14 @@
|
||||
#include "qwt_symbol.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Internal constants
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define DOUBLE_INF std::numeric_limits<double>::infinity()
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
namespace caf
|
||||
{
|
||||
template<>
|
||||
@@ -57,11 +66,6 @@ namespace caf
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Internal constants
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define DOUBLE_INF std::numeric_limits<double>::infinity()
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimEnsembleCurveSet, "RimEnsembleCurveSet");
|
||||
|
||||
@@ -208,6 +212,7 @@ void RimEnsembleCurveSet::loadDataAndUpdate(bool updateParentPlot)
|
||||
}
|
||||
}
|
||||
|
||||
m_legendConfig->initForEnsembleCurveSet(this);
|
||||
updateCurveColors();
|
||||
}
|
||||
|
||||
@@ -715,7 +720,7 @@ void RimEnsembleCurveSet::updateCurveColors()
|
||||
}
|
||||
else
|
||||
{
|
||||
curve->setColor(cvf::Color3f::GRAY);
|
||||
curve->setColor(RiaColorTables::undefinedCellColor());
|
||||
}
|
||||
curve->updateCurveAppearance();
|
||||
}
|
||||
@@ -751,7 +756,7 @@ void RimEnsembleCurveSet::updateCurveColors()
|
||||
rimCase->caseRealizationParameters()->parameterValue(parameterName).numericValue() :
|
||||
DOUBLE_INF;
|
||||
if(value != DOUBLE_INF) curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(value)));
|
||||
else curve->setColor(cvf::Color3f::GRAY);
|
||||
else curve->setColor(RiaColorTables::undefinedCellColor());
|
||||
curve->updateCurveAppearance();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimEnsembleCurveSetColorManager.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::map<RimRegularLegendConfig::ColorRangesType, cvf::Color3ubArray> RimEnsembleCurveSetColorManager::ENSEMBLE_COLOR_RANGES(
|
||||
{
|
||||
{ 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) }) },
|
||||
{ RimRegularLegendConfig::RED_LIGHT_DARK, cvf::Color3ubArray({ cvf::Color3ub(0xff, 0xcc, 0xcc), cvf::Color3ub(0x99, 0x00, 0x00) }) },
|
||||
{ RimRegularLegendConfig::GREEN_LIGHT_DARK, cvf::Color3ubArray({ cvf::Color3ub(0xcc, 0xff, 0xcc), cvf::Color3ub(0x00, 0x99, 0x00) }) },
|
||||
{ RimRegularLegendConfig::BLUE_LIGHT_DARK, cvf::Color3ubArray({ cvf::Color3ub(0xcc, 0xcc, 0xff), cvf::Color3ub(0x00, 0x00, 0x99) }) }
|
||||
});
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::DEFAULT_ENSEMBLE_COLOR_RANGE = RimRegularLegendConfig::GREEN_RED;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::nextColorRange(RimEnsembleCurveSet* curveSet)
|
||||
{
|
||||
CVF_ASSERT(curveSet);
|
||||
|
||||
RimEnsembleCurveSetCollection* coll;
|
||||
curveSet->firstAncestorOrThisOfType(coll);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
std::map<RimEnsembleCurveSetCollection*, int> RimEnsembleCurveSetColorManager::m_nextColorIndexes;
|
||||
|
||||
std::map<RimEnsembleCurveSetCollection*, std::map<RimEnsembleCurveSet*, RimRegularLegendConfig::ColorRangesType>> RimEnsembleCurveSetColorManager::m_colorCache;
|
||||
@@ -0,0 +1,54 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RiaDefines.h"
|
||||
|
||||
#include "RimRegularLegendConfig.h"
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
class RimEnsembleCurveSetCollection;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RimEnsembleCurveSetColorManager
|
||||
{
|
||||
public:
|
||||
static const std::map<RimRegularLegendConfig::ColorRangesType, cvf::Color3ubArray> ENSEMBLE_COLOR_RANGES;
|
||||
|
||||
static const RimRegularLegendConfig::ColorRangesType DEFAULT_ENSEMBLE_COLOR_RANGE;
|
||||
|
||||
static bool isEnsembleColorRange(RimRegularLegendConfig::ColorRangesType colorRange)
|
||||
{
|
||||
return ENSEMBLE_COLOR_RANGES.find(colorRange) != ENSEMBLE_COLOR_RANGES.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;
|
||||
};
|
||||
Reference in New Issue
Block a user