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

@@ -398,8 +398,7 @@ std::vector<Rim3dView*> RimGeoMechCase::allSpecialViews() const
//--------------------------------------------------------------------------------------------------
void RimGeoMechCase::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ )
{
std::vector<PdmObjectHandle*> children;
geoMechViews.children( &children );
std::vector<PdmObjectHandle*> children = geoMechViews.children();
for ( auto child : children )
uiTreeOrdering.add( child );

View File

@@ -51,10 +51,7 @@ RimGeoMechCellColors::~RimGeoMechCellColors()
//--------------------------------------------------------------------------------------------------
void RimGeoMechCellColors::updateIconState()
{
Rim3dView* rimView = nullptr;
this->firstAncestorOrThisOfType( rimView );
CVF_ASSERT( rimView );
auto rimView = firstAncestorOrThisOfTypeAsserted<Rim3dView>();
if ( rimView )
{
RimViewController* viewController = rimView->viewController();

View File

@@ -568,9 +568,7 @@ std::vector<double> RimGeoMechContourMapProjection::gridCellValues( RigFemResult
//--------------------------------------------------------------------------------------------------
RimGeoMechCase* RimGeoMechContourMapProjection::geoMechCase() const
{
RimGeoMechCase* geoMechCase = nullptr;
firstAncestorOrThisOfType( geoMechCase );
return geoMechCase;
return firstAncestorOrThisOfType<RimGeoMechCase>();
}
//--------------------------------------------------------------------------------------------------
@@ -578,9 +576,7 @@ RimGeoMechCase* RimGeoMechContourMapProjection::geoMechCase() const
//--------------------------------------------------------------------------------------------------
RimGeoMechContourMapView* RimGeoMechContourMapProjection::view() const
{
RimGeoMechContourMapView* view = nullptr;
firstAncestorOrThisOfTypeAsserted( view );
return view;
return firstAncestorOrThisOfTypeAsserted<RimGeoMechContourMapView>();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -104,8 +104,7 @@ QString RimGeoMechContourMapView::createAutoName() const
QStringList generatedAutoTags;
RimCase* ownerCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted( ownerCase );
auto ownerCase = firstAncestorOrThisOfTypeAsserted<RimCase>();
if ( nameConfig()->addCaseName() )
{

View File

@@ -28,7 +28,7 @@ RimGeoMechContourMapViewCollection::~RimGeoMechContourMapViewCollection()
//--------------------------------------------------------------------------------------------------
std::vector<RimGeoMechContourMapView*> RimGeoMechContourMapViewCollection::views()
{
return m_contourMapViews.children();
return m_contourMapViews.childrenByType();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -52,7 +52,7 @@ RimGeoMechModels::~RimGeoMechModels()
//--------------------------------------------------------------------------------------------------
std::vector<RimGeoMechCase*> RimGeoMechModels::cases() const
{
return m_cases.children();
return m_cases.childrenByType();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -72,8 +72,7 @@ void RimGeoMechPart::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
if ( changedField == objectToggleField() )
{
RimGeoMechView* ownerView;
firstAncestorOrThisOfType( ownerView );
auto ownerView = firstAncestorOrThisOfType<RimGeoMechView>();
if ( ownerView ) ownerView->scheduleCreateDisplayModelAndRedraw();
}
}

View File

@@ -88,7 +88,7 @@ void RimGeoMechPartCollection::syncWithCase( RimGeoMechCase* geoCase )
//--------------------------------------------------------------------------------------------------
std::vector<RimGeoMechPart*> RimGeoMechPartCollection::parts() const
{
return m_parts.children();
return m_parts.childrenByType();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -351,13 +351,10 @@ void RimGeoMechResultDefinition::fieldChangedByUi( const caf::PdmFieldHandle* ch
}
// Get the possible property filter owner
RimGeoMechPropertyFilter* propFilter = dynamic_cast<RimGeoMechPropertyFilter*>( this->parentField()->ownerObject() );
RimGridView* view = nullptr;
this->firstAncestorOrThisOfType( view );
RimPlotCurve* curve = nullptr;
this->firstAncestorOrThisOfType( curve );
Rim3dWellLogCurve* rim3dWellLogCurve = nullptr;
this->firstAncestorOrThisOfType( rim3dWellLogCurve );
auto propFilter = dynamic_cast<RimGeoMechPropertyFilter*>( this->parentField()->ownerObject() );
auto view = firstAncestorOrThisOfType<RimGridView>();
auto curve = firstAncestorOrThisOfType<RimPlotCurve>();
auto rim3dWellLogCurve = firstAncestorOrThisOfType<Rim3dWellLogCurve>();
if ( &m_resultVariableUiField == changedField || &m_compactionRefLayerUiField == changedField ||
&m_timeLapseBaseTimestep == changedField || &m_normalizeByHydrostaticPressure == changedField ||

View File

@@ -229,8 +229,7 @@ QString RimGeoMechView::createAutoName() const
QStringList generatedAutoTags;
RimCase* ownerCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted( ownerCase );
RimCase* ownerCase = firstAncestorOrThisOfTypeAsserted<RimCase>();
if ( nameConfig()->addCaseName() )
{