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

@@ -187,8 +187,7 @@ double RimWellPath::wellPathRadius( double characteristicCellSize ) const
{
double radius = characteristicCellSize * m_wellPathRadiusScaleFactor();
RimWellPathCollection* coll = nullptr;
this->firstAncestorOrThisOfType( coll );
RimWellPathCollection* coll = RimTools::wellPathCollection();
if ( coll )
{
radius *= coll->wellPathRadiusScaleFactor();
@@ -466,8 +465,7 @@ double RimWellPath::uniqueEndMD() const
//--------------------------------------------------------------------------------------------------
void RimWellPath::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted( proj );
RimProject* proj = RimProject::current();
if ( changedField == &m_showWellPath )
{
proj->reloadCompletionTypeResultsInAllViews();
@@ -818,8 +816,7 @@ size_t RimWellPath::simulationWellBranchCount( const QString& simWellName )
//--------------------------------------------------------------------------------------------------
double RimWellPath::combinedScaleFactor() const
{
RimWellPathCollection* wellPathColl = nullptr;
this->firstAncestorOrThisOfTypeAsserted( wellPathColl );
RimWellPathCollection* wellPathColl = firstAncestorOrThisOfTypeAsserted<RimWellPathCollection>();
return this->m_wellPathRadiusScaleFactor() * wellPathColl->wellPathRadiusScaleFactor();
}
@@ -833,8 +830,7 @@ void RimWellPath::setUnitSystem( RiaDefines::EclipseUnitSystem unitSystem )
m_completions->setUnitSystemSpecificDefaults();
std::vector<RimMswCompletionParameters*> mswParameters;
descendantsOfType( mswParameters );
std::vector<RimMswCompletionParameters*> mswParameters = descendantsOfType<RimMswCompletionParameters>();
for ( auto mswParams : mswParameters )
{
mswParams->setUnitSystemSpecificDefaults();
@@ -1104,8 +1100,7 @@ bool RimWellPath::isMultiLateralWellPath() const
{
auto top = topLevelWellPath();
std::vector<RimWellPath*> wells;
top->descendantsIncludingThisOfType( wells );
std::vector<RimWellPath*> wells = top->descendantsIncludingThisOfType<RimWellPath>();
return wells.size() > 1;
}
@@ -1147,8 +1142,7 @@ void RimWellPath::wellPathLateralsRecursively( std::vector<RimWellPath*>& wellPa
{
wellPathLaterals.push_back( const_cast<RimWellPath*>( this ) );
std::vector<caf::PdmObjectHandle*> referringObjects;
this->objectsWithReferringPtrFields( referringObjects );
std::vector<caf::PdmObjectHandle*> referringObjects = objectsWithReferringPtrFields();
for ( auto obj : referringObjects )
{
if ( auto tieIn = dynamic_cast<RimWellPathTieIn*>( obj ) )
@@ -1184,8 +1178,7 @@ std::vector<RimWellPath*> RimWellPath::wellPathLaterals() const
{
std::vector<RimWellPath*> laterals;
std::vector<caf::PdmObjectHandle*> referringObjects;
this->objectsWithReferringPtrFields( referringObjects );
std::vector<caf::PdmObjectHandle*> referringObjects = objectsWithReferringPtrFields();
for ( auto obj : referringObjects )
{
if ( auto tieIn = dynamic_cast<RimWellPathTieIn*>( obj ) )