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

@@ -123,7 +123,7 @@ void RimAnalysisPlotCollection::updateSummaryNameHasChanged()
//--------------------------------------------------------------------------------------------------
std::vector<RimAnalysisPlot*> RimAnalysisPlotCollection::plots() const
{
return m_analysisPlots.children();
return m_analysisPlots.childrenByType();
}
//--------------------------------------------------------------------------------------------------
@@ -164,8 +164,7 @@ void RimAnalysisPlotCollection::applyFirstSummaryCaseCollectionAndFieldAddresses
//--------------------------------------------------------------------------------------------------
void RimAnalysisPlotCollection::applyAllSummaryCasesAndFieldAddressesToPlot( RimAnalysisPlot* plot, const std::string& quantityName /*= "" */ )
{
std::vector<RimSummaryCase*> allSummaryCases;
RimProject::current()->descendantsOfType( allSummaryCases );
std::vector<RimSummaryCase*> allSummaryCases = RimProject::current()->descendantsOfType<RimSummaryCase>();
if ( !allSummaryCases.empty() )
{
@@ -223,8 +222,7 @@ void RimAnalysisPlotCollection::applySummaryCaseCollectionAndFieldAddressToPlot(
//--------------------------------------------------------------------------------------------------
RimSummaryCaseCollection* RimAnalysisPlotCollection::firstEnsemble() const
{
std::vector<RimSummaryCaseCollection*> allSummaryCaseCollections;
RimProject::current()->descendantsOfType( allSummaryCaseCollections );
std::vector<RimSummaryCaseCollection*> allSummaryCaseCollections = RimProject::current()->descendantsOfType<RimSummaryCaseCollection>();
for ( auto summaryCaseCollection : allSummaryCaseCollections )
{
if ( summaryCaseCollection->isEnsemble() ) return summaryCaseCollection;
@@ -237,8 +235,7 @@ RimSummaryCaseCollection* RimAnalysisPlotCollection::firstEnsemble() const
//--------------------------------------------------------------------------------------------------
RimSummaryCaseCollection* RimAnalysisPlotCollection::firstSummaryCaseCollection() const
{
std::vector<RimSummaryCaseCollection*> allSummaryCaseCollections;
RimProject::current()->descendantsOfType( allSummaryCaseCollections );
std::vector<RimSummaryCaseCollection*> allSummaryCaseCollections = RimProject::current()->descendantsOfType<RimSummaryCaseCollection>();
if ( !allSummaryCaseCollections.empty() ) return allSummaryCaseCollections.front();

View File

@@ -67,7 +67,7 @@ void RimPlotDataFilterCollection::removeFilter( RimPlotDataFilterItem* filter )
//--------------------------------------------------------------------------------------------------
std::vector<RimPlotDataFilterItem*> RimPlotDataFilterCollection::filters() const
{
return m_filters.children();
return m_filters.childrenByType();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -270,8 +270,7 @@ void RimPlotDataFilterItem::fieldChangedByUi( const caf::PdmFieldHandle* changed
QList<caf::PdmOptionItemInfo> RimPlotDataFilterItem::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
QList<caf::PdmOptionItemInfo> options;
RimAnalysisPlot* parentPlot;
this->firstAncestorOrThisOfTypeAsserted( parentPlot );
auto parentPlot = firstAncestorOrThisOfTypeAsserted<RimAnalysisPlot>();
if ( fieldNeedingOptions == &m_filterQuantityUiField )
{
@@ -417,8 +416,7 @@ void RimPlotDataFilterItem::defineEditorAttribute( const caf::PdmFieldHandle* fi
//--------------------------------------------------------------------------------------------------
void RimPlotDataFilterItem::updateMaxMinAndDefaultValues( bool forceDefault )
{
RimAnalysisPlot* parentPlot;
this->firstAncestorOrThisOfTypeAsserted( parentPlot );
auto parentPlot = firstAncestorOrThisOfTypeAsserted<RimAnalysisPlot>();
if ( m_filterTarget == ENSEMBLE_CASE )
{
@@ -471,7 +469,6 @@ void RimPlotDataFilterItem::updateMaxMinAndDefaultValues( bool forceDefault )
//--------------------------------------------------------------------------------------------------
RigEnsembleParameter RimPlotDataFilterItem::selectedEnsembleParameter() const
{
RimAnalysisPlot* parentPlot;
this->firstAncestorOrThisOfTypeAsserted( parentPlot );
auto parentPlot = firstAncestorOrThisOfTypeAsserted<RimAnalysisPlot>();
return parentPlot->ensembleParameter( m_filterEnsembleParameter );
}