Change API for PdmObjectHandle and PdmFieldHandle

* Refactor interface to PdmObjectHandle and PdmFieldHandle
Return objects instead of passing in structures as parameters

* Add nodiscard to several functions
* Remove redundant this->
* Rename to ptrReferencedObjectsByType
This commit is contained in:
Magne Sjaastad
2023-05-12 21:41:34 +02:00
committed by GitHub
parent 37e29a0f68
commit 0c90f67dcc
510 changed files with 1651 additions and 3111 deletions

View File

@@ -231,8 +231,7 @@ void RimElasticProperties::loadDataAndUpdate()
{
if ( !m_filePath().path().isEmpty() )
{
RimStimPlanModelTemplate* stimPlanModelTemplate;
firstAncestorOrThisOfType( stimPlanModelTemplate );
auto stimPlanModelTemplate = firstAncestorOrThisOfType<RimStimPlanModelTemplate>();
RicElasticPropertiesImportTools::importElasticPropertiesFromFile( m_filePath().path(), stimPlanModelTemplate );
}
}

View File

@@ -148,8 +148,7 @@ void RimElasticPropertyScaling::updateAutoName()
//--------------------------------------------------------------------------------------------------
RimColorLegend* RimElasticPropertyScaling::getFaciesColorLegend()
{
RimStimPlanModelTemplate* stimPlanModelTemplate;
firstAncestorOrThisOfType( stimPlanModelTemplate );
auto stimPlanModelTemplate = firstAncestorOrThisOfType<RimStimPlanModelTemplate>();
if ( !stimPlanModelTemplate ) return nullptr;
RimFaciesProperties* faciesProperties = stimPlanModelTemplate->faciesProperties();

View File

@@ -197,8 +197,7 @@ void RimFaciesProperties::loadDataAndUpdate()
{
if ( !m_filePath().path().isEmpty() )
{
RimStimPlanModelTemplate* stimPlanModelTemplate;
firstAncestorOrThisOfType( stimPlanModelTemplate );
auto stimPlanModelTemplate = firstAncestorOrThisOfType<RimStimPlanModelTemplate>();
RicFaciesPropertiesImportTools::importFaciesPropertiesFromFile( m_filePath().path(), stimPlanModelTemplate );
}
}

View File

@@ -156,8 +156,7 @@ const QString& RimNonNetLayers::facies() const
//--------------------------------------------------------------------------------------------------
RimColorLegend* RimNonNetLayers::getFaciesColorLegend()
{
RimStimPlanModelTemplate* stimPlanModelTemplate;
firstAncestorOrThisOfType( stimPlanModelTemplate );
auto stimPlanModelTemplate = firstAncestorOrThisOfType<RimStimPlanModelTemplate>();
if ( !stimPlanModelTemplate ) return nullptr;
RimFaciesProperties* faciesProperties = stimPlanModelTemplate->faciesProperties();

View File

@@ -56,7 +56,7 @@ RimPressureTable::~RimPressureTable()
//--------------------------------------------------------------------------------------------------
std::vector<RimPressureTableItem*> RimPressureTable::items() const
{
std::vector<RimPressureTableItem*> pressureTableItems = m_pressureTableItems.children();
std::vector<RimPressureTableItem*> pressureTableItems = m_pressureTableItems.childrenByType();
// Sort by depth
std::sort( pressureTableItems.begin(), pressureTableItems.end(), []( auto const& a, auto const& b ) { return a->depth() < b->depth(); } );

View File

@@ -926,9 +926,7 @@ RimWellPath* RimStimPlanModel::wellPath() const
const caf::PdmObjectHandle* objHandle = dynamic_cast<const caf::PdmObjectHandle*>( this );
if ( !objHandle ) return nullptr;
RimWellPath* wellPath = nullptr;
objHandle->firstAncestorOrThisOfType( wellPath );
return wellPath;
return objHandle->firstAncestorOrThisOfType<RimWellPath>();
}
//--------------------------------------------------------------------------------------------------
@@ -1301,8 +1299,7 @@ QString RimStimPlanModel::underburdenFacies() const
void RimStimPlanModel::updateReferringPlots()
{
// Update plots referring to this fracture model
std::vector<RimStimPlanModelPlot*> referringObjects;
objectsWithReferringPtrFieldsOfType( referringObjects );
std::vector<RimStimPlanModelPlot*> referringObjects = objectsWithReferringPtrFieldsOfType<RimStimPlanModelPlot>();
for ( auto modelPlot : referringObjects )
{
@@ -1551,8 +1548,7 @@ void RimStimPlanModel::stimPlanModelTemplateChanged( const caf::SignalEmitter* e
//--------------------------------------------------------------------------------------------------
void RimStimPlanModel::updateViewsAndPlots()
{
RimEclipseCase* eclipseCase = nullptr;
this->firstAncestorOrThisOfType( eclipseCase );
auto eclipseCase = firstAncestorOrThisOfType<RimEclipseCase>();
if ( eclipseCase )
{
RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews( { eclipseCase } );

View File

@@ -77,7 +77,7 @@ void RimStimPlanModelCollection::deleteStimPlanModels()
//--------------------------------------------------------------------------------------------------
std::vector<RimStimPlanModel*> RimStimPlanModelCollection::allStimPlanModels() const
{
return m_stimPlanModels.children();
return m_stimPlanModels.childrenByType();
}
//--------------------------------------------------------------------------------------------------
@@ -114,8 +114,7 @@ void RimStimPlanModelCollection::defineUiOrdering( QString uiConfigName, caf::Pd
//--------------------------------------------------------------------------------------------------
void RimStimPlanModelCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted( proj );
RimProject* proj = RimProject::current();
if ( changedField == &m_isChecked )
{
proj->reloadCompletionTypeResultsInAllViews();

View File

@@ -98,9 +98,8 @@ RiaDefines::CurveProperty RimStimPlanModelCurve::curveProperty() const
void RimStimPlanModelCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
RimWellLogExtractionCurve::fieldChangedByUi( changedField, oldValue, newValue );
RimStimPlanModelPlot* stimPlanModelPlot;
firstAncestorOrThisOfTypeAsserted( stimPlanModelPlot );
auto stimPlanModelPlot = firstAncestorOrThisOfTypeAsserted<RimStimPlanModelPlot>();
if ( stimPlanModelPlot )
{
stimPlanModelPlot->loadDataAndUpdate();
@@ -154,8 +153,7 @@ void RimStimPlanModelCurve::performDataExtraction( bool* isUsingPseudoLength )
bool performDataSmoothing = false;
if ( !values.empty() && !measuredDepthValues.empty() && measuredDepthValues.size() == values.size() )
{
RimWellLogTrack* track = nullptr;
firstAncestorOfType( track );
auto track = firstAncestorOfType<RimWellLogTrack>();
if ( track && track->isLogarithmicScale() )
{
filterInvalidValuesForLogarithmicScale( values );

View File

@@ -178,8 +178,7 @@ void RimStimPlanModelPlot::applyDataSource()
//--------------------------------------------------------------------------------------------------
RimWellLogExtractionCurve* RimStimPlanModelPlot::findCurveByProperty( RiaDefines::CurveProperty curveProperty ) const
{
std::vector<RimStimPlanModelPropertyCurve*> curves;
descendantsIncludingThisOfType( curves );
std::vector<RimStimPlanModelPropertyCurve*> curves = descendantsIncludingThisOfType<RimStimPlanModelPropertyCurve>();
for ( RimStimPlanModelPropertyCurve* curve : curves )
{

View File

@@ -76,7 +76,7 @@ void RimStimPlanModelPlotCollection::addStimPlanModelPlot( RimStimPlanModelPlot*
//--------------------------------------------------------------------------------------------------
std::vector<RimStimPlanModelPlot*> RimStimPlanModelPlotCollection::stimPlanModelPlots() const
{
return m_stimPlanModelPlots.children();
return m_stimPlanModelPlots.childrenByType();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -485,7 +485,7 @@ void RimStimPlanModelTemplate::initAfterRead()
m_faciesProperties->setEclipseCase( eclipseCase );
}
for ( auto& fipConfig : m_faciesInitialPressureConfigs.children() )
for ( auto& fipConfig : m_faciesInitialPressureConfigs.childrenByType() )
{
fipConfig->changed.connect( this, &RimStimPlanModelTemplate::faciesPropertiesChanged );
}
@@ -811,7 +811,7 @@ RimEclipseCase* RimStimPlanModelTemplate::initialPressureEclipseCase() const
std::map<int, double> RimStimPlanModelTemplate::faciesWithInitialPressure() const
{
std::map<int, double> valueFractionMap;
for ( const RimFaciesInitialPressureConfig* c : m_faciesInitialPressureConfigs.children() )
for ( const RimFaciesInitialPressureConfig* c : m_faciesInitialPressureConfigs.childrenByType() )
{
if ( c->isEnabled() ) valueFractionMap[c->faciesValue()] = c->fraction();
}

View File

@@ -127,8 +127,7 @@ int RimStimPlanModelTemplateCollection::nextFractureTemplateId()
void RimStimPlanModelTemplateCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects )
{
RimProject* proj = nullptr;
firstAncestorOrThisOfType( proj );
RimProject* proj = RimProject::current();
if ( proj )
{
proj->scheduleCreateDisplayModelAndRedrawAllViews();