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 authored and GitHub committed 2023-05-12 21:41:34 +02:00
1 parent 37e29a0f68
commit 0c90f67dcc
510 files changed
+1651 -3111

No files matched your search

@@ -134,14 +134,13 @@ std::vector<Rim3dWellLogCurve*> Rim3dWellLogCurveCollection::vectorOf3dWellLogCu
//--------------------------------------------------------------------------------------------------
void Rim3dWellLogCurveCollection::redrawAffectedViewsAndEditors()
{
RimProject* proj = nullptr;
this->firstAncestorOrThisOfType( proj );
RimProject* proj = RimProject::current();
if ( proj )
{
proj->scheduleCreateDisplayModelAndRedrawAllViews();
}
RimWellPath* path = nullptr;
this->firstAncestorOrThisOfType( path );
auto path = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
if ( path )
{
path->updateConnectedEditors();
@@ -183,8 +182,7 @@ Rim3dWellLogCurve* Rim3dWellLogCurveCollection::checkForCurveIntersection( const
//--------------------------------------------------------------------------------------------------
void Rim3dWellLogCurveCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted( proj );
RimProject* proj = RimProject::current();
proj->scheduleCreateDisplayModelAndRedrawAllViews();
}
@@ -385,8 +385,7 @@ void RimEllipseFractureTemplate::onLoadDataAndUpdateGeometryHasChanged()
{
loadDataAndUpdate();
RimEclipseCase* eclipseCase = nullptr;
this->firstAncestorOrThisOfType( eclipseCase );
auto eclipseCase = firstAncestorOrThisOfType<RimEclipseCase>();
if ( eclipseCase )
{
RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews( { eclipseCase } );
@@ -278,8 +278,7 @@ void RimEnsembleFractureStatistics::fieldChangedByUi( const caf::PdmFieldHandle*
// Update views
if ( !updatedTemplates.empty() )
{
RimFractureTemplateCollection* templateCollection = nullptr;
updatedTemplates.front()->firstAncestorOrThisOfTypeAsserted( templateCollection );
auto templateCollection = updatedTemplates.front()->firstAncestorOrThisOfTypeAsserted<RimFractureTemplateCollection>();
templateCollection->updateConnectedEditors();
RimProject::current()->scheduleCreateDisplayModelAndRedrawAllViews();
@@ -291,8 +290,7 @@ void RimEnsembleFractureStatistics::fieldChangedByUi( const caf::PdmFieldHandle*
#ifdef USE_QTCHARTS
// Update referring plots
std::vector<caf::PdmObjectHandle*> referringObjects;
this->objectsWithReferringPtrFields( referringObjects );
std::vector<caf::PdmObjectHandle*> referringObjects = this->objectsWithReferringPtrFields();
for ( caf::PdmObjectHandle* obj : referringObjects )
{
auto plot = dynamic_cast<RimEnsembleFractureStatisticsPlot*>( obj );
@@ -46,7 +46,7 @@ void RimEnsembleFractureStatisticsCollection::addFractureGroupStatistics( RimEns
//--------------------------------------------------------------------------------------------------
void RimEnsembleFractureStatisticsCollection::loadAndUpdateData()
{
for ( auto f : m_fractureGroupStatistics.children() )
for ( auto f : m_fractureGroupStatistics.childrenByType() )
{
f->loadAndUpdateData();
}
@@ -216,8 +216,7 @@ double RimFishbones::buildAngle() const
//--------------------------------------------------------------------------------------------------
double RimFishbones::tubingDiameter( RiaDefines::EclipseUnitSystem unitSystem ) const
{
RimWellPath* wellPath;
firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
if ( unitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
{
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
@@ -284,8 +283,7 @@ double RimFishbones::skinFactor() const
//--------------------------------------------------------------------------------------------------
double RimFishbones::openHoleRoughnessFactor( RiaDefines::EclipseUnitSystem unitSystem ) const
{
RimWellPath* wellPath;
firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_FIELD && unitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
{
return RiaEclipseUnitTools::feetToMeter( m_lateralOpenHoleRoghnessFactor() );
@@ -302,8 +300,7 @@ double RimFishbones::openHoleRoughnessFactor( RiaDefines::EclipseUnitSystem unit
//--------------------------------------------------------------------------------------------------
double RimFishbones::icdOrificeDiameter( RiaDefines::EclipseUnitSystem unitSystem ) const
{
RimWellPath* wellPath;
firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
return RimWellPathValve::convertOrificeDiameter( m_icdOrificeDiameter(), wellPath->unitSystem(), unitSystem );
}
@@ -358,12 +355,10 @@ void RimFishbones::geometryUpdated()
computeRotationAngles();
computeSubLateralIndices();
RimFishbonesCollection* collection;
this->firstAncestorOrThisOfTypeAsserted( collection );
auto collection = firstAncestorOrThisOfTypeAsserted<RimFishbonesCollection>();
collection->recalculateStartMD();
RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted( proj );
RimProject* proj = RimProject::current();
proj->reloadCompletionTypeResultsInAllViews();
}
@@ -413,8 +408,7 @@ void RimFishbones::recomputeLateralLocations()
//--------------------------------------------------------------------------------------------------
void RimFishbones::setUnitSystemSpecificDefaults()
{
RimWellPath* wellPath;
firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( wellPath )
{
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
@@ -556,8 +550,7 @@ void RimFishbones::computeRangesAndLocations()
void RimFishbones::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
{
RimWellPath* wellPath;
firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( wellPath )
{
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
@@ -671,8 +664,7 @@ cvf::BoundingBox RimFishbones::boundingBoxInDomainCoords() const
//--------------------------------------------------------------------------------------------------
bool RimFishbones::isEnabled() const
{
RimFishbonesCollection* collection;
this->firstAncestorOrThisOfTypeAsserted( collection );
auto collection = firstAncestorOrThisOfTypeAsserted<RimFishbonesCollection>();
return collection->isChecked() && isActive();
}
@@ -64,8 +64,7 @@ void RimFishbonesCollection::fieldChangedByUi( const caf::PdmFieldHandle* change
manuallyModifiedStartMD = true;
}
RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted( proj );
RimProject* proj = RimProject::current();
if ( changedField == &m_isChecked )
{
proj->reloadCompletionTypeResultsInAllViews();
@@ -82,8 +81,7 @@ void RimFishbonesCollection::fieldChangedByUi( const caf::PdmFieldHandle* change
void RimFishbonesCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
{
RimWellPath* wellPath;
firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( wellPath )
{
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
@@ -153,7 +151,7 @@ std::vector<RimFishbones*> RimFishbonesCollection::activeFishbonesSubs() const
//--------------------------------------------------------------------------------------------------
std::vector<RimFishbones*> RimFishbonesCollection::allFishbonesSubs() const
{
return m_fishbones.children();
return m_fishbones.childrenByType();
}
//--------------------------------------------------------------------------------------------------
@@ -161,8 +159,7 @@ std::vector<RimFishbones*> RimFishbonesCollection::allFishbonesSubs() const
//--------------------------------------------------------------------------------------------------
cvf::Color3f RimFishbonesCollection::nextFishbonesColor() const
{
RimWellPath* wellPath;
firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
cvf::Color3ub wellPathColor( wellPath->wellPathColor() );
QColor qWellPathColor = QColor( wellPathColor.r(), wellPathColor.g(), wellPathColor.b() );
@@ -226,7 +223,7 @@ double RimFishbonesCollection::endMD() const
double endMD = m_startMD;
if ( !m_fishbones.empty() )
{
auto lastFishbone = m_fishbones.children().back();
auto lastFishbone = m_fishbones.childrenByType().back();
CVF_ASSERT( lastFishbone );
endMD = lastFishbone->endMD();
}
@@ -238,8 +235,7 @@ double RimFishbonesCollection::endMD() const
//--------------------------------------------------------------------------------------------------
double RimFishbonesCollection::mainBoreDiameter( RiaDefines::EclipseUnitSystem unitSystem ) const
{
RimWellPath* wellPath;
firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_FIELD && unitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
{
return RiaEclipseUnitTools::feetToMeter( m_mainBoreDiameter() );
@@ -256,8 +252,7 @@ double RimFishbonesCollection::mainBoreDiameter( RiaDefines::EclipseUnitSystem u
//--------------------------------------------------------------------------------------------------
void RimFishbonesCollection::setUnitSystemSpecificDefaults()
{
RimWellPath* wellPath;
firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( wellPath )
{
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
@@ -49,8 +49,7 @@ RimFishbonesPipeProperties::~RimFishbonesPipeProperties()
//--------------------------------------------------------------------------------------------------
double RimFishbonesPipeProperties::holeDiameter( RiaDefines::EclipseUnitSystem unitSystem ) const
{
RimWellPath* wellPath;
firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
if ( unitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
{
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
@@ -82,8 +81,7 @@ double RimFishbonesPipeProperties::holeDiameter( RiaDefines::EclipseUnitSystem u
//--------------------------------------------------------------------------------------------------
void RimFishbonesPipeProperties::setUnitSystemSpecificDefaults()
{
RimWellPath* wellPath;
firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( wellPath )
{
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
@@ -102,19 +100,16 @@ void RimFishbonesPipeProperties::setUnitSystemSpecificDefaults()
//--------------------------------------------------------------------------------------------------
void RimFishbonesPipeProperties::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( wellPath )
{
RimWellPath* wellPath;
firstAncestorOrThisOfType( wellPath );
if ( wellPath )
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
{
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
{
m_lateralHoleDiameter.uiCapability()->setUiName( "Hole Diameter [mm]" );
}
else if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
{
m_lateralHoleDiameter.uiCapability()->setUiName( "Hole Diameter [in]" );
}
m_lateralHoleDiameter.uiCapability()->setUiName( "Hole Diameter [mm]" );
}
else if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
{
m_lateralHoleDiameter.uiCapability()->setUiName( "Hole Diameter [in]" );
}
}
@@ -79,9 +79,7 @@ void setDefaultFractureColorResult()
{
for ( Rim3dView* const view : eclCase->views() )
{
std::vector<RimStimPlanColors*> fractureColors;
view->descendantsIncludingThisOfType( fractureColors );
std::vector<RimStimPlanColors*> fractureColors = view->descendantsIncludingThisOfType<RimStimPlanColors>();
for ( RimStimPlanColors* const stimPlanColors : fractureColors )
{
stimPlanColors->setDefaultResultName();
@@ -286,8 +284,7 @@ void RimFracture::fieldChangedByUi( const caf::PdmFieldHandle* changedField, con
{
clearCachedNonDarcyProperties();
RimEclipseCase* eclipseCase = nullptr;
this->firstAncestorOrThisOfType( eclipseCase );
auto eclipseCase = firstAncestorOrThisOfType<RimEclipseCase>();
if ( eclipseCase )
{
RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews( { eclipseCase } );
@@ -179,8 +179,7 @@ void RimFractureContainment::defineUiOrdering( QString uiConfigName, caf::PdmUiO
void RimFractureContainment::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
{
RimProject* proj;
this->firstAncestorOrThisOfType( proj );
RimProject* proj = RimProject::current();
if ( proj )
{
proj->reloadCompletionTypeResultsInAllViews();
@@ -189,8 +188,7 @@ void RimFractureContainment::fieldChangedByUi( const caf::PdmFieldHandle* change
if ( changedField == &m_useContainment || changedField == &m_truncateAtFaults )
{
RimFractureTemplate* fractureTemplate = nullptr;
this->firstAncestorOrThisOfType( fractureTemplate );
auto fractureTemplate = firstAncestorOrThisOfType<RimFractureTemplate>();
if ( fractureTemplate )
{
fractureTemplate->updateConnectedEditors();
@@ -877,10 +877,7 @@ void RimFractureTemplate::loadDataAndUpdateGeometryHasChanged()
//--------------------------------------------------------------------------------------------------
std::vector<RimFracture*> RimFractureTemplate::fracturesUsingThisTemplate() const
{
std::vector<RimFracture*> fractures;
this->objectsWithReferringPtrFieldsOfType( fractures );
return fractures;
return this->objectsWithReferringPtrFieldsOfType<RimFracture>();
}
//--------------------------------------------------------------------------------------------------
@@ -215,9 +215,7 @@ void RimFractureTemplateCollection::createAndAssignTemplateCopyForNonMatchingUni
{
RimFractureTemplate* templateWithMatchingUnit = nullptr;
std::vector<RimFracture*> referringObjects;
fractureTemplate->objectsWithReferringPtrFieldsOfType( referringObjects );
std::vector<RimFracture*> referringObjects = fractureTemplate->objectsWithReferringPtrFieldsOfType<RimFracture>();
for ( auto fracture : referringObjects )
{
if ( fracture && fracture->fractureUnit() != fractureTemplate->fractureTemplateUnit() )
@@ -313,8 +311,7 @@ int RimFractureTemplateCollection::nextFractureTemplateId()
void RimFractureTemplateCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects )
{
RimProject* proj = nullptr;
firstAncestorOrThisOfType( proj );
RimProject* proj = RimProject::current();
if ( proj )
{
proj->scheduleCreateDisplayModelAndRedrawAllViews();
@@ -230,9 +230,7 @@ WellFractureIntersectionData RimMeshFractureTemplate::wellFractureIntersectionDa
const RigFractureGrid* fractureGrid = fractureInstance->fractureGrid();
if ( orientationType() == ALONG_WELL_PATH )
{
RimWellPath* rimWellPath = nullptr;
fractureInstance->firstAncestorOrThisOfType( rimWellPath );
auto rimWellPath = fractureInstance->firstAncestorOrThisOfType<RimWellPath>();
if ( rimWellPath && rimWellPath->wellPathGeometry() )
{
double totalLength = 0.0;
@@ -136,8 +136,7 @@ double RimMswCompletionParameters::manualReferenceMD() const
//--------------------------------------------------------------------------------------------------
double RimMswCompletionParameters::linerDiameter( RiaDefines::EclipseUnitSystem unitSystem ) const
{
RimWellPath* wellPath;
firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
double diameter = m_linerDiameter();
if ( !wellPath->isTopLevelWellPath() && !m_customValuesForLateral )
@@ -176,8 +175,7 @@ double RimMswCompletionParameters::defaultLinerDiameter( RiaDefines::EclipseUnit
//--------------------------------------------------------------------------------------------------
double RimMswCompletionParameters::roughnessFactor( RiaDefines::EclipseUnitSystem unitSystem ) const
{
RimWellPath* wellPath;
firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
double rFactor = m_roughnessFactor();
if ( !wellPath->isTopLevelWellPath() && !m_customValuesForLateral )
@@ -307,8 +305,7 @@ void RimMswCompletionParameters::fieldChangedByUi( const caf::PdmFieldHandle* ch
//--------------------------------------------------------------------------------------------------
void RimMswCompletionParameters::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
RimWellPath* wellPath;
firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
if ( wellPath )
{
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
@@ -366,8 +363,7 @@ void RimMswCompletionParameters::initAfterRead()
//--------------------------------------------------------------------------------------------------
void RimMswCompletionParameters::setUnitSystemSpecificDefaults()
{
RimWellPath* wellPath;
firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
if ( wellPath )
{
m_linerDiameter = defaultLinerDiameter( wellPath->unitSystem() );
@@ -152,8 +152,7 @@ void RimMultipleValveLocations::computeRangesAndLocations()
{
std::vector<double> validMeasuredDepths;
{
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
double firstWellPathMD = wellPath->startMD();
double lastWellPathMD = wellPath->endMD();
@@ -228,8 +227,7 @@ void RimMultipleValveLocations::applyOffset( double offset )
void RimMultipleValveLocations::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
{
RimWellPath* wellPath;
firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( wellPath )
{
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
@@ -329,8 +327,7 @@ void RimMultipleValveLocations::fieldChangedByUi( const caf::PdmFieldHandle* cha
{
double minimumDistanceMeter = minimumSpacingMeters();
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
{
double minimumDistanceFeet = RiaEclipseUnitTools::meterToFeet( minimumDistanceMeter );
@@ -349,9 +346,8 @@ void RimMultipleValveLocations::fieldChangedByUi( const caf::PdmFieldHandle* cha
computeRangesAndLocations();
}
RimWellPathComponentInterface* parentCompletion = nullptr;
this->firstAncestorOrThisOfType( parentCompletion );
caf::PdmObject* pdmParent = dynamic_cast<caf::PdmObject*>( parentCompletion );
auto parentCompletion = firstAncestorOrThisOfType<RimWellPathComponentInterface>();
caf::PdmObject* pdmParent = dynamic_cast<caf::PdmObject*>( parentCompletion );
if ( recomputeLocations || changedField == &m_locationOfValves )
{
@@ -405,9 +401,7 @@ double RimMultipleValveLocations::minimumSpacingMeters() const
//--------------------------------------------------------------------------------------------------
double RimMultipleValveLocations::perforationStartMD() const
{
const RimPerforationInterval* perfInterval = nullptr;
this->firstAncestorOrThisOfType( perfInterval );
const RimPerforationInterval* perfInterval = firstAncestorOrThisOfType<RimPerforationInterval>();
if ( perfInterval )
{
return perfInterval->startMD();
@@ -420,16 +414,13 @@ double RimMultipleValveLocations::perforationStartMD() const
//--------------------------------------------------------------------------------------------------
double RimMultipleValveLocations::perforationEndMD() const
{
const RimPerforationInterval* perfInterval = nullptr;
this->firstAncestorOrThisOfType( perfInterval );
const RimPerforationInterval* perfInterval = firstAncestorOrThisOfType<RimPerforationInterval>();
if ( perfInterval )
{
return perfInterval->endMD();
}
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
return wellPath->endMD();
}
@@ -88,8 +88,7 @@ void RimPerforationCollection::appendPerforation( RimPerforationInterval* perfor
Rim3dView* activeView = RiaApplication::instance()->activeReservoirView();
if ( activeView )
{
RimEclipseCase* eclipseCase = nullptr;
activeView->firstAncestorOrThisOfType( eclipseCase );
auto eclipseCase = activeView->firstAncestorOrThisOfType<RimEclipseCase>();
if ( eclipseCase )
{
auto dates = eclipseCase->timeStepDates();
@@ -117,8 +116,7 @@ void RimPerforationCollection::appendPerforation( RimPerforationInterval* perfor
updateConnectedEditors();
Riu3DMainWindowTools::selectAsCurrentItem( perforation );
RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted( proj );
RimProject* proj = RimProject::current();
proj->reloadCompletionTypeResultsInAllViews();
}
@@ -184,8 +182,7 @@ void RimPerforationCollection::defineUiOrdering( QString uiConfigName, caf::PdmU
//--------------------------------------------------------------------------------------------------
void RimPerforationCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted( proj );
RimProject* proj = RimProject::current();
if ( changedField == &m_isChecked )
{
proj->reloadCompletionTypeResultsInAllViews();
@@ -136,8 +136,7 @@ void RimPerforationInterval::setSkinFactor( double skinFactor )
//--------------------------------------------------------------------------------------------------
double RimPerforationInterval::diameter( RiaDefines::EclipseUnitSystem unitSystem ) const
{
RimWellPath* wellPath;
firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
if ( unitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC && wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
{
return RiaEclipseUnitTools::feetToMeter( m_diameter() );
@@ -177,8 +176,7 @@ cvf::BoundingBox RimPerforationInterval::boundingBoxInDomainCoords() const
{
cvf::BoundingBox bb;
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
RigWellPath* rigWellPath = wellPath->wellPathGeometry();
if ( rigWellPath )
@@ -195,8 +193,7 @@ cvf::BoundingBox RimPerforationInterval::boundingBoxInDomainCoords() const
//--------------------------------------------------------------------------------------------------
void RimPerforationInterval::setUnitSystemSpecificDefaults()
{
RimWellPath* wellPath;
firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( wellPath )
{
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
@@ -236,9 +233,7 @@ std::vector<RimWellPathValve*> RimPerforationInterval::valves() const
//--------------------------------------------------------------------------------------------------
void RimPerforationInterval::updateAllReferringTracks()
{
std::vector<RimWellLogTrack*> wellLogTracks;
this->objectsWithReferringPtrFieldsOfType( wellLogTracks );
std::vector<RimWellLogTrack*> wellLogTracks = objectsWithReferringPtrFieldsOfType<RimWellLogTrack>();
for ( RimWellLogTrack* track : wellLogTracks )
{
track->loadDataAndUpdate();
@@ -251,8 +246,7 @@ void RimPerforationInterval::updateAllReferringTracks()
//--------------------------------------------------------------------------------------------------
bool RimPerforationInterval::isEnabled() const
{
RimPerforationCollection* perforationCollection;
this->firstAncestorOrThisOfTypeAsserted( perforationCollection );
auto perforationCollection = firstAncestorOrThisOfTypeAsserted<RimPerforationCollection>();
return perforationCollection->isChecked() && isChecked();
}
@@ -328,8 +322,7 @@ void RimPerforationInterval::fieldChangedByUi( const caf::PdmFieldHandle* change
this->updateAllReferringTracks();
RimProject* proj = nullptr;
this->firstAncestorOrThisOfTypeAsserted( proj );
RimProject* proj = RimProject::current();
proj->reloadCompletionTypeResultsInAllViews();
}
@@ -347,8 +340,7 @@ void RimPerforationInterval::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTre
void RimPerforationInterval::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
{
RimWellPath* wellPath;
firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( wellPath )
{
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
@@ -401,8 +393,7 @@ void RimPerforationInterval::defineEditorAttribute( const caf::PdmFieldHandle* f
if ( myAttr )
{
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( !wellPath ) return;
myAttr->m_minimum = wellPath->uniqueStartMD();
@@ -186,8 +186,7 @@ void RimSimWellFracture::fieldChangedByUi( const caf::PdmFieldHandle* changedFie
updateAzimuthBasedOnWellAzimuthAngle();
}
RimProject* proj;
this->firstAncestorOrThisOfType( proj );
RimProject* proj = RimProject::current();
if ( proj ) proj->reloadCompletionTypeResultsInAllViews();
}
}
@@ -215,8 +214,7 @@ void RimSimWellFracture::updateFracturePositionFromLocation()
this->setAnchorPosition( interpolated );
RimProject* proj;
this->firstAncestorOrThisOfType( proj );
RimProject* proj = RimProject::current();
if ( proj ) proj->scheduleCreateDisplayModelAndRedrawAllViews();
}
}
@@ -314,9 +312,7 @@ QList<caf::PdmOptionItemInfo> RimSimWellFracture::calculateValueOptions( const c
//--------------------------------------------------------------------------------------------------
RigMainGrid* RimSimWellFracture::ownerCaseMainGrid() const
{
RimEclipseView* ownerEclView;
this->firstAncestorOrThisOfType( ownerEclView );
auto ownerEclView = firstAncestorOrThisOfType<RimEclipseView>();
if ( ownerEclView )
return ownerEclView->mainGrid();
else
@@ -341,10 +337,7 @@ void RimSimWellFracture::computeSimWellBranchCenterLines()
{
m_branchCenterLines.clear();
RimSimWellInView* rimWell = nullptr;
this->firstAncestorOrThisOfType( rimWell );
CVF_ASSERT( rimWell );
auto rimWell = firstAncestorOrThisOfTypeAsserted<RimSimWellInView>();
const auto simWellBranches = RigSimulationWellCenterLineCalculator::calculateWellPipeStaticCenterline( rimWell );
for ( const auto& [coords, wellCells] : simWellBranches )
{
@@ -773,8 +773,7 @@ RimThermalFractureTemplate::FilterCakePressureDrop RimThermalFractureTemplate::f
//--------------------------------------------------------------------------------------------------
bool RimThermalFractureTemplate::placeFractureUsingTemplateData( RimFracture* fracture )
{
RimWellPath* wellPath = nullptr;
fracture->firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPath = fracture->firstAncestorOrThisOfTypeAsserted<RimWellPath>();
auto wellPathGeometry = wellPath->wellPathGeometry();
if ( !wellPathGeometry ) return false;
@@ -788,7 +787,7 @@ bool RimThermalFractureTemplate::placeFractureUsingTemplateData( RimFracture* fr
double md = wellPathGeometry->closestMeasuredDepth( centerPosition );
RiaLogging::info(
QString( "Placing thermal fracture. Posotion: [%1 %2 %3]" ).arg( centerPosition.x() ).arg( centerPosition.y() ).arg( centerPosition.z() ) );
QString( "Placing thermal fracture. Position: [%1 %2 %3]" ).arg( centerPosition.x() ).arg( centerPosition.y() ).arg( centerPosition.z() ) );
RiaLogging::info( QString( "Computed MD: %1" ).arg( md ) );
RimWellPathFracture* wellPathFracture = dynamic_cast<RimWellPathFracture*>( fracture );
@@ -238,8 +238,7 @@ void RimValveTemplate::fieldChangedByUi( const caf::PdmFieldHandle* changedField
}
if ( changedField == &m_type )
{
std::vector<caf::PdmFieldHandle*> referringFields;
this->referringPtrFields( referringFields );
std::vector<caf::PdmFieldHandle*> referringFields = referringPtrFields();
for ( caf::PdmFieldHandle* field : referringFields )
{
RimWellPathValve* valve = dynamic_cast<RimWellPathValve*>( field->ownerObject() );
@@ -81,8 +81,7 @@ RimWellPathAicdParameters::RimWellPathAicdParameters()
QString( "1*" ),
"Viscosity Exponent of Gas Fraction" );
std::vector<caf::PdmFieldHandle*> allFields;
this->fields( allFields );
std::vector<caf::PdmFieldHandle*> allFields = fields();
for ( caf::PdmFieldHandle* field : allFields )
{
caf::PdmField<QString>* stringField = dynamic_cast<caf::PdmField<QString>*>( field );
@@ -226,9 +225,8 @@ void RimWellPathAicdParameters::setUnitLabels()
//--------------------------------------------------------------------------------------------------
bool RimWellPathAicdParameters::isMetric() const
{
bool metric = false;
RimWellPath* wellPath;
firstAncestorOrThisOfType( wellPath );
bool metric = false;
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( wellPath )
{
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
@@ -275,8 +275,7 @@ RimMswCompletionParameters* RimWellPathCompletionSettings::mswCompletionParamete
//--------------------------------------------------------------------------------------------------
void RimWellPathCompletionSettings::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
if ( wellPath->isTopLevelWellPath() )
{
@@ -136,9 +136,7 @@ RimStimPlanModelCollection* RimWellPathCompletions::stimPlanModelCollection() co
//--------------------------------------------------------------------------------------------------
std::vector<RimWellPathValve*> RimWellPathCompletions::valves() const
{
std::vector<RimWellPathValve*> allValves;
this->descendantsIncludingThisOfType( allValves );
return allValves;
return descendantsIncludingThisOfType<RimWellPathValve>();
}
//--------------------------------------------------------------------------------------------------
@@ -287,10 +285,9 @@ void RimWellPathCompletions::initAfterRead()
{
if ( RimProject::current()->isProjectFileVersionEqualOrOlderThan( "2020.10.1.2" ) )
{
std::vector<RimWellPath*> wellPathHierarchy;
this->allAncestorsOrThisOfType( wellPathHierarchy );
RimWellPath* topLevelWellPath = wellPathHierarchy.back();
auto settings = topLevelWellPath->completionSettings();
std::vector<RimWellPath*> wellPathHierarchy = allAncestorsOrThisOfType<RimWellPath>();
RimWellPath* topLevelWellPath = wellPathHierarchy.back();
auto settings = topLevelWellPath->completionSettings();
applyToSettings( settings );
};
@@ -115,8 +115,7 @@ void RimWellPathFracture::updateAzimuthBasedOnWellAzimuthAngle()
//--------------------------------------------------------------------------------------------------
double RimWellPathFracture::wellAzimuthAtFracturePosition() const
{
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( !wellPath ) return cvf::UNDEFINED_DOUBLE;
double wellPathAzimuth = 0.0;
@@ -137,8 +136,7 @@ double RimWellPathFracture::wellAzimuthAtFracturePosition() const
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RimWellPathFracture::computeFractureDirectionNormal() const
{
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( !wellPath ) return cvf::Vec3d::UNDEFINED;
RigWellPath* wellPathGeometry = wellPath->wellPathGeometry();
@@ -184,8 +182,7 @@ std::vector<cvf::Vec3d> RimWellPathFracture::perforationLengthCenterLineCoords()
{
std::vector<cvf::Vec3d> wellPathCoords;
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( wellPath && wellPath->wellPathGeometry() )
{
double startMd = m_measuredDepth - perforationLength() / 2.0;
@@ -206,11 +203,8 @@ bool RimWellPathFracture::compareByWellPathNameAndMD( const RimWellPathFracture*
{
CVF_TIGHT_ASSERT( lhs && rhs );
RimWellPath* lhsWellPath = nullptr;
lhs->firstAncestorOrThisOfType( lhsWellPath );
RimWellPath* rhsWellPath = nullptr;
rhs->firstAncestorOrThisOfType( rhsWellPath );
RimWellPath* lhsWellPath = lhs->firstAncestorOrThisOfType<RimWellPath>();
RimWellPath* rhsWellPath = rhs->firstAncestorOrThisOfType<RimWellPath>();
if ( lhsWellPath && rhsWellPath )
{
@@ -228,8 +222,7 @@ bool RimWellPathFracture::compareByWellPathNameAndMD( const RimWellPathFracture*
//--------------------------------------------------------------------------------------------------
bool RimWellPathFracture::isEnabled() const
{
RimWellPathFractureCollection* fractureCollection = nullptr;
this->firstAncestorOrThisOfTypeAsserted( fractureCollection );
auto fractureCollection = firstAncestorOrThisOfTypeAsserted<RimWellPathFractureCollection>();
return fractureCollection->isChecked() && isChecked();
}
@@ -244,8 +237,7 @@ void RimWellPathFracture::updatePositionFromMeasuredDepth()
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>( this );
if ( !objHandle ) return;
RimWellPath* wellPath = nullptr;
objHandle->firstAncestorOrThisOfType( wellPath );
auto wellPath = objHandle->firstAncestorOrThisOfType<RimWellPath>();
if ( !wellPath ) return;
RigWellPath* wellPathGeometry = wellPath->wellPathGeometry();
@@ -325,8 +317,7 @@ void RimWellPathFracture::defineEditorAttribute( const caf::PdmFieldHandle* fiel
if ( myAttr )
{
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( !wellPath ) return;
myAttr->m_minimum = wellPath->uniqueStartMD();
@@ -85,7 +85,7 @@ void RimWellPathFractureCollection::deleteFractures()
//--------------------------------------------------------------------------------------------------
std::vector<RimWellPathFracture*> RimWellPathFractureCollection::allFractures() const
{
return m_fractures.children();
return m_fractures.childrenByType();
}
//--------------------------------------------------------------------------------------------------
@@ -80,10 +80,9 @@ void RimWellPathValve::perforationIntervalUpdated()
{
if ( componentType() == RiaDefines::WellPathComponentType::ICV )
{
const RimPerforationInterval* perfInterval = nullptr;
this->firstAncestorOrThisOfType( perfInterval );
double startMD = perfInterval->startMD();
double endMD = perfInterval->endMD();
const RimPerforationInterval* perfInterval = firstAncestorOrThisOfType<RimPerforationInterval>();
double startMD = perfInterval->startMD();
double endMD = perfInterval->endMD();
m_measuredDepth = std::clamp( m_measuredDepth(), std::min( startMD, endMD ), std::max( startMD, endMD ) );
}
else if ( componentType() == RiaDefines::WellPathComponentType::ICD || componentType() == RiaDefines::WellPathComponentType::AICD )
@@ -112,8 +111,7 @@ void RimWellPathValve::multipleValveGeometryUpdated()
m_measuredDepth = m_multipleValveLocations->valveLocations().front();
RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted( proj );
RimProject* proj = RimProject::current();
proj->reloadCompletionTypeResultsInAllViews();
}
@@ -263,8 +261,7 @@ double RimWellPathValve::convertOrificeDiameter( double o
//--------------------------------------------------------------------------------------------------
std::vector<std::pair<double, double>> RimWellPathValve::valveSegments() const
{
RimPerforationInterval* perforationInterval = nullptr;
this->firstAncestorOrThisOfType( perforationInterval );
auto perforationInterval = firstAncestorOrThisOfType<RimPerforationInterval>();
std::vector<std::pair<double, double>> segments;
if ( componentType() == RiaDefines::WellPathComponentType::ICV )
@@ -315,8 +312,7 @@ void RimWellPathValve::setComponentTypeFilter( const std::set<RiaDefines::WellPa
//--------------------------------------------------------------------------------------------------
bool RimWellPathValve::isEnabled() const
{
RimPerforationInterval* perforationInterval = nullptr;
this->firstAncestorOrThisOfType( perforationInterval );
auto perforationInterval = firstAncestorOrThisOfType<RimPerforationInterval>();
return perforationInterval->isEnabled() && isChecked();
}
@@ -447,12 +443,10 @@ void RimWellPathValve::templateUpdated()
{
applyValveLabelAndIcon();
RimPerforationInterval* perfInterval;
this->firstAncestorOrThisOfTypeAsserted( perfInterval );
perfInterval->updateAllReferringTracks();
auto perforationInterval = firstAncestorOrThisOfType<RimPerforationInterval>();
perforationInterval->updateAllReferringTracks();
RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted( proj );
RimProject* proj = RimProject::current();
proj->reloadCompletionTypeResultsInAllViews();
}
@@ -463,8 +457,7 @@ QList<caf::PdmOptionItemInfo> RimWellPathValve::calculateValueOptions( const caf
{
QList<caf::PdmOptionItemInfo> options;
RimProject* project = nullptr;
this->firstAncestorOrThisOfTypeAsserted( project );
RimProject* project = RimProject::current();
std::vector<RimValveTemplate*> allTemplates = project->allValveTemplates();
for ( RimValveTemplate* valveTemplate : allTemplates )
@@ -500,15 +493,13 @@ void RimWellPathValve::fieldChangedByUi( const caf::PdmFieldHandle* changedField
Riu3DMainWindowTools::selectAsCurrentItem( m_valveTemplate() );
}
RimPerforationInterval* perfInterval;
this->firstAncestorOrThisOfType( perfInterval );
auto perfInterval = firstAncestorOrThisOfType<RimPerforationInterval>();
if ( perfInterval )
{
perfInterval->updateAllReferringTracks();
}
RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted( proj );
RimProject* proj = RimProject::current();
proj->reloadCompletionTypeResultsInAllViews();
}
@@ -535,8 +526,7 @@ void RimWellPathValve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
{
if ( componentType() == RiaDefines::WellPathComponentType::ICV )
{
RimWellPath* wellPath;
firstAncestorOrThisOfType( wellPath );
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( wellPath )
{
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
@@ -580,9 +570,7 @@ void RimWellPathValve::defineEditorAttribute( const caf::PdmFieldHandle* field,
{
double minimumValue = 0.0, maximumValue = 0.0;
RimPerforationInterval* perforationInterval = nullptr;
this->firstAncestorOrThisOfType( perforationInterval );
auto perforationInterval = firstAncestorOrThisOfType<RimPerforationInterval>();
if ( perforationInterval )
{
minimumValue = perforationInterval->startMD();
@@ -590,8 +578,7 @@ void RimWellPathValve::defineEditorAttribute( const caf::PdmFieldHandle* field,
}
else
{
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
minimumValue = wellPath->startMD();
maximumValue = wellPath->endMD();