#4168 Treat some properties as categories.

This commit is contained in:
Gaute Lindkvist committed 2019-03-05 13:12:40 +01:00
1 parent ac7eccee88
commit b6a2bcfa59
6 files changed
+95 -115

No files matched your search

@@ -35,6 +35,7 @@
#include "RimCase.h" #include "RimCase.h"
#include "RimEclipseCase.h" #include "RimEclipseCase.h"
#include "RimEclipseView.h" #include "RimEclipseView.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseResultDefinition.h" #include "RimEclipseResultDefinition.h"
#include "RimGridCrossPlot.h" #include "RimGridCrossPlot.h"
#include "RimGridCrossPlotCurve.h" #include "RimGridCrossPlotCurve.h"
@@ -93,9 +94,8 @@ RimGridCrossPlotCurveSet::RimGridCrossPlotCurveSet()
m_yAxisProperty.uiCapability()->setUiTreeChildrenHidden(true); m_yAxisProperty.uiCapability()->setUiTreeChildrenHidden(true);
CAF_PDM_InitFieldNoDefault(&m_categoryProperty, "CategoryProperty", "Data Grouping Property", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_categoryProperty, "CategoryProperty", "Data Grouping Property", "", "", "");
m_categoryProperty = new RimEclipseResultDefinition; m_categoryProperty = new RimEclipseCellColors;
m_categoryProperty.uiCapability()->setUiHidden(true); m_categoryProperty.uiCapability()->setUiHidden(true);
m_categoryProperty.uiCapability()->setUiTreeChildrenHidden(true);
CAF_PDM_InitFieldNoDefault(&m_nameConfig, "NameConfig", "Name", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_nameConfig, "NameConfig", "Name", "", "", "");
m_nameConfig = new RimGridCrossPlotCurveSetNameConfig(this); m_nameConfig = new RimGridCrossPlotCurveSetNameConfig(this);
@@ -105,12 +105,6 @@ RimGridCrossPlotCurveSet::RimGridCrossPlotCurveSet()
CAF_PDM_InitFieldNoDefault(&m_crossPlotCurves, "CrossPlotCurves", "Curves", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_crossPlotCurves, "CrossPlotCurves", "Curves", "", "", "");
m_crossPlotCurves.uiCapability()->setUiTreeHidden(true); m_crossPlotCurves.uiCapability()->setUiTreeHidden(true);
CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendConfig", "", "", "", "");
m_legendConfig = new RimRegularLegendConfig();
m_legendConfig->setColorRange(RimRegularLegendConfig::CATEGORY);
m_legendConfig->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER);
m_legendConfig->setTickNumberFormat(RimRegularLegendConfig::AUTO);
setDefaults(); setDefaults();
} }
@@ -212,20 +206,17 @@ QString RimGridCrossPlotCurveSet::createAutoName() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimGridCrossPlotCurveSet::categoryTitle() const QString RimGridCrossPlotCurveSet::categoryTitle() const
{ {
if (hasCategoryResult()) if (m_categorization() == TIME_CATEGORIZATION)
{ {
if (m_categorization() == TIME_CATEGORIZATION) return QString("Time Steps");
{ }
return QString("Time Steps"); else if (m_categorization() == FORMATION_CATEGORIZATION)
} {
else if (m_categorization() == FORMATION_CATEGORIZATION) return QString("Formations");
{ }
return QString("Formations"); else if (m_categorization() == RESULT_CATEGORIZATION && m_categoryProperty->hasResult())
} {
else if (m_categorization() == RESULT_CATEGORIZATION && m_categoryProperty->hasResult()) return QString("%1").arg(m_categoryProperty->resultVariableUiShortName());
{
return QString("%1").arg(m_categoryProperty->resultVariableUiShortName());
}
} }
return ""; return "";
} }
@@ -255,9 +246,9 @@ void RimGridCrossPlotCurveSet::cellFilterViewUpdated()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimRegularLegendConfig* RimGridCrossPlotCurveSet::legendConfig() RimRegularLegendConfig* RimGridCrossPlotCurveSet::legendConfig() const
{ {
return m_legendConfig; return m_categoryProperty->legendConfig();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -316,7 +307,7 @@ std::vector<QString> RimGridCrossPlotCurveSet::categoryStrings() const
std::vector<QString> catStrings; std::vector<QString> catStrings;
for (auto curve : m_crossPlotCurves()) for (auto curve : m_crossPlotCurves())
{ {
catStrings.push_back(m_legendConfig->categoryNameFromCategoryValue(curve->categoryIndex())); catStrings.push_back(legendConfig()->categoryNameFromCategoryValue(curve->categoryIndex()));
} }
return catStrings; return catStrings;
} }
@@ -407,17 +398,22 @@ void RimGridCrossPlotCurveSet::createCurves(const RigEclipseCrossPlotResult& res
std::vector<double> tickValues; std::vector<double> tickValues;
if (m_categorization == TIME_CATEGORIZATION || m_categorization == FORMATION_CATEGORIZATION) if (hasCategoryResult())
{ {
for (size_t i = 0; i < result.xValues.size(); ++i) for (size_t i = 0; i < result.xValues.size(); ++i)
{ {
categorizedResults[result.catValuesDiscrete[i]].first.push_back(result.xValues[i]); int categoryNum =
categorizedResults[result.catValuesDiscrete[i]].second.push_back(result.yValues[i]); m_categorization == RESULT_CATEGORIZATION
? static_cast<int>(result.catValuesContinuous[i])
: result.catValuesDiscrete[i];
categorizedResults[categoryNum].first.push_back(result.xValues[i]);
categorizedResults[categoryNum].second.push_back(result.yValues[i]);
} }
} }
else else
{ {
m_legendConfig->scalarMapper()->majorTickValues(&tickValues); legendConfig()->scalarMapper()->majorTickValues(&tickValues);
for (size_t i = 0; i < result.xValues.size(); ++i) for (size_t i = 0; i < result.xValues.size(); ++i)
{ {
@@ -433,13 +429,13 @@ void RimGridCrossPlotCurveSet::createCurves(const RigEclipseCrossPlotResult& res
{ {
RimGridCrossPlotCurve* curve = new RimGridCrossPlotCurve(); RimGridCrossPlotCurve* curve = new RimGridCrossPlotCurve();
curve->setCategoryInformation(indexInPlot(), it->first); curve->setCategoryInformation(indexInPlot(), it->first);
if (m_categorization == RESULT_CATEGORIZATION) if (hasCategoryResult())
{ {
curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(tickValues[it->first]))); curve->setColor(cvf::Color3f(legendConfig()->scalarMapper()->mapToColor(it->first)));
} }
else else
{ {
curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(it->first))); curve->setColor(cvf::Color3f(legendConfig()->scalarMapper()->mapToColor(tickValues[it->first])));
} }
curve->setSamples(it->second.first, it->second.second); curve->setSamples(it->second.first, it->second.second);
curve->showLegend(m_crossPlotCurves.empty()); curve->showLegend(m_crossPlotCurves.empty());
@@ -551,18 +547,18 @@ void RimGridCrossPlotCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* chang
{ {
if (m_categorization == TIME_CATEGORIZATION) if (m_categorization == TIME_CATEGORIZATION)
{ {
m_legendConfig->setColorRange(RimRegularLegendConfig::NORMAL); legendConfig()->setColorRange(RimRegularLegendConfig::NORMAL);
m_legendConfig->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER); legendConfig()->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER);
} }
else if (m_categorization == FORMATION_CATEGORIZATION) else if (hasCategoryResult())
{ {
m_legendConfig->setColorRange(RimRegularLegendConfig::CATEGORY); legendConfig()->setColorRange(RimRegularLegendConfig::CATEGORY);
m_legendConfig->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER); legendConfig()->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER);
} }
else else
{ {
m_legendConfig->setColorRange(RimRegularLegendConfig::NORMAL); legendConfig()->setColorRange(RimRegularLegendConfig::NORMAL);
m_legendConfig->setMappingMode(RimRegularLegendConfig::LINEAR_DISCRETE); legendConfig()->setMappingMode(RimRegularLegendConfig::LINEAR_DISCRETE);
} }
@@ -642,7 +638,7 @@ QList<caf::PdmOptionItemInfo> RimGridCrossPlotCurveSet::calculateValueOptions(co
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimGridCrossPlotCurveSet::updateLegend() void RimGridCrossPlotCurveSet::updateLegend()
{ {
m_legendConfig->setTitle(categoryTitle()); legendConfig()->setTitle(categoryTitle());
RimGridCrossPlot* parent; RimGridCrossPlot* parent;
this->firstAncestorOrThisOfTypeAsserted(parent); this->firstAncestorOrThisOfTypeAsserted(parent);
@@ -656,8 +652,8 @@ void RimGridCrossPlotCurveSet::updateLegend()
RigFormationNames* formationNames = eclipseCase->eclipseCaseData()->activeFormationNames(); RigFormationNames* formationNames = eclipseCase->eclipseCaseData()->activeFormationNames();
const std::vector<QString>& categoryNames = formationNames->formationNames(); const std::vector<QString>& categoryNames = formationNames->formationNames();
m_legendConfig->setNamedCategories(categoryNames); legendConfig()->setNamedCategories(categoryNames);
m_legendConfig->setAutomaticRanges(0, categoryNames.size() - 1, 0, categoryNames.size() - 1); legendConfig()->setAutomaticRanges(0, categoryNames.size() - 1, 0, categoryNames.size() - 1);
} }
else if (m_categorization() == TIME_CATEGORIZATION) else if (m_categorization() == TIME_CATEGORIZATION)
{ {
@@ -667,48 +663,16 @@ void RimGridCrossPlotCurveSet::updateLegend()
{ {
categoryNames.push_back(name); categoryNames.push_back(name);
} }
m_legendConfig->setNamedCategories(categoryNames); legendConfig()->setNamedCategories(categoryNames);
m_legendConfig->setAutomaticRanges(0, categoryNames.size() - 1, 0, categoryNames.size() - 1); legendConfig()->setAutomaticRanges(0, categoryNames.size() - 1, 0, categoryNames.size() - 1);
} }
else if (m_categoryProperty->eclipseResultAddress().isValid()) else if (m_categoryProperty->eclipseResultAddress().isValid())
{ {
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case()); RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case());
RigEclipseCaseData* caseData = eclipseCase->eclipseCaseData(); if (eclipseCase)
CVF_ASSERT(caseData);
if (!caseData) return;
RigCaseCellResultsData* cellResultsData = caseData->results(RiaDefines::MATRIX_MODEL);
CVF_ASSERT(cellResultsData);
double globalMin, globalMax;
double globalPosClosestToZero, globalNegClosestToZero;
cellResultsData->minMaxCellScalarValues(m_categoryProperty->eclipseResultAddress(), globalMin, globalMax);
cellResultsData->posNegClosestToZero(
m_categoryProperty->eclipseResultAddress(), globalPosClosestToZero, globalNegClosestToZero);
double localMin, localMax;
double localPosClosestToZero, localNegClosestToZero;
if (m_categoryProperty->hasDynamicResult() && m_timeStep != -1)
{ {
cellResultsData->minMaxCellScalarValues(m_categoryProperty->eclipseResultAddress(), m_timeStep, localMin, localMax); m_categoryProperty->updateLegendData(eclipseCase, m_timeStep());
cellResultsData->posNegClosestToZero(
m_categoryProperty->eclipseResultAddress(), m_timeStep, localPosClosestToZero, localNegClosestToZero);
} }
else
{
localMin = globalMin;
localMax = globalMax;
localPosClosestToZero = globalPosClosestToZero;
localNegClosestToZero = globalNegClosestToZero;
}
CVF_ASSERT(m_legendConfig);
m_legendConfig->setClosestToZeroValues(
globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
m_legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
} }
parent->qwtPlot()->addOrUpdateCurveSetLegend(this); parent->qwtPlot()->addOrUpdateCurveSetLegend(this);
} }
@@ -724,7 +688,15 @@ void RimGridCrossPlotCurveSet::updateLegend()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimGridCrossPlotCurveSet::hasCategoryResult() const bool RimGridCrossPlotCurveSet::hasCategoryResult() const
{ {
return m_categorization == FORMATION_CATEGORIZATION || m_categorization == TIME_CATEGORIZATION || m_categorization == RESULT_CATEGORIZATION; if (m_categorization == FORMATION_CATEGORIZATION || m_categorization == TIME_CATEGORIZATION)
{
return true;
}
else if (m_categorization == RESULT_CATEGORIZATION)
{
return m_categoryProperty->hasCategoryResult();
}
return false;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -768,20 +740,20 @@ void RimGridCrossPlotCurveSet::updateCurveNames(bool applyCaseName,
if (applyCategory && m_categorization != NO_CATEGORIZATION) if (applyCategory && m_categorization != NO_CATEGORIZATION)
{ {
if (m_categorization == RESULT_CATEGORIZATION) if (hasCategoryResult())
{
nameTags += legendConfig()->categoryNameFromCategoryValue(curve->categoryIndex());
}
else
{ {
std::vector<double> tickValues; std::vector<double> tickValues;
m_legendConfig->scalarMapper()->majorTickValues(&tickValues); legendConfig()->scalarMapper()->majorTickValues(&tickValues);
size_t catIndex = (size_t) curve->categoryIndex(); size_t catIndex = (size_t) curve->categoryIndex();
double lowerLimit = tickValues[catIndex]; double lowerLimit = tickValues[catIndex];
double upperLimit = catIndex + 1u < tickValues.size() double upperLimit = catIndex + 1u < tickValues.size()
? tickValues[catIndex + 1u] : std::numeric_limits<double>::infinity(); ? tickValues[catIndex + 1u] : std::numeric_limits<double>::infinity();
nameTags += QString("%1 [%2, %3]").arg(categoryTitle()).arg(lowerLimit).arg(upperLimit); nameTags += QString("%1 [%2, %3]").arg(categoryTitle()).arg(lowerLimit).arg(upperLimit);
} }
else
{
nameTags += m_legendConfig->categoryNameFromCategoryValue(curve->categoryIndex());
}
} }
curve->setCustomName(nameTags.join(", ")); curve->setCustomName(nameTags.join(", "));
@@ -852,7 +824,7 @@ void RimGridCrossPlotCurveSet::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTr
{ {
if (m_categorization() != NO_CATEGORIZATION) if (m_categorization() != NO_CATEGORIZATION)
{ {
uiTreeOrdering.add(m_legendConfig()); m_categoryProperty->uiTreeOrdering(uiTreeOrdering, uiConfigName);
} }
for (auto curve : m_crossPlotCurves()) for (auto curve : m_crossPlotCurves())
@@ -39,6 +39,7 @@ class RimCase;
class RimGridCrossPlotCurve; class RimGridCrossPlotCurve;
class RimGridView; class RimGridView;
class RimEclipseCase; class RimEclipseCase;
class RimEclipseCellColors;
class RimEclipseResultDefinition; class RimEclipseResultDefinition;
class RimRegularLegendConfig; class RimRegularLegendConfig;
class QwtPlot; class QwtPlot;
@@ -89,7 +90,7 @@ public:
void detachAllCurves(); void detachAllCurves();
void cellFilterViewUpdated(); void cellFilterViewUpdated();
RimRegularLegendConfig* legendConfig(); RimRegularLegendConfig* legendConfig() const;
std::vector< RimGridCrossPlotCurve*> curves() const; std::vector< RimGridCrossPlotCurve*> curves() const;
@@ -129,10 +130,9 @@ private:
caf::PdmField<CurveCategorizationEnum> m_categorization; caf::PdmField<CurveCategorizationEnum> m_categorization;
caf::PdmChildField<RimEclipseResultDefinition*> m_xAxisProperty; caf::PdmChildField<RimEclipseResultDefinition*> m_xAxisProperty;
caf::PdmChildField<RimEclipseResultDefinition*> m_yAxisProperty; caf::PdmChildField<RimEclipseResultDefinition*> m_yAxisProperty;
caf::PdmChildField<RimEclipseResultDefinition*> m_categoryProperty; caf::PdmChildField<RimEclipseCellColors*> m_categoryProperty;
caf::PdmChildField<RimGridCrossPlotCurveSetNameConfig*> m_nameConfig; caf::PdmChildField<RimGridCrossPlotCurveSetNameConfig*> m_nameConfig;
caf::PdmChildArrayField<RimGridCrossPlotCurve*> m_crossPlotCurves; caf::PdmChildArrayField<RimGridCrossPlotCurve*> m_crossPlotCurves;
caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig;
}; };
@@ -660,7 +660,7 @@ void Rim2dIntersectionView::updateLegends()
{ {
m_legendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->legendConfig()); m_legendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->legendConfig());
m_ternaryLegendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->ternaryLegendConfig()); m_ternaryLegendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->ternaryLegendConfig());
eclView->cellResult()->updateLegendData(m_currentTimeStep(), m_legendConfig(), m_ternaryLegendConfig()); eclView->cellResult()->updateLegendData(eclView->eclipseCase(), m_currentTimeStep(), m_legendConfig(), m_ternaryLegendConfig());
if ( eclView->cellResult()->isTernarySaturationSelected() ) if ( eclView->cellResult()->isTernarySaturationSelected() )
{ {
@@ -226,6 +226,14 @@ void RimEclipseCellColors::updateLegendCategorySettings()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseCellColors::uiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
{
defineUiTreeOrdering(uiTreeOrdering, uiConfigName);
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -274,7 +282,8 @@ public :
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimEclipseCellColors::updateLegendData(size_t currentTimeStep, void RimEclipseCellColors::updateLegendData(RimEclipseCase* rimEclipseCase,
int currentTimeStep,
RimRegularLegendConfig* legendConfig, RimRegularLegendConfig* legendConfig,
RimTernaryLegendConfig* ternaryLegendConfig) RimTernaryLegendConfig* ternaryLegendConfig)
{ {
@@ -285,22 +294,22 @@ void RimEclipseCellColors::updateLegendData(size_t currentTimeStep,
{ {
if ( this->isFlowDiagOrInjectionFlooding() ) if ( this->isFlowDiagOrInjectionFlooding() )
{ {
CVF_ASSERT(currentTimeStep >= 0);
double globalMin, globalMax; double globalMin, globalMax;
double globalPosClosestToZero, globalNegClosestToZero; double globalPosClosestToZero, globalNegClosestToZero;
RigFlowDiagResults* flowResultsData = this->flowDiagSolution()->flowDiagResults(); RigFlowDiagResults* flowResultsData = this->flowDiagSolution()->flowDiagResults();
RigFlowDiagResultAddress resAddr = this->flowDiagResAddress(); RigFlowDiagResultAddress resAddr = this->flowDiagResAddress();
int integerTimeStep = static_cast<int>(currentTimeStep); flowResultsData->minMaxScalarValues(resAddr, currentTimeStep, &globalMin, &globalMax);
flowResultsData->posNegClosestToZero(resAddr, currentTimeStep, &globalPosClosestToZero, &globalNegClosestToZero);
flowResultsData->minMaxScalarValues(resAddr, integerTimeStep, &globalMin, &globalMax);
flowResultsData->posNegClosestToZero(resAddr, integerTimeStep, &globalPosClosestToZero, &globalNegClosestToZero);
double localMin, localMax; double localMin, localMax;
double localPosClosestToZero, localNegClosestToZero; double localPosClosestToZero, localNegClosestToZero;
if ( this->hasDynamicResult() ) if ( this->hasDynamicResult() )
{ {
flowResultsData->minMaxScalarValues(resAddr, integerTimeStep, &localMin, &localMax); flowResultsData->minMaxScalarValues(resAddr, currentTimeStep, &localMin, &localMax);
flowResultsData->posNegClosestToZero(resAddr, integerTimeStep, &localPosClosestToZero, &localNegClosestToZero); flowResultsData->posNegClosestToZero(resAddr, currentTimeStep, &localPosClosestToZero, &localNegClosestToZero);
} }
else else
{ {
@@ -318,7 +327,7 @@ void RimEclipseCellColors::updateLegendData(size_t currentTimeStep,
localPosClosestToZero, localNegClosestToZero); localPosClosestToZero, localNegClosestToZero);
legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
if ( this->hasCategoryResult() ) if ( this->hasCategoryResult() && m_reservoirView)
{ {
std::set<std::tuple<QString, int, cvf::Color3ub>, TupleCompare > categories; std::set<std::tuple<QString, int, cvf::Color3ub>, TupleCompare > categories;
//std::set<std::tuple<QString, int, cvf::Color3ub> > categories; //std::set<std::tuple<QString, int, cvf::Color3ub> > categories;
@@ -346,8 +355,6 @@ void RimEclipseCellColors::updateLegendData(size_t currentTimeStep,
} }
else else
{ {
RimEclipseCase* rimEclipseCase = nullptr;
this->firstAncestorOrThisOfType(rimEclipseCase);
CVF_ASSERT(rimEclipseCase); CVF_ASSERT(rimEclipseCase);
if ( !rimEclipseCase ) return; if ( !rimEclipseCase ) return;
@@ -366,7 +373,7 @@ void RimEclipseCellColors::updateLegendData(size_t currentTimeStep,
double localMin, localMax; double localMin, localMax;
double localPosClosestToZero, localNegClosestToZero; double localPosClosestToZero, localNegClosestToZero;
if ( this->hasDynamicResult() ) if ( this->hasDynamicResult() && currentTimeStep >= 0)
{ {
cellResultsData->minMaxCellScalarValues(this->eclipseResultAddress(), currentTimeStep, localMin, localMax); cellResultsData->minMaxCellScalarValues(this->eclipseResultAddress(), currentTimeStep, localMin, localMax);
cellResultsData->posNegClosestToZero(this->eclipseResultAddress(), currentTimeStep, localPosClosestToZero, localNegClosestToZero); cellResultsData->posNegClosestToZero(this->eclipseResultAddress(), currentTimeStep, localPosClosestToZero, localNegClosestToZero);
@@ -424,8 +431,6 @@ void RimEclipseCellColors::updateLegendData(size_t currentTimeStep,
// Ternary legend update // Ternary legend update
{ {
RimEclipseCase* rimEclipseCase = nullptr;
this->firstAncestorOrThisOfType(rimEclipseCase);
CVF_ASSERT(rimEclipseCase); CVF_ASSERT(rimEclipseCase);
if ( !rimEclipseCase ) return; if ( !rimEclipseCase ) return;
@@ -525,16 +530,18 @@ RimTernaryLegendConfig* RimEclipseCellColors::ternaryLegendConfig()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimEclipseCellColors::updateIconState() void RimEclipseCellColors::updateIconState()
{ {
RimViewController* viewController = m_reservoirView->viewController(); if (m_reservoirView)
if (viewController && viewController->isResultColorControlled())
{ {
updateUiIconFromState(false); RimViewController* viewController = m_reservoirView->viewController();
if (viewController && viewController->isResultColorControlled())
{
updateUiIconFromState(false);
}
else
{
updateUiIconFromState(true);
}
} }
else
{
updateUiIconFromState(true);
}
uiCapability()->updateConnectedEditors(); uiCapability()->updateConnectedEditors();
} }
@@ -26,6 +26,7 @@
#include "cafPdmChildField.h" #include "cafPdmChildField.h"
#include "cafPdmPtrField.h" #include "cafPdmPtrField.h"
class RimEclipseCase;
class RimTernaryLegendConfig; class RimTernaryLegendConfig;
class RimRegularLegendConfig; class RimRegularLegendConfig;
@@ -43,10 +44,10 @@ public:
void setReservoirView(RimEclipseView* ownerReservoirView); void setReservoirView(RimEclipseView* ownerReservoirView);
RimEclipseView* reservoirView(); RimEclipseView* reservoirView();
void updateLegendData(size_t timestep, void updateLegendData(RimEclipseCase* rimEclipseCase,
int timestep,
RimRegularLegendConfig* legendConfig = nullptr, RimRegularLegendConfig* legendConfig = nullptr,
RimTernaryLegendConfig* ternaryLegendConfig = nullptr); RimTernaryLegendConfig* ternaryLegendConfig = nullptr);
RimRegularLegendConfig* legendConfig(); RimRegularLegendConfig* legendConfig();
RimTernaryLegendConfig* ternaryLegendConfig(); RimTernaryLegendConfig* ternaryLegendConfig();
@@ -55,7 +56,7 @@ public:
void updateIconState(); void updateIconState();
void updateLegendCategorySettings() override; void updateLegendCategorySettings() override;
void uiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "");
protected: protected:
// Overridden methods // Overridden methods
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
@@ -1159,7 +1159,7 @@ void RimEclipseView::updateLegends()
{ {
if (this->cellEdgeResult()->isUsingSingleVariable()) if (this->cellEdgeResult()->isUsingSingleVariable())
{ {
this->cellEdgeResult()->singleVarEdgeResultColors()->updateLegendData(m_currentTimeStep); this->cellEdgeResult()->singleVarEdgeResultColors()->updateLegendData(m_eclipseCase, m_currentTimeStep);
} }
else else
{ {
@@ -1226,7 +1226,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString
RimEclipseCellColors* resultColors, RimEclipseCellColors* resultColors,
RigCaseCellResultsData* cellResultsData) RigCaseCellResultsData* cellResultsData)
{ {
resultColors->updateLegendData(m_currentTimeStep); resultColors->updateLegendData(m_eclipseCase, m_currentTimeStep);
if (resultColors->hasResult() && resultColors->legendConfig()->showLegend()) if (resultColors->hasResult() && resultColors->legendConfig()->showLegend())
{ {