Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjenssen committed Dec 12, 2024
1 parent 9254037 commit c5b55d3
Show file tree
Hide file tree
Showing 9 changed files with 545 additions and 485 deletions.
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 @@ -58,36 +58,7 @@ void RicNewStatisticsContourMapViewFeature::onActionTriggered( bool isChecked )
auto contourMap = caf::SelectionManager::instance()->selectedItemOfType<RimStatisticsContourMap>();
if ( !contourMap ) return;

RimEclipseCase* eclipseCase = contourMap->eclipseCase();
if ( !eclipseCase ) return;

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 );
}
createAndAddView( contourMap );
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -102,9 +73,11 @@ void RicNewStatisticsContourMapViewFeature::setupActionLook( QAction* actionToSe
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsContourMapView* RicNewStatisticsContourMapViewFeature::createStatisticsContourMapView( RimStatisticsContourMap* statisticsContourMap,
RimEclipseCase* eclipseCase )
RimStatisticsContourMapView* RicNewStatisticsContourMapViewFeature::createStatisticsContourMapView( RimStatisticsContourMap* statisticsContourMap )
{
RimEclipseCase* eclipseCase = statisticsContourMap->eclipseCase();
if ( !eclipseCase ) return nullptr;

RimStatisticsContourMapView* contourMap = new RimStatisticsContourMapView;
contourMap->setStatisticsContourMap( statisticsContourMap );
contourMap->setEclipseCase( eclipseCase );
Expand All @@ -126,3 +99,41 @@ RimStatisticsContourMapView* RicNewStatisticsContourMapViewFeature::createStatis

return contourMap;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsContourMapView* RicNewStatisticsContourMapViewFeature::createAndAddView( RimStatisticsContourMap* statisticsContourMap )
{
if ( auto eclipseContourMap = createStatisticsContourMapView( statisticsContourMap ) )
{
// 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 ( auto eclipseCase = statisticsContourMap->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 );

return eclipseContourMap;
}

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 @@ -201,4 +201,5 @@ void RimEclipseCaseEnsemble::addWellTargetsGenerator( RimWellTargetCandidatesGen
void RimEclipseCaseEnsemble::addStatisticsContourMap( RimStatisticsContourMap* statisticsContourMap )
{
m_statisticsContourMaps.push_back( statisticsContourMap );
statisticsContourMap->setName( QString( "Statisics Contour Map #%1" ).arg( m_statisticsContourMaps.size() ) );
}
15 changes: 8 additions & 7 deletions ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "Rim3dView.h"
#include "RimCase.h"
#include "RimCellEdgeColors.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RimFaultInViewCollection.h"
Expand Down Expand Up @@ -92,13 +93,6 @@ RimEclipseView* RimEclipseViewCollection::addView( RimEclipseCase* eclipseCase )

view->setEclipseCase( eclipseCase );

// Set default values
if ( view->currentGridCellResults() )
{
auto defaultResult = view->currentGridCellResults()->defaultResult();
view->cellResult()->setFromEclipseResultAddress( defaultResult );
}

auto prefs = RiaPreferences::current();
view->faultCollection()->setActive( prefs->enableFaultsByDefault() );

Expand All @@ -114,6 +108,13 @@ RimEclipseView* RimEclipseViewCollection::addView( RimEclipseCase* eclipseCase )

view->loadDataAndUpdate();

// Set default values
if ( view->currentGridCellResults() )
{
auto defaultResult = view->currentGridCellResults()->defaultResult();
view->cellResult()->setFromEclipseResultAddress( defaultResult );
}

updateConnectedEditors();

return view;
Expand Down
32 changes: 27 additions & 5 deletions ApplicationLibCode/ProjectDataModel/RimStatisticsContourMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "RiaLogging.h"
#include "RiaStatisticsTools.h"

#include "RicNewStatisticsContourMapViewFeature.h"

#include "RigCaseCellResultsData.h"
#include "RigContourMapCalculator.h"
#include "RigContourMapGrid.h"
Expand Down Expand Up @@ -66,7 +68,10 @@ void caf::AppEnum<RimStatisticsContourMap::StatisticsType>::setUp()
//--------------------------------------------------------------------------------------------------
RimStatisticsContourMap::RimStatisticsContourMap()
{
CAF_PDM_InitObject( "StatisticsContourMap", ":/Histogram16x16.png" );
CAF_PDM_InitObject( "Statistics Contour Map", ":/Histogram16x16.png" );

CAF_PDM_InitField( &m_boundingBoxExpPercent, "BoundingBoxExpPercent", 5.0, "Bounding Box Expansion (%)" );
m_boundingBoxExpPercent.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );

CAF_PDM_InitField( &m_relativeSampleSpacing, "SampleSpacing", 0.9, "Sample Spacing Factor" );
m_relativeSampleSpacing.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
Expand All @@ -85,16 +90,20 @@ RimStatisticsContourMap::RimStatisticsContourMap()
CAF_PDM_InitFieldNoDefault( &m_computeStatisticsButton, "ComputeStatisticsButton", "" );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_computeStatisticsButton );
m_computeStatisticsButton = false;

setDeletable( true );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsContourMap::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_relativeSampleSpacing );
uiOrdering.add( nameField() );
uiOrdering.add( &m_resultAggregation );
uiOrdering.add( &m_timeStep );
uiOrdering.add( &m_relativeSampleSpacing );
uiOrdering.add( &m_boundingBoxExpPercent );

caf::PdmUiGroup* resultDefinitionGroup = uiOrdering.addNewGroup( "Result Definition" );
m_resultDefinition->uiOrdering( uiConfigName, *resultDefinitionGroup );
Expand Down Expand Up @@ -162,8 +171,7 @@ void RimStatisticsContourMap::defineEditorAttribute( const caf::PdmFieldHandle*
attrib->m_buttonText = "Compute";
}
}

if ( &m_relativeSampleSpacing == field )
else if ( &m_relativeSampleSpacing == field )
{
if ( auto myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute ) )
{
Expand All @@ -173,6 +181,15 @@ void RimStatisticsContourMap::defineEditorAttribute( const caf::PdmFieldHandle*
myAttr->m_delaySliderUpdateUntilRelease = true;
}
}
else if ( &m_boundingBoxExpPercent == field )
{
if ( auto myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute ) )
{
myAttr->m_minimum = 0.0;
myAttr->m_maximum = 25.0;
myAttr->m_delaySliderUpdateUntilRelease = true;
}
}
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -205,6 +222,7 @@ void RimStatisticsContourMap::computeStatistics()
RigContourMapCalculator::ResultAggregationType resultAggregation = m_resultAggregation();

cvf::BoundingBox gridBoundingBox = firstEclipseCase->activeCellsBoundingBox();
gridBoundingBox.expandPercent( m_boundingBoxExpPercent() );

auto computeSampleSpacing = []( auto ec, double relativeSampleSpacing )
{
Expand All @@ -215,7 +233,6 @@ void RimStatisticsContourMap::computeStatistics()
return relativeSampleSpacing * mainGrid->characteristicIJCellSize();
}
}

return 0.0;
};

Expand All @@ -229,6 +246,8 @@ void RimStatisticsContourMap::computeStatistics()
RigEclipseContourMapProjection contourMapProjection( *contourMapGrid, *firstEclipseCaseData, *firstResultData );
m_gridMapping = contourMapProjection.generateGridMapping( resultAggregation, {} );

caf::ProgressInfo progInfo( ensemble->cases().size() + 1, "Reading Eclipse Ensemble" );

std::vector<std::vector<double>> results;
for ( RimEclipseCase* eclipseCase : ensemble->cases() )
{
Expand All @@ -246,6 +265,7 @@ void RimStatisticsContourMap::computeStatistics()
contourMapProjection.generateResults( m_resultDefinition()->eclipseResultAddress(), resultAggregation, m_timeStep() );
results.push_back( result );
}
progInfo.incrementProgress();
}

if ( !results.empty() )
Expand Down Expand Up @@ -292,6 +312,8 @@ void RimStatisticsContourMap::computeStatistics()
m_result[StatisticsType::MEAN] = meanResults;
m_result[StatisticsType::MIN] = minResults;
m_result[StatisticsType::MAX] = maxResults;

RicNewStatisticsContourMapViewFeature::createAndAddView( this );
}
}

Expand Down
5 changes: 3 additions & 2 deletions ApplicationLibCode/ProjectDataModel/RimStatisticsContourMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

#pragma once

#include "RimNamedObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"

#include "RimContourMapProjection.h"

Expand All @@ -34,7 +34,7 @@ class RimEclipseCaseEnsemble;
//
//
//==================================================================================================
class RimStatisticsContourMap : public caf::PdmObject
class RimStatisticsContourMap : public RimNamedObject
{
CAF_PDM_HEADER_INIT;

Expand Down Expand Up @@ -82,6 +82,7 @@ class RimStatisticsContourMap : public caf::PdmObject
caf::PdmField<double> m_relativeSampleSpacing;
caf::PdmField<RimContourMapProjection::ResultAggregation> m_resultAggregation;
caf::PdmField<int> m_timeStep;
caf::PdmField<double> m_boundingBoxExpPercent;

caf::PdmChildField<RimEclipseResultDefinition*> m_resultDefinition;
caf::PdmField<bool> m_computeStatisticsButton;
Expand Down
Loading

0 comments on commit c5b55d3

Please sign in to comment.