mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 22:50:25 -05:00
#14001 Python: Use AppEnum fields for property_data_type arguments
Replace QString + setFromText parsing with typed caf::PdmField<caf::AppEnum<...>> for m_propertyType and m_porosityModel on RimcEclipseCase_propertyDataType. The script keywords stay "PropertyType" / "PorosityModel" so the Python parameter names are unchanged (property_type, porosity_model), and the auto-generated StrEnum classes are now PropertyType and PorosityModelType (typed annotations on the call site). Register caf::AppEnum<RiaDefines::PorosityModelType> -> "PorosityModelType" alongside the existing ResultCatType override so PorosityModelType's auto-generated class name is stable regardless of which field the generator visits first. executeEnum() drops the setFromText parsing and the "Invalid property type / porosity model" branches — the values now flow through typed already, so an invalid enum text cannot reach the method body.
This commit is contained in:
1 parent
01ceb57323
commit
e21a32a180
3 files changed
+20
-23
No files matched your search
@@ -420,7 +420,10 @@ RimcEclipseCase_propertyDataType::RimcEclipseCase_propertyDataType( caf::PdmObje
|
||||
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_propertyType, "PropertyType", "" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_propertyName, "PropertyName", "" );
|
||||
CAF_PDM_InitScriptableField( &m_porosityModel, "PorosityModel", QString( "MATRIX_MODEL" ), "" );
|
||||
CAF_PDM_InitScriptableField( &m_porosityModel,
|
||||
"PorosityModel",
|
||||
caf::AppEnum<RiaDefines::PorosityModelType>( RiaDefines::PorosityModelType::MATRIX_MODEL ),
|
||||
"" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -431,19 +434,7 @@ std::expected<RiaDefines::ResultDataType, QString> RimcEclipseCase_propertyDataT
|
||||
auto eclipseCase = self<RimEclipseCase>();
|
||||
if ( !eclipseCase ) return std::unexpected( "No eclipse case" );
|
||||
|
||||
caf::AppEnum<RiaDefines::ResultCatType> resultCatTypeEnum;
|
||||
if ( !resultCatTypeEnum.setFromText( m_propertyType ) )
|
||||
{
|
||||
return std::unexpected( "Invalid property type." );
|
||||
}
|
||||
|
||||
caf::AppEnum<RiaDefines::PorosityModelType> porosityModel;
|
||||
if ( !porosityModel.setFromText( m_porosityModel ) )
|
||||
{
|
||||
return std::unexpected( "Invalid porosity model." );
|
||||
}
|
||||
|
||||
auto resultsData = eclipseCase->results( porosityModel );
|
||||
auto resultsData = eclipseCase->results( m_porosityModel() );
|
||||
if ( !resultsData )
|
||||
{
|
||||
return std::unexpected( "Eclipse case has no result data." );
|
||||
@@ -451,7 +442,7 @@ std::expected<RiaDefines::ResultDataType, QString> RimcEclipseCase_propertyDataT
|
||||
|
||||
for ( const auto& address : resultsData->existingResults() )
|
||||
{
|
||||
if ( address.resultCatType() == resultCatTypeEnum && address.resultName() == m_propertyName() )
|
||||
if ( address.resultCatType() == m_propertyType() && address.resultName() == m_propertyName() )
|
||||
{
|
||||
return address.dataType();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user