mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 05:37:21 -05:00
#12609 RimWellPathAicdParameters: add field migration.
QString to std::optional<double> where applicable.
This commit is contained in:
committed by
Magne Sjaastad
parent
ceb6afa719
commit
34ef2a14a3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user