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

@@ -181,12 +181,10 @@ void RimWellMeasurement::setFilePath( const QString& filePath )
//--------------------------------------------------------------------------------------------------
void RimWellMeasurement::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted( proj );
RimProject* proj = RimProject::current();
proj->scheduleCreateDisplayModelAndRedrawAllViews();
RimWellMeasurementCollection* wellMeasurementCollection;
this->firstAncestorOrThisOfTypeAsserted( wellMeasurementCollection );
auto wellMeasurementCollection = firstAncestorOrThisOfTypeAsserted<RimWellMeasurementCollection>();
wellMeasurementCollection->updateAllCurves();
}

View File

@@ -62,8 +62,7 @@ void RimWellMeasurementCollection::updateAllCurves()
{
RimMainPlotCollection* plotCollection = RimMainPlotCollection::current();
std::vector<RimWellMeasurementCurve*> measurementCurves;
plotCollection->descendantsIncludingThisOfType( measurementCurves );
std::vector<RimWellMeasurementCurve*> measurementCurves = plotCollection->descendantsIncludingThisOfType<RimWellMeasurementCurve>();
for ( auto curve : measurementCurves )
{
@@ -80,15 +79,13 @@ void RimWellMeasurementCollection::deleteAllEmptyCurves()
{
RimMainPlotCollection* plotCollection = RimMainPlotCollection::current();
std::vector<RimWellMeasurementCurve*> measurementCurves;
plotCollection->descendantsIncludingThisOfType( measurementCurves );
std::vector<RimWellMeasurementCurve*> measurementCurves = plotCollection->descendantsIncludingThisOfType<RimWellMeasurementCurve>();
for ( auto curve : measurementCurves )
{
if ( curve->curveData()->propertyValues().empty() )
{
RimWellLogTrack* track = nullptr;
curve->firstAncestorOrThisOfTypeAsserted( track );
auto track = curve->firstAncestorOrThisOfTypeAsserted<RimWellLogTrack>();
track->removeCurve( curve );
delete curve;

View File

@@ -73,9 +73,7 @@ RimWellMeasurementCurve::~RimWellMeasurementCurve()
//--------------------------------------------------------------------------------------------------
void RimWellMeasurementCurve::onLoadDataAndUpdate( bool updateParentPlot )
{
RimDepthTrackPlot* wellLogPlot;
firstAncestorOrThisOfType( wellLogPlot );
CVF_ASSERT( wellLogPlot );
auto wellLogPlot = firstAncestorOrThisOfTypeAsserted<RimDepthTrackPlot>();
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
if ( m_wellPath && !m_measurementKind().isEmpty() && wellPathCollection )
@@ -257,14 +255,9 @@ QList<caf::PdmOptionItemInfo> RimWellMeasurementCurve::calculateValueOptions( co
}
else if ( fieldNeedingOptions == &m_measurementKind )
{
RimWellPathCollection* wellPathCollection = nullptr;
if ( m_wellPath )
{
m_wellPath->firstAncestorOrThisOfTypeAsserted( wellPathCollection );
}
std::set<QString> kindNames;
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
if ( wellPathCollection )
{
const RimWellMeasurementCollection* measurementCollection = wellPathCollection->measurementCollection();

View File

@@ -171,8 +171,7 @@ void RimWellMeasurementInView::fieldChangedByUi( const caf::PdmFieldHandle* chan
}
updateLegendData();
RimGridView* rimGridView = nullptr;
this->firstAncestorOrThisOfTypeAsserted( rimGridView );
auto rimGridView = firstAncestorOrThisOfTypeAsserted<RimGridView>();
rimGridView->scheduleCreateDisplayModelAndRedraw();
}

View File

@@ -122,8 +122,7 @@ void RimWellMeasurementInViewCollection::fieldChangedByUi( const caf::PdmFieldHa
const QVariant& oldValue,
const QVariant& newValue )
{
RimGridView* rimGridView = nullptr;
this->firstAncestorOrThisOfTypeAsserted( rimGridView );
auto rimGridView = firstAncestorOrThisOfTypeAsserted<RimGridView>();
rimGridView->scheduleCreateDisplayModelAndRedraw();
}