#12609 RimWellPathAicdParameters: add field migration.

QString to std::optional<double> where applicable.
This commit is contained in:
Kristian Bendiksen
2025-08-15 18:57:35 +02:00
committed by Magne Sjaastad
parent ceb6afa719
commit 34ef2a14a3
3 changed files with 31 additions and 2 deletions
@@ -242,3 +242,31 @@ bool RimWellPathAicdParameters::isMetric() const
}
return metric;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathAicdParameters::migrateFieldContent( QString& fieldContent, caf::PdmFieldHandle* fieldHandle )
{
// Optional fields changed from QString to std::optional<double> in first release after v2025.04.4.
// These fields used to have "1*" as default/empty value, but these are now converted to empty string.
// Empty strings becomes an unset std::optional<double> in the xml parsing.
// Check if the incoming field matches the new type.
const caf::PdmField<std::optional<double>>* optionalField = dynamic_cast<const caf::PdmField<std::optional<double>>*>( fieldHandle );
if ( !optionalField ) return;
// Check if fieldContent is "1*" - if not, nothing to do.
if ( fieldContent != "1*" ) return;
// Find matching field in the array
for ( const auto& field : m_aicdParameterFields )
{
if ( &field == optionalField )
{
// Found the matching field, clear the fieldContent
fieldContent = QString();
return;
}
}
}
@@ -61,6 +61,7 @@ public:
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void migrateFieldContent( QString& fieldContent, caf::PdmFieldHandle* fieldHandle ) override;
private:
std::set<const caf::PdmField<std::optional<double>>*> optionalFieldsWithNoValidDefault() const;
@@ -37,8 +37,8 @@ perforation = well_path.append_perforation_interval(3300, 3350, 0.2, 0.76)
valve_templates = resinsight.project.valve_templates()
aicd_template = valve_templates.valve_definitions()[0]
aicd_parameters = aicd_template.aicd_parameters()
aicd_parameters.max_flow_rate = "899.43"
aicd_parameters.density_calibration_fluid = "45.5"
aicd_parameters.max_flow_rate = 899.43
aicd_parameters.density_calibration_fluid = 45.5
aicd_parameters.update()
# Add a valve to the perforation interval