mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
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:
@@ -145,9 +145,8 @@ void RimFlowCharacteristicsPlot::setFromFlowSolution( RimFlowDiagSolution* flowS
|
||||
}
|
||||
else
|
||||
{
|
||||
RimEclipseResultCase* eclCase;
|
||||
flowSolution->firstAncestorOrThisOfType( eclCase );
|
||||
m_case = eclCase;
|
||||
auto eclCase = flowSolution->firstAncestorOrThisOfType<RimEclipseResultCase>();
|
||||
m_case = eclCase;
|
||||
if ( !eclCase->reservoirViews.empty() )
|
||||
{
|
||||
m_cellFilterView = eclCase->reservoirViews()[0];
|
||||
|
||||
@@ -99,9 +99,7 @@ RigFlowDiagResults* RimFlowDiagSolution::flowDiagResults()
|
||||
{
|
||||
size_t timeStepCount;
|
||||
{
|
||||
RimEclipseResultCase* eclCase;
|
||||
this->firstAncestorOrThisOfType( eclCase );
|
||||
|
||||
auto eclCase = firstAncestorOrThisOfType<RimEclipseResultCase>();
|
||||
if ( !eclCase || !eclCase->eclipseCaseData() )
|
||||
{
|
||||
return nullptr;
|
||||
@@ -129,8 +127,7 @@ const RigFlowDiagResults* RimFlowDiagSolution::flowDiagResults() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QString> RimFlowDiagSolution::tracerNames() const
|
||||
{
|
||||
RimEclipseResultCase* eclCase;
|
||||
this->firstAncestorOrThisOfType( eclCase );
|
||||
auto eclCase = firstAncestorOrThisOfType<RimEclipseResultCase>();
|
||||
|
||||
std::vector<QString> tracerNameSet;
|
||||
|
||||
@@ -169,8 +166,7 @@ std::map<std::string, std::vector<int>> RimFlowDiagSolution::allProducerTracerAc
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<std::string, std::vector<int>> RimFlowDiagSolution::allTracerActiveCellIndices( size_t timeStepIndex, bool useInjectors ) const
|
||||
{
|
||||
RimEclipseResultCase* eclCase;
|
||||
this->firstAncestorOrThisOfType( eclCase );
|
||||
auto eclCase = firstAncestorOrThisOfType<RimEclipseResultCase>();
|
||||
|
||||
std::map<std::string, std::vector<int>> tracersWithCells;
|
||||
|
||||
@@ -233,8 +229,7 @@ std::map<std::string, std::vector<int>> RimFlowDiagSolution::allTracerActiveCell
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusOverall( const QString& tracerName ) const
|
||||
{
|
||||
RimEclipseResultCase* eclCase;
|
||||
this->firstAncestorOrThisOfTypeAsserted( eclCase );
|
||||
auto eclCase = firstAncestorOrThisOfTypeAsserted<RimEclipseResultCase>();
|
||||
|
||||
TracerStatusType tracerStatus = TracerStatusType::UNDEFINED;
|
||||
if ( eclCase && eclCase->eclipseCaseData() )
|
||||
@@ -287,9 +282,7 @@ RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusOverall(
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusInTimeStep( const QString& tracerName, size_t timeStepIndex ) const
|
||||
{
|
||||
RimEclipseResultCase* eclCase;
|
||||
this->firstAncestorOrThisOfTypeAsserted( eclCase );
|
||||
|
||||
auto eclCase = firstAncestorOrThisOfTypeAsserted<RimEclipseResultCase>();
|
||||
if ( eclCase && eclCase->eclipseCaseData() )
|
||||
{
|
||||
const cvf::Collection<RigSimWellData>& simWellData = eclCase->eclipseCaseData()->wellResults();
|
||||
@@ -337,9 +330,7 @@ cvf::Color3f RimFlowDiagSolution::tracerColor( const QString& tracerName ) const
|
||||
if ( wellName == RIG_RESERVOIR_TRACER_NAME ) return cvf::Color3f::LIGHT_GRAY;
|
||||
if ( wellName == RIG_TINY_TRACER_GROUP_NAME ) return cvf::Color3f::DARK_GRAY;
|
||||
|
||||
RimEclipseResultCase* eclCase;
|
||||
this->firstAncestorOrThisOfType( eclCase );
|
||||
|
||||
auto eclCase = firstAncestorOrThisOfType<RimEclipseResultCase>();
|
||||
if ( eclCase )
|
||||
{
|
||||
return eclCase->defaultWellColor( wellName );
|
||||
|
||||
@@ -107,8 +107,7 @@ void RimTofAccumulatedPhaseFractionsPlot::reloadFromWell()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseResultCase* RimTofAccumulatedPhaseFractionsPlot::resultCase()
|
||||
{
|
||||
RimWellAllocationPlot* allocationPlot;
|
||||
firstAncestorOrThisOfTypeAsserted( allocationPlot );
|
||||
auto allocationPlot = firstAncestorOrThisOfTypeAsserted<RimWellAllocationPlot>();
|
||||
|
||||
return allocationPlot->rimCase();
|
||||
}
|
||||
@@ -118,8 +117,7 @@ RimEclipseResultCase* RimTofAccumulatedPhaseFractionsPlot::resultCase()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimTofAccumulatedPhaseFractionsPlot::tracerName()
|
||||
{
|
||||
RimWellAllocationPlot* allocationPlot;
|
||||
firstAncestorOrThisOfTypeAsserted( allocationPlot );
|
||||
auto allocationPlot = firstAncestorOrThisOfTypeAsserted<RimWellAllocationPlot>();
|
||||
|
||||
return allocationPlot->wellName();
|
||||
}
|
||||
@@ -129,8 +127,7 @@ QString RimTofAccumulatedPhaseFractionsPlot::tracerName()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RimTofAccumulatedPhaseFractionsPlot::timeStep()
|
||||
{
|
||||
RimWellAllocationPlot* allocationPlot;
|
||||
firstAncestorOrThisOfTypeAsserted( allocationPlot );
|
||||
auto allocationPlot = firstAncestorOrThisOfTypeAsserted<RimWellAllocationPlot>();
|
||||
|
||||
return static_cast<size_t>( allocationPlot->timeStep() );
|
||||
}
|
||||
|
||||
@@ -152,10 +152,8 @@ void RimWellAllocationOverTimePlot::setDescription( const QString& description )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellAllocationOverTimePlot::setFromSimulationWell( RimSimWellInView* simWell )
|
||||
{
|
||||
RimEclipseView* eclView;
|
||||
simWell->firstAncestorOrThisOfType( eclView );
|
||||
RimEclipseResultCase* eclCase;
|
||||
simWell->firstAncestorOrThisOfType( eclCase );
|
||||
auto eclView = simWell->firstAncestorOrThisOfType<RimEclipseView>();
|
||||
auto eclCase = simWell->firstAncestorOrThisOfType<RimEclipseResultCase>();
|
||||
|
||||
m_case = eclCase;
|
||||
m_wellName = simWell->simWellData()->m_wellName;
|
||||
|
||||
@@ -168,10 +168,8 @@ void RimWellAllocationPlot::setFromSimulationWell( RimSimWellInView* simWell )
|
||||
{
|
||||
m_showWindow = true;
|
||||
|
||||
RimEclipseView* eclView;
|
||||
simWell->firstAncestorOrThisOfType( eclView );
|
||||
RimEclipseResultCase* eclCase;
|
||||
simWell->firstAncestorOrThisOfType( eclCase );
|
||||
auto eclView = simWell->firstAncestorOrThisOfType<RimEclipseView>();
|
||||
auto eclCase = simWell->firstAncestorOrThisOfType<RimEclipseResultCase>();
|
||||
|
||||
m_case = eclCase;
|
||||
m_wellName = simWell->simWellData()->m_wellName;
|
||||
@@ -210,9 +208,7 @@ void RimWellAllocationPlot::updateFromWell()
|
||||
|
||||
// Delete existing tracks
|
||||
{
|
||||
std::vector<RimWellLogTrack*> tracks;
|
||||
accumulatedWellFlowPlot()->descendantsIncludingThisOfType( tracks );
|
||||
|
||||
std::vector<RimWellLogTrack*> tracks = accumulatedWellFlowPlot()->descendantsIncludingThisOfType<RimWellLogTrack>();
|
||||
for ( RimWellLogTrack* t : tracks )
|
||||
{
|
||||
for ( auto c : t->curves() )
|
||||
|
||||
@@ -52,8 +52,7 @@ void RimWellAllocationPlotLegend::fieldChangedByUi( const caf::PdmFieldHandle* c
|
||||
{
|
||||
if ( changedField == &m_showLegend )
|
||||
{
|
||||
RimWellAllocationPlot* walp;
|
||||
firstAncestorOrThisOfType( walp );
|
||||
auto walp = firstAncestorOrThisOfType<RimWellAllocationPlot>();
|
||||
|
||||
if ( walp ) walp->showPlotLegend( m_showLegend() );
|
||||
}
|
||||
|
||||
@@ -202,10 +202,8 @@ void RimWellConnectivityTable::setFromSimulationWell( RimSimWellInView* simWell
|
||||
{
|
||||
if ( !simWell ) return;
|
||||
|
||||
RimEclipseView* eclView;
|
||||
simWell->firstAncestorOrThisOfType( eclView );
|
||||
RimEclipseResultCase* eclCase;
|
||||
simWell->firstAncestorOrThisOfType( eclCase );
|
||||
auto eclView = simWell->firstAncestorOrThisOfType<RimEclipseView>();
|
||||
auto eclCase = simWell->firstAncestorOrThisOfType<RimEclipseResultCase>();
|
||||
|
||||
m_cellFilterView = eclView;
|
||||
m_case = eclCase;
|
||||
@@ -665,7 +663,7 @@ QList<caf::PdmOptionItemInfo> RimWellConnectivityTable::calculateValueOptions( c
|
||||
else if ( fieldNeedingOptions == &m_cellFilterView && m_case() )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( "Disabled", nullptr ) );
|
||||
for ( RimEclipseView* view : m_case()->reservoirViews.children() )
|
||||
for ( RimEclipseView* view : m_case()->reservoirViews.childrenByType() )
|
||||
{
|
||||
CVF_ASSERT( view && "Really always should have a valid view pointer in ReservoirViews" );
|
||||
options.push_back( caf::PdmOptionItemInfo( view->name(), view, false, view->uiIconProvider() ) );
|
||||
|
||||
@@ -370,7 +370,7 @@ void RimWellDistributionPlotCollection::updatePlots()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlotCollection::cleanupBeforeClose()
|
||||
{
|
||||
auto plotVector = m_plots.children();
|
||||
auto plotVector = m_plots.childrenByType();
|
||||
for ( size_t tIdx = 0; tIdx < plotVector.size(); ++tIdx )
|
||||
{
|
||||
plotVector[tIdx]->detachAllCurves();
|
||||
|
||||
@@ -165,8 +165,7 @@ void RimWellFlowRateCurve::onLoadDataAndUpdate( bool updateParentPlot )
|
||||
|
||||
if ( updateParentPlot )
|
||||
{
|
||||
RimWellLogTrack* track = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted( track );
|
||||
auto track = firstAncestorOrThisOfTypeAsserted<RimWellLogTrack>();
|
||||
track->updateStackedCurveData();
|
||||
|
||||
updateZoomInParentPlot();
|
||||
@@ -184,8 +183,7 @@ void RimWellFlowRateCurve::updateCurveAppearance()
|
||||
|
||||
bool isLastCurveInGroup = false;
|
||||
{
|
||||
RimWellLogTrack* wellLogTrack;
|
||||
firstAncestorOrThisOfTypeAsserted( wellLogTrack );
|
||||
auto wellLogTrack = firstAncestorOrThisOfTypeAsserted<RimWellLogTrack>();
|
||||
std::map<int, std::vector<RimWellLogCurve*>> stackedCurveGroups = wellLogTrack->visibleStackedCurves();
|
||||
const std::vector<RimWellLogCurve*>& curveGroup = stackedCurveGroups[this->m_groupId];
|
||||
|
||||
@@ -269,8 +267,7 @@ void RimWellFlowRateCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedF
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellFlowRateCurve::isUsingConnectionNumberDepthType() const
|
||||
{
|
||||
RimWellLogPlot* wellLogPlot;
|
||||
firstAncestorOrThisOfType( wellLogPlot );
|
||||
auto wellLogPlot = firstAncestorOrThisOfType<RimWellLogPlot>();
|
||||
if ( wellLogPlot && wellLogPlot->depthType() == RiaDefines::DepthTypeEnum::CONNECTION_NUMBER )
|
||||
{
|
||||
return true;
|
||||
@@ -284,10 +281,7 @@ bool RimWellFlowRateCurve::isUsingConnectionNumberDepthType() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellAllocationPlot* RimWellFlowRateCurve::wellAllocationPlot() const
|
||||
{
|
||||
RimWellAllocationPlot* wap = nullptr;
|
||||
this->firstAncestorOrThisOfType( wap );
|
||||
|
||||
return wap;
|
||||
return firstAncestorOrThisOfType<RimWellAllocationPlot>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -627,9 +627,7 @@ RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve( const RimWellLogCu
|
||||
}
|
||||
else if ( rftSummaryCase != nullptr )
|
||||
{
|
||||
RimSummaryCaseCollection* parentEnsemble = nullptr;
|
||||
|
||||
rftSummaryCase->firstAncestorOrThisOfType( parentEnsemble );
|
||||
RimSummaryCaseCollection* parentEnsemble = rftSummaryCase->firstAncestorOrThisOfType<RimSummaryCaseCollection>();
|
||||
return RiaRftPltCurveDefinition( RifDataSourceForRftPlt( rftSummaryCase, parentEnsemble ), wellName, timeStep );
|
||||
}
|
||||
else if ( rftEnsemble != nullptr )
|
||||
|
||||
@@ -184,8 +184,7 @@ void RimWellRftEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* ch
|
||||
{
|
||||
if ( changedField == &m_ensembleColorMode || changedField == &m_ensembleParameter )
|
||||
{
|
||||
RimWellRftPlot* rftPlot = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted( rftPlot );
|
||||
RimWellRftPlot* rftPlot = firstAncestorOrThisOfTypeAsserted<RimWellRftPlot>();
|
||||
rftPlot->syncCurvesFromUiSelection();
|
||||
rftPlot->updateConnectedEditors();
|
||||
}
|
||||
|
||||
@@ -121,11 +121,6 @@ RimWellRftPlot::RimWellRftPlot()
|
||||
m_selectedTimeSteps.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
m_selectedTimeSteps.uiCapability()->setAutoAddingOptionFromValue( false );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_wellPathCollection, "WellPathCollection", "Well Path Collection" );
|
||||
m_wellPathCollection.uiCapability()->setUiHidden( true );
|
||||
m_wellPathCollection.xmlCapability()->disableIO();
|
||||
m_wellPathCollection = RimProject::current()->activeOilField()->wellPathCollection();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_ensembleCurveSets, "EnsembleCurveSets", "Ensemble Curve Sets" );
|
||||
|
||||
// TODO: may want to support TRUE_VERTICAL_DEPTH_RKB in the future
|
||||
@@ -848,9 +843,8 @@ QList<caf::PdmOptionItemInfo> RimWellRftPlot::calculateValueOptionsForSources()
|
||||
{
|
||||
if ( summaryCase->rftReader() && summaryCase->rftReader()->wellNames().contains( m_wellPathNameOrSimWellName ) )
|
||||
{
|
||||
RimSummaryCaseCollection* parentEnsemble = nullptr;
|
||||
summaryCase->firstAncestorOrThisOfType( parentEnsemble );
|
||||
auto addr = RifDataSourceForRftPlt( summaryCase, parentEnsemble );
|
||||
auto parentEnsemble = summaryCase->firstAncestorOrThisOfType<RimSummaryCaseCollection>();
|
||||
auto addr = RifDataSourceForRftPlt( summaryCase, parentEnsemble );
|
||||
|
||||
auto item = caf::PdmOptionItemInfo( summaryCase->displayCaseName(), QVariant::fromValue( addr ) );
|
||||
item.setLevel( 1 );
|
||||
|
||||
@@ -153,8 +153,6 @@ private:
|
||||
caf::PdmField<std::vector<RifDataSourceForRftPlt>> m_selectedSources;
|
||||
caf::PdmField<std::vector<QDateTime>> m_selectedTimeSteps;
|
||||
|
||||
caf::PdmPtrField<RimWellPathCollection*> m_wellPathCollection;
|
||||
|
||||
caf::PdmChildArrayField<RimWellRftEnsembleCurveSet*> m_ensembleCurveSets;
|
||||
std::map<RimWellRftEnsembleCurveSet*, QPointer<RiuDraggableOverlayFrame>> m_ensembleLegendFrames;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user