diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCellColors.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCellColors.cpp index 4219273eea..d03d6fde4e 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCellColors.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCellColors.cpp @@ -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 ); diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.cpp index ae773d48ad..8c1265f002 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.cpp @@ -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,11 +543,19 @@ void RimGeoMechResultDefinition::initAfterRead() { if ( m_resultComponentName() == "STM" || m_resultComponentName() == "SEM" ) m_resultComponentName = "SM"; + updateUiFieldsFromActiveResult(); + + m_timeLapseBaseTimestep.uiCapability()->setUiReadOnly( resultPositionType() == RIG_WELLPATH_DERIVED ); +} + +//-------------------------------------------------------------------------------------------------- +/// 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; - - m_timeLapseBaseTimestep.uiCapability()->setUiReadOnly( resultPositionType() == RIG_WELLPATH_DERIVED ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.h b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.h index 3398acdb0e..32049898e9 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.h +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.h @@ -55,6 +55,7 @@ class RimGeoMechResultDefinition : public RimFemResultObserver, public RimChecka RigGeoMechCaseData* ownerCaseData() const; bool hasResult(); void loadResult(); + void updateUiFieldsFromActiveResult(); void setAddWellPathDerivedResults( bool addWellPathDerivedResults ); RigFemResultAddress resultAddress() const; diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp index 2ae4152e94..cd28f6186c 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp @@ -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" ); diff --git a/GrpcInterface/Python/rips/view.py b/GrpcInterface/Python/rips/view.py index 29c812671a..76b5709097 100644 --- a/GrpcInterface/Python/rips/view.py +++ b/GrpcInterface/Python/rips/view.py @@ -202,6 +202,10 @@ def extract_address(address) -> int: @add_method(View) def case(self): """Get the case the view belongs to""" + # Geomechanical views are children of their case + if not hasattr(self, "eclipse_case"): + return self.ancestor(rips.case.Case) + project = self.ancestor(rips.project.Project) eclipse_case_addr = extract_address(self.eclipse_case) diff --git a/GrpcInterface/RiaGrpcPdmObjectService.cpp b/GrpcInterface/RiaGrpcPdmObjectService.cpp index d32257a100..55fae4a709 100644 --- a/GrpcInterface/RiaGrpcPdmObjectService.cpp +++ b/GrpcInterface/RiaGrpcPdmObjectService.cpp @@ -25,6 +25,7 @@ #include "RiaOpenTelemetryManager.h" #include "RimEclipseResultDefinition.h" +#include "RimGeoMechResultDefinition.h" #include "RimProject.h" #include "cafPdmAbstractFieldScriptingCapability.h" @@ -458,6 +459,11 @@ grpc::Status RiaGrpcPdmObjectService::UpdateExistingPdmObject( grpc::ServerConte resultDefinition->updateUiFieldsFromActiveResult(); resultDefinition->loadResult(); } + if ( auto geoMechResultDefinition = dynamic_cast( matchingObject ) ) + { + geoMechResultDefinition->updateUiFieldsFromActiveResult(); + geoMechResultDefinition->loadResult(); + } matchingObject->updateAllRequiredEditors(); RimProject::current()->scheduleCreateDisplayModelAndRedrawAllViews();