Scripting: geomechanical cell result (replaces #14952)

Make RimGeoMechResultDefinition (position, field and component) and the view's cell result scriptable, as for grid views.
This commit is contained in:
Magne Sjaastad authored and GitHub committed 2026-10-21 06:49:14 +02:00
1 parent 914cab9084
commit 848c2394bb
10 files changed
+94 -14

No files matched your search

@@ -24,6 +24,8 @@
#include "RimViewController.h"
#include "RimViewLinker.h"
#include "cafPdmObjectScriptingCapability.h"
CAF_PDM_SOURCE_INIT( RimGeoMechCellColors, "GeoMechResultSlot" );
//--------------------------------------------------------------------------------------------------
@@ -32,6 +34,8 @@ CAF_PDM_SOURCE_INIT( RimGeoMechCellColors, "GeoMechResultSlot" );
RimGeoMechCellColors::RimGeoMechCellColors()
: legendConfigChanged( this )
{
CAF_PDM_InitScriptableObjectWithNameAndComment( "Color Result", ":/CellResult.png", "", "", "GeoMechCellColors", "Geomechanical cell colors" );
CAF_PDM_InitFieldNoDefault( &legendConfig, "LegendDefinition", "Color Legend" );
legendConfig = new RimRegularLegendConfig();
legendConfig->changed.connect( this, &RimGeoMechCellColors::onLegendConfigChanged );
@@ -48,6 +48,8 @@
#include "RimViewLinker.h"
#include "RimWellPath.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiDoubleValueEditor.h"
#include "cafPdmUiTreeSelectionEditor.h"
@@ -77,15 +79,15 @@ CAF_PDM_SOURCE_INIT( RimGeoMechResultDefinition, "GeoMechResultDefinition" );
//--------------------------------------------------------------------------------------------------
RimGeoMechResultDefinition::RimGeoMechResultDefinition()
{
CAF_PDM_InitObject( "Color Result", ":/CellResult.png" );
CAF_PDM_InitScriptableObjectWithNameAndComment( "Color Result", ":/CellResult.png", "", "", "GeoMechResult", "A geomechanical result definition" );
CAF_PDM_InitFieldNoDefault( &m_resultPositionType, "ResultPositionType", "Result Position" );
CAF_PDM_InitScriptableFieldNoDefault( &m_resultPositionType, "ResultPositionType", "Result Position" );
m_resultPositionType.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_resultFieldName, "ResultFieldName", QString( "" ), "Field Name" );
CAF_PDM_InitScriptableField( &m_resultFieldName, "ResultFieldName", QString( "" ), "Field Name" );
m_resultFieldName.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_resultComponentName, "ResultComponentName", QString( "" ), "Component" );
CAF_PDM_InitScriptableField( &m_resultComponentName, "ResultComponentName", QString( "" ), "Component" );
m_resultComponentName.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_timeLapseBaseTimestep, "TimeLapseBaseTimeStep", RigFemResultAddress::noTimeLapseValue(), "Base Time Step" );
@@ -541,6 +543,14 @@ void RimGeoMechResultDefinition::initAfterRead()
{
if ( m_resultComponentName() == "STM" || m_resultComponentName() == "SEM" ) m_resultComponentName = "SM";
updateUiFieldsFromActiveResult();
}
//--------------------------------------------------------------------------------------------------
/// Sync the UI fields after the result fields are set directly, e.g. from scripting
//--------------------------------------------------------------------------------------------------
void RimGeoMechResultDefinition::updateUiFieldsFromActiveResult()
{
m_resultPositionTypeUiField = m_resultPositionType;
m_resultVariableUiField = composeFieldCompString( m_resultFieldName(), m_resultComponentName() );
m_compactionRefLayerUiField = m_compactionRefLayer;
@@ -22,6 +22,7 @@
#include "RimCheckableObject.h"
#include "RimFemResultObserver.h"
#include "RimResultDefinitionInterface.h"
#include "RigFemResultPosEnum.h"
@@ -41,7 +42,7 @@ class RimRegularLegendConfig;
///
///
//==================================================================================================
class RimGeoMechResultDefinition : public RimFemResultObserver, public RimCheckableObject
class RimGeoMechResultDefinition : public RimFemResultObserver, public RimCheckableObject, public RimResultDefinitionInterface
{
CAF_PDM_HEADER_INIT;
@@ -54,7 +55,8 @@ public:
RigGeoMechCaseData* ownerCaseData() const;
bool hasResult();
void loadResult();
void loadResult() override;
void updateUiFieldsFromActiveResult() override;
void setAddWellPathDerivedResults( bool addWellPathDerivedResults );
RigFemResultAddress resultAddress() const;
@@ -76,6 +76,7 @@
#include "cafDisplayCoordTransform.h"
#include "cafFrameAnimationControl.h"
#include "cafOverlayScalarMapperLegend.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafProgressInfo.h"
@@ -96,7 +97,7 @@ RimGeoMechView::RimGeoMechView()
{
CAF_PDM_InitScriptableObject( "Geomechanical View", ":/3DViewGeoMech16x16.png", "", "The Geomechanical 3d View" );
CAF_PDM_InitFieldNoDefault( &cellResult, "GridCellResult", "Color Result", ":/CellResult.png" );
CAF_PDM_InitScriptableFieldWithScriptKeywordNoDefault( &cellResult, "GridCellResult", "CellResult", "Color Result", ":/CellResult.png" );
cellResult = new RimGeoMechCellColors();
CAF_PDM_InitFieldNoDefault( &m_tensorResults, "TensorResults", "Tensor Results" );
@@ -27,6 +27,7 @@
#include "RimCheckableObject.h"
#include "RimFlowDiagSolution.h"
#include "RimResultDefinitionInterface.h"
#include "cafAppEnum.h"
#include "cafPdmField.h"
@@ -49,7 +50,7 @@ class RigEclipseResultAddress;
///
///
//==================================================================================================
class RimEclipseResultDefinition : public RimCheckableObject
class RimEclipseResultDefinition : public RimCheckableObject, public RimResultDefinitionInterface
{
CAF_PDM_HEADER_INIT;
@@ -102,7 +103,7 @@ public:
int caseDiffIndex() const;
QString additionalResultText() const;
virtual void loadResult();
void loadResult() override;
void setEagerResultLoadingEnabled( bool enabled );
RigEclipseResultAddress eclipseResultAddress() const;
void setFromEclipseResultAddress( const RigEclipseResultAddress& resultAddress );
@@ -125,7 +126,7 @@ public:
void setSelectedProducerTracers( const std::vector<QString>& selectedTracers );
void setSelectedSouringTracers( const std::vector<QString>& selectedTracers );
void updateUiFieldsFromActiveResult();
void updateUiFieldsFromActiveResult() override;
bool showDualPorosityLabel() const;
@@ -0,0 +1,33 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2026- 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
//==================================================================================================
// Interface implemented by result definitions (e.g. RimEclipseResultDefinition and
// RimGeoMechResultDefinition) that can be updated after their active result has been changed
// programmatically, e.g. from the scripting/gRPC interface.
//==================================================================================================
class RimResultDefinitionInterface
{
public:
virtual ~RimResultDefinitionInterface() = default;
virtual void updateUiFieldsFromActiveResult() = 0;
virtual void loadResult() = 0;
};