From 1ab815e673c3416405ed400df18fe0eeb41febab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 22 Nov 2019 13:31:35 +0100 Subject: [PATCH] #5019 Use same code for separate intersection legend setup in eclipse and geomech --- .../ProjectDataModel/RimEclipseView.cpp | 55 ++++++------------- .../ProjectDataModel/RimEclipseView.h | 10 ++-- .../ProjectDataModel/RimGeoMechView.cpp | 43 +-------------- .../RimIntersectionResultDefinition.cpp | 48 ++++++++++++++++ .../RimIntersectionResultDefinition.h | 3 + 5 files changed, 73 insertions(+), 86 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 6d4068559b..ad7946fff2 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1204,48 +1204,25 @@ void RimEclipseView::onUpdateLegends() RigCaseCellResultsData* results = eclipseCase->results( cellResult()->porosityModel() ); CVF_ASSERT( results ); - updateLegendTextAndRanges( this->cellResult()->legendConfig(), - this->cellResult()->ternaryLegendConfig(), - QString( "Cell Results: \n" ), - this->cellResult(), - m_currentTimeStep ); + updateLegendRangesTextAndVisibility( this->cellResult()->legendConfig(), + this->cellResult()->ternaryLegendConfig(), + QString( "Cell Results: \n" ), + this->cellResult(), + m_currentTimeStep ); if ( this->faultResultSettings()->showCustomFaultResult() && this->faultResultSettings()->hasValidCustomResult() ) { - updateLegendTextAndRanges( currentFaultResultColors()->legendConfig(), - currentFaultResultColors()->ternaryLegendConfig(), - QString( "Fault Results: \n" ), - this->currentFaultResultColors(), - m_currentTimeStep ); + updateLegendRangesTextAndVisibility( 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() ); - } - } + sepInterResDef->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(), isUsingOverrideViewer() ); } if ( this->cellEdgeResult()->legendConfig()->showLegend() ) @@ -1341,11 +1318,11 @@ void RimEclipseView::onUpdateLegends() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEclipseView::updateLegendTextAndRanges( RimRegularLegendConfig* legendConfig, - RimTernaryLegendConfig* ternaryLegendConfig, - QString legendHeading, - RimEclipseResultDefinition* eclResultDef, - int timeStepIndex ) +void RimEclipseView::updateLegendRangesTextAndVisibility( RimRegularLegendConfig* legendConfig, + RimTernaryLegendConfig* ternaryLegendConfig, + QString legendHeading, + RimEclipseResultDefinition* eclResultDef, + int timeStepIndex ) { eclResultDef->updateRangesForExplicitLegends( legendConfig, ternaryLegendConfig, timeStepIndex ); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index 3408c58e85..c2ae098535 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -179,11 +179,11 @@ private: void updateStaticCellColors( RivCellSetEnum geometryType ); void onUpdateLegends() override; - void updateLegendTextAndRanges( RimRegularLegendConfig* legendConfig, - RimTernaryLegendConfig* ternaryLegendConfig, - QString legendLabel, - RimEclipseResultDefinition* eclResDef, - int timeStepIndex ); + void updateLegendRangesTextAndVisibility( RimRegularLegendConfig* legendConfig, + RimTernaryLegendConfig* ternaryLegendConfig, + QString legendLabel, + RimEclipseResultDefinition* eclResDef, + int timeStepIndex ); void onResetLegendsInViewer() override; void updateVirtualConnectionLegendRanges(); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index e5d19c9585..b506fe087b 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -470,48 +470,7 @@ void RimGeoMechView::onUpdateLegends() 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() ); - } - } + sepInterResDef->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(), isUsingOverrideViewer() ); } if ( tensorResults()->showTensors() ) diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionResultDefinition.cpp index 323a5db933..6181a19a45 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionResultDefinition.cpp @@ -28,6 +28,9 @@ #include "RimRegularLegendConfig.h" #include "RimTernaryLegendConfig.h" #include "RimTools.h" + +#include "RiuViewer.h" + #include "cafPdmUiTreeOrdering.h" CAF_PDM_SOURCE_INIT( RimIntersectionResultDefinition, "IntersectionResultDefinition" ); @@ -183,6 +186,51 @@ RimGeoMechResultDefinition* RimIntersectionResultDefinition::geoMechResultDefini return m_geomResultDefinition(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionResultDefinition::updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, + bool isUsingOverrideViewer ) +{ + if ( !this->isInAction() ) return; + + if ( this->isEclipseResultDefinition() ) + { + RimEclipseResultDefinition* eclResultDef = this->eclipseResultDefinition(); + eclResultDef->updateRangesForExplicitLegends( this->regularLegendConfig(), + this->ternaryLegendConfig(), + this->timeStep() ); + + eclResultDef->updateLegendTitle( this->regularLegendConfig(), "Intersection Results:\n" ); + + if ( this->regularLegendConfig()->showLegend() && eclResultDef->hasResult() ) + { + nativeOrOverrideViewer->addColorLegendToBottomLeftCorner( this->regularLegendConfig()->titledOverlayFrame(), + isUsingOverrideViewer ); + } + else if ( eclResultDef->isTernarySaturationSelected() && + eclResultDef->currentGridCellResults()->maxTimeStepCount() > 1 && + this->ternaryLegendConfig()->showLegend() && this->ternaryLegendConfig()->titledOverlayFrame() ) + { + this->ternaryLegendConfig()->setTitle( "Intersection Results: \n" ); + nativeOrOverrideViewer->addColorLegendToBottomLeftCorner( this->ternaryLegendConfig()->titledOverlayFrame(), + isUsingOverrideViewer ); + } + } + else + { + this->geoMechResultDefinition()->updateLegendTextAndRanges( this->regularLegendConfig(), + "Intersection Results:\n", + this->timeStep() ); + + if ( this->geoMechResultDefinition()->hasResult() && this->regularLegendConfig()->showLegend() ) + { + nativeOrOverrideViewer->addColorLegendToBottomLeftCorner( this->regularLegendConfig()->titledOverlayFrame(), + isUsingOverrideViewer ); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionResultDefinition.h b/ApplicationCode/ProjectDataModel/RimIntersectionResultDefinition.h index 259f901ab8..07efa510b0 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionResultDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimIntersectionResultDefinition.h @@ -29,6 +29,7 @@ class RimGeoMechResultDefinition; class RimCase; class RimRegularLegendConfig; class RimTernaryLegendConfig; +class RiuViewer; class RimIntersectionResultDefinition : public caf::PdmObject { @@ -51,6 +52,8 @@ public: RimEclipseResultDefinition* eclipseResultDefinition() const; RimGeoMechResultDefinition* geoMechResultDefinition() const; + void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer ); + protected: virtual caf::PdmFieldHandle* userDescriptionField() override; virtual caf::PdmFieldHandle* objectToggleField() override;