#14486 Contour Map: Always use an available cell result as data source

A new contour map created from the right-click menu on a case used a hardcoded SOIL result, resulting in an empty view when SOIL was not present in the case. Use the cell result of an existing view for the same case if one is available, and otherwise fall back to RigCaseCellResultsData::defaultResult(), which verifies that the result exists before selecting it. Completion Type is a category result and is now excluded as a default result for both 3d views and contour maps.
This commit is contained in:
Magne Sjaastad committed 2026-08-10 12:38:21 +02:00
1 parent b851801cfb
commit 2237f578c8
3 files changed
+47 -15

No files matched your search

@@ -19,6 +19,7 @@
#include "RicNewContourMapViewFeature.h"
#include "RigActiveCellInfo.h"
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
#include "RigFemPartCollection.h"
@@ -51,7 +52,7 @@
#include "RiaColorTools.h"
#include "RiaLogging.h"
#include "RiaPreferencesGrid.h"
#include "RiaResultNames.h"
#include "cafPdmDocument.h"
#include "cafSelectionManager.h"
@@ -311,7 +312,11 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMap(
contourMap->setEclipseCase( eclipseCase );
contourMap->resetDockWindowId();
assignDefaultResultAndLegend( contourMap );
// Prefer the cell result of an existing view for this case, fall back to the default result of the case
if ( !assignResultFromExistingView( contourMap ) )
{
assignDefaultResultAndLegend( contourMap );
}
caf::PdmDocument::updateUiIconStateRecursively( contourMap );
@@ -415,13 +420,35 @@ RimGeoMechContourMapView* RicNewContourMapViewFeature::createGeoMechContourMap(
//--------------------------------------------------------------------------------------------------
void RicNewContourMapViewFeature::assignDefaultResultAndLegend( RimEclipseContourMapView* contourMap )
{
if ( contourMap->cellResult() )
{
contourMap->cellResult()->setResultType( RiaDefines::ResultCatType::DYNAMIC_NATIVE );
if ( !contourMap->cellResult() ) return;
if ( RiaPreferencesGrid::current()->loadAndShowSoil() )
{
contourMap->cellResult()->setResultVariable( "SOIL" );
}
// Use the default result of the case, as this result is guaranteed to be available. See issue #14486.
if ( auto cellResultsData = contourMap->currentGridCellResults() )
{
contourMap->cellResult()->setFromEclipseResultAddress( cellResultsData->defaultResult() );
}
}
//--------------------------------------------------------------------------------------------------
/// Use the cell result of an existing view for the same case, if this result is available
//--------------------------------------------------------------------------------------------------
bool RicNewContourMapViewFeature::assignResultFromExistingView( RimEclipseContourMapView* contourMap )
{
if ( !contourMap->cellResult() || !contourMap->eclipseCase() ) return false;
for ( auto view : contourMap->eclipseCase()->reservoirViews() )
{
if ( !view || view == contourMap ) continue;
auto sourceCellResult = view->cellResult();
if ( !sourceCellResult || sourceCellResult->isTernarySaturationSelected() || !sourceCellResult->hasResult() ) continue;
// Completion Type is a category result, and is not useful as a contour map data source
if ( sourceCellResult->resultVariable() == RiaResultNames::completionTypeResultName() ) continue;
contourMap->cellResult()->setFromEclipseResultAddress( sourceCellResult->eclipseResultAddress() );
return true;
}
return false;
}
@@ -51,4 +51,5 @@ protected:
static RimGeoMechContourMapView* createGeoMechContourMap( RimGeoMechCase* geoMechCase );
static void assignDefaultResultAndLegend( RimEclipseContourMapView* contourMap );
static bool assignResultFromExistingView( RimEclipseContourMapView* contourMap );
};
@@ -830,6 +830,10 @@ RigEclipseResultAddress RigCaseCellResultsData::defaultResult() const
{
auto allResults = existingResults();
// Completion Type is a category result, and is not useful as a default result. See issue #14486.
auto isCandidateResult = []( const RigEclipseResultAddress& adr, RiaDefines::ResultCatType category )
{ return adr.resultCatType() == category && adr.resultName() != RiaResultNames::completionTypeResultName(); };
if ( maxTimeStepCount() > 0 )
{
auto prefs = RiaPreferencesGrid::current();
@@ -860,8 +864,8 @@ RigEclipseResultAddress RigCaseCellResultsData::defaultResult() const
auto dynamicResult = std::find_if( allResults.begin(),
allResults.end(),
[]( const RigEclipseResultAddress& adr )
{ return adr.resultCatType() == RiaDefines::ResultCatType::DYNAMIC_NATIVE; } );
[&isCandidateResult]( const RigEclipseResultAddress& adr )
{ return isCandidateResult( adr, RiaDefines::ResultCatType::DYNAMIC_NATIVE ); } );
if ( dynamicResult != allResults.end() ) return *dynamicResult;
}
@@ -869,16 +873,16 @@ RigEclipseResultAddress RigCaseCellResultsData::defaultResult() const
// If any input property exists, use that
auto inputProperty = std::find_if( allResults.begin(),
allResults.end(),
[]( const RigEclipseResultAddress& adr )
{ return adr.resultCatType() == RiaDefines::ResultCatType::INPUT_PROPERTY; } );
[&isCandidateResult]( const RigEclipseResultAddress& adr )
{ return isCandidateResult( adr, RiaDefines::ResultCatType::INPUT_PROPERTY ); } );
if ( inputProperty != allResults.end() ) return *inputProperty;
// If any static property exists, use that
auto staticResult = std::find_if( allResults.begin(),
allResults.end(),
[]( const RigEclipseResultAddress& adr )
{ return adr.resultCatType() == RiaDefines::ResultCatType::STATIC_NATIVE; } );
[&isCandidateResult]( const RigEclipseResultAddress& adr )
{ return isCandidateResult( adr, RiaDefines::ResultCatType::STATIC_NATIVE ); } );
if ( staticResult != allResults.end() ) return *staticResult;