Skip to content

Commit

Permalink
Add Statistics Contour Map for eclipse grid ensembles.
Browse files Browse the repository at this point in the history
  • Loading branch information
kriben committed Dec 10, 2024
1 parent feba066 commit a9f902e
Show file tree
Hide file tree
Showing 25 changed files with 1,232 additions and 28 deletions.
2 changes: 2 additions & 0 deletions ApplicationLibCode/Commands/CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewCustomVfpPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewWellTargetCandidatesGeneratorFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewStatisticsContourMapFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewStatisticsContourMapViewFeature.h
)

set(SOURCE_GROUP_SOURCE_FILES
Expand Down Expand Up @@ -200,6 +201,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewCustomVfpPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewWellTargetCandidatesGeneratorFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewStatisticsContourMapFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewStatisticsContourMapViewFeature.cpp
)

if(RESINSIGHT_USE_QT_CHARTS)
Expand Down
128 changes: 128 additions & 0 deletions ApplicationLibCode/Commands/RicNewStatisticsContourMapViewFeature.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////

#include "RicNewStatisticsContourMapViewFeature.h"

#include "RimCellFilterCollection.h"
#include "RimEclipseCase.h"
#include "RimEclipseContourMapViewCollection.h"
#include "RimFaultInViewCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSimWellInViewCollection.h"
#include "RimStatisticsContourMap.h"
#include "RimStatisticsContourMapView.h"
#include "RimSurfaceInViewCollection.h"

#include "Riu3DMainWindowTools.h"
#include "RiuGuiTheme.h"

#include "RiaColorTools.h"

#include "cafPdmDocument.h"
#include "cafSelectionManager.h"

#include <QAction>

CAF_CMD_SOURCE_INIT( RicNewStatisticsContourMapViewFeature, "RicNewStatisticsContourMapViewFeature" );

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewStatisticsContourMapViewFeature::isCommandEnabled() const
{
auto contourMap = caf::SelectionManager::instance()->selectedItemOfType<RimStatisticsContourMap>();
return contourMap != nullptr;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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 );
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewStatisticsContourMapViewFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Create View" );
actionToSetup->setIcon( QIcon( ":/2DMap16x16.png" ) );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsContourMapView* RicNewStatisticsContourMapViewFeature::createStatisticsContourMapView( RimStatisticsContourMap* statisticsContourMap,
RimEclipseCase* eclipseCase )
{
RimStatisticsContourMapView* contourMap = new RimStatisticsContourMapView;
contourMap->setStatisticsContourMap( statisticsContourMap );
contourMap->setEclipseCase( eclipseCase );

caf::PdmDocument::updateUiIconStateRecursively( contourMap );

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

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

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

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

contourMap->initAfterReadRecursively();

return contourMap;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////

#pragma once

#include "cafCmdFeature.h"

class RimEclipseCase;
class RimStatisticsContourMapView;
class RimStatisticsContourMap;

//==================================================================================================
///
//==================================================================================================
class RicNewStatisticsContourMapViewFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;

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

static RimStatisticsContourMapView* createStatisticsContourMapView( RimStatisticsContourMap* statisticsContourMap,
RimEclipseCase* eclipseCase );
};
4 changes: 4 additions & 0 deletions ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimCameraPosition.h
${CMAKE_CURRENT_LIST_DIR}/RimWellTargetCandidatesGenerator.h
${CMAKE_CURRENT_LIST_DIR}/RimStatisticsContourMap.h
${CMAKE_CURRENT_LIST_DIR}/RimStatisticsContourMapProjection.h
${CMAKE_CURRENT_LIST_DIR}/RimStatisticsContourMapView.h
)

set(SOURCE_GROUP_SOURCE_FILES
Expand Down Expand Up @@ -270,6 +272,8 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimCameraPosition.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellTargetCandidatesGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RimStatisticsContourMap.cpp
${CMAKE_CURRENT_LIST_DIR}/RimStatisticsContourMapProjection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimStatisticsContourMapView.cpp
)

if(RESINSIGHT_USE_QT_CHARTS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,36 @@ QString RimGeoMechContourMapProjection::resultDescriptionText() const
return resultText;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimGeoMechContourMapProjection::resultVariableName() const
{
if ( auto v = view() )
{
if ( auto c = v->cellResult() )
{
return c->resultFieldUiName();
}
}

return "";
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimRegularLegendConfig* RimGeoMechContourMapProjection::legendConfig() const
{
return view()->cellResult()->legendConfig();
if ( auto v = view() )
{
if ( auto c = v->cellResult() )
{
return c->legendConfig();
}
}

return nullptr;
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class RimGeoMechContourMapProjection : public RimContourMapProjection
~RimGeoMechContourMapProjection() override;

// GeoMech case overrides for contour map methods
QString resultVariableName() const override;
QString resultDescriptionText() const override;
RimRegularLegendConfig* legendConfig() const override;
void updateLegend() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,17 @@ QString Rim3dOverlayInfoConfig::caseInfoText( RimEclipseView* eclipseView )
RimEclipseContourMapView* contourMap = dynamic_cast<RimEclipseContourMapView*>( eclipseView );
if ( contourMap && contourMap->contourMapProjection() && contourMap->contourMapProjection()->mapProjection() )
{
RimEclipseContourMapProjection* eclipseProjection =
dynamic_cast<RimEclipseContourMapProjection*>( contourMap->contourMapProjection() );
QString totCellCount =
localeWithSpaceAsGroupSeparator.toString( contourMap->contourMapProjection()->mapProjection()->numberOfCells() );
cvf::uint validCellCount = contourMap->contourMapProjection()->mapProjection()->numberOfValidCells();
QString activeCellCountText = localeWithSpaceAsGroupSeparator.toString( validCellCount );
QString aggregationType = contourMap->contourMapProjection()->resultAggregationText();
QString weightingParameterString;
if ( contourMap->contourMapProjection()->weightingParameter() != "None" )
if ( eclipseProjection && eclipseProjection->weightingParameter() != "None" )
{
weightingParameterString += QString( " (Weight: %1)" ).arg( contourMap->contourMapProjection()->weightingParameter() );
weightingParameterString += QString( " (Weight: %1)" ).arg( eclipseProjection->weightingParameter() );
}

infoText += QString( "<p><b>-- Contour Map: %1 --</b><p> "
Expand Down Expand Up @@ -452,7 +454,7 @@ QString Rim3dOverlayInfoConfig::resultInfoText( const RigHistogramData& histData
bool isResultsInfoRelevant = contourMap->contourMapProjection()->mapProjection()->numberOfValidCells() > 0u;
if ( isResultsInfoRelevant )
{
QString propName = eclipseView->cellResult()->resultVariableUiShortName();
QString propName = contourMap->contourMapProjection()->resultVariableName();
QString diffResString = eclipseView->cellResult()->additionalResultText();
if ( !contourMap->contourMapProjection()->isColumnResult() )
{
Expand Down
9 changes: 5 additions & 4 deletions ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,22 @@ class RimContourMapProjection : public RimCheckableNamedObject
bool showContourLines() const;
bool showContourLabels() const;

QString resultAggregationText() const;
virtual QString resultAggregationText() const;

QString caseName() const;
QString currentTimeStepName() const;

bool isColumnResult() const;
bool isMeanResult() const;
bool isStraightSummationResult() const;
virtual bool isColumnResult() const;
bool isMeanResult() const;
bool isStraightSummationResult() const;

void setPickPoint( cvf::Vec2d globalPickPoint );
cvf::Vec2d pickPoint() const;

cvf::Vec3d origin3d() const;

// Pure-virtual public methods which should be overridden by Eclipse and Geo-mechanical contour map implementations
virtual QString resultVariableName() const = 0;
virtual QString resultDescriptionText() const = 0;
virtual RimRegularLegendConfig* legendConfig() const = 0;
virtual void updateLegend() = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ QString RimEclipseContourMapProjection::resultDescriptionText() const
return resultText;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimEclipseContourMapProjection::resultVariableName() const
{
if ( !isColumnResult() ) return view()->cellResult()->resultVariable();
return resultAggregationText();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class RimEclipseContourMapProjection : public RimContourMapProjection
void clearGridMappingAndRedraw();

// Eclipse case overrides for contour map methods
QString resultVariableName() const override;
QString resultDescriptionText() const override;
RimRegularLegendConfig* legendConfig() const override;
void updateLegend() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ RimEclipseContourMapView::RimEclipseContourMapView()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseContourMapProjection* RimEclipseContourMapView::contourMapProjection() const
RimContourMapProjection* RimEclipseContourMapView::contourMapProjection() const
{
return m_contourMapProjection().p();
}
Expand Down
11 changes: 5 additions & 6 deletions ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ class RimRegularLegendConfig;
class RimViewNameConfig;
class RimScaleLegendConfig;
class RivContourMapProjectionPartMgr;
class RimContourMapProjection;

class RimEclipseContourMapView : public RimEclipseView
{
CAF_PDM_HEADER_INIT;

public:
RimEclipseContourMapView();
RimEclipseContourMapProjection* contourMapProjection() const;
RimContourMapProjection* contourMapProjection() const;

RiaDefines::View3dContent viewContent() const override;

Expand Down Expand Up @@ -83,14 +84,12 @@ class RimEclipseContourMapView : public RimEclipseView

void onLegendConfigChanged( const caf::SignalEmitter* emitter, RimLegendConfigChangeType changeType );

private:
cvf::ref<RivContourMapProjectionPartMgr> m_contourMapProjectionPartMgr;
caf::PdmChildField<RimContourMapProjection*> m_contourMapProjection;

bool isFaultLinesVisible() const;
void setFaultLinesVisible( const bool& visible );

private:
cvf::ref<RivContourMapProjectionPartMgr> m_contourMapProjectionPartMgr;
caf::PdmChildField<RimEclipseContourMapProjection*> m_contourMapProjection;

caf::PdmProxyValueField<bool> m_showFaultLines;
caf::PdmField<bool> m_showAxisLines;
caf::PdmField<bool> m_showScaleLegend;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ void RimEclipseResultDefinition::fieldChangedByUi( const caf::PdmFieldHandle* ch

if ( contourMapView )
{
contourMapView->contourMapProjection()->clearGridMappingAndRedraw();
if ( auto projection = dynamic_cast<RimEclipseContourMapProjection*>( contourMapView->contourMapProjection() ) )
projection->clearGridMappingAndRedraw();
}

loadDataAndUpdate();
Expand All @@ -336,7 +337,8 @@ void RimEclipseResultDefinition::fieldChangedByUi( const caf::PdmFieldHandle* ch
{
if ( contourMapView )
{
contourMapView->contourMapProjection()->clearGridMappingAndRedraw();
if ( auto projection = dynamic_cast<RimEclipseContourMapProjection*>( contourMapView->contourMapProjection() ) )
projection->clearGridMappingAndRedraw();
}

loadDataAndUpdate();
Expand Down
Loading

0 comments on commit a9f902e

Please sign in to comment.