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

@@ -253,8 +253,7 @@ void RivBoxIntersectionGeometryGenerator::calculateArrays()
cvf::Vec3d displayOffset( 0, 0, 0 );
{
RimGridView* gridView = nullptr;
m_intersectionBoxDefinition->firstAncestorOrThisOfType( gridView );
auto gridView = m_intersectionBoxDefinition->firstAncestorOrThisOfType<RimGridView>();
if ( gridView && gridView->ownerCase() )
{
displayOffset = gridView->ownerCase()->displayModelOffset();

View File

@@ -51,9 +51,7 @@
cvf::ref<caf::DisplayCoordTransform> displayCoordTransform( const RimExtrudedCurveIntersection* intersection )
{
Rim3dView* rimView = nullptr;
intersection->firstAncestorOrThisOfType( rimView );
CVF_ASSERT( rimView );
auto rimView = intersection->firstAncestorOrThisOfTypeAsserted<Rim3dView>();
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
return transForm;
@@ -114,8 +112,7 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateLineSegementTransfo
cvf::Vec3d displayOffset( 0, 0, 0 );
{
RimGridView* gridView = nullptr;
m_intersection->firstAncestorOrThisOfType( gridView );
auto gridView = m_intersection->firstAncestorOrThisOfType<RimGridView>();
if ( gridView && gridView->ownerCase() )
{
displayOffset = gridView->ownerCase()->displayModelOffset();

View File

@@ -341,8 +341,7 @@ void RivExtrudedCurveIntersectionPartMgr::createFaultLabelParts( const std::vect
if ( !m_rimIntersection->activeSeparateResultDefinition() )
{
RimEclipseView* eclipseView = nullptr;
m_rimIntersection->firstAncestorOrThisOfType( eclipseView );
auto eclipseView = m_rimIntersection->firstAncestorOrThisOfType<RimEclipseView>();
if ( eclipseView )
{
faultInViewColl = eclipseView->faultCollection();

View File

@@ -62,9 +62,7 @@ void RivIntersectionResultsColoringTools::calculateIntersectionResultColors( int
{
if ( !intersectionGeomGenIF || !intersectionGeomGenIF->isAnyGeometryPresent() ) return;
RimGridView* gridView = nullptr;
rimIntersectionHandle->firstAncestorOrThisOfType( gridView );
auto gridView = rimIntersectionHandle->firstAncestorOrThisOfType<RimGridView>();
if ( !gridView ) return;
bool isLightingDisabled = gridView->isLightingDisabled();
@@ -100,9 +98,7 @@ void RivIntersectionResultsColoringTools::calculateIntersectionResultColors( int
if ( !eclipseResDef && !geomResultDef )
{
RimEclipseView* eclipseView = nullptr;
rimIntersectionHandle->firstAncestorOrThisOfType( eclipseView );
auto eclipseView = rimIntersectionHandle->firstAncestorOrThisOfType<RimEclipseView>();
if ( eclipseView )
{
eclipseResDef = eclipseView->cellResult();
@@ -110,9 +106,7 @@ void RivIntersectionResultsColoringTools::calculateIntersectionResultColors( int
if ( !ternaryColorMapper ) ternaryColorMapper = eclipseView->cellResult()->ternaryLegendConfig()->scalarMapper();
}
RimGeoMechView* geoView;
rimIntersectionHandle->firstAncestorOrThisOfType( geoView );
auto geoView = rimIntersectionHandle->firstAncestorOrThisOfType<RimGeoMechView>();
if ( geoView )
{
geomResultDef = geoView->cellResult();

View File

@@ -87,8 +87,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables( gsl::not_null<con
if ( resultValues.empty() ) return;
CVF_ASSERT( resultValues.size() == resultMds.size() );
RimWellPathCollection* wellPathCollection = nullptr;
m_wellPath->firstAncestorOrThisOfTypeAsserted( wellPathCollection );
auto wellPathCollection = m_wellPath->firstAncestorOrThisOfTypeAsserted<RimWellPathCollection>();
cvf::Vec3d clipLocation = wellPathGeometry->wellPathPoints().front();
if ( wellPathCollection->wellPathClip )

View File

@@ -67,8 +67,7 @@ bool Riv3dWellLogDrawSurfaceGenerator::createDrawSurface( const caf::DisplayCoor
return false;
}
RimWellPathCollection* wellPathCollection = nullptr;
m_wellPath->firstAncestorOrThisOfTypeAsserted( wellPathCollection );
auto wellPathCollection = m_wellPath->firstAncestorOrThisOfTypeAsserted<RimWellPathCollection>();
std::vector<cvf::Vec3d> wellPathDisplayCoords;
{

View File

@@ -76,8 +76,7 @@ void RivAnnotationsPartMgr::appendGeometryPartsToModel( cvf::ModelBasicList*
//--------------------------------------------------------------------------------------------------
void RivAnnotationsPartMgr::createAnnotationPartManagers()
{
std::vector<RimAnnotationInViewCollection*> colls;
m_rimView->descendantsIncludingThisOfType( colls );
std::vector<RimAnnotationInViewCollection*> colls = m_rimView->descendantsIncludingThisOfType<RimAnnotationInViewCollection>();
if ( colls.empty() ) return;
auto coll = colls.front();

View File

@@ -61,8 +61,7 @@ void RivCellFilterPartMgr::appendGeometryPartsToModel( cvf::ModelBasicList*
//--------------------------------------------------------------------------------------------------
void RivCellFilterPartMgr::createCellFilterPartManagers()
{
std::vector<RimCellFilterCollection*> colls;
m_rimView->descendantsIncludingThisOfType( colls );
std::vector<RimCellFilterCollection*> colls = m_rimView->descendantsIncludingThisOfType<RimCellFilterCollection>();
if ( colls.empty() ) return;
auto coll = colls.front();

View File

@@ -591,8 +591,7 @@ void RivFaultPartMgr::createLabelWithAnchorLine( const cvf::Part* part )
cvf::Color3f defWellLabelColor = app->preferences()->defaultWellLabelColor();
{
{
RimFaultInViewCollection* parentObject;
m_rimFault->firstAncestorOrThisOfType( parentObject );
auto parentObject = m_rimFault->firstAncestorOrThisOfType<RimFaultInViewCollection>();
if ( parentObject )
{
defWellLabelColor = parentObject->faultLabelColor();

View File

@@ -84,8 +84,7 @@ void RivFishbonesSubsPartMgr::clearGeometryCache()
//--------------------------------------------------------------------------------------------------
void RivFishbonesSubsPartMgr::buildParts( const caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize )
{
RimWellPath* wellPath = nullptr;
m_rimFishbonesSubs->firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPath = m_rimFishbonesSubs->firstAncestorOrThisOfTypeAsserted<RimWellPath>();
for ( const auto& [subIndex, lateralIndex] : m_rimFishbonesSubs->installedLateralIndices() )
{

View File

@@ -210,7 +210,6 @@ std::vector<cvf::Vec3d> RivReachCircleAnnotationPartMgr::computeCirclePointsInDo
//--------------------------------------------------------------------------------------------------
RimAnnotationInViewCollection* RivReachCircleAnnotationPartMgr::annotationCollection() const
{
std::vector<RimAnnotationInViewCollection*> colls;
m_rimView->descendantsIncludingThisOfType( colls );
auto colls = m_rimView->descendantsIncludingThisOfType<RimAnnotationInViewCollection>();
return !colls.empty() ? colls.front() : nullptr;
}

View File

@@ -151,13 +151,6 @@ void RivReservoirViewPartMgr::scheduleGeometryRegen( RivCellSetEnum geometryType
//--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::clearGeometryCache( RivCellSetEnum geomType )
{
RimEclipseCase* rimEclipseCase = nullptr;
if ( m_reservoirView )
{
m_reservoirView->firstAncestorOrThisOfType( rimEclipseCase );
}
if ( geomType == PROPERTY_FILTERED )
{
for ( size_t i = 0; i < m_propFilteredGeometryFramesNeedsRegen.size(); ++i )

View File

@@ -79,10 +79,9 @@ RivSimWellPipesPartMgr::~RivSimWellPipesPartMgr()
//--------------------------------------------------------------------------------------------------
Rim3dView* RivSimWellPipesPartMgr::viewWithSettings()
{
Rim3dView* view = nullptr;
if ( m_simWellInView ) m_simWellInView->firstAncestorOrThisOfType( view );
if ( m_simWellInView ) return m_simWellInView->firstAncestorOrThisOfType<Rim3dView>();
return view;
return nullptr;
}
//--------------------------------------------------------------------------------------------------
@@ -292,8 +291,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts( const caf::DisplayCoordTransfor
pbd.m_connectionFactorsPart = nullptr;
pbd.m_valveParts.clear();
RimEclipseView* eclipseView = nullptr;
m_simWellInView->firstAncestorOrThisOfType( eclipseView );
auto eclipseView = m_simWellInView->firstAncestorOrThisOfType<RimEclipseView>();
appendVirtualConnectionFactorGeo( eclipseView, frameIndex, brIdx, displayXf, pipeRadius, pbd );
appendValvesGeo( eclipseView, frameIndex, brIdx, displayXf, pipeRadius, pbd );
@@ -581,7 +579,7 @@ void RivSimWellPipesPartMgr::updatePipeResultColor( size_t frameIndex )
RimSimWellInViewCollection* wellColl = nullptr;
if ( m_simWellInView )
{
m_simWellInView->firstAncestorOrThisOfType( wellColl );
wellColl = m_simWellInView->firstAncestorOrThisOfType<RimSimWellInViewCollection>();
}
if ( wellColl && wellColl->showConnectionStatusColors() )

View File

@@ -229,8 +229,7 @@ bool RivTextAnnotationPartMgr::validateAnnotation( const RimTextAnnotation* anno
//--------------------------------------------------------------------------------------------------
RimAnnotationInViewCollection* RivTextAnnotationPartMgr::annotationCollection() const
{
std::vector<RimAnnotationInViewCollection*> colls;
m_rimView->descendantsIncludingThisOfType( colls );
auto colls = m_rimView->descendantsIncludingThisOfType<RimAnnotationInViewCollection>();
return !colls.empty() ? colls.front() : nullptr;
}

View File

@@ -68,13 +68,11 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel( cvf::Mod
{
m_geometryGenerator = nullptr;
RimEclipseView* eclView = nullptr;
m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted( eclView );
RimEclipseView* eclView = m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted<RimEclipseView>();
auto coordTransform = eclView->displayCoordTransform();
RimEclipseCase* eclipseCase = nullptr;
m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted( eclipseCase );
RimEclipseCase* eclipseCase = m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted<RimEclipseCase>();
const RigMainGrid* mainGrid = eclipseCase->mainGrid();

View File

@@ -487,10 +487,9 @@ void RivWellDiskPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicList*
//--------------------------------------------------------------------------------------------------
Rim3dView* RivWellDiskPartMgr::viewWithSettings()
{
Rim3dView* view = nullptr;
if ( m_rimWell ) m_rimWell->firstAncestorOrThisOfType( view );
if ( m_rimWell ) return m_rimWell->firstAncestorOrThisOfType<Rim3dView>();
return view;
return nullptr;
}
//--------------------------------------------------------------------------------------------------
@@ -498,10 +497,9 @@ Rim3dView* RivWellDiskPartMgr::viewWithSettings()
//--------------------------------------------------------------------------------------------------
RimSimWellInViewCollection* RivWellDiskPartMgr::simWellInViewCollection()
{
RimSimWellInViewCollection* wellCollection = nullptr;
if ( m_rimWell ) m_rimWell->firstAncestorOrThisOfType( wellCollection );
if ( m_rimWell ) return m_rimWell->firstAncestorOrThisOfType<RimSimWellInViewCollection>();
return wellCollection;
return nullptr;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -125,15 +125,13 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel( cvf::ModelBasicList* mo
double distanceToCenterLine = 1.0;
{
RimWellPathCollection* wellPathColl = nullptr;
m_rimFracture->firstAncestorOrThisOfType( wellPathColl );
auto wellPathColl = m_rimFracture->firstAncestorOrThisOfType<RimWellPathCollection>();
if ( wellPathColl )
{
distanceToCenterLine = wellPathColl->wellPathRadiusScaleFactor() * characteristicCellSize;
}
RimSimWellInView* simWell = nullptr;
m_rimFracture->firstAncestorOrThisOfType( simWell );
auto simWell = m_rimFracture->firstAncestorOrThisOfType<RimSimWellInView>();
if ( simWell )
{
distanceToCenterLine = simWell->pipeRadius();
@@ -662,8 +660,7 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createContainmentMaskPart( const Rim
std::vector<cvf::Vec3f> maskTriangles;
RimEclipseCase* eclipseCase = nullptr;
activeView.firstAncestorOrThisOfType( eclipseCase );
auto eclipseCase = activeView.firstAncestorOrThisOfType<RimEclipseCase>();
auto reservoirCellIndicesOpenForFlow = RimFractureContainmentTools::reservoirCellIndicesOpenForFlow( eclipseCase, m_rimFracture );
for ( size_t resCellIdx : cellCandidates )
@@ -935,8 +932,7 @@ void RivWellFracturePartMgr::appendFracturePerforationLengthParts( const RimEcli
double wellPathRadius = 1.0;
{
RimWellPath* rimWellPath = nullptr;
m_rimFracture->firstAncestorOrThisOfType( rimWellPath );
auto rimWellPath = m_rimFracture->firstAncestorOrThisOfType<RimWellPath>();
if ( rimWellPath )
{
wellPathRadius = rimWellPath->wellPathRadius( characteristicCellSize );
@@ -944,8 +940,7 @@ void RivWellFracturePartMgr::appendFracturePerforationLengthParts( const RimEcli
}
{
RimSimWellInView* simWell = nullptr;
m_rimFracture->firstAncestorOrThisOfType( simWell );
auto simWell = m_rimFracture->firstAncestorOrThisOfType<RimSimWellInView>();
if ( simWell )
{
wellPathRadius = simWell->pipeRadius();

View File

@@ -243,7 +243,7 @@ void RivWellHeadPartMgr::buildWellHeadParts( size_t frameIndex, const caf::Displ
RimSimWellInViewCollection* wellColl = nullptr;
if ( m_rimWell )
{
m_rimWell->firstAncestorOrThisOfType( wellColl );
wellColl = m_rimWell->firstAncestorOrThisOfType<RimSimWellInViewCollection>();
}
if ( wellColl && wellColl->showConnectionStatusColors() )
@@ -395,10 +395,9 @@ void RivWellHeadPartMgr::appendFlattenedDynamicGeometryPartsToModel( cvf::ModelB
//--------------------------------------------------------------------------------------------------
Rim3dView* RivWellHeadPartMgr::viewWithSettings()
{
Rim3dView* view = nullptr;
if ( m_rimWell ) m_rimWell->firstAncestorOrThisOfType( view );
if ( m_rimWell ) return m_rimWell->firstAncestorOrThisOfType<Rim3dView>();
return view;
return nullptr;
}
//--------------------------------------------------------------------------------------------------
@@ -406,8 +405,7 @@ Rim3dView* RivWellHeadPartMgr::viewWithSettings()
//--------------------------------------------------------------------------------------------------
RimSimWellInViewCollection* RivWellHeadPartMgr::simWellInViewCollection()
{
RimSimWellInViewCollection* wellCollection = nullptr;
if ( m_rimWell ) m_rimWell->firstAncestorOrThisOfType( wellCollection );
if ( m_rimWell ) return m_rimWell->firstAncestorOrThisOfType<RimSimWellInViewCollection>();
return wellCollection;
return nullptr;
}

View File

@@ -381,8 +381,7 @@ void RivWellPathPartMgr::appendPerforationsToModel( cvf::ModelBasicList*
QDateTime currentTimeStamp;
if ( m_rimView )
{
RimCase* rimCase = nullptr;
m_rimView->firstAncestorOrThisOfType( rimCase );
auto rimCase = m_rimView->firstAncestorOrThisOfType<RimCase>();
if ( rimCase )
{
@@ -400,8 +399,7 @@ void RivWellPathPartMgr::appendPerforationsToModel( cvf::ModelBasicList*
double wellPathRadius = this->wellPathRadius( characteristicCellSize, wellPathCollection );
double perforationRadius = wellPathRadius * 1.1;
std::vector<RimPerforationInterval*> perforations;
m_rimWellPath->descendantsIncludingThisOfType( perforations );
std::vector<RimPerforationInterval*> perforations = m_rimWellPath->descendantsIncludingThisOfType<RimPerforationInterval>();
for ( RimPerforationInterval* perforation : perforations )
{
using namespace std;
@@ -578,8 +576,7 @@ void RivWellPathPartMgr::appendVirtualTransmissibilitiesToModel( cvf::ModelBasic
if ( !eclView->isVirtualConnectionFactorGeometryVisible() ) return;
RimEclipseCase* eclipseCase = nullptr;
eclView->firstAncestorOrThisOfType( eclipseCase );
auto eclipseCase = eclView->firstAncestorOrThisOfType<RimEclipseCase>();
if ( !eclipseCase ) return;
const RigVirtualPerforationTransmissibilities* trans = eclipseCase->computeAndGetVirtualPerforationTransmissibilities();
@@ -976,10 +973,7 @@ RimWellPathCollection* RivWellPathPartMgr::wellPathCollection() const
{
if ( !m_rimWellPath ) return nullptr;
RimWellPathCollection* wellPathCollection = nullptr;
m_rimWellPath->firstAncestorOrThisOfType( wellPathCollection );
return wellPathCollection;
return m_rimWellPath->firstAncestorOrThisOfType<RimWellPathCollection>();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -203,7 +203,7 @@ cvf::Color3f RivWellSpheresPartMgr::wellCellColor( const RigWellResultFrame* wel
RimSimWellInViewCollection* wellColl = nullptr;
if ( m_rimWell )
{
m_rimWell->firstAncestorOrThisOfType( wellColl );
wellColl = m_rimWell->firstAncestorOrThisOfType<RimSimWellInViewCollection>();
}
if ( wellColl )

View File

@@ -52,10 +52,7 @@
cvf::ref<caf::DisplayCoordTransform> displayCoordTransform( const RimIntersection* intersection )
{
Rim3dView* rimView = nullptr;
intersection->firstAncestorOrThisOfType( rimView );
CVF_ASSERT( rimView );
auto rimView = intersection->firstAncestorOrThisOfTypeAsserted<Rim3dView>();
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
return transForm;
}

View File

@@ -369,8 +369,7 @@ void RivSurfacePartMgr::generatePartGeometry()
//--------------------------------------------------------------------------------------------------
void RivSurfacePartMgr::generateNativePartGeometry()
{
RimCase* ownerCase;
m_surfaceInView->firstAncestorOrThisOfTypeAsserted( ownerCase );
auto ownerCase = m_surfaceInView->firstAncestorOrThisOfTypeAsserted<RimCase>();
cvf::Vec3d displayModOffsett = ownerCase->displayModelOffset();
m_usedSurfaceData = m_surfaceInView->surface()->surfaceData();