Skip to content

Commit

Permalink
Statistics Contourmap UI updates (#12060)
Browse files Browse the repository at this point in the history
* Enable time step selections and controls in view
* Support loading just what we need for statistics contour maps by using custom reader settings
* Close case once done with it unless there are active views.
* Add selection of user interface case (for result selection, display of wells, faults...)
* Avoid int overflow for nested progresses by using double
* Improve auto naming
* Misc. UI improvements
  • Loading branch information
jonjenssen authored Jan 14, 2025
1 parent ba1224c commit b999faf
Show file tree
Hide file tree
Showing 47 changed files with 1,250 additions and 786 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ int RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( const QStr
else
{
// Make sure the placeholder result entries are created, as this functionality is triggered when creating a
// view. See RimEclipseView::onLoadDataAndUpdate() and the call to openReserviorCase()
rimResultReservoir->openReserviorCase();
// view. See RimEclipseView::onLoadDataAndUpdate() and the call to openReservoirCase()
rimResultReservoir->openReservoirCase();

analysisModels->updateConnectedEditors();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ caf::PdmScriptResponse RicfExportProperty::execute()

if ( !eclipseCase->eclipseCaseData() )
{
if ( !eclipseCase->openReserviorCase() )
if ( !eclipseCase->openReservoirCase() )
{
QString error = QString( "exportProperty: Could not find eclipseCaseData with ID %1" ).arg( m_caseId() );
RiaLogging::error( error );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ RimEclipseCaseEnsemble* RicCreateGridCaseEnsemblesFromFilesFeature::importSingle

caf::ProgressInfo progInfo( fileNames.size() + 1, "Creating Grid Ensembles" );

for ( auto caseFileName : fileNames )
for ( const auto& caseFileName : fileNames )
{
auto task = progInfo.task( "Loading files", 1 );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ QString RicSnapshotFilenameGenerator::generateSnapshotFileName( RimViewWindow* v
//--------------------------------------------------------------------------------------------------
QString RicSnapshotFilenameGenerator::generateSnapshotFilenameForRimView( Rim3dView* rimView )
{
QStringList timeSteps = rimView->ownerCase()->timeStepStrings();
QStringList timeSteps = rimView->timeStepStrings();
int timeStep = rimView->currentTimeStep();

QString fileName =
Expand Down
3 changes: 3 additions & 0 deletions ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "RimProject.h"
#include "RimRegularLegendConfig.h"
#include "RimSimWellInViewCollection.h"
#include "RimStatisticsContourMapView.h"
#include "RimSurfaceInViewCollection.h"

#include "Riu3DMainWindowTools.h"
Expand All @@ -67,6 +68,8 @@ const size_t largeSamplingThresholdCellCount = 5000000u;
//--------------------------------------------------------------------------------------------------
bool RicNewContourMapViewFeature::isCommandEnabled() const
{
if ( caf::SelectionManager::instance()->selectedItemOfType<RimStatisticsContourMapView>() != nullptr ) return false;

bool selectedView = caf::SelectionManager::instance()->selectedItemOfType<RimGridView>() != nullptr;
bool selectedCase = caf::SelectionManager::instance()->selectedItemOfType<RimCase>() != nullptr;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "RimEclipseCaseEnsemble.h"
#include "RimStatisticsContourMap.h"

#include "Riu3DMainWindowTools.h"

#include "cafSelectionManager.h"

#include <QAction>
Expand All @@ -41,6 +43,8 @@ void RicNewStatisticsContourMapFeature::addStatisticsContourMap( RimEclipseCaseE
statisticsContourMap->setEclipseCase( cases[0] );
eclipseCaseEnsemble->addStatisticsContourMap( statisticsContourMap );
eclipseCaseEnsemble->updateConnectedEditors();

Riu3DMainWindowTools::selectAsCurrentItem( statisticsContourMap );
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,36 +58,13 @@ void RicNewStatisticsContourMapViewFeature::onActionTriggered( bool isChecked )
auto contourMap = caf::SelectionManager::instance()->selectedItemOfType<RimStatisticsContourMap>();
if ( !contourMap ) return;

RimEclipseCase* eclipseCase = contourMap->eclipseCase();
if ( !eclipseCase ) return;
contourMap->ensureResultsComputed();
auto view = createAndAddView( contourMap );
contourMap->updateConnectedEditors();

if ( auto eclipseContourMap = createStatisticsContourMapView( contourMap, eclipseCase ) )
{
// Must be run before buildViewItems, as wells are created in this function
eclipseContourMap->loadDataAndUpdate();

// make sure no surfaces are shown in the view when the contourmap is generated
if ( eclipseContourMap->surfaceInViewCollection() ) eclipseContourMap->surfaceInViewCollection()->setCheckState( Qt::Unchecked );

if ( eclipseCase )
{
eclipseCase->updateConnectedEditors();
eclipseContourMap->cellFilterCollection()->setCase( eclipseCase );
}
caf::SelectionManager::instance()->setSelectedItem( eclipseContourMap );

eclipseContourMap->createDisplayModelAndRedraw();
eclipseContourMap->zoomAll();

RimProject* project = RimProject::current();

RimOilField* oilField = project->activeOilField();

oilField->eclipseContourMapCollection()->updateConnectedEditors();

Riu3DMainWindowTools::setExpanded( eclipseContourMap );
Riu3DMainWindowTools::selectAsCurrentItem( eclipseContourMap );
}
Riu3DMainWindowTools::selectAsCurrentItem( view );
Riu3DMainWindowTools::setExpanded( contourMap );
Riu3DMainWindowTools::setExpanded( view );
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -102,27 +79,55 @@ void RicNewStatisticsContourMapViewFeature::setupActionLook( QAction* actionToSe
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsContourMapView* RicNewStatisticsContourMapViewFeature::createStatisticsContourMapView( RimStatisticsContourMap* statisticsContourMap,
RimEclipseCase* eclipseCase )
RimStatisticsContourMapView* RicNewStatisticsContourMapViewFeature::createStatisticsContourMapView( RimStatisticsContourMap* statisticsContourMap )
{
RimStatisticsContourMapView* contourMap = new RimStatisticsContourMapView;
contourMap->setStatisticsContourMap( statisticsContourMap );
contourMap->setEclipseCase( eclipseCase );
RimEclipseCase* eclipseCase = statisticsContourMap->eclipseCase();
if ( !eclipseCase ) return nullptr;

caf::PdmDocument::updateUiIconStateRecursively( contourMap );
RimStatisticsContourMapView* contourMapView = new RimStatisticsContourMapView;
contourMapView->setStatisticsContourMap( statisticsContourMap );
contourMapView->setEclipseCase( eclipseCase );

size_t i = eclipseCase->contourMapCollection()->views().size();
contourMap->setName( QString( "Contour Map %1" ).arg( i + 1 ) );
caf::PdmDocument::updateUiIconStateRecursively( contourMapView );

contourMap->faultCollection()->setActive( false );
contourMap->wellCollection()->isActive = false;
contourMapView->faultCollection()->setActive( false );
contourMapView->wellCollection()->isActive = false;

eclipseCase->contourMapCollection()->addView( contourMap );
statisticsContourMap->addView( contourMapView );

auto col = RiuGuiTheme::getColorByVariableName( "backgroundColor2" );
contourMap->setBackgroundColor( RiaColorTools::fromQColorTo3f( col ) ); // Ignore original view background
contourMapView->setBackgroundColor( RiaColorTools::fromQColorTo3f( col ) ); // Ignore original view background
contourMapView->initAfterReadRecursively();

return contourMapView;
}

contourMap->initAfterReadRecursively();
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsContourMapView* RicNewStatisticsContourMapViewFeature::createAndAddView( RimStatisticsContourMap* statisticsContourMap )
{
if ( auto contourMapView = createStatisticsContourMapView( statisticsContourMap ) )
{
// Must be run before buildViewItems, as wells are created in this function
contourMapView->loadDataAndUpdate();

// make sure no surfaces are shown in the view when the contourmap is generated
if ( contourMapView->surfaceInViewCollection() ) contourMapView->surfaceInViewCollection()->setCheckState( Qt::Unchecked );

if ( auto eclipseCase = statisticsContourMap->eclipseCase() )
{
eclipseCase->updateConnectedEditors();
contourMapView->cellFilterCollection()->setCase( eclipseCase );
}

contourMapView->createDisplayModelAndRedraw();
contourMapView->zoomAll();

statisticsContourMap->updateConnectedEditors();

return contourMapView;
}

return contourMap;
return nullptr;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "cafCmdFeature.h"

class RimEclipseCase;
class RimStatisticsContourMapView;
class RimStatisticsContourMap;

Expand All @@ -31,11 +30,12 @@ class RicNewStatisticsContourMapViewFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;

static RimStatisticsContourMapView* createAndAddView( RimStatisticsContourMap* statisticsContourMap );

protected:
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;

static RimStatisticsContourMapView* createStatisticsContourMapView( RimStatisticsContourMap* statisticsContourMap,
RimEclipseCase* eclipseCase );
static RimStatisticsContourMapView* createStatisticsContourMapView( RimStatisticsContourMap* statisticsContourMap );
};
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ std::vector<RimEclipseCase*> openEclipseCasesForCellPlotting( QStringList gridFi

analysisModels->cases.push_back( rimResultReservoir );

if ( !rimResultReservoir->openReserviorCase() )
if ( !rimResultReservoir->openReservoirCase() )
{
analysisModels->removeCaseFromAllGroups( rimResultReservoir );

Expand Down
10 changes: 5 additions & 5 deletions ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclips
RigActiveCellGrid* activeGrid = new RigActiveCellGrid();
eclipseCaseData->setMainGrid( activeGrid );

caf::ProgressInfo progInfo( 5, "Importing Eclipse Grid" );
caf::ProgressInfo progInfo( 4, "Importing Eclipse Grid" );

Opm::EclIO::EGrid opmGrid( m_gridFileName );

Expand Down Expand Up @@ -119,7 +119,7 @@ bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclips
activeCellInfo->setGridCount( 1 + numLGRs );
fractureActiveCellInfo->setGridCount( 1 + numLGRs );

auto task = progInfo.task( "Getting Active Cell Information", 1 );
auto task = progInfo.task( "Getting Active Cell Information" );

for ( int lgrIdx = 0; lgrIdx < numLGRs; lgrIdx++ )
{
Expand Down Expand Up @@ -163,12 +163,12 @@ bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclips
.arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( opmGrid.totalActiveCells() ) ) )
.arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( opmGrid.totalNumberOfCells() ) ) ) );

auto task = progInfo.task( "Loading Active Cell Main Grid Geometry", 1 );
auto task = progInfo.task( "Loading Active Cell Main Grid Geometry" );
transferActiveGeometry( opmGrid, opmGrid, activeGrid, activeGrid, eclipseCaseData );

bool hasParentInfo = ( lgr_parent_names.size() >= (size_t)numLGRs );

auto task2 = progInfo.task( "Loading Active Cell LGR Grid Geometry ", 1 );
auto task2 = progInfo.task( "Loading Active Cell LGR Grid Geometry" );

for ( int lgrIdx = 0; lgrIdx < numLGRs; lgrIdx++ )
{
Expand All @@ -193,7 +193,7 @@ bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclips

if ( isNNCsEnabled() )
{
auto task = progInfo.task( "Loading NNC data", 1 );
auto task = progInfo.task( "Loading NNC data" );
transferStaticNNCData( opmGrid, lgrGrids, activeGrid );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ size_t Rim2dIntersectionView::onTimeStepCountRequested()
{
if ( isTimeStepDependentDataVisible() && ownerCase() )
{
return ownerCase()->timeStepStrings().size();
return timeStepStrings().size();
}

return 0;
Expand Down
29 changes: 17 additions & 12 deletions ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,13 @@ QString Rim3dOverlayInfoConfig::caseInfoText( RimEclipseView* eclipseView )
}

infoText += QString( "<p><b>-- Contour Map: %1 --</b><p> "
"<b>Sample Count. Total:</b> %2 <b>Valid Results:</b> %3 <br>"
"<b>Projection Type:</b> %4%5<br>" )
.arg( caseName, totCellCount, activeCellCountText, aggregationType, weightingParameterString );
"<b>Sample Count. Total:</b> %2 <b>Valid Results:</b> %3 <br>" )
.arg( caseName, totCellCount, activeCellCountText );

if ( !contourMap->contourMapProjection()->isColumnResult() )
{
infoText += QString( "<b>Projection Type:</b> %1%2<br>" ).arg( aggregationType, weightingParameterString );
}
}
else if ( eclipseView->mainGrid() )
{
Expand Down Expand Up @@ -392,9 +396,13 @@ QString Rim3dOverlayInfoConfig::caseInfoText( RimGeoMechView* geoMechView )
QString aggregationType = contourMap->contourMapProjection()->resultAggregationText();

infoText += QString( "<p><b>-- Contour Map: %1 --</b><p> "
"<b>Sample Count. Total:</b> %2 <b>Valid Results:</b> %3 <br>"
"<b>Projection Type:</b> %4<br>" )
.arg( caseName, totCellCount, activeCellCountText, aggregationType );
"<b>Sample Count. Total:</b> %2 <b>Valid Results:</b> %3 <br>" )
.arg( caseName, totCellCount, activeCellCountText );

if ( !contourMap->contourMapProjection()->isColumnResult() )
{
infoText += QString( "<b>Projection Type:</b> %1<br>" ).arg( aggregationType );
}
}
else
{
Expand Down Expand Up @@ -456,10 +464,7 @@ QString Rim3dOverlayInfoConfig::resultInfoText( const RigHistogramData& histData
{
QString propName = contourMap->contourMapProjection()->resultVariableName();
QString diffResString = eclipseView->cellResult()->additionalResultText();
if ( !contourMap->contourMapProjection()->isColumnResult() )
{
infoText += QString( "<b>Cell Property:</b> %1<br>" ).arg( propName );
}
infoText += QString( "<b>Cell Property:</b> %1<br>" ).arg( propName );
if ( !diffResString.isEmpty() )
{
infoText += QString( "%1<br>" ).arg( diffResString );
Expand Down Expand Up @@ -1048,7 +1053,7 @@ QString Rim3dOverlayInfoConfig::timeStepText( RimEclipseView* eclipseView )
QString dateString = RiaQDateTimeTools::toStringUsingApplicationLocale( timeSteps[currTimeStepIndex], dateFormat );

dateTimeString =
QString( "Time Step: %1/%2 %3" ).arg( QString::number( currTimeStepIndex ), QString::number( timeSteps.size() - 1 ), dateString );
QString( "Time Step: %1/%2 %3" ).arg( QString::number( currTimeStepIndex + 1 ), QString::number( timeSteps.size() ), dateString );
}
}

Expand All @@ -1071,7 +1076,7 @@ QString Rim3dOverlayInfoConfig::timeStepText( RimGeoMechView* geoMechView )
{
dateTimeString =
QString( "Time Step: %1/%2 %3" )
.arg( QString::number( currTimeStepIndex ), QString::number( timeSteps.size() - 1 ), timeSteps[currTimeStepIndex] );
.arg( QString::number( currTimeStepIndex + 1 ), QString::number( timeSteps.size() ), timeSteps[currTimeStepIndex] );
}

return QString( "<p><b><center>-- %1 --</center></b>" ).arg( dateTimeString ) +
Expand Down
16 changes: 14 additions & 2 deletions ApplicationLibCode/ProjectDataModel/Rim3dView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,13 +604,25 @@ size_t Rim3dView::timeStepCount()
//--------------------------------------------------------------------------------------------------
QString Rim3dView::timeStepName( int frameIdx ) const
{
if ( this->ownerCase() )
if ( ownerCase() )
{
return this->ownerCase()->timeStepName( frameIdx );
return ownerCase()->timeStepName( frameIdx );
}
return QString( "" );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList Rim3dView::timeStepStrings() const
{
if ( ownerCase() )
{
return ownerCase()->timeStepStrings();
}
return QStringList();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
13 changes: 7 additions & 6 deletions ApplicationLibCode/ProjectDataModel/Rim3dView.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,13 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface, public
void forceShowWindowOn();

// Timestep control
int currentTimeStep() const;
void setCurrentTimeStep( int frameIdx );
void setCurrentTimeStepAndUpdate( int frameIdx ) override;
bool isTimeStepDependentDataVisibleInThisOrComparisonView() const;
size_t timeStepCount();
QString timeStepName( int frameIdx ) const override;
int currentTimeStep() const;
void setCurrentTimeStep( int frameIdx );
void setCurrentTimeStepAndUpdate( int frameIdx ) override;
bool isTimeStepDependentDataVisibleInThisOrComparisonView() const;
size_t timeStepCount();
QString timeStepName( int frameIdx ) const override;
virtual QStringList timeStepStrings() const;

// Animation control
caf::Signal<> updateAnimations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void RimAdvancedSnapshotExportDefinition::getTimeStepStrings( QList<caf::PdmOpti

QStringList timeSteps;

timeSteps = view->ownerCase()->timeStepStrings();
timeSteps = view->timeStepStrings();

for ( int i = 0; i < timeSteps.size(); i++ )
{
Expand Down
Loading

0 comments on commit b999faf

Please sign in to comment.