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

@@ -60,10 +60,6 @@ RimStimPlanModel* RicNewStimPlanModelFeature::addStimPlanModel( RimWellPath*
RimStimPlanModelCollection* stimPlanModelCollection = wellPath->stimPlanModelCollection();
CVF_ASSERT( stimPlanModelCollection );
RimOilField* oilfield = nullptr;
stimPlanModelCollection->firstAncestorOrThisOfType( oilfield );
if ( !oilfield ) return nullptr;
RimStimPlanModel* stimPlanModel = new RimStimPlanModel();
stimPlanModelCollection->addStimPlanModel( stimPlanModel );
@@ -73,9 +69,6 @@ RimStimPlanModel* RicNewStimPlanModelFeature::addStimPlanModel( RimWellPath*
QString stimPlanModelName = RicFractureNameGenerator::nameForNewStimPlanModel();
stimPlanModel->setName( stimPlanModelName );
RimProject* project = nullptr;
stimPlanModelCollection->firstAncestorOrThisOfType( project );
// Add a "fake" well path for thickess direction
RimModeledWellPath* thicknessDirectionWellPath = new RimModeledWellPath;
stimPlanModel->setThicknessDirectionWellPath( thicknessDirectionWellPath );
@@ -83,6 +76,7 @@ RimStimPlanModel* RicNewStimPlanModelFeature::addStimPlanModel( RimWellPath*
std::vector<RimWellPath*> wellPaths = { thicknessDirectionWellPath };
wellPathCollection->addWellPaths( wellPaths );
RimProject* project = RimProject::current();
if ( project )
{
project->reloadCompletionTypeResultsInAllViews();
@@ -106,11 +100,8 @@ void RicNewStimPlanModelFeature::onActionTriggered( bool isChecked )
RimStimPlanModelCollection* fractureColl = RicNewStimPlanModelFeature::selectedStimPlanModelCollection();
if ( !fractureColl ) return;
RimWellPath* wellPath = nullptr;
fractureColl->firstAncestorOrThisOfTypeAsserted( wellPath );
RimWellPathCollection* wellPathCollection = nullptr;
fractureColl->firstAncestorOrThisOfTypeAsserted( wellPathCollection );
auto wellPath = fractureColl->firstAncestorOrThisOfTypeAsserted<RimWellPath>();
auto wellPathCollection = fractureColl->firstAncestorOrThisOfTypeAsserted<RimWellPathCollection>();
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>( RiaApplication::instance()->activeGridView() );
RimEclipseCase* eclipseCase = nullptr;
@@ -152,12 +143,10 @@ RimStimPlanModelCollection* RicNewStimPlanModelFeature::selectedStimPlanModelCol
caf::PdmUiItem* pdmUiItem = selectedItems.front();
RimStimPlanModelCollection* stimPlanModelCollection = nullptr;
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>( pdmUiItem );
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>( pdmUiItem );
if ( objHandle )
{
objHandle->firstAncestorOrThisOfType( stimPlanModelCollection );
RimStimPlanModelCollection* stimPlanModelCollection = objHandle->firstAncestorOrThisOfType<RimStimPlanModelCollection>();
if ( stimPlanModelCollection ) return stimPlanModelCollection;
RimWellPath* wellPath = dynamic_cast<RimWellPath*>( objHandle );