diff --git a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp index d5d7f52c8f..ce238dd589 100644 --- a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp +++ b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp @@ -1017,7 +1017,7 @@ void RimGridCrossPlotDataSet::updateLegendRange() RimEclipseCase* eclipseCase = dynamic_cast( m_case() ); if ( eclipseCase ) { - m_groupingProperty->updateLegendData( eclipseCase, m_timeStep() ); + m_groupingProperty->updateRangesForEmbeddedLegends( m_timeStep() ); } } parent->addOrUpdateDataSetLegend( this ); diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 192e24e7e6..d71d9a3d3a 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -659,10 +659,9 @@ void Rim2dIntersectionView::onUpdateLegends() m_ternaryLegendConfig()->setUiValuesFromLegendConfig( eclView->cellResult()->ternaryLegendConfig() ); } - eclView->cellResult()->updateLegendData( eclView->eclipseCase(), - m_currentTimeStep(), - m_legendConfig(), - m_ternaryLegendConfig() ); + eclView->cellResult()->updateRangesForExplicitLegends( m_legendConfig(), + m_ternaryLegendConfig(), + m_currentTimeStep() ); if ( eclView->cellResult()->isTernarySaturationSelected() ) { @@ -673,7 +672,7 @@ void Rim2dIntersectionView::onUpdateLegends() } else { - m_legendConfig()->setTitle( "Cell Result:\n" + eclView->cellResult()->resultVariableUiShortName() ); + eclView->cellResult()->updateLegendTitle( m_legendConfig, "Cell Result:\n" ); legend = m_legendConfig()->titledOverlayFrame(); m_legendObjectToSelect = eclView->cellResult()->legendConfig(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp index dad2e8b30c..d62c0a577c 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -269,287 +269,12 @@ RimEclipseView* RimEclipseCellColors::reservoirView() return m_reservoirView; } -bool operator<( const cvf::Color3ub first, const cvf::Color3ub second ) -{ - if ( first.r() != second.r() ) return first.r() < second.r(); - if ( first.g() != second.g() ) return first.g() < second.g(); - if ( first.b() != second.b() ) return first.b() < second.b(); - - return false; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -class TupleCompare +void RimEclipseCellColors::updateRangesForEmbeddedLegends( int currentTimeStep ) { -public: - bool operator()( const std::tuple& t1, - const std::tuple& t2 ) const - { - using namespace std; - if ( get<0>( t1 ) != get<0>( t2 ) ) return get<0>( t1 ) < get<0>( t2 ); - if ( get<1>( t1 ) != get<1>( t2 ) ) return get<1>( t1 ) < get<1>( t2 ); - if ( get<2>( t1 ) != get<2>( t2 ) ) return get<2>( t1 ) < get<2>( t2 ); - - return false; - } -}; - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEclipseCellColors::updateLegendData( RimEclipseCase* rimEclipseCase, - int currentTimeStep, - RimRegularLegendConfig* legendConfig, - RimTernaryLegendConfig* ternaryLegendConfig ) -{ - if ( !legendConfig ) legendConfig = this->legendConfig(); - if ( !ternaryLegendConfig ) ternaryLegendConfig = this->m_ternaryLegendConfig(); - - if ( this->hasResult() ) - { - if ( this->isFlowDiagOrInjectionFlooding() ) - { - CVF_ASSERT( currentTimeStep >= 0 ); - - double globalMin, globalMax; - double globalPosClosestToZero, globalNegClosestToZero; - RigFlowDiagResults* flowResultsData = this->flowDiagSolution()->flowDiagResults(); - RigFlowDiagResultAddress resAddr = this->flowDiagResAddress(); - - flowResultsData->minMaxScalarValues( resAddr, currentTimeStep, &globalMin, &globalMax ); - flowResultsData->posNegClosestToZero( resAddr, - currentTimeStep, - &globalPosClosestToZero, - &globalNegClosestToZero ); - - double localMin, localMax; - double localPosClosestToZero, localNegClosestToZero; - if ( this->hasDynamicResult() ) - { - flowResultsData->minMaxScalarValues( resAddr, currentTimeStep, &localMin, &localMax ); - flowResultsData->posNegClosestToZero( resAddr, - currentTimeStep, - &localPosClosestToZero, - &localNegClosestToZero ); - } - else - { - localMin = globalMin; - localMax = globalMax; - - localPosClosestToZero = globalPosClosestToZero; - localNegClosestToZero = globalNegClosestToZero; - } - - CVF_ASSERT( legendConfig ); - - legendConfig->disableAllTimeStepsRange( true ); - legendConfig->setClosestToZeroValues( globalPosClosestToZero, - globalNegClosestToZero, - localPosClosestToZero, - localNegClosestToZero ); - legendConfig->setAutomaticRanges( globalMin, globalMax, localMin, localMax ); - - if ( this->hasCategoryResult() && m_reservoirView ) - { - std::set, TupleCompare> categories; - // std::set > categories; - - std::vector tracerNames = this->flowDiagSolution()->tracerNames(); - int tracerIndex = 0; - for ( const auto& tracerName : tracerNames ) - { - RimSimWellInView* well = m_reservoirView->wellCollection()->findWell( - RimFlowDiagSolution::removeCrossFlowEnding( tracerName ) ); - cvf::Color3ub color( cvf::Color3::GRAY ); - if ( well ) color = cvf::Color3ub( well->wellPipeColor() ); - - categories.insert( std::make_tuple( tracerName, tracerIndex, color ) ); - ++tracerIndex; - } - - std::vector> reverseCategories; - for ( auto tupIt = categories.rbegin(); tupIt != categories.rend(); ++tupIt ) - { - reverseCategories.push_back( *tupIt ); - } - - legendConfig->setCategoryItems( reverseCategories ); - } - } - else - { - CVF_ASSERT( rimEclipseCase ); - if ( !rimEclipseCase ) return; - - RigEclipseCaseData* eclipseCase = rimEclipseCase->eclipseCaseData(); - CVF_ASSERT( eclipseCase ); - if ( !eclipseCase ) return; - - RigCaseCellResultsData* cellResultsData = eclipseCase->results( this->porosityModel() ); - CVF_ASSERT( cellResultsData ); - - double globalMin, globalMax; - double globalPosClosestToZero, globalNegClosestToZero; - - cellResultsData->minMaxCellScalarValues( this->eclipseResultAddress(), globalMin, globalMax ); - cellResultsData->posNegClosestToZero( this->eclipseResultAddress(), - globalPosClosestToZero, - globalNegClosestToZero ); - - double localMin, localMax; - double localPosClosestToZero, localNegClosestToZero; - if ( this->hasDynamicResult() && currentTimeStep >= 0 ) - { - cellResultsData->minMaxCellScalarValues( this->eclipseResultAddress(), currentTimeStep, localMin, localMax ); - cellResultsData->posNegClosestToZero( this->eclipseResultAddress(), - currentTimeStep, - localPosClosestToZero, - localNegClosestToZero ); - } - else - { - localMin = globalMin; - localMax = globalMax; - - localPosClosestToZero = globalPosClosestToZero; - localNegClosestToZero = globalNegClosestToZero; - } - - CVF_ASSERT( legendConfig ); - - legendConfig->disableAllTimeStepsRange( false ); - legendConfig->setClosestToZeroValues( globalPosClosestToZero, - globalNegClosestToZero, - localPosClosestToZero, - localNegClosestToZero ); - legendConfig->setAutomaticRanges( globalMin, globalMax, localMin, localMax ); - - if ( this->hasCategoryResult() ) - { - if ( this->resultType() == RiaDefines::FORMATION_NAMES ) - { - const std::vector& fnVector = eclipseCase->activeFormationNames()->formationNames(); - legendConfig->setNamedCategoriesInverse( fnVector ); - } - else if ( this->resultType() == RiaDefines::DYNAMIC_NATIVE && - this->resultVariable() == RiaDefines::completionTypeResultName() ) - { - const std::vector& visibleCategories = cellResultsData->uniqueCellScalarValues( - this->eclipseResultAddress() ); - - std::vector supportedCompletionTypes = {RiaDefines::WELL_PATH, - RiaDefines::FISHBONES, - RiaDefines::PERFORATION_INTERVAL, - RiaDefines::FRACTURE}; - - RiaColorTables::WellPathComponentColors colors = RiaColorTables::wellPathComponentColors(); - - std::vector> categories; - for ( auto completionType : supportedCompletionTypes ) - { - if ( std::find( visibleCategories.begin(), visibleCategories.end(), completionType ) != - visibleCategories.end() ) - { - QString categoryText = caf::AppEnum::uiText( - completionType ); - categories.push_back( - std::make_tuple( categoryText, completionType, colors[completionType] ) ); - } - } - - legendConfig->setCategoryItems( categories ); - } - else - { - legendConfig->setIntegerCategories( - cellResultsData->uniqueCellScalarValues( this->eclipseResultAddress() ) ); - } - } - } - } - - // Ternary legend update - { - CVF_ASSERT( rimEclipseCase ); - if ( !rimEclipseCase ) return; - - RigEclipseCaseData* eclipseCase = rimEclipseCase->eclipseCaseData(); - CVF_ASSERT( eclipseCase ); - if ( !eclipseCase ) return; - - RigCaseCellResultsData* cellResultsData = eclipseCase->results( this->porosityModel() ); - - size_t maxTimeStepCount = cellResultsData->maxTimeStepCount(); - if ( this->isTernarySaturationSelected() && maxTimeStepCount > 1 ) - { - RigCaseCellResultsData* gridCellResults = this->currentGridCellResults(); - { - RigEclipseResultAddress resAddr( RiaDefines::DYNAMIC_NATIVE, "SOIL" ); - - if ( gridCellResults->ensureKnownResultLoaded( resAddr ) ) - { - double globalMin = 0.0; - double globalMax = 1.0; - double localMin = 0.0; - double localMax = 1.0; - - cellResultsData->minMaxCellScalarValues( resAddr, globalMin, globalMax ); - cellResultsData->minMaxCellScalarValues( resAddr, currentTimeStep, localMin, localMax ); - - ternaryLegendConfig->setAutomaticRanges( RimTernaryLegendConfig::TERNARY_SOIL_IDX, - globalMin, - globalMax, - localMin, - localMax ); - } - } - - { - RigEclipseResultAddress resAddr( RiaDefines::DYNAMIC_NATIVE, "SGAS" ); - - if ( gridCellResults->ensureKnownResultLoaded( resAddr ) ) - { - double globalMin = 0.0; - double globalMax = 1.0; - double localMin = 0.0; - double localMax = 1.0; - - cellResultsData->minMaxCellScalarValues( resAddr, globalMin, globalMax ); - cellResultsData->minMaxCellScalarValues( resAddr, currentTimeStep, localMin, localMax ); - - ternaryLegendConfig->setAutomaticRanges( RimTernaryLegendConfig::TERNARY_SGAS_IDX, - globalMin, - globalMax, - localMin, - localMax ); - } - } - - { - RigEclipseResultAddress resAddr( RiaDefines::DYNAMIC_NATIVE, "SWAT" ); - - if ( gridCellResults->ensureKnownResultLoaded( resAddr ) ) - { - double globalMin = 0.0; - double globalMax = 1.0; - double localMin = 0.0; - double localMax = 1.0; - - cellResultsData->minMaxCellScalarValues( resAddr, globalMin, globalMax ); - cellResultsData->minMaxCellScalarValues( resAddr, currentTimeStep, localMin, localMax ); - - ternaryLegendConfig->setAutomaticRanges( RimTernaryLegendConfig::TERNARY_SWAT_IDX, - globalMin, - globalMax, - localMin, - localMax ); - } - } - } - } + this->updateRangesForExplicitLegends( legendConfig(), m_ternaryLegendConfig(), currentTimeStep ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h index 902367a9b7..6d3485bf82 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h @@ -45,10 +45,7 @@ public: void setReservoirView( RimEclipseView* ownerReservoirView ); RimEclipseView* reservoirView(); - void updateLegendData( RimEclipseCase* rimEclipseCase, - int timestep, - RimRegularLegendConfig* legendConfig = nullptr, - RimTernaryLegendConfig* ternaryLegendConfig = nullptr ); + void updateRangesForEmbeddedLegends( int timestep ); RimRegularLegendConfig* legendConfig(); RimTernaryLegendConfig* ternaryLegendConfig(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index ea716ded26..c12abad809 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -21,6 +21,7 @@ #include "RimEclipseResultDefinition.h" #include "RiaApplication.h" +#include "RiaColorTables.h" #include "RiaLogging.h" #include "RiaQDateTimeTools.h" @@ -32,6 +33,7 @@ #include "RigEclipseResultInfo.h" #include "RigFlowDiagResultAddress.h" #include "RigFlowDiagResults.h" +#include "RigFormationNames.h" #include "Rim3dView.h" #include "Rim3dWellLogCurve.h" @@ -50,9 +52,13 @@ #include "RimGridCrossPlotDataSet.h" #include "RimGridTimeHistoryCurve.h" #include "RimIntersectionCollection.h" +#include "RimIntersectionResultDefinition.h" #include "RimPlotCurve.h" #include "RimProject.h" #include "RimReservoirCellResultsStorage.h" +#include "RimSimWellInView.h" +#include "RimSimWellInViewCollection.h" +#include "RimTernaryLegendConfig.h" #include "RimViewLinker.h" #include "RimWellLogExtractionCurve.h" @@ -60,7 +66,6 @@ #include "cafPdmUiToolButtonEditor.h" #include "cafPdmUiTreeSelectionEditor.h" #include "cafUtils.h" -#include "RimIntersectionResultDefinition.h" namespace caf { @@ -225,7 +230,7 @@ void RimEclipseResultDefinition::setEclipseCase( RimEclipseCase* eclipseCase ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEclipseCase* RimEclipseResultDefinition::eclipseCase() const +RimEclipseCase* RimEclipseResultDefinition::eclipseCase() const { return m_eclipseCase; } @@ -555,11 +560,11 @@ void RimEclipseResultDefinition::loadDataAndUpdate() RimIntersectionResultDefinition* sepIntersectionResDef = nullptr; this->firstAncestorOrThisOfType( sepIntersectionResDef ); - if (sepIntersectionResDef && sepIntersectionResDef->isInAction()) + if ( sepIntersectionResDef && sepIntersectionResDef->isInAction() ) { if ( view ) view->scheduleCreateDisplayModelAndRedraw(); - RimGridView* eclView = dynamic_cast( view ); - if ( eclView ) eclView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); + RimGridView* gridView = dynamic_cast( view ); + if ( gridView ) gridView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } RimCellEdgeColors* cellEdgeColors = nullptr; @@ -1685,6 +1690,320 @@ void RimEclipseResultDefinition::setTernaryEnabled( bool enabled ) m_ternaryEnabled = enabled; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool operator<( const cvf::Color3ub first, const cvf::Color3ub second ) +{ + if ( first.r() != second.r() ) return first.r() < second.r(); + if ( first.g() != second.g() ) return first.g() < second.g(); + if ( first.b() != second.b() ) return first.b() < second.b(); + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class TupleCompare +{ +public: + bool operator()( const std::tuple& t1, + const std::tuple& t2 ) const + { + using namespace std; + if ( get<0>( t1 ) != get<0>( t2 ) ) return get<0>( t1 ) < get<0>( t2 ); + if ( get<1>( t1 ) != get<1>( t2 ) ) return get<1>( t1 ) < get<1>( t2 ); + if ( get<2>( t1 ) != get<2>( t2 ) ) return get<2>( t1 ) < get<2>( t2 ); + + return false; + } +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegendConfig* legendConfigToUpdate, + RimTernaryLegendConfig* ternaryLegendConfigToUpdate, + int currentTimeStep ) + +{ + RimEclipseCase* rimEclipseCase = this->eclipseCase(); + + if ( this->hasResult() ) + { + if ( this->isFlowDiagOrInjectionFlooding() ) + { + CVF_ASSERT( currentTimeStep >= 0 ); + + double globalMin, globalMax; + double globalPosClosestToZero, globalNegClosestToZero; + RigFlowDiagResults* flowResultsData = this->flowDiagSolution()->flowDiagResults(); + RigFlowDiagResultAddress resAddr = this->flowDiagResAddress(); + + flowResultsData->minMaxScalarValues( resAddr, currentTimeStep, &globalMin, &globalMax ); + flowResultsData->posNegClosestToZero( resAddr, + currentTimeStep, + &globalPosClosestToZero, + &globalNegClosestToZero ); + + double localMin, localMax; + double localPosClosestToZero, localNegClosestToZero; + if ( this->hasDynamicResult() ) + { + flowResultsData->minMaxScalarValues( resAddr, currentTimeStep, &localMin, &localMax ); + flowResultsData->posNegClosestToZero( resAddr, + currentTimeStep, + &localPosClosestToZero, + &localNegClosestToZero ); + } + else + { + localMin = globalMin; + localMax = globalMax; + + localPosClosestToZero = globalPosClosestToZero; + localNegClosestToZero = globalNegClosestToZero; + } + + CVF_ASSERT( legendConfigToUpdate ); + + legendConfigToUpdate->disableAllTimeStepsRange( true ); + legendConfigToUpdate->setClosestToZeroValues( globalPosClosestToZero, + globalNegClosestToZero, + localPosClosestToZero, + localNegClosestToZero ); + legendConfigToUpdate->setAutomaticRanges( globalMin, globalMax, localMin, localMax ); + + if ( this->hasCategoryResult() ) + { + RimEclipseView* eclView = nullptr; + this->firstAncestorOrThisOfType( eclView ); + + if ( eclView ) + { + std::set, TupleCompare> categories; + + std::vector tracerNames = this->flowDiagSolution()->tracerNames(); + int tracerIndex = 0; + + for ( const auto& tracerName : tracerNames ) + { + cvf::Color3ub color( cvf::Color3::GRAY ); + + RimSimWellInView* well = eclView->wellCollection()->findWell( + RimFlowDiagSolution::removeCrossFlowEnding( tracerName ) ); + + if ( well ) color = cvf::Color3ub( well->wellPipeColor() ); + + categories.insert( std::make_tuple( tracerName, tracerIndex, color ) ); + ++tracerIndex; + } + + std::vector> reverseCategories; + for ( auto tupIt = categories.rbegin(); tupIt != categories.rend(); ++tupIt ) + { + reverseCategories.push_back( *tupIt ); + } + + legendConfigToUpdate->setCategoryItems( reverseCategories ); + } + } + } + else + { + CVF_ASSERT( rimEclipseCase ); + if ( !rimEclipseCase ) return; + + RigEclipseCaseData* eclipseCaseData = rimEclipseCase->eclipseCaseData(); + CVF_ASSERT( eclipseCaseData ); + if ( !eclipseCaseData ) return; + + RigCaseCellResultsData* cellResultsData = eclipseCaseData->results( this->porosityModel() ); + CVF_ASSERT( cellResultsData ); + + double globalMin, globalMax; + double globalPosClosestToZero, globalNegClosestToZero; + + cellResultsData->minMaxCellScalarValues( this->eclipseResultAddress(), globalMin, globalMax ); + cellResultsData->posNegClosestToZero( this->eclipseResultAddress(), + globalPosClosestToZero, + globalNegClosestToZero ); + + double localMin, localMax; + double localPosClosestToZero, localNegClosestToZero; + if ( this->hasDynamicResult() && currentTimeStep >= 0 ) + { + cellResultsData->minMaxCellScalarValues( this->eclipseResultAddress(), currentTimeStep, localMin, localMax ); + cellResultsData->posNegClosestToZero( this->eclipseResultAddress(), + currentTimeStep, + localPosClosestToZero, + localNegClosestToZero ); + } + else + { + localMin = globalMin; + localMax = globalMax; + + localPosClosestToZero = globalPosClosestToZero; + localNegClosestToZero = globalNegClosestToZero; + } + + CVF_ASSERT( legendConfigToUpdate ); + + legendConfigToUpdate->disableAllTimeStepsRange( false ); + legendConfigToUpdate->setClosestToZeroValues( globalPosClosestToZero, + globalNegClosestToZero, + localPosClosestToZero, + localNegClosestToZero ); + legendConfigToUpdate->setAutomaticRanges( globalMin, globalMax, localMin, localMax ); + + if ( this->hasCategoryResult() ) + { + if ( this->resultType() == RiaDefines::FORMATION_NAMES ) + { + const std::vector& fnVector = eclipseCaseData->activeFormationNames()->formationNames(); + legendConfigToUpdate->setNamedCategoriesInverse( fnVector ); + } + else if ( this->resultType() == RiaDefines::DYNAMIC_NATIVE && + this->resultVariable() == RiaDefines::completionTypeResultName() ) + { + const std::vector& visibleCategories = cellResultsData->uniqueCellScalarValues( + this->eclipseResultAddress() ); + + std::vector supportedCompletionTypes = {RiaDefines::WELL_PATH, + RiaDefines::FISHBONES, + RiaDefines::PERFORATION_INTERVAL, + RiaDefines::FRACTURE}; + + RiaColorTables::WellPathComponentColors colors = RiaColorTables::wellPathComponentColors(); + + std::vector> categories; + for ( auto completionType : supportedCompletionTypes ) + { + if ( std::find( visibleCategories.begin(), visibleCategories.end(), completionType ) != + visibleCategories.end() ) + { + QString categoryText = caf::AppEnum::uiText( + completionType ); + categories.push_back( + std::make_tuple( categoryText, completionType, colors[completionType] ) ); + } + } + + legendConfigToUpdate->setCategoryItems( categories ); + } + else + { + legendConfigToUpdate->setIntegerCategories( + cellResultsData->uniqueCellScalarValues( this->eclipseResultAddress() ) ); + } + } + } + } + + // Ternary legend update + { + CVF_ASSERT( rimEclipseCase ); + if ( !rimEclipseCase ) return; + + RigEclipseCaseData* eclipseCase = rimEclipseCase->eclipseCaseData(); + CVF_ASSERT( eclipseCase ); + if ( !eclipseCase ) return; + + RigCaseCellResultsData* cellResultsData = eclipseCase->results( this->porosityModel() ); + + size_t maxTimeStepCount = cellResultsData->maxTimeStepCount(); + if ( this->isTernarySaturationSelected() && maxTimeStepCount > 1 ) + { + RigCaseCellResultsData* gridCellResults = this->currentGridCellResults(); + { + RigEclipseResultAddress resAddr( RiaDefines::DYNAMIC_NATIVE, "SOIL" ); + + if ( gridCellResults->ensureKnownResultLoaded( resAddr ) ) + { + double globalMin = 0.0; + double globalMax = 1.0; + double localMin = 0.0; + double localMax = 1.0; + + cellResultsData->minMaxCellScalarValues( resAddr, globalMin, globalMax ); + cellResultsData->minMaxCellScalarValues( resAddr, currentTimeStep, localMin, localMax ); + + ternaryLegendConfigToUpdate->setAutomaticRanges( RimTernaryLegendConfig::TERNARY_SOIL_IDX, + globalMin, + globalMax, + localMin, + localMax ); + } + } + + { + RigEclipseResultAddress resAddr( RiaDefines::DYNAMIC_NATIVE, "SGAS" ); + + if ( gridCellResults->ensureKnownResultLoaded( resAddr ) ) + { + double globalMin = 0.0; + double globalMax = 1.0; + double localMin = 0.0; + double localMax = 1.0; + + cellResultsData->minMaxCellScalarValues( resAddr, globalMin, globalMax ); + cellResultsData->minMaxCellScalarValues( resAddr, currentTimeStep, localMin, localMax ); + + ternaryLegendConfigToUpdate->setAutomaticRanges( RimTernaryLegendConfig::TERNARY_SGAS_IDX, + globalMin, + globalMax, + localMin, + localMax ); + } + } + + { + RigEclipseResultAddress resAddr( RiaDefines::DYNAMIC_NATIVE, "SWAT" ); + + if ( gridCellResults->ensureKnownResultLoaded( resAddr ) ) + { + double globalMin = 0.0; + double globalMax = 1.0; + double localMin = 0.0; + double localMax = 1.0; + + cellResultsData->minMaxCellScalarValues( resAddr, globalMin, globalMax ); + cellResultsData->minMaxCellScalarValues( resAddr, currentTimeStep, localMin, localMax ); + + ternaryLegendConfigToUpdate->setAutomaticRanges( RimTernaryLegendConfig::TERNARY_SWAT_IDX, + globalMin, + globalMax, + localMin, + localMax ); + } + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseResultDefinition::updateLegendTitle( RimRegularLegendConfig* legendConfig, const QString& legendHeading ) +{ + QString title = legendHeading + this->resultVariableUiName(); + if ( !this->diffResultUiShortName().isEmpty() ) + { + title += QString( "\n%1" ).arg( this->diffResultUiShortName() ); + } + + if ( this->hasDualPorFractureResult() ) + { + QString porosityModelText = caf::AppEnum::uiText( this->porosityModel() ); + + title += QString( "\nDual Por : %1" ).arg( porosityModelText ); + } + + legendConfig->setTitle( title ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h index 9abbd2a284..6050851fc8 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h @@ -41,6 +41,8 @@ class RigCaseCellResultsData; class RimEclipseCase; class RimEclipseView; class RimReservoirCellResultsStorage; +class RimRegularLegendConfig; +class RimTernaryLegendConfig; //================================================================================================== /// @@ -145,6 +147,11 @@ public: void setTernaryEnabled( bool enabled ); + void updateRangesForExplicitLegends( RimRegularLegendConfig* legendConfig, + RimTernaryLegendConfig* ternaryLegendConfig, + int currentTimeStep ); + void updateLegendTitle( RimRegularLegendConfig* legendConfig, const QString& legendHeading ); + protected: virtual void updateLegendCategorySettings(){}; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 90747432c1..6d4068559b 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -55,10 +55,14 @@ #include "RimFlowDiagSolution.h" #include "RimFracture.h" #include "RimFractureTemplateCollection.h" +#include "RimGeoMechResultDefinition.h" #include "RimGridCollection.h" #include "RimGridCrossPlotDataSet.h" +#include "RimGridView.h" #include "RimIntersection.h" #include "RimIntersectionCollection.h" +#include "RimIntersectionResultDefinition.h" +#include "RimIntersectionResultsDefinitionCollection.h" #include "RimOilField.h" #include "RimProject.h" #include "RimRegularLegendConfig.h" @@ -101,9 +105,6 @@ #include -#include "RimGridView.h" -#include "RimIntersectionResultDefinition.h" -#include "RimIntersectionResultsDefinitionCollection.h" #include CAF_PDM_SOURCE_INIT( RimEclipseView, "ReservoirView" ); @@ -1203,11 +1204,48 @@ void RimEclipseView::onUpdateLegends() RigCaseCellResultsData* results = eclipseCase->results( cellResult()->porosityModel() ); CVF_ASSERT( results ); - updateMinMaxValuesAndAddLegendToView( QString( "Cell Results: \n" ), this->cellResult(), results ); + updateLegendTextAndRanges( this->cellResult()->legendConfig(), + this->cellResult()->ternaryLegendConfig(), + QString( "Cell Results: \n" ), + this->cellResult(), + m_currentTimeStep ); if ( this->faultResultSettings()->showCustomFaultResult() && this->faultResultSettings()->hasValidCustomResult() ) { - updateMinMaxValuesAndAddLegendToView( QString( "Fault Results: \n" ), this->currentFaultResultColors(), results ); + updateLegendTextAndRanges( currentFaultResultColors()->legendConfig(), + currentFaultResultColors()->ternaryLegendConfig(), + QString( "Fault Results: \n" ), + this->currentFaultResultColors(), + m_currentTimeStep ); + } + + for ( RimIntersectionResultDefinition* sepInterResDef : + this->separateIntersectionResultsCollection()->intersectionResultsDefinitions() ) + { + if ( !sepInterResDef->isInAction() ) continue; + + if ( sepInterResDef->isEclipseResultDefinition() ) + { + updateLegendTextAndRanges( sepInterResDef->regularLegendConfig(), + sepInterResDef->ternaryLegendConfig(), + QString( "Intersection Results: \n" ), + sepInterResDef->eclipseResultDefinition(), + sepInterResDef->timeStep() ); + } + else + { + sepInterResDef->geoMechResultDefinition()->updateLegendTextAndRanges( sepInterResDef->regularLegendConfig(), + "Intersection Results:\n", + sepInterResDef->timeStep() ); + + if ( sepInterResDef->geoMechResultDefinition()->hasResult() && + sepInterResDef->regularLegendConfig()->showLegend() ) + { + nativeOrOverrideViewer() + ->addColorLegendToBottomLeftCorner( sepInterResDef->regularLegendConfig()->titledOverlayFrame(), + isUsingOverrideViewer() ); + } + } } if ( this->cellEdgeResult()->legendConfig()->showLegend() ) @@ -1216,7 +1254,7 @@ void RimEclipseView::onUpdateLegends() { if ( this->cellEdgeResult()->isUsingSingleVariable() ) { - this->cellEdgeResult()->singleVarEdgeResultColors()->updateLegendData( m_eclipseCase, m_currentTimeStep ); + this->cellEdgeResult()->singleVarEdgeResultColors()->updateRangesForEmbeddedLegends( m_currentTimeStep ); } else { @@ -1303,43 +1341,30 @@ void RimEclipseView::onUpdateLegends() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEclipseView::updateMinMaxValuesAndAddLegendToView( QString legendLabel, - RimEclipseCellColors* resultColors, - RigCaseCellResultsData* cellResultsData ) +void RimEclipseView::updateLegendTextAndRanges( RimRegularLegendConfig* legendConfig, + RimTernaryLegendConfig* ternaryLegendConfig, + QString legendHeading, + RimEclipseResultDefinition* eclResultDef, + int timeStepIndex ) { - resultColors->updateLegendData( m_eclipseCase, m_currentTimeStep ); + eclResultDef->updateRangesForExplicitLegends( legendConfig, ternaryLegendConfig, timeStepIndex ); - if ( resultColors->hasResult() && resultColors->legendConfig()->showLegend() ) + if ( eclResultDef->hasResult() && legendConfig->showLegend() ) { - QString title = legendLabel + resultColors->resultVariableUiName(); - if ( !resultColors->diffResultUiShortName().isEmpty() ) - { - title += QString( "\n%1" ).arg( resultColors->diffResultUiShortName() ); - } + eclResultDef->updateLegendTitle( legendConfig, legendHeading ); - if ( resultColors->hasDualPorFractureResult() ) - { - QString porosityModelText = caf::AppEnum::uiText( - resultColors->porosityModel() ); - - title += QString( "\nDual Por : %1" ).arg( porosityModelText ); - } - - resultColors->legendConfig()->setTitle( title ); - nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( resultColors->legendConfig()->titledOverlayFrame(), + nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( legendConfig->titledOverlayFrame(), isUsingOverrideViewer() ); } - size_t maxTimeStepCount = cellResultsData->maxTimeStepCount(); - if ( resultColors->isTernarySaturationSelected() && maxTimeStepCount > 1 ) + size_t maxTimeStepCount = eclResultDef->currentGridCellResults()->maxTimeStepCount(); + if ( eclResultDef->isTernarySaturationSelected() && maxTimeStepCount > 1 ) { - if ( resultColors->ternaryLegendConfig()->showLegend() && - resultColors->ternaryLegendConfig()->titledOverlayFrame() ) + if ( ternaryLegendConfig->showLegend() && ternaryLegendConfig->titledOverlayFrame() ) { - resultColors->ternaryLegendConfig()->setTitle( legendLabel ); - nativeOrOverrideViewer() - ->addColorLegendToBottomLeftCorner( resultColors->ternaryLegendConfig()->titledOverlayFrame(), - isUsingOverrideViewer() ); + ternaryLegendConfig->setTitle( legendHeading ); + nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( ternaryLegendConfig->titledOverlayFrame(), + isUsingOverrideViewer() ); } } } @@ -2007,6 +2032,13 @@ std::vector RimEclipseView::legendConfigs() const absLegends.push_back( fractureColors()->activeLegend() ); absLegends.push_back( virtualPerforationResult()->legendConfig() ); + for ( RimIntersectionResultDefinition* sepInterResDef : + this->separateIntersectionResultsCollection()->intersectionResultsDefinitions() ) + { + absLegends.push_back( sepInterResDef->regularLegendConfig() ); + absLegends.push_back( sepInterResDef->ternaryLegendConfig() ); + } + return absLegends; } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index 3330a95173..3408c58e85 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -59,6 +59,9 @@ class RiuViewer; class RivReservoirSimWellsPartMgr; class RivIntersectionPartMgr; class RivReservoirViewPartMgr; +class RimRegularLegendConfig; +class RimTernaryLegendConfig; +class RimEclipseResultDefinition; namespace cvf { @@ -176,9 +179,12 @@ private: void updateStaticCellColors( RivCellSetEnum geometryType ); void onUpdateLegends() override; - void updateMinMaxValuesAndAddLegendToView( QString legendLabel, - RimEclipseCellColors* resultColors, - RigCaseCellResultsData* cellResultsData ); + void updateLegendTextAndRanges( RimRegularLegendConfig* legendConfig, + RimTernaryLegendConfig* ternaryLegendConfig, + QString legendLabel, + RimEclipseResultDefinition* eclResDef, + int timeStepIndex ); + void onResetLegendsInViewer() override; void updateVirtualConnectionLegendRanges(); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index 25f951ba91..e31f4da4f2 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -26,6 +26,7 @@ #include "RigFemPartGrid.h" #include "RigFemPartResultsCollection.h" #include "RigFemResultAddress.h" +#include "RigFormationNames.h" #include "RigGeoMechCaseData.h" #include "RiaDefines.h" @@ -37,6 +38,7 @@ #include "RimGeoMechView.h" #include "RimIntersectionCollection.h" #include "RimPlotCurve.h" +#include "RimRegularLegendConfig.h" #include "RimViewLinker.h" #include "cafPdmUiListEditor.h" @@ -647,3 +649,77 @@ void RimGeoMechResultDefinition::setResultAddress( const RigFemResultAddress& re m_resultVariableUiField = composeFieldCompString( m_resultFieldName(), m_resultComponentName() ); m_compactionRefLayerUiField = m_compactionRefLayer; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechResultDefinition::updateLegendTextAndRanges( RimRegularLegendConfig* legendConfigToUpdate, + const QString& legendHeading, + int timeStepIndex ) +{ + if ( !this->ownerCaseData() || !( this->resultAddress().isValid() ) ) + { + return; + } + + double localMin, localMax; + double localPosClosestToZero, localNegClosestToZero; + double globalMin, globalMax; + double globalPosClosestToZero, globalNegClosestToZero; + + RigGeoMechCaseData* gmCase = this->ownerCaseData(); + CVF_ASSERT( gmCase ); + + RigFemResultAddress resVarAddress = this->resultAddress(); + + gmCase->femPartResults()->minMaxScalarValues( resVarAddress, timeStepIndex, &localMin, &localMax ); + gmCase->femPartResults()->posNegClosestToZero( resVarAddress, + timeStepIndex, + &localPosClosestToZero, + &localNegClosestToZero ); + + gmCase->femPartResults()->minMaxScalarValues( resVarAddress, &globalMin, &globalMax ); + gmCase->femPartResults()->posNegClosestToZero( resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero ); + + legendConfigToUpdate->setClosestToZeroValues( globalPosClosestToZero, + globalNegClosestToZero, + localPosClosestToZero, + localNegClosestToZero ); + legendConfigToUpdate->setAutomaticRanges( globalMin, globalMax, localMin, localMax ); + + if ( this->hasCategoryResult() ) + { + std::vector fnVector; + if ( gmCase->femPartResults()->activeFormationNames() ) + { + fnVector = gmCase->femPartResults()->activeFormationNames()->formationNames(); + } + legendConfigToUpdate->setNamedCategoriesInverse( fnVector ); + } + + QString legendTitle = legendHeading + caf::AppEnum( this->resultPositionType() ).uiText() + + "\n" + this->resultFieldUiName(); + + if ( !this->resultComponentUiName().isEmpty() ) + { + legendTitle += ", " + this->resultComponentUiName(); + } + + if ( this->resultFieldName() == "SE" || this->resultFieldName() == "ST" || this->resultFieldName() == "POR-Bar" || + this->resultFieldName() == "SM" || this->resultFieldName() == "SEM" || this->resultFieldName() == "Q" ) + { + legendTitle += " [Bar]"; + } + + if ( this->resultFieldName() == "MODULUS" ) + { + legendTitle += " [GPa]"; + } + + if ( !this->diffResultUiShortName().isEmpty() ) + { + legendTitle += QString( "\nTime Diff:\n%1" ).arg( this->diffResultUiShortName() ); + } + + legendConfigToUpdate->setTitle( legendTitle ); +} diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h index 05e1698e12..0985228e3a 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h @@ -32,6 +32,7 @@ class RimGeoMechPropertyFilter; class RifGeoMechReaderInterface; class RigGeoMechCaseData; class RimGeoMechCase; +class RimRegularLegendConfig; //================================================================================================== /// @@ -70,11 +71,16 @@ public: return m_resultPositionType() == RIG_FORMATION_NAMES; } + void updateLegendTextAndRanges( RimRegularLegendConfig* legendConfigToUpdate, + const QString& legendHeading, + int timeStepIndex ); + protected: virtual void updateLegendCategorySettings(){}; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; friend class RimIntersectionResultDefinition; + private: // Overridden PDM methods diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index d9e9f78444..e5d19c9585 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -32,6 +32,7 @@ #include "Rim3dOverlayInfoConfig.h" #include "RimCellRangeFilterCollection.h" +#include "RimEclipseResultDefinition.h" #include "RimEclipseView.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" @@ -466,6 +467,53 @@ void RimGeoMechView::onUpdateLegends() isUsingOverrideViewer() ); } + for ( RimIntersectionResultDefinition* sepInterResDef : + this->separateIntersectionResultsCollection()->intersectionResultsDefinitions() ) + { + if ( !sepInterResDef->isInAction() ) continue; + + if ( sepInterResDef->isEclipseResultDefinition() ) + { + RimEclipseResultDefinition* eclResultDef = sepInterResDef->eclipseResultDefinition(); + eclResultDef->updateRangesForExplicitLegends( sepInterResDef->regularLegendConfig(), + sepInterResDef->ternaryLegendConfig(), + sepInterResDef->timeStep() ); + + eclResultDef->updateLegendTitle( sepInterResDef->regularLegendConfig(), "Intersection Results:\n" ); + + if ( sepInterResDef->regularLegendConfig()->showLegend() && eclResultDef->hasResult() ) + { + nativeOrOverrideViewer() + ->addColorLegendToBottomLeftCorner( sepInterResDef->regularLegendConfig()->titledOverlayFrame(), + isUsingOverrideViewer() ); + } + else if ( eclResultDef->isTernarySaturationSelected() && + eclResultDef->currentGridCellResults()->maxTimeStepCount() > 1 && + sepInterResDef->ternaryLegendConfig()->showLegend() && + sepInterResDef->ternaryLegendConfig()->titledOverlayFrame() ) + { + sepInterResDef->ternaryLegendConfig()->setTitle( "Intersection Results: \n" ); + nativeOrOverrideViewer() + ->addColorLegendToBottomLeftCorner( sepInterResDef->ternaryLegendConfig()->titledOverlayFrame(), + isUsingOverrideViewer() ); + } + } + else + { + sepInterResDef->geoMechResultDefinition()->updateLegendTextAndRanges( sepInterResDef->regularLegendConfig(), + "Intersection Results:\n", + sepInterResDef->timeStep() ); + + if ( sepInterResDef->geoMechResultDefinition()->hasResult() && + sepInterResDef->regularLegendConfig()->showLegend() ) + { + nativeOrOverrideViewer() + ->addColorLegendToBottomLeftCorner( sepInterResDef->regularLegendConfig()->titledOverlayFrame(), + isUsingOverrideViewer() ); + } + } + } + if ( tensorResults()->showTensors() ) { updateTensorLegendTextAndRanges( m_tensorResults->arrowColorLegendConfig(), m_currentTimeStep() ); @@ -531,74 +579,12 @@ void RimGeoMechView::updateTensorLegendTextAndRanges( RimRegularLegendConfig* le //-------------------------------------------------------------------------------------------------- void RimGeoMechView::updateLegendTextAndRanges( RimRegularLegendConfig* legendConfig, int timeStepIndex ) { - if ( !m_geomechCase || !m_geomechCase->geoMechData() || !this->isTimeStepDependentDataVisible() || - !( cellResult()->resultAddress().isValid() ) ) + if ( !this->isTimeStepDependentDataVisible() ) { return; } - double localMin, localMax; - double localPosClosestToZero, localNegClosestToZero; - double globalMin, globalMax; - double globalPosClosestToZero, globalNegClosestToZero; - - RigGeoMechCaseData* gmCase = m_geomechCase->geoMechData(); - CVF_ASSERT( gmCase ); - - RigFemResultAddress resVarAddress = cellResult()->resultAddress(); - - gmCase->femPartResults()->minMaxScalarValues( resVarAddress, timeStepIndex, &localMin, &localMax ); - gmCase->femPartResults()->posNegClosestToZero( resVarAddress, - timeStepIndex, - &localPosClosestToZero, - &localNegClosestToZero ); - - gmCase->femPartResults()->minMaxScalarValues( resVarAddress, &globalMin, &globalMax ); - gmCase->femPartResults()->posNegClosestToZero( resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero ); - - legendConfig->setClosestToZeroValues( globalPosClosestToZero, - globalNegClosestToZero, - localPosClosestToZero, - localNegClosestToZero ); - legendConfig->setAutomaticRanges( globalMin, globalMax, localMin, localMax ); - - if ( cellResult()->hasCategoryResult() ) - { - std::vector fnVector; - if ( gmCase->femPartResults()->activeFormationNames() ) - { - fnVector = gmCase->femPartResults()->activeFormationNames()->formationNames(); - } - legendConfig->setNamedCategoriesInverse( fnVector ); - } - - QString legendTitle = "Cell Results:\n" + - caf::AppEnum( cellResult->resultPositionType() ).uiText() + "\n" + - cellResult->resultFieldUiName(); - - if ( !cellResult->resultComponentUiName().isEmpty() ) - { - legendTitle += ", " + cellResult->resultComponentUiName(); - } - - if ( cellResult->resultFieldName() == "SE" || cellResult->resultFieldName() == "ST" || - cellResult->resultFieldName() == "POR-Bar" || cellResult->resultFieldName() == "SM" || - cellResult->resultFieldName() == "SEM" || cellResult->resultFieldName() == "Q" ) - { - legendTitle += " [Bar]"; - } - - if ( cellResult->resultFieldName() == "MODULUS" ) - { - legendTitle += " [GPa]"; - } - - if ( !cellResult->diffResultUiShortName().isEmpty() ) - { - legendTitle += QString( "\nTime Diff:\n%1" ).arg( cellResult->diffResultUiShortName() ); - } - - legendConfig->setTitle( legendTitle ); + cellResult()->updateLegendTextAndRanges( legendConfig, "Cell Result:\n", timeStepIndex ); } //-------------------------------------------------------------------------------------------------- @@ -635,6 +621,12 @@ std::vector RimGeoMechView::legendConfigs() const absLegendConfigs.push_back( cellResult()->legendConfig() ); absLegendConfigs.push_back( tensorResults()->arrowColorLegendConfig() ); + for ( RimIntersectionResultDefinition* sepInterResDef : + this->separateIntersectionResultsCollection()->intersectionResultsDefinitions() ) + { + absLegendConfigs.push_back( sepInterResDef->regularLegendConfig() ); + } + return absLegendConfigs; }