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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
510 changed files with 1651 additions and 3111 deletions

View File

@ -568,8 +568,8 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
oilField->fractureDefinitionCollection()->createAndAssignTemplateCopyForNonMatchingUnit(); oilField->fractureDefinitionCollection()->createAndAssignTemplateCopyForNonMatchingUnit();
{ {
std::vector<RimWellPathFracture*> wellPathFractures; std::vector<RimWellPathFracture*> wellPathFractures =
oilField->wellPathCollection->descendantsIncludingThisOfType( wellPathFractures ); oilField->wellPathCollection->descendantsIncludingThisOfType<RimWellPathFracture>();
for ( auto fracture : wellPathFractures ) for ( auto fracture : wellPathFractures )
{ {
@ -627,8 +627,7 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
if ( m_project->isProjectFileVersionEqualOrOlderThan( "2018.1.0.103" ) ) if ( m_project->isProjectFileVersionEqualOrOlderThan( "2018.1.0.103" ) )
{ {
std::vector<RimStimPlanColors*> stimPlanColors; std::vector<RimStimPlanColors*> stimPlanColors = riv->descendantsIncludingThisOfType<RimStimPlanColors>();
riv->descendantsIncludingThisOfType( stimPlanColors );
if ( stimPlanColors.size() == 1 ) if ( stimPlanColors.size() == 1 )
{ {
stimPlanColors[0]->updateConductivityResultName(); stimPlanColors[0]->updateConductivityResultName();

View File

@ -81,6 +81,7 @@
#include "RimSummaryPlot.h" #include "RimSummaryPlot.h"
#include "RimTextAnnotation.h" #include "RimTextAnnotation.h"
#include "RimTextAnnotationInView.h" #include "RimTextAnnotationInView.h"
#include "RimTools.h"
#include "RimViewLinker.h" #include "RimViewLinker.h"
#include "RimViewLinkerCollection.h" #include "RimViewLinkerCollection.h"
#include "RimWellLogFile.h" #include "RimWellLogFile.h"
@ -1375,10 +1376,9 @@ void RiaGuiApplication::applyGuiPreferences( const RiaPreferences*
if ( this->project() ) if ( this->project() )
{ {
std::vector<RimViewWindow*> allViewWindows; std::vector<RimViewWindow*> allViewWindows = project()->descendantsIncludingThisOfType<RimViewWindow>();
project()->descendantsIncludingThisOfType( allViewWindows );
RimWellPathCollection* wellPathCollection = this->project()->activeOilField()->wellPathCollection(); RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
bool existingViewsWithDifferentMeshLines = false; bool existingViewsWithDifferentMeshLines = false;
bool existingViewsWithCustomColors = false; bool existingViewsWithCustomColors = false;

View File

@ -153,8 +153,7 @@ std::set<RigFemResultAddress> RiaMemoryCleanup::findGeoMechCaseResultsInUse() co
auto geoMechCase = dynamic_cast<RimGeoMechCase*>( m_case() ); auto geoMechCase = dynamic_cast<RimGeoMechCase*>( m_case() );
if ( geoMechCase ) if ( geoMechCase )
{ {
std::vector<RimFemResultObserver*> geoMechResults; std::vector<RimFemResultObserver*> geoMechResults = geoMechCase->descendantsIncludingThisOfType<RimFemResultObserver>();
geoMechCase->descendantsIncludingThisOfType( geoMechResults );
for ( RimFemResultObserver* resultDef : geoMechResults ) for ( RimFemResultObserver* resultDef : geoMechResults )
{ {
auto pdmObj = dynamic_cast<caf::PdmObject*>( resultDef ); auto pdmObj = dynamic_cast<caf::PdmObject*>( resultDef );
@ -181,8 +180,7 @@ std::set<RigEclipseResultAddress> RiaMemoryCleanup::findEclipseResultsInUse() co
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( m_case() ); RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( m_case() );
if ( eclipseCase ) if ( eclipseCase )
{ {
std::vector<RimEclipseResultDefinition*> eclipseResultDefs; auto eclipseResultDefs = eclipseCase->descendantsIncludingThisOfType<RimEclipseResultDefinition>();
eclipseCase->descendantsIncludingThisOfType( eclipseResultDefs );
for ( RimEclipseResultDefinition* resultDef : eclipseResultDefs ) for ( RimEclipseResultDefinition* resultDef : eclipseResultDefs )
{ {
RigEclipseResultAddress resultAddr( resultDef->resultType(), resultDef->resultVariable() ); RigEclipseResultAddress resultAddr( resultDef->resultType(), resultDef->resultVariable() );

View File

@ -265,8 +265,7 @@ QString RiaEnsembleNameTools::uniqueShortNameForSummaryCase( RimSummaryCase* sum
{ {
std::set<QString> allAutoShortNames; std::set<QString> allAutoShortNames;
std::vector<RimSummaryCase*> allCases; std::vector<RimSummaryCase*> allCases = RimProject::current()->descendantsOfType<RimSummaryCase>();
RimProject::current()->descendantsOfType( allCases );
for ( auto sumCase : allCases ) for ( auto sumCase : allCases )
{ {

View File

@ -60,8 +60,7 @@ RigEclipseWellLogExtractor* RiaExtractionTools::findOrCreateSimWellExtractor( co
auto wlPlotCollection = wellLogPlotCollection(); auto wlPlotCollection = wellLogPlotCollection();
if ( !wlPlotCollection ) return nullptr; if ( !wlPlotCollection ) return nullptr;
RimEclipseCase* eclipseCase = nullptr; auto eclipseCase = simWell->firstAncestorOrThisOfType<RimEclipseCase>();
simWell->firstAncestorOrThisOfType( eclipseCase );
if ( !( eclipseCase && eclipseCase->eclipseCaseData() ) ) if ( !( eclipseCase && eclipseCase->eclipseCaseData() ) )
{ {
return nullptr; return nullptr;

View File

@ -123,11 +123,10 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList&
auto existingSummaryCase = sumCaseColl->findTopLevelSummaryCaseFromFileName( newSumCase->summaryHeaderFilename() ); auto existingSummaryCase = sumCaseColl->findTopLevelSummaryCaseFromFileName( newSumCase->summaryHeaderFilename() );
if ( existingSummaryCase ) if ( existingSummaryCase )
{ {
existingSummaryCase->firstAncestorOrThisOfType( existingCollection ); existingCollection = existingSummaryCase->firstAncestorOrThisOfType<RimSummaryCaseCollection>();
// Replace file summary case pointers in Rft Curves // Replace file summary case pointers in Rft Curves
std::vector<RimWellLogRftCurve*> rftCurves; auto rftCurves = existingSummaryCase->objectsWithReferringPtrFieldsOfType<RimWellLogRftCurve>();
existingSummaryCase->objectsWithReferringPtrFieldsOfType( rftCurves );
for ( RimWellLogRftCurve* curve : rftCurves ) for ( RimWellLogRftCurve* curve : rftCurves )
{ {
if ( curve->summaryCase() == existingSummaryCase ) if ( curve->summaryCase() == existingSummaryCase )
@ -138,8 +137,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList&
// Replace all occurrences of file sum with ecl sum // Replace all occurrences of file sum with ecl sum
std::vector<RimSummaryCurve*> objects; auto objects = existingSummaryCase->objectsWithReferringPtrFieldsOfType<RimSummaryCurve>();
existingSummaryCase->objectsWithReferringPtrFieldsOfType( objects );
// UI settings of a curve filter is updated based // UI settings of a curve filter is updated based
// on the new case association for the curves in the curve filter // on the new case association for the curves in the curve filter
@ -158,8 +156,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList&
summaryCurve->setSummaryCaseY( newSumCase ); summaryCurve->setSummaryCaseY( newSumCase );
} }
RimSummaryCurveCollection* parentCollection = nullptr; auto parentCollection = summaryCurve->firstAncestorOrThisOfType<RimSummaryCurveCollection>();
summaryCurve->firstAncestorOrThisOfType( parentCollection );
if ( parentCollection ) if ( parentCollection )
{ {
parentCollection->loadDataAndUpdate( true ); parentCollection->loadDataAndUpdate( true );

View File

@ -44,9 +44,8 @@ void RiaOptionItemFactory::appendOptionItemsForEnsembleCurveSets( QList<caf::Pdm
{ {
options->push_back( caf::PdmOptionItemInfo( "None", nullptr ) ); options->push_back( caf::PdmOptionItemInfo( "None", nullptr ) );
RimMainPlotCollection* mainPlotColl = RimMainPlotCollection::current(); RimMainPlotCollection* mainPlotColl = RimMainPlotCollection::current();
std::vector<RimEnsembleCurveSet*> ensembleCurveSets; std::vector<RimEnsembleCurveSet*> ensembleCurveSets = mainPlotColl->descendantsOfType<RimEnsembleCurveSet>();
mainPlotColl->descendantsOfType( ensembleCurveSets );
for ( auto ensembleCurveSet : ensembleCurveSets ) for ( auto ensembleCurveSet : ensembleCurveSets )
{ {
options->push_back( caf::PdmOptionItemInfo( ensembleCurveSet->name(), ensembleCurveSet ) ); options->push_back( caf::PdmOptionItemInfo( ensembleCurveSet->name(), ensembleCurveSet ) );

View File

@ -127,14 +127,12 @@ RimSummaryPlot* RiaSummaryTools::parentSummaryPlot( caf::PdmObject* object )
return nullptr; return nullptr;
} }
RimSummaryPlot* summaryPlot = nullptr;
if ( object ) if ( object )
{ {
object->firstAncestorOrThisOfType( summaryPlot ); return object->firstAncestorOrThisOfType<RimSummaryPlot>();
} }
return summaryPlot; return nullptr;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -142,14 +140,12 @@ RimSummaryPlot* RiaSummaryTools::parentSummaryPlot( caf::PdmObject* object )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimSummaryMultiPlotCollection* RiaSummaryTools::parentSummaryPlotCollection( caf::PdmObject* object ) RimSummaryMultiPlotCollection* RiaSummaryTools::parentSummaryPlotCollection( caf::PdmObject* object )
{ {
RimSummaryMultiPlotCollection* summaryPlotColl = nullptr;
if ( object ) if ( object )
{ {
object->firstAncestorOrThisOfType( summaryPlotColl ); return object->firstAncestorOrThisOfType<RimSummaryMultiPlotCollection>();
} }
return summaryPlotColl; return nullptr;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -157,14 +153,12 @@ RimSummaryMultiPlotCollection* RiaSummaryTools::parentSummaryPlotCollection( caf
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimSummaryMultiPlot* RiaSummaryTools::parentSummaryMultiPlot( caf::PdmObject* object ) RimSummaryMultiPlot* RiaSummaryTools::parentSummaryMultiPlot( caf::PdmObject* object )
{ {
RimSummaryMultiPlot* multiPlot = nullptr;
if ( object ) if ( object )
{ {
object->firstAncestorOrThisOfType( multiPlot ); return object->firstAncestorOrThisOfType<RimSummaryMultiPlot>();
} }
return multiPlot; return nullptr;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -172,14 +166,12 @@ RimSummaryMultiPlot* RiaSummaryTools::parentSummaryMultiPlot( caf::PdmObject* ob
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimSummaryCrossPlot* RiaSummaryTools::parentCrossPlot( caf::PdmObject* object ) RimSummaryCrossPlot* RiaSummaryTools::parentCrossPlot( caf::PdmObject* object )
{ {
RimSummaryCrossPlot* crossPlot = nullptr;
if ( object ) if ( object )
{ {
object->firstAncestorOrThisOfType( crossPlot ); return object->firstAncestorOrThisOfType<RimSummaryCrossPlot>();
} }
return crossPlot; return nullptr;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -187,14 +179,12 @@ RimSummaryCrossPlot* RiaSummaryTools::parentCrossPlot( caf::PdmObject* object )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimSummaryCrossPlotCollection* RiaSummaryTools::parentCrossPlotCollection( caf::PdmObject* object ) RimSummaryCrossPlotCollection* RiaSummaryTools::parentCrossPlotCollection( caf::PdmObject* object )
{ {
RimSummaryCrossPlotCollection* crossPlotColl = nullptr;
if ( object ) if ( object )
{ {
object->firstAncestorOrThisOfType( crossPlotColl ); return object->firstAncestorOrThisOfType<RimSummaryCrossPlotCollection>();
} }
return crossPlotColl; return nullptr;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -210,14 +200,12 @@ bool RiaSummaryTools::isSummaryCrossPlot( const RimSummaryPlot* plot )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimSummaryTable* RiaSummaryTools::parentSummaryTable( caf::PdmObject* object ) RimSummaryTable* RiaSummaryTools::parentSummaryTable( caf::PdmObject* object )
{ {
RimSummaryTable* summaryTable = nullptr;
if ( object ) if ( object )
{ {
object->firstAncestorOrThisOfType( summaryTable ); return object->firstAncestorOrThisOfType<RimSummaryTable>();
} }
return summaryTable; return nullptr;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -225,14 +213,12 @@ RimSummaryTable* RiaSummaryTools::parentSummaryTable( caf::PdmObject* object )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimSummaryTableCollection* RiaSummaryTools::parentSummaryTableCollection( caf::PdmObject* object ) RimSummaryTableCollection* RiaSummaryTools::parentSummaryTableCollection( caf::PdmObject* object )
{ {
RimSummaryTableCollection* summaryTableColl = nullptr;
if ( object ) if ( object )
{ {
object->firstAncestorOrThisOfType( summaryTableColl ); return object->firstAncestorOrThisOfType<RimSummaryTableCollection>();
} }
return summaryTableColl; return nullptr;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -33,9 +33,8 @@ RicfCloneView::RicfCloneView()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
caf::PdmScriptResponse RicfCloneView::execute() caf::PdmScriptResponse RicfCloneView::execute()
{ {
RimProject* project = RimProject::current(); RimProject* project = RimProject::current();
std::vector<Rim3dView*> allViews; std::vector<Rim3dView*> allViews = project->descendantsIncludingThisOfType<Rim3dView>();
project->descendantsIncludingThisOfType( allViews );
for ( Rim3dView* view : allViews ) for ( Rim3dView* view : allViews )
{ {

View File

@ -59,8 +59,7 @@ caf::PdmScriptResponse RicfCreateStatisticsCase::execute()
{ {
RimProject* project = RimProject::current(); RimProject* project = RimProject::current();
std::vector<RimIdenticalGridCaseGroup*> gridCaseGroups; std::vector<RimIdenticalGridCaseGroup*> gridCaseGroups = project->descendantsIncludingThisOfType<RimIdenticalGridCaseGroup>();
project->descendantsIncludingThisOfType( gridCaseGroups );
for ( auto gridCaseGroup : gridCaseGroups ) for ( auto gridCaseGroup : gridCaseGroups )
{ {
if ( gridCaseGroup->groupId() == m_caseGroupId() ) if ( gridCaseGroup->groupId() == m_caseGroupId() )

View File

@ -64,8 +64,7 @@ caf::PdmScriptResponse RicfCreateWellBoreStabilityPlotFeature::execute()
{ {
RimProject* project = RimProject::current(); RimProject* project = RimProject::current();
std::vector<RimGeoMechCase*> geoMechCases; std::vector<RimGeoMechCase*> geoMechCases = project->descendantsIncludingThisOfType<RimGeoMechCase>();
project->descendantsIncludingThisOfType( geoMechCases );
RimGeoMechCase* chosenCase = nullptr; RimGeoMechCase* chosenCase = nullptr;
for ( RimGeoMechCase* geoMechCase : geoMechCases ) for ( RimGeoMechCase* geoMechCase : geoMechCases )

View File

@ -81,8 +81,7 @@ caf::PdmScriptResponse RicfExportWellLogPlotData::execute()
if ( QFileInfo::exists( m_folder ) ) if ( QFileInfo::exists( m_folder ) )
{ {
std::vector<RimWellLogPlot*> plots; std::vector<RimWellLogPlot*> plots = RimProject::current()->descendantsIncludingThisOfType<RimWellLogPlot>();
RimProject::current()->descendantsIncludingThisOfType( plots );
RicfExportWellLogPlotDataResult* result = new RicfExportWellLogPlotDataResult; RicfExportWellLogPlotDataResult* result = new RicfExportWellLogPlotDataResult;
for ( RimWellLogPlot* plot : plots ) for ( RimWellLogPlot* plot : plots )

View File

@ -28,6 +28,7 @@
#include "RiuPlotMainWindowTools.h" #include "RiuPlotMainWindowTools.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include <QAction> #include <QAction>
@ -38,19 +39,8 @@ CAF_CMD_SOURCE_INIT( RicNewAnalysisPlotFeature, "RicNewAnalysisPlotFeature" );
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicNewAnalysisPlotFeature::isCommandEnabled() bool RicNewAnalysisPlotFeature::isCommandEnabled()
{ {
RimAnalysisPlotCollection* analysisPlotColl = nullptr; if ( caf::firstAncestorOfTypeFromSelectedObject<RimAnalysisPlotCollection>() ) return true;
RimSummaryPlot* summaryPlot = nullptr; if ( caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlot>() ) return true;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( analysisPlotColl );
selObj->firstAncestorOrThisOfType( summaryPlot );
}
if ( analysisPlotColl ) return true;
if ( summaryPlot ) return true;
return false; return false;
} }
@ -60,13 +50,7 @@ bool RicNewAnalysisPlotFeature::isCommandEnabled()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicNewAnalysisPlotFeature::onActionTriggered( bool isChecked ) void RicNewAnalysisPlotFeature::onActionTriggered( bool isChecked )
{ {
RimAnalysisPlotCollection* analysisPlotColl = nullptr; RimAnalysisPlotCollection* analysisPlotColl = caf::firstAncestorOfTypeFromSelectedObject<RimAnalysisPlotCollection>();
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( analysisPlotColl );
}
RimAnalysisPlot* newPlot = nullptr; RimAnalysisPlot* newPlot = nullptr;
if ( !analysisPlotColl ) if ( !analysisPlotColl )
@ -74,8 +58,7 @@ void RicNewAnalysisPlotFeature::onActionTriggered( bool isChecked )
QVariant userData = this->userData(); QVariant userData = this->userData();
if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() ) if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() )
{ {
std::vector<RimAnalysisPlotCollection*> correlationPlotCollections; auto correlationPlotCollections = RimProject::current()->descendantsOfType<RimAnalysisPlotCollection>();
RimProject::current()->descendantsOfType( correlationPlotCollections );
CAF_ASSERT( !correlationPlotCollections.empty() ); CAF_ASSERT( !correlationPlotCollections.empty() );
analysisPlotColl = correlationPlotCollections.front(); analysisPlotColl = correlationPlotCollections.front();

View File

@ -83,12 +83,11 @@ RimAnnotationCollectionBase* RicCreateTextAnnotationFeature::annotationCollectio
auto selColls = caf::selectedObjectsByTypeStrict<RimAnnotationCollectionBase*>(); auto selColls = caf::selectedObjectsByTypeStrict<RimAnnotationCollectionBase*>();
if ( selColls.size() == 1 ) return selColls.front(); if ( selColls.size() == 1 ) return selColls.front();
RimAnnotationCollectionBase* coll = nullptr; auto selGroupColl = caf::selectedObjectsByTypeStrict<RimAnnotationGroupCollection*>();
auto selGroupColl = caf::selectedObjectsByTypeStrict<RimAnnotationGroupCollection*>();
if ( selGroupColl.size() == 1 ) if ( selGroupColl.size() == 1 )
{ {
selGroupColl.front()->firstAncestorOrThisOfType( coll ); return selGroupColl.front()->firstAncestorOrThisOfType<RimAnnotationCollectionBase>();
} }
return coll; return nullptr;
} }

View File

@ -45,9 +45,8 @@ bool RicEditPreferencesFeature::isCommandEnabled()
std::vector<caf::FontHolderInterface*> findFontObjects() std::vector<caf::FontHolderInterface*> findFontObjects()
{ {
auto project = RimProject::current(); auto project = RimProject::current();
std::vector<caf::FontHolderInterface*> allFontObjects; std::vector<caf::FontHolderInterface*> allFontObjects = project->descendantsIncludingThisOfType<caf::FontHolderInterface>();
project->descendantsIncludingThisOfType( allFontObjects );
std::vector<caf::FontHolderInterface*> defaultFontObjects; std::vector<caf::FontHolderInterface*> defaultFontObjects;
for ( auto fontObject : allFontObjects ) for ( auto fontObject : allFontObjects )

View File

@ -116,8 +116,7 @@ void RicExportObjectAndFieldKeywordsFeature::exportObjectAndFieldKeywords( const
stream << "\n"; stream << "\n";
std::vector<caf::PdmFieldHandle*> fields; std::vector<caf::PdmFieldHandle*> fields = myClass->fields();
myClass->fields( fields );
for ( auto f : fields ) for ( auto f : fields )
{ {

View File

@ -49,8 +49,7 @@ void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked )
RimCellFilterCollection* filtColl = colls[0]; RimCellFilterCollection* filtColl = colls[0];
// and the case to use // and the case to use
RimCase* sourceCase = nullptr; RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted<RimCase>();
filtColl->firstAncestorOrThisOfTypeAsserted( sourceCase );
RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase ); RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase );
if ( lastCreatedOrUpdated ) if ( lastCreatedOrUpdated )

View File

@ -53,8 +53,7 @@ void RicNewRangeFilterSliceFeature::onActionTriggered( bool isChecked )
RimCellFilterCollection* filtColl = colls[0]; RimCellFilterCollection* filtColl = colls[0];
// and the case to use // and the case to use
RimCase* sourceCase = nullptr; RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted<RimCase>();
filtColl->firstAncestorOrThisOfTypeAsserted( sourceCase );
int gridIndex = 0; int gridIndex = 0;
RimCellFilter* lastCreatedOrUpdated = filtColl->addNewCellRangeFilter( sourceCase, gridIndex, m_sliceDirection ); RimCellFilter* lastCreatedOrUpdated = filtColl->addNewCellRangeFilter( sourceCase, gridIndex, m_sliceDirection );

View File

@ -49,8 +49,7 @@ void RicNewUserDefinedFilterFeature::onActionTriggered( bool isChecked )
RimCellFilterCollection* filtColl = colls[0]; RimCellFilterCollection* filtColl = colls[0];
// and the case to use // and the case to use
RimCase* sourceCase = nullptr; RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted<RimCase>();
filtColl->firstAncestorOrThisOfTypeAsserted( sourceCase );
RimUserDefinedFilter* lastCreatedOrUpdated = filtColl->addNewUserDefinedFilter( sourceCase ); RimUserDefinedFilter* lastCreatedOrUpdated = filtColl->addNewUserDefinedFilter( sourceCase );
if ( lastCreatedOrUpdated ) if ( lastCreatedOrUpdated )

View File

@ -23,6 +23,7 @@
#include "RimProject.h" #include "RimProject.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include "Riu3DMainWindowTools.h" #include "Riu3DMainWindowTools.h"
@ -79,14 +80,5 @@ void RicCopyStandardLegendFeature::setupActionLook( QAction* actionToSetup )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimColorLegend* RicCopyStandardLegendFeature::selectedColorLegend() RimColorLegend* RicCopyStandardLegendFeature::selectedColorLegend()
{ {
caf::PdmObject* selectedObject = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() ); return caf::firstAncestorOfTypeFromSelectedObject<RimColorLegend>();
if ( !selectedObject ) return nullptr;
RimColorLegend* colorLegend = nullptr;
selectedObject->firstAncestorOrThisOfType( colorLegend );
if ( colorLegend ) return colorLegend;
return nullptr;
} }

View File

@ -32,6 +32,7 @@
#include "RiuFileDialogTools.h" #include "RiuFileDialogTools.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include <QAction> #include <QAction>
#include <QFileInfo> #include <QFileInfo>
@ -43,17 +44,7 @@ CAF_CMD_SOURCE_INIT( RicImportColorCategoriesFeature, "RicImportColorCategoriesF
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicImportColorCategoriesFeature::isCommandEnabled() bool RicImportColorCategoriesFeature::isCommandEnabled()
{ {
RimColorLegendCollection* legendCollection = nullptr; return caf::firstAncestorOfTypeFromSelectedObject<RimColorLegendCollection>() != nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( legendCollection );
}
if ( legendCollection ) return true;
return false;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -83,9 +83,7 @@ RimColorLegendCollection* RicInsertColorLegendFeature::selectedColorLegendCollec
if ( !selectedObject ) return nullptr; if ( !selectedObject ) return nullptr;
RimColorLegendCollection* colorLegendCollection = nullptr; RimColorLegendCollection* colorLegendCollection = selectedObject->firstAncestorOrThisOfType<RimColorLegendCollection>();
selectedObject->firstAncestorOrThisOfType( colorLegendCollection );
if ( colorLegendCollection ) if ( colorLegendCollection )
{ {
// Disable the menu for standard color legends // Disable the menu for standard color legends

View File

@ -26,6 +26,7 @@
#include "Riu3DMainWindowTools.h" #include "Riu3DMainWindowTools.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include <QAction> #include <QAction>
@ -40,9 +41,7 @@ bool RicInsertColorLegendItemFeature::isCommandEnabled()
if ( legend ) if ( legend )
{ {
RimColorLegendCollection* colorLegendCollection = nullptr; RimColorLegendCollection* colorLegendCollection = legend->firstAncestorOrThisOfType<RimColorLegendCollection>();
legend->firstAncestorOrThisOfType( colorLegendCollection );
if ( colorLegendCollection && !colorLegendCollection->isStandardColorLegend( legend ) ) return true; if ( colorLegendCollection && !colorLegendCollection->isStandardColorLegend( legend ) ) return true;
} }
@ -88,15 +87,5 @@ void RicInsertColorLegendItemFeature::setupActionLook( QAction* actionToSetup )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimColorLegend* RicInsertColorLegendItemFeature::selectedColorLegend() RimColorLegend* RicInsertColorLegendItemFeature::selectedColorLegend()
{ {
caf::PdmObject* selectedObject = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() ); return caf::firstAncestorOfTypeFromSelectedObject<RimColorLegend>();
if ( !selectedObject ) return nullptr;
RimColorLegend* colorLegend = nullptr;
selectedObject->firstAncestorOrThisOfType( colorLegend );
if ( colorLegend ) return colorLegend;
return nullptr;
} }

View File

@ -49,10 +49,8 @@ void RicDeleteValveTemplateFeature::onActionTriggered( bool isChecked )
if ( valveTemplate ) if ( valveTemplate )
{ {
RimProject* project = nullptr; RimProject* project = RimProject::current();
valveTemplate->firstAncestorOrThisOfTypeAsserted( project ); std::vector<RimWellPathValve*> valves = project->descendantsIncludingThisOfType<RimWellPathValve>();
std::vector<RimWellPathValve*> valves;
project->descendantsIncludingThisOfType( valves );
for ( RimWellPathValve* valve : valves ) for ( RimWellPathValve* valve : valves )
{ {
if ( valve->valveTemplate() == valveTemplate ) if ( valve->valveTemplate() == valveTemplate )
@ -62,8 +60,7 @@ void RicDeleteValveTemplateFeature::onActionTriggered( bool isChecked )
} }
} }
RimValveTemplateCollection* collection = nullptr; RimValveTemplateCollection* collection = valveTemplate->firstAncestorOrThisOfTypeAsserted<RimValveTemplateCollection>();
valveTemplate->firstAncestorOrThisOfTypeAsserted( collection );
collection->removeAndDeleteValveTemplate( valveTemplate ); collection->removeAndDeleteValveTemplate( valveTemplate );
collection->updateAllRequiredEditors(); collection->updateAllRequiredEditors();

View File

@ -50,8 +50,7 @@ void RicEditPerforationCollectionFeature::onActionTriggered( bool isChecked )
if ( perforationCollection == nullptr ) return; if ( perforationCollection == nullptr ) return;
RimWellPath* wellPath; RimWellPath* wellPath = perforationCollection->firstAncestorOrThisOfTypeAsserted<RimWellPath>();
perforationCollection->firstAncestorOrThisOfTypeAsserted( wellPath );
if ( !RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem( wellPath ) ) return; if ( !RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem( wellPath ) ) return;
RiuEditPerforationCollectionWidget dlg( nullptr, perforationCollection ); RiuEditPerforationCollectionWidget dlg( nullptr, perforationCollection );
@ -73,15 +72,12 @@ void RicEditPerforationCollectionFeature::setupActionLook( QAction* actionToSetu
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimPerforationCollection* RicEditPerforationCollectionFeature::selectedPerforationCollection() RimPerforationCollection* RicEditPerforationCollectionFeature::selectedPerforationCollection()
{ {
RimPerforationCollection* objToFind = nullptr; caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>( pdmUiItem ); caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>( pdmUiItem );
if ( objHandle ) if ( objHandle )
{ {
objHandle->firstAncestorOrThisOfType( objToFind ); return objHandle->firstAncestorOrThisOfType<RimPerforationCollection>();
} }
return objToFind; return nullptr;
} }

View File

@ -30,6 +30,7 @@
#include "RimWellPath.h" #include "RimWellPath.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include "cafUtils.h" #include "cafUtils.h"
#include "cvfAssert.h" #include "cvfAssert.h"
@ -48,9 +49,7 @@ void RicExportFishbonesLateralsFeature::onActionTriggered( bool isChecked )
RimFishbonesCollection* fishbonesCollection = selectedFishbonesCollection(); RimFishbonesCollection* fishbonesCollection = selectedFishbonesCollection();
CVF_ASSERT( fishbonesCollection ); CVF_ASSERT( fishbonesCollection );
RimWellPath* wellPath = nullptr; auto wellPath = fishbonesCollection->firstAncestorOrThisOfTypeAsserted<RimWellPath>();
fishbonesCollection->firstAncestorOrThisOfType( wellPath );
CVF_ASSERT( wellPath );
auto fileName = caf::Utils::makeValidFileBasename( wellPath->name() ) + "_laterals.dev"; auto fileName = caf::Utils::makeValidFileBasename( wellPath->name() ) + "_laterals.dev";
@ -109,17 +108,7 @@ void RicExportFishbonesLateralsFeature::onActionTriggered( bool isChecked )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimFishbonesCollection* RicExportFishbonesLateralsFeature::selectedFishbonesCollection() RimFishbonesCollection* RicExportFishbonesLateralsFeature::selectedFishbonesCollection()
{ {
RimFishbonesCollection* objToFind = nullptr; return caf::firstAncestorOfTypeFromSelectedObject<RimFishbonesCollection>();
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>( pdmUiItem );
if ( objHandle )
{
objHandle->firstAncestorOrThisOfType( objToFind );
}
return objToFind;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -58,8 +58,7 @@ void RicNewFishbonesSubsAtMeasuredDepthFeature::onActionTriggered( bool isChecke
wellPath->updateConnectedEditors(); wellPath->updateConnectedEditors();
Riu3DMainWindowTools::selectAsCurrentItem( obj ); Riu3DMainWindowTools::selectAsCurrentItem( obj );
RimProject* proj; RimProject* proj = RimProject::current();
wellPath->firstAncestorOrThisOfTypeAsserted( proj );
proj->reloadCompletionTypeResultsInAllViews(); proj->reloadCompletionTypeResultsInAllViews();
} }

View File

@ -40,6 +40,7 @@
#include <QAction> #include <QAction>
#include <QMessageBox> #include <QMessageBox>
#include "RimTools.h"
#include <cmath> #include <cmath>
CAF_CMD_SOURCE_INIT( RicNewFishbonesSubsFeature, "RicNewFishbonesSubsFeature" ); CAF_CMD_SOURCE_INIT( RicNewFishbonesSubsFeature, "RicNewFishbonesSubsFeature" );
@ -52,8 +53,7 @@ void RicNewFishbonesSubsFeature::onActionTriggered( bool isChecked )
RimFishbonesCollection* fishbonesCollection = selectedFishbonesCollection(); RimFishbonesCollection* fishbonesCollection = selectedFishbonesCollection();
CVF_ASSERT( fishbonesCollection ); CVF_ASSERT( fishbonesCollection );
RimWellPath* wellPath; RimWellPath* wellPath = fishbonesCollection->firstAncestorOrThisOfTypeAsserted<RimWellPath>();
fishbonesCollection->firstAncestorOrThisOfTypeAsserted( wellPath );
if ( !RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem( wellPath ) ) return; if ( !RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem( wellPath ) ) return;
RimFishbones* obj = new RimFishbones; RimFishbones* obj = new RimFishbones;
@ -70,8 +70,7 @@ void RicNewFishbonesSubsFeature::onActionTriggered( bool isChecked )
RicNewFishbonesSubsFeature::adjustWellPathScaling( fishbonesCollection ); RicNewFishbonesSubsFeature::adjustWellPathScaling( fishbonesCollection );
RimWellPathCollection* wellPathCollection = nullptr; RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
fishbonesCollection->firstAncestorOrThisOfType( wellPathCollection );
if ( wellPathCollection ) if ( wellPathCollection )
{ {
wellPathCollection->uiCapability()->updateConnectedEditors(); wellPathCollection->uiCapability()->updateConnectedEditors();
@ -79,8 +78,7 @@ void RicNewFishbonesSubsFeature::onActionTriggered( bool isChecked )
RiuMainWindow::instance()->selectAsCurrentItem( obj ); RiuMainWindow::instance()->selectAsCurrentItem( obj );
RimProject* proj; RimProject* proj = RimProject::current();
fishbonesCollection->firstAncestorOrThisOfTypeAsserted( proj );
proj->reloadCompletionTypeResultsInAllViews(); proj->reloadCompletionTypeResultsInAllViews();
} }
@ -100,7 +98,7 @@ RimFishbonesCollection* RicNewFishbonesSubsFeature::selectedFishbonesCollection(
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>( pdmUiItem ); caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>( pdmUiItem );
if ( objHandle ) if ( objHandle )
{ {
objHandle->firstAncestorOrThisOfType( objToFind ); objToFind = objHandle->firstAncestorOrThisOfType<RimFishbonesCollection>();
} }
if ( objToFind == nullptr ) if ( objToFind == nullptr )
@ -149,8 +147,7 @@ bool RicNewFishbonesSubsFeature::isCommandEnabled()
void RicNewFishbonesSubsFeature::adjustWellPathScaling( RimFishbonesCollection* fishboneCollection ) void RicNewFishbonesSubsFeature::adjustWellPathScaling( RimFishbonesCollection* fishboneCollection )
{ {
CVF_ASSERT( fishboneCollection ); CVF_ASSERT( fishboneCollection );
RimWellPathCollection* wellPathColl = nullptr; RimWellPathCollection* wellPathColl = RimTools::wellPathCollection();
fishboneCollection->firstAncestorOrThisOfTypeAsserted( wellPathColl );
if ( wellPathColl->wellPathRadiusScaleFactor > 0.05 ) if ( wellPathColl->wellPathRadiusScaleFactor > 0.05 )
{ {

View File

@ -24,6 +24,7 @@
#include "RimPerforationCollection.h" #include "RimPerforationCollection.h"
#include "RimPerforationInterval.h" #include "RimPerforationInterval.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimTools.h"
#include "RimWellPath.h" #include "RimWellPath.h"
#include "RimWellPathCollection.h" #include "RimWellPathCollection.h"
@ -56,8 +57,7 @@ void RicNewPerforationIntervalAtMeasuredDepthFeature::onActionTriggered( bool is
wellPath->perforationIntervalCollection()->appendPerforation( perforationInterval ); wellPath->perforationIntervalCollection()->appendPerforation( perforationInterval );
RimWellPathCollection* wellPathCollection = nullptr; RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
wellPath->firstAncestorOrThisOfTypeAsserted( wellPathCollection );
wellPathCollection->uiCapability()->updateConnectedEditors(); wellPathCollection->uiCapability()->updateConnectedEditors();
wellPathCollection->scheduleRedrawAffectedViews(); wellPathCollection->scheduleRedrawAffectedViews();

View File

@ -25,6 +25,7 @@
#include "RimPerforationCollection.h" #include "RimPerforationCollection.h"
#include "RimPerforationInterval.h" #include "RimPerforationInterval.h"
#include "RimTools.h"
#include "RimWellPath.h" #include "RimWellPath.h"
#include "RimWellPathCollection.h" #include "RimWellPathCollection.h"
#include "RimWellPathCompletions.h" #include "RimWellPathCompletions.h"
@ -51,8 +52,7 @@ void RicNewPerforationIntervalFeature::onActionTriggered( bool isChecked )
RimPerforationCollection* perforationCollection = selectedPerforationCollection(); RimPerforationCollection* perforationCollection = selectedPerforationCollection();
if ( perforationCollection == nullptr ) return; if ( perforationCollection == nullptr ) return;
RimWellPath* wellPath; RimWellPath* wellPath = perforationCollection->firstAncestorOrThisOfTypeAsserted<RimWellPath>();
perforationCollection->firstAncestorOrThisOfTypeAsserted( wellPath );
if ( !RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem( wellPath ) ) return; if ( !RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem( wellPath ) ) return;
RimPerforationInterval* perforationInterval = new RimPerforationInterval; RimPerforationInterval* perforationInterval = new RimPerforationInterval;
@ -61,8 +61,7 @@ void RicNewPerforationIntervalFeature::onActionTriggered( bool isChecked )
perforationCollection->appendPerforation( perforationInterval ); perforationCollection->appendPerforation( perforationInterval );
RimWellPathCollection* wellPathCollection = nullptr; RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
perforationCollection->firstAncestorOrThisOfType( wellPathCollection );
if ( !wellPathCollection ) return; if ( !wellPathCollection ) return;
wellPathCollection->uiCapability()->updateConnectedEditors(); wellPathCollection->uiCapability()->updateConnectedEditors();
@ -95,7 +94,7 @@ RimPerforationCollection* RicNewPerforationIntervalFeature::selectedPerforationC
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>( pdmUiItem ); caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>( pdmUiItem );
if ( objHandle ) if ( objHandle )
{ {
objHandle->firstAncestorOrThisOfType( perforationCollection ); perforationCollection = objHandle->firstAncestorOrThisOfType<RimPerforationCollection>();
if ( perforationCollection ) return perforationCollection; if ( perforationCollection ) return perforationCollection;

View File

@ -23,6 +23,7 @@
#include "RimPerforationCollection.h" #include "RimPerforationCollection.h"
#include "RimPerforationInterval.h" #include "RimPerforationInterval.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimTools.h"
#include "RimWellPath.h" #include "RimWellPath.h"
#include "RimWellPathCollection.h" #include "RimWellPathCollection.h"
#include "RimWellPathValve.h" #include "RimWellPathValve.h"
@ -57,8 +58,7 @@ void RicNewValveAtMeasuredDepthFeature::onActionTriggered( bool isChecked )
std::vector<RimWellPathValve*> existingValves = perfInterval->valves(); std::vector<RimWellPathValve*> existingValves = perfInterval->valves();
valve->setName( QString( "Valve #%1" ).arg( existingValves.size() + 1 ) ); valve->setName( QString( "Valve #%1" ).arg( existingValves.size() + 1 ) );
RimProject* project; RimProject* project = RimProject::current();
perfInterval->firstAncestorOrThisOfTypeAsserted( project );
std::vector<RimValveTemplate*> allValveTemplates = project->allValveTemplates(); std::vector<RimValveTemplate*> allValveTemplates = project->allValveTemplates();
if ( !allValveTemplates.empty() ) if ( !allValveTemplates.empty() )
@ -68,8 +68,7 @@ void RicNewValveAtMeasuredDepthFeature::onActionTriggered( bool isChecked )
perfInterval->addValve( valve ); perfInterval->addValve( valve );
valve->setMeasuredDepthAndCount( measuredDepth, perfInterval->endMD() - measuredDepth, 1 ); valve->setMeasuredDepthAndCount( measuredDepth, perfInterval->endMD() - measuredDepth, 1 );
RimWellPathCollection* wellPathCollection = nullptr; RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
wellPath->firstAncestorOrThisOfTypeAsserted( wellPathCollection );
wellPathCollection->uiCapability()->updateConnectedEditors(); wellPathCollection->uiCapability()->updateConnectedEditors();
wellPathCollection->scheduleRedrawAffectedViews(); wellPathCollection->scheduleRedrawAffectedViews();

View File

@ -3,6 +3,7 @@
#include "RimPerforationInterval.h" #include "RimPerforationInterval.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimTools.h"
#include "RimWellPathCollection.h" #include "RimWellPathCollection.h"
#include "RimWellPathValve.h" #include "RimWellPathValve.h"
@ -35,8 +36,7 @@ void RicNewValveFeature::onActionTriggered( bool isChecked )
{ {
RimWellPathValve* valve = new RimWellPathValve; RimWellPathValve* valve = new RimWellPathValve;
RimProject* project = nullptr; RimProject* project = RimProject::current();
perfInterval->firstAncestorOrThisOfTypeAsserted( project );
std::vector<RimWellPathValve*> existingValves = perfInterval->valves(); std::vector<RimWellPathValve*> existingValves = perfInterval->valves();
valve->setName( QString( "Valve #%1" ).arg( existingValves.size() + 1 ) ); valve->setName( QString( "Valve #%1" ).arg( existingValves.size() + 1 ) );
@ -50,8 +50,7 @@ void RicNewValveFeature::onActionTriggered( bool isChecked )
perfInterval->addValve( valve ); perfInterval->addValve( valve );
valve->setMeasuredDepthAndCount( perfInterval->startMD(), perfInterval->endMD() - perfInterval->startMD(), 1 ); valve->setMeasuredDepthAndCount( perfInterval->startMD(), perfInterval->endMD() - perfInterval->startMD(), 1 );
RimWellPathCollection* wellPathCollection = nullptr; RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
perfInterval->firstAncestorOrThisOfType( wellPathCollection );
if ( !wellPathCollection ) return; if ( !wellPathCollection ) return;
wellPathCollection->uiCapability()->updateConnectedEditors(); wellPathCollection->uiCapability()->updateConnectedEditors();

View File

@ -42,8 +42,7 @@ void RicNewValveTemplateFeature::selectValveTemplateAndUpdate( RimValveTemplate*
{ {
valveTemplate->loadDataAndUpdate(); valveTemplate->loadDataAndUpdate();
RimValveTemplateCollection* templateCollection = nullptr; RimValveTemplateCollection* templateCollection = valveTemplate->firstAncestorOrThisOfType<RimValveTemplateCollection>();
valveTemplate->firstAncestorOrThisOfType( templateCollection );
if ( templateCollection ) if ( templateCollection )
{ {
templateCollection->updateConnectedEditors(); templateCollection->updateConnectedEditors();

View File

@ -468,10 +468,9 @@ std::map<int, std::vector<std::pair<QString, QString>>> RicExportCompletionDataS
{ {
std::map<int, std::vector<std::pair<QString, QString>>> wellProductionStartStrings; std::map<int, std::vector<std::pair<QString, QString>>> wellProductionStartStrings;
const RimProject* project = nullptr; const RimProject* project = RimProject::current();
if ( caseToApply ) if ( caseToApply )
{ {
caseToApply->firstAncestorOrThisOfTypeAsserted( project );
for ( const RimWellPath* wellPath : project->allWellPaths() ) for ( const RimWellPath* wellPath : project->allWellPaths() )
{ {
int initialWellProductionTimeStep = -1; int initialWellProductionTimeStep = -1;

View File

@ -83,7 +83,7 @@ std::vector<RimWellPath*> RicExportCompletionsForTemporaryLgrsFeature::wellPaths
{ {
std::vector<RimWellPath*> wellPaths; std::vector<RimWellPath*> wellPaths;
auto selectedEclipseCase = caf::firstAncestorOfTypeFromSelectedObject<RimEclipseCase*>(); auto selectedEclipseCase = caf::firstAncestorOfTypeFromSelectedObject<RimEclipseCase>();
if ( selectedEclipseCase ) if ( selectedEclipseCase )
{ {
auto mainGrid = selectedEclipseCase->mainGrid(); auto mainGrid = selectedEclipseCase->mainGrid();

View File

@ -85,8 +85,7 @@ std::vector<RimSimWellInView*> RicExportCompletionsForVisibleSimWellsFeature::vi
if ( !selectedSimWells.empty() ) if ( !selectedSimWells.empty() )
{ {
RimSimWellInViewCollection* parent = nullptr; RimSimWellInViewCollection* parent = selectedSimWells[0]->firstAncestorOrThisOfType<RimSimWellInViewCollection>();
selectedSimWells[0]->firstAncestorOrThisOfType( parent );
if ( parent ) if ( parent )
{ {
simWellCollection.push_back( parent ); simWellCollection.push_back( parent );

View File

@ -45,9 +45,7 @@ bool RicExportCompletionsForVisibleWellPathsFeature::isCommandEnabled()
caf::SelectionManager::instance()->objectsByType( &selectedObjects ); caf::SelectionManager::instance()->objectsByType( &selectedObjects );
for ( caf::PdmObject* object : selectedObjects ) for ( caf::PdmObject* object : selectedObjects )
{ {
RimWellPathCollection* wellPathCollection; RimWellPathCollection* wellPathCollection = object->firstAncestorOrThisOfType<RimWellPathCollection>();
object->firstAncestorOrThisOfType( wellPathCollection );
if ( wellPathCollection ) if ( wellPathCollection )
{ {
foundWellPathCollection = true; foundWellPathCollection = true;
@ -116,8 +114,7 @@ std::vector<RimWellPath*> RicExportCompletionsForVisibleWellPathsFeature::visibl
if ( !selectedWellPaths.empty() ) if ( !selectedWellPaths.empty() )
{ {
RimWellPathCollection* parent = nullptr; RimWellPathCollection* parent = selectedWellPaths[0]->firstAncestorOrThisOfType<RimWellPathCollection>();
selectedWellPaths[0]->firstAncestorOrThisOfType( parent );
if ( parent ) if ( parent )
{ {
wellPathCollections.push_back( parent ); wellPathCollections.push_back( parent );

View File

@ -94,7 +94,8 @@ void RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompl
for ( auto s : simWells ) for ( auto s : simWells )
{ {
s->descendantsIncludingThisOfType( simWellFractures ); auto fratures = s->descendantsIncludingThisOfType<RimSimWellFracture>();
simWellFractures.insert( simWellFractures.end(), fratures.begin(), fratures.end() );
} }
std::vector<RimWellPath*> topLevelWells; std::vector<RimWellPath*> topLevelWells;
@ -127,9 +128,14 @@ void RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompl
for ( auto w : allLaterals ) for ( auto w : allLaterals )
{ {
w->descendantsIncludingThisOfType( wellPathFractures ); auto fractures = w->descendantsIncludingThisOfType<RimWellPathFracture>();
w->descendantsIncludingThisOfType( wellPathFishbones ); wellPathFractures.insert( wellPathFractures.end(), fractures.begin(), fractures.end() );
w->descendantsIncludingThisOfType( wellPathPerforations );
auto fishbones = w->descendantsIncludingThisOfType<RimFishbones>();
wellPathFishbones.insert( wellPathFishbones.end(), fishbones.begin(), fishbones.end() );
auto perforations = w->descendantsIncludingThisOfType<RimPerforationInterval>();
wellPathPerforations.insert( wellPathPerforations.end(), perforations.begin(), perforations.end() );
} }
if ( ( !simWellFractures.empty() ) || ( !wellPathFractures.empty() ) ) if ( ( !simWellFractures.empty() ) || ( !wellPathFractures.empty() ) )
@ -157,7 +163,8 @@ void RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompl
std::vector<const RimWellPathValve*> perforationValves; std::vector<const RimWellPathValve*> perforationValves;
for ( const auto& perf : wellPathPerforations ) for ( const auto& perf : wellPathPerforations )
{ {
perf->descendantsIncludingThisOfType( perforationValves ); auto other = perf->descendantsIncludingThisOfType<const RimWellPathValve>();
perforationValves.insert( perforationValves.end(), other.begin(), other.end() );
} }
if ( !perforationValves.empty() ) if ( !perforationValves.empty() )

View File

@ -1641,15 +1641,13 @@ std::pair<double, cvf::Vec2i>
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimWellPath* RicWellPathExportCompletionDataFeatureImpl::topLevelWellPath( const RigCompletionData& completion ) RimWellPath* RicWellPathExportCompletionDataFeatureImpl::topLevelWellPath( const RigCompletionData& completion )
{ {
RimWellPath* parentWellPath = nullptr;
if ( completion.sourcePdmObject() ) if ( completion.sourcePdmObject() )
{ {
completion.sourcePdmObject()->firstAncestorOrThisOfType( parentWellPath ); auto parentWellPath = completion.sourcePdmObject()->firstAncestorOrThisOfType<RimWellPath>();
} if ( parentWellPath )
{
if ( parentWellPath ) return parentWellPath->topLevelWellPath();
{ }
return parentWellPath->topLevelWellPath();
} }
return nullptr; return nullptr;

View File

@ -1159,9 +1159,7 @@ void RicWellPathExportMswCompletionsImpl::createValveCompletions( gsl::not_null<
{ {
if ( !interval->isChecked() ) continue; if ( !interval->isChecked() ) continue;
std::vector<const RimWellPathValve*> perforationValves; auto perforationValves = interval->descendantsIncludingThisOfType<RimWellPathValve>();
interval->descendantsIncludingThisOfType( perforationValves );
for ( const RimWellPathValve* valve : perforationValves ) for ( const RimWellPathValve* valve : perforationValves )
{ {
if ( !valve->isChecked() ) continue; if ( !valve->isChecked() ) continue;
@ -1306,10 +1304,8 @@ void RicWellPathExportMswCompletionsImpl::assignValveContributionsToSuperICDsOrA
{ {
if ( !interval->isChecked() ) continue; if ( !interval->isChecked() ) continue;
std::vector<const RimWellPathValve*> perforationValves; std::vector<const RimWellPathValve*> perforationValves = interval->descendantsIncludingThisOfType<const RimWellPathValve>();
interval->descendantsIncludingThisOfType( perforationValves ); double totalPerforationLength = 0.0;
double totalPerforationLength = 0.0;
for ( const RimWellPathValve* valve : perforationValves ) for ( const RimWellPathValve* valve : perforationValves )
{ {
if ( !valve->isChecked() ) continue; if ( !valve->isChecked() ) continue;
@ -1409,8 +1405,7 @@ void RicWellPathExportMswCompletionsImpl::moveIntersectionsToICVs( gsl::not_null
{ {
if ( !interval->isChecked() ) continue; if ( !interval->isChecked() ) continue;
std::vector<const RimWellPathValve*> perforationValves; std::vector<const RimWellPathValve*> perforationValves = interval->descendantsIncludingThisOfType<const RimWellPathValve>();
interval->descendantsIncludingThisOfType( perforationValves );
for ( const RimWellPathValve* valve : perforationValves ) for ( const RimWellPathValve* valve : perforationValves )
{ {

View File

@ -552,8 +552,7 @@ QString RicWellPathFractureTextReportFeatureImpl::createFractureInstancesText( c
QString wellName; QString wellName;
RimWellPath* wellPath = nullptr; auto wellPath = fracture->firstAncestorOrThisOfType<RimWellPath>();
fracture->firstAncestorOrThisOfType( wellPath );
if ( wellPath ) if ( wellPath )
{ {
wellName = wellPath->completionSettings()->wellNameForExport(); wellName = wellPath->completionSettings()->wellNameForExport();

View File

@ -29,6 +29,7 @@
#include "RiuPlotMainWindowTools.h" #include "RiuPlotMainWindowTools.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include <QAction> #include <QAction>
@ -39,19 +40,8 @@ CAF_CMD_SOURCE_INIT( RicNewCorrelationMatrixPlotFeature, "RicNewCorrelationMatri
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicNewCorrelationMatrixPlotFeature::isCommandEnabled() bool RicNewCorrelationMatrixPlotFeature::isCommandEnabled()
{ {
RimCorrelationPlotCollection* correlationPlotColl = nullptr; if ( caf::firstAncestorOfTypeFromSelectedObject<RimCorrelationPlotCollection>() ) return true;
RimSummaryPlot* summaryPlot = nullptr; if ( caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlot>() ) return true;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( correlationPlotColl );
selObj->firstAncestorOrThisOfType( summaryPlot );
}
if ( correlationPlotColl ) return true;
if ( summaryPlot ) return true;
return false; return false;
} }
@ -61,13 +51,7 @@ bool RicNewCorrelationMatrixPlotFeature::isCommandEnabled()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicNewCorrelationMatrixPlotFeature::onActionTriggered( bool isChecked ) void RicNewCorrelationMatrixPlotFeature::onActionTriggered( bool isChecked )
{ {
RimCorrelationPlotCollection* correlationPlotColl = nullptr; RimCorrelationPlotCollection* correlationPlotColl = caf::firstAncestorOfTypeFromSelectedObject<RimCorrelationPlotCollection>();
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( correlationPlotColl );
}
RimCorrelationMatrixPlot* newPlot = nullptr; RimCorrelationMatrixPlot* newPlot = nullptr;
if ( !correlationPlotColl ) if ( !correlationPlotColl )
@ -75,8 +59,7 @@ void RicNewCorrelationMatrixPlotFeature::onActionTriggered( bool isChecked )
QVariant userData = this->userData(); QVariant userData = this->userData();
if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() ) if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() )
{ {
std::vector<RimCorrelationPlotCollection*> correlationPlotCollections; auto correlationPlotCollections = RimProject::current()->descendantsOfType<RimCorrelationPlotCollection>();
RimProject::current()->descendantsOfType( correlationPlotCollections );
CAF_ASSERT( !correlationPlotCollections.empty() ); CAF_ASSERT( !correlationPlotCollections.empty() );
correlationPlotColl = correlationPlotCollections.front(); correlationPlotColl = correlationPlotCollections.front();

View File

@ -26,6 +26,7 @@
#include "RiuPlotMainWindowTools.h" #include "RiuPlotMainWindowTools.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include <QAction> #include <QAction>
@ -36,19 +37,8 @@ CAF_CMD_SOURCE_INIT( RicNewCorrelationPlotFeature, "RicNewCorrelationPlotFeature
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicNewCorrelationPlotFeature::isCommandEnabled() bool RicNewCorrelationPlotFeature::isCommandEnabled()
{ {
RimCorrelationPlotCollection* correlationPlotColl = nullptr; if ( caf::firstAncestorOfTypeFromSelectedObject<RimCorrelationPlotCollection>() ) return true;
RimSummaryPlot* summaryPlot = nullptr; if ( caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlot>() ) return true;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( correlationPlotColl );
selObj->firstAncestorOrThisOfType( summaryPlot );
}
if ( correlationPlotColl ) return true;
if ( summaryPlot ) return true;
return false; return false;
} }
@ -58,13 +48,7 @@ bool RicNewCorrelationPlotFeature::isCommandEnabled()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicNewCorrelationPlotFeature::onActionTriggered( bool isChecked ) void RicNewCorrelationPlotFeature::onActionTriggered( bool isChecked )
{ {
RimCorrelationPlotCollection* correlationPlotColl = nullptr; RimCorrelationPlotCollection* correlationPlotColl = caf::firstAncestorOfTypeFromSelectedObject<RimCorrelationPlotCollection>();
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( correlationPlotColl );
}
RimCorrelationPlot* newPlot = nullptr; RimCorrelationPlot* newPlot = nullptr;
if ( !correlationPlotColl ) if ( !correlationPlotColl )
@ -72,8 +56,7 @@ void RicNewCorrelationPlotFeature::onActionTriggered( bool isChecked )
QVariant userData = this->userData(); QVariant userData = this->userData();
if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() ) if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() )
{ {
std::vector<RimCorrelationPlotCollection*> correlationPlotCollections; auto correlationPlotCollections = RimProject::current()->descendantsOfType<RimCorrelationPlotCollection>();
RimProject::current()->descendantsOfType( correlationPlotCollections );
CAF_ASSERT( !correlationPlotCollections.empty() ); CAF_ASSERT( !correlationPlotCollections.empty() );
correlationPlotColl = correlationPlotCollections.front(); correlationPlotColl = correlationPlotCollections.front();

View File

@ -27,6 +27,7 @@
#include "RiuPlotMainWindowTools.h" #include "RiuPlotMainWindowTools.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include <QAction> #include <QAction>
@ -37,19 +38,8 @@ CAF_CMD_SOURCE_INIT( RicNewCorrelationReportPlotFeature, "RicNewCorrelationRepor
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicNewCorrelationReportPlotFeature::isCommandEnabled() bool RicNewCorrelationReportPlotFeature::isCommandEnabled()
{ {
RimCorrelationPlotCollection* correlationPlotColl = nullptr; if ( caf::firstAncestorOfTypeFromSelectedObject<RimCorrelationPlotCollection>() ) return true;
RimSummaryPlot* summaryPlot = nullptr; if ( caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlot>() ) return true;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( correlationPlotColl );
selObj->firstAncestorOrThisOfType( summaryPlot );
}
if ( correlationPlotColl ) return true;
if ( summaryPlot ) return true;
return false; return false;
} }
@ -59,13 +49,7 @@ bool RicNewCorrelationReportPlotFeature::isCommandEnabled()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicNewCorrelationReportPlotFeature::onActionTriggered( bool isChecked ) void RicNewCorrelationReportPlotFeature::onActionTriggered( bool isChecked )
{ {
RimCorrelationPlotCollection* correlationPlotColl = nullptr; RimCorrelationPlotCollection* correlationPlotColl = caf::firstAncestorOfTypeFromSelectedObject<RimCorrelationPlotCollection>();
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( correlationPlotColl );
}
RimCorrelationReportPlot* newPlot = nullptr; RimCorrelationReportPlot* newPlot = nullptr;
if ( !correlationPlotColl ) if ( !correlationPlotColl )
@ -73,8 +57,7 @@ void RicNewCorrelationReportPlotFeature::onActionTriggered( bool isChecked )
QVariant userData = this->userData(); QVariant userData = this->userData();
if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() ) if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() )
{ {
std::vector<RimCorrelationPlotCollection*> correlationPlotCollections; auto correlationPlotCollections = RimProject::current()->descendantsOfType<RimCorrelationPlotCollection>();
RimProject::current()->descendantsOfType( correlationPlotCollections );
CAF_ASSERT( !correlationPlotCollections.empty() ); CAF_ASSERT( !correlationPlotCollections.empty() );
correlationPlotColl = correlationPlotCollections.front(); correlationPlotColl = correlationPlotCollections.front();

View File

@ -28,6 +28,7 @@
#include "RiuPlotMainWindowTools.h" #include "RiuPlotMainWindowTools.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include <QAction> #include <QAction>
@ -38,19 +39,8 @@ CAF_CMD_SOURCE_INIT( RicNewParameterResultCrossPlotFeature, "RicNewParameterResu
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicNewParameterResultCrossPlotFeature::isCommandEnabled() bool RicNewParameterResultCrossPlotFeature::isCommandEnabled()
{ {
RimCorrelationPlotCollection* correlationPlotColl = nullptr; if ( caf::firstAncestorOfTypeFromSelectedObject<RimCorrelationPlotCollection>() ) return true;
RimSummaryPlot* summaryPlot = nullptr; if ( caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlot>() ) return true;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( correlationPlotColl );
selObj->firstAncestorOrThisOfType( summaryPlot );
}
if ( correlationPlotColl ) return true;
if ( summaryPlot ) return true;
return false; return false;
} }
@ -60,13 +50,7 @@ bool RicNewParameterResultCrossPlotFeature::isCommandEnabled()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicNewParameterResultCrossPlotFeature::onActionTriggered( bool isChecked ) void RicNewParameterResultCrossPlotFeature::onActionTriggered( bool isChecked )
{ {
RimCorrelationPlotCollection* correlationPlotColl = nullptr; RimCorrelationPlotCollection* correlationPlotColl = caf::firstAncestorOfTypeFromSelectedObject<RimCorrelationPlotCollection>();
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( correlationPlotColl );
}
RimSummaryCaseCollection* ensemble = nullptr; RimSummaryCaseCollection* ensemble = nullptr;
QString quantityName; QString quantityName;
@ -79,8 +63,7 @@ void RicNewParameterResultCrossPlotFeature::onActionTriggered( bool isChecked )
QVariant userData = this->userData(); QVariant userData = this->userData();
if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() ) if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() )
{ {
std::vector<RimCorrelationPlotCollection*> correlationPlotCollections; auto correlationPlotCollections = RimProject::current()->descendantsOfType<RimCorrelationPlotCollection>();
RimProject::current()->descendantsOfType( correlationPlotCollections );
CAF_ASSERT( !correlationPlotCollections.empty() ); CAF_ASSERT( !correlationPlotCollections.empty() );
correlationPlotColl = correlationPlotCollections.front(); correlationPlotColl = correlationPlotCollections.front();

View File

@ -51,8 +51,7 @@ void RicAppendIntersectionFeature::onActionTriggered( bool isChecked )
caf::SelectionManager::instance()->objectsByType( &collection ); caf::SelectionManager::instance()->objectsByType( &collection );
CVF_ASSERT( collection.size() == 1 ); CVF_ASSERT( collection.size() == 1 );
RimIntersectionCollection* intersectionCollection = nullptr; RimIntersectionCollection* intersectionCollection = collection[0]->firstAncestorOrThisOfType<RimIntersectionCollection>();
collection[0]->firstAncestorOrThisOfType( intersectionCollection );
CVF_ASSERT( intersectionCollection ); CVF_ASSERT( intersectionCollection );
@ -104,8 +103,7 @@ void RicAppendIntersectionFeatureCmd::redo()
intersection->setName( "Intersection" ); intersection->setName( "Intersection" );
m_intersectionCollection->appendIntersectionAndUpdate( intersection ); m_intersectionCollection->appendIntersectionAndUpdate( intersection );
RimGridView* view = nullptr; RimGridView* view = m_intersectionCollection->firstAncestorOrThisOfTypeAsserted<RimGridView>();
m_intersectionCollection->firstAncestorOrThisOfTypeAsserted( view );
RimGeoMechView* geoMechView = nullptr; RimGeoMechView* geoMechView = nullptr;
geoMechView = dynamic_cast<RimGeoMechView*>( view ); geoMechView = dynamic_cast<RimGeoMechView*>( view );

View File

@ -49,8 +49,8 @@ void RicAppendSeparateIntersectionResultFeature::onActionTriggered( bool isCheck
caf::SelectionManager::instance()->objectsByType( &collection ); caf::SelectionManager::instance()->objectsByType( &collection );
CVF_ASSERT( collection.size() == 1 ); CVF_ASSERT( collection.size() == 1 );
RimIntersectionResultsDefinitionCollection* intersectionResCollection = nullptr; RimIntersectionResultsDefinitionCollection* intersectionResCollection =
collection[0]->firstAncestorOrThisOfType( intersectionResCollection ); collection[0]->firstAncestorOrThisOfType<RimIntersectionResultsDefinitionCollection>();
CVF_ASSERT( intersectionResCollection ); CVF_ASSERT( intersectionResCollection );

View File

@ -67,11 +67,7 @@ bool RicCopyIntersectionsToAllViewsInCaseFeature::isCommandEnabled()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicCopyIntersectionsToAllViewsInCaseFeature::onActionTriggered( bool isChecked ) void RicCopyIntersectionsToAllViewsInCaseFeature::onActionTriggered( bool isChecked )
{ {
RimCase* gridCase = nullptr; RimCase* gridCase = caf::firstAncestorOfTypeFromSelectedObject<RimCase>();
std::vector<caf::PdmUiItem*> selItems;
caf::SelectionManager::instance()->selectedItems( selItems );
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>( selItems.front() );
if ( objHandle ) objHandle->firstAncestorOrThisOfType( gridCase );
if ( gridCase ) if ( gridCase )
{ {
@ -117,8 +113,7 @@ void RicCopyIntersectionsToAllViewsInCaseFeature::copyIntersectionsToOtherViews(
for ( Rim3dView* const view : gridCase.views() ) for ( Rim3dView* const view : gridCase.views() )
{ {
RimGridView* currGridView = dynamic_cast<RimGridView*>( view ); RimGridView* currGridView = dynamic_cast<RimGridView*>( view );
RimGridView* parentView = nullptr; RimGridView* parentView = intersection->firstAncestorOrThisOfType<RimGridView>();
intersection->firstAncestorOrThisOfType( parentView );
if ( currGridView && parentView != nullptr && parentView != currGridView ) if ( currGridView && parentView != nullptr && parentView != currGridView )
{ {
@ -149,8 +144,7 @@ void RicCopyIntersectionsToAllViewsInCaseFeature::copyIntersectionBoxesToOtherVi
for ( Rim3dView* const view : gridCase.views() ) for ( Rim3dView* const view : gridCase.views() )
{ {
RimGridView* currGridView = dynamic_cast<RimGridView*>( view ); RimGridView* currGridView = dynamic_cast<RimGridView*>( view );
RimGridView* parentView = nullptr; RimGridView* parentView = intersectionBox->firstAncestorOrThisOfType<RimGridView>();
intersectionBox->firstAncestorOrThisOfType( parentView );
if ( currGridView && parentView != nullptr && parentView != currGridView ) if ( currGridView && parentView != nullptr && parentView != currGridView )
{ {
@ -238,8 +232,7 @@ RimCase* commonGridCase( std::vector<caf::PdmUiItem*> selectedItems )
continue; continue;
} }
RimCase* itemCase = nullptr; RimCase* itemCase = obj->firstAncestorOrThisOfType<RimCase>();
obj->firstAncestorOrThisOfType( itemCase );
if ( gridCase == nullptr ) if ( gridCase == nullptr )
gridCase = itemCase; gridCase = itemCase;

View File

@ -111,9 +111,8 @@ void RicNewAzimuthDipIntersectionFeatureCmd::redo()
intersection->setName( "Azimuth and Dip" ); intersection->setName( "Azimuth and Dip" );
intersection->configureForAzimuthLine(); intersection->configureForAzimuthLine();
RimCase* rimCase; RimCase* rimCase = m_intersectionCollection->firstAncestorOrThisOfTypeAsserted<RimCase>();
m_intersectionCollection->firstAncestorOrThisOfTypeAsserted( rimCase ); cvf::BoundingBox bBox = rimCase->allCellsBoundingBox();
cvf::BoundingBox bBox = rimCase->allCellsBoundingBox();
if ( bBox.isValid() ) if ( bBox.isValid() )
{ {
intersection->setLengthUp( cvf::Math::floor( bBox.extent()[2] / 2 ) ); intersection->setLengthUp( cvf::Math::floor( bBox.extent()[2] / 2 ) );

View File

@ -51,9 +51,7 @@ void RicNewSimWellIntersectionFeature::onActionTriggered( bool isChecked )
for ( auto simWell : simWells ) for ( auto simWell : simWells )
{ {
RimEclipseView* eclView = nullptr; RimEclipseView* eclView = simWell->firstAncestorOrThisOfTypeAsserted<RimEclipseView>();
simWell->firstAncestorOrThisOfType( eclView );
CVF_ASSERT( eclView );
auto* cmd = new RicNewSimWellIntersectionCmd( eclView->intersectionCollection(), simWell ); auto* cmd = new RicNewSimWellIntersectionCmd( eclView->intersectionCollection(), simWell );
caf::CmdExecCommandManager::instance()->processExecuteCommand( cmd ); caf::CmdExecCommandManager::instance()->processExecuteCommand( cmd );

View File

@ -114,7 +114,7 @@ RimEclipseCase* RicAddEclipseInputPropertyFeature::getEclipseCase() const
RimEclipseCellColors* cellColors = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseCellColors>(); RimEclipseCellColors* cellColors = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseCellColors>();
if ( cellColors ) if ( cellColors )
{ {
cellColors->firstAncestorOrThisOfType( eclipseCase ); eclipseCase = cellColors->firstAncestorOrThisOfType<RimEclipseCase>();
if ( eclipseCase ) if ( eclipseCase )
{ {
return eclipseCase; return eclipseCase;
@ -124,7 +124,7 @@ RimEclipseCase* RicAddEclipseInputPropertyFeature::getEclipseCase() const
RimEclipseView* eclipseView = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>(); RimEclipseView* eclipseView = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>();
if ( eclipseView ) if ( eclipseView )
{ {
eclipseView->firstAncestorOrThisOfType( eclipseCase ); eclipseCase = eclipseView->firstAncestorOrThisOfType<RimEclipseCase>();
if ( eclipseCase ) if ( eclipseCase )
{ {
return eclipseCase; return eclipseCase;

View File

@ -76,8 +76,7 @@ void RicApplyPropertyFilterAsCellResultFeature::onActionTriggered( bool isChecke
RimEclipsePropertyFilter* propertyFilter = objects[0]; RimEclipsePropertyFilter* propertyFilter = objects[0];
if ( !propertyFilter ) return; if ( !propertyFilter ) return;
RimEclipseView* rimEclipseView = nullptr; RimEclipseView* rimEclipseView = propertyFilter->firstAncestorOrThisOfType<RimEclipseView>();
propertyFilter->firstAncestorOrThisOfType( rimEclipseView );
if ( !rimEclipseView ) return; if ( !rimEclipseView ) return;
rimEclipseView->cellResult()->simpleCopy( propertyFilter->resultDefinition() ); rimEclipseView->cellResult()->simpleCopy( propertyFilter->resultDefinition() );
@ -98,8 +97,7 @@ void RicApplyPropertyFilterAsCellResultFeature::onActionTriggered( bool isChecke
RimGeoMechPropertyFilter* propertyFilter = objects[0]; RimGeoMechPropertyFilter* propertyFilter = objects[0];
if ( !propertyFilter ) return; if ( !propertyFilter ) return;
RimGeoMechView* geoMechView = nullptr; RimGeoMechView* geoMechView = propertyFilter->firstAncestorOrThisOfType<RimGeoMechView>();
propertyFilter->firstAncestorOrThisOfType( geoMechView );
if ( !geoMechView ) return; if ( !geoMechView ) return;
geoMechView->cellResultResultDefinition()->setResultAddress( propertyFilter->resultDefinition()->resultAddress() ); geoMechView->cellResultResultDefinition()->setResultAddress( propertyFilter->resultDefinition()->resultAddress() );

View File

@ -43,8 +43,7 @@ bool RicComputeStatisticsFeature::isCommandEnabled()
RimEclipseStatisticsCase* statisticsCase = selection[0]; RimEclipseStatisticsCase* statisticsCase = selection[0];
if ( statisticsCase ) if ( statisticsCase )
{ {
RimIdenticalGridCaseGroup* gridCaseGroup = nullptr; RimIdenticalGridCaseGroup* gridCaseGroup = statisticsCase->firstAncestorOrThisOfType<RimIdenticalGridCaseGroup>();
statisticsCase->firstAncestorOrThisOfType( gridCaseGroup );
RimCaseCollection* caseCollection = gridCaseGroup ? gridCaseGroup->caseCollection() : nullptr; RimCaseCollection* caseCollection = gridCaseGroup ? gridCaseGroup->caseCollection() : nullptr;
return caseCollection ? caseCollection->reservoirs.size() > 0 : false; return caseCollection ? caseCollection->reservoirs.size() > 0 : false;

View File

@ -94,8 +94,7 @@ void RicEclipsePropertyFilterFeatureImpl::insertPropertyFilter( RimEclipseProper
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicEclipsePropertyFilterFeatureImpl::isPropertyFilterCommandAvailable( caf::PdmObjectHandle* object ) bool RicEclipsePropertyFilterFeatureImpl::isPropertyFilterCommandAvailable( caf::PdmObjectHandle* object )
{ {
Rim3dView* rimView = nullptr; auto rimView = object->firstAncestorOrThisOfType<Rim3dView>();
object->firstAncestorOrThisOfType( rimView );
if ( rimView ) if ( rimView )
{ {
RimViewController* vc = rimView->viewController(); RimViewController* vc = rimView->viewController();
@ -115,11 +114,7 @@ void RicEclipsePropertyFilterFeatureImpl::setDefaults( RimEclipsePropertyFilter*
{ {
CVF_ASSERT( propertyFilter ); CVF_ASSERT( propertyFilter );
RimEclipsePropertyFilterCollection* propertyFilterCollection = nullptr; auto reservoirView = propertyFilter->firstAncestorOrThisOfTypeAsserted<RimEclipseView>();
propertyFilter->firstAncestorOrThisOfTypeAsserted( propertyFilterCollection );
RimEclipseView* reservoirView = nullptr;
propertyFilter->firstAncestorOrThisOfTypeAsserted( reservoirView );
propertyFilter->resultDefinition()->setEclipseCase( reservoirView->eclipseCase() ); propertyFilter->resultDefinition()->setEclipseCase( reservoirView->eclipseCase() );

View File

@ -56,8 +56,8 @@ QString RicEclipsePropertyFilterInsertExec::name()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicEclipsePropertyFilterInsertExec::redo() void RicEclipsePropertyFilterInsertExec::redo()
{ {
RimEclipsePropertyFilterCollection* propertyFilterCollection = nullptr; RimEclipsePropertyFilterCollection* propertyFilterCollection =
m_propertyFilter->firstAncestorOrThisOfTypeAsserted( propertyFilterCollection ); m_propertyFilter->firstAncestorOrThisOfTypeAsserted<RimEclipsePropertyFilterCollection>();
size_t index = propertyFilterCollection->propertyFiltersField().indexOf( m_propertyFilter ); size_t index = propertyFilterCollection->propertyFiltersField().indexOf( m_propertyFilter );
CVF_ASSERT( index < propertyFilterCollection->propertyFilters().size() ); CVF_ASSERT( index < propertyFilterCollection->propertyFilters().size() );

View File

@ -57,8 +57,7 @@ void RicEclipsePropertyFilterNewExec::redo()
{ {
RicEclipsePropertyFilterFeatureImpl::addPropertyFilter( m_propertyFilterCollection ); RicEclipsePropertyFilterFeatureImpl::addPropertyFilter( m_propertyFilterCollection );
RimGridView* view = nullptr; RimGridView* view = m_propertyFilterCollection->firstAncestorOrThisOfTypeAsserted<RimGridView>();
m_propertyFilterCollection->firstAncestorOrThisOfTypeAsserted( view );
// Enable display of grid cells, to be able to show generated property filter // Enable display of grid cells, to be able to show generated property filter
view->showGridCells( true ); view->showGridCells( true );

View File

@ -76,9 +76,7 @@ void RicEclipseShowOnlyFaultFeature::onActionTriggered( bool isChecked )
if ( !rimFault ) return; if ( !rimFault ) return;
if ( !rimFault->parentField() ) return; if ( !rimFault->parentField() ) return;
std::vector<caf::PdmObjectHandle*> children; std::vector<caf::PdmObjectHandle*> children = rimFault->parentField()->children();
rimFault->parentField()->children( &children );
for ( auto& child : children ) for ( auto& child : children )
{ {
caf::PdmUiObjectHandle* childUiObject = uiObj( child ); caf::PdmUiObjectHandle* childUiObject = uiObj( child );

View File

@ -177,8 +177,7 @@ void RicCellRangeUi::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
} }
// If this object is contained in another object, make sure the other object is updated // If this object is contained in another object, make sure the other object is updated
RicExportCarfinUi* exportCarfin = nullptr; RicExportCarfinUi* exportCarfin = firstAncestorOrThisOfType<RicExportCarfinUi>();
this->firstAncestorOrThisOfType( exportCarfin );
if ( exportCarfin ) if ( exportCarfin )
{ {
exportCarfin->uiCapability()->updateConnectedEditors(); exportCarfin->uiCapability()->updateConnectedEditors();

View File

@ -75,7 +75,7 @@ void RicCreateDepthAdjustedLasFilesFeature::onActionTriggered( bool isChecked )
RimCase* selectedCase = featureUi.selectedCase(); RimCase* selectedCase = featureUi.selectedCase();
RimWellPath* sourceWell = featureUi.sourceWell(); RimWellPath* sourceWell = featureUi.sourceWell();
RimWellLogFile* soureWellLogFile = featureUi.wellLogFile(); RimWellLogFile* soureWellLogFile = featureUi.wellLogFile();
std::vector<RimWellPath*> destinationWells = featureUi.destinationWells().ptrReferencedObjects(); std::vector<RimWellPath*> destinationWells = featureUi.destinationWells().ptrReferencedObjectsByType();
std::vector<QString> selectedResultProperties = featureUi.selectedResultProperties(); std::vector<QString> selectedResultProperties = featureUi.selectedResultProperties();
QString exportFolder = featureUi.exportFolder(); QString exportFolder = featureUi.exportFolder();

View File

@ -78,9 +78,7 @@ void RicExportFaultsFeature::onActionTriggered( bool isChecked )
for ( RimFaultInView* rimFault : selectedFaults ) for ( RimFaultInView* rimFault : selectedFaults )
{ {
RimEclipseCase* eclCase = nullptr; RimEclipseCase* eclCase = rimFault->firstAncestorOrThisOfType<RimEclipseCase>();
rimFault->firstAncestorOrThisOfType( eclCase );
if ( eclCase ) if ( eclCase )
{ {
QString caseName = eclCase->caseUserDescription(); QString caseName = eclCase->caseUserDescription();

View File

@ -834,8 +834,7 @@ std::vector<RimWellPath*> RicExportLgrFeature::selectedWellPaths()
for ( auto completion : selectedCompletions ) for ( auto completion : selectedCompletions )
{ {
RimWellPath* parentWellPath; RimWellPath* parentWellPath = completion->firstAncestorOrThisOfType<RimWellPath>();
completion->firstAncestorOrThisOfType( parentWellPath );
if ( parentWellPath ) wellPaths.push_back( parentWellPath ); if ( parentWellPath ) wellPaths.push_back( parentWellPath );
} }

View File

@ -86,9 +86,7 @@ void RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( const QS
const QString absSnapshotPath = snapshotPath.absolutePath(); const QString absSnapshotPath = snapshotPath.absolutePath();
std::vector<RimViewWindow*> viewWindows; std::vector<RimViewWindow*> viewWindows = RimMainPlotCollection::current()->descendantsIncludingThisOfType<RimViewWindow>();
RimMainPlotCollection::current()->descendantsIncludingThisOfType( viewWindows );
for ( auto viewWindow : viewWindows ) for ( auto viewWindow : viewWindows )
{ {
if ( viewWindow->isMdiWindow() && viewWindow->viewWidget() && ( viewId == -1 || viewId == viewWindow->id() ) ) if ( viewWindow->isMdiWindow() && viewWindow->viewWidget() && ( viewId == -1 || viewId == viewWindow->id() ) )

View File

@ -45,7 +45,7 @@ void RicSelectViewUI::setView( RimEclipseView* currentView )
{ {
m_currentView = currentView; m_currentView = currentView;
m_currentView->firstAncestorOrThisOfTypeAsserted( m_currentCase ); m_currentCase = m_currentView->firstAncestorOrThisOfTypeAsserted<RimEclipseResultCase>();
m_selectedView = m_currentView; m_selectedView = m_currentView;
} }

View File

@ -45,17 +45,14 @@ bool RicShowContributingWellsFeature::isCommandEnabled()
if ( collection.size() == 1 ) if ( collection.size() == 1 )
{ {
RimSimWellInView* well = collection[0]; RimSimWellInView* well = collection[0];
RimEclipseView* eclipseView = nullptr; RimEclipseView* eclipseView = well->firstAncestorOrThisOfType<RimEclipseView>();
well->firstAncestorOrThisOfType( eclipseView );
if ( eclipseView ) if ( eclipseView )
{ {
RimFlowDiagSolution* flowDiagSolution = eclipseView->cellResult()->flowDiagSolution(); RimFlowDiagSolution* flowDiagSolution = eclipseView->cellResult()->flowDiagSolution();
if ( !flowDiagSolution ) if ( !flowDiagSolution )
{ {
RimEclipseResultCase* eclipseResultCase = nullptr; RimEclipseResultCase* eclipseResultCase = well->firstAncestorOrThisOfType<RimEclipseResultCase>();
well->firstAncestorOrThisOfType( eclipseResultCase );
if ( eclipseResultCase ) if ( eclipseResultCase )
{ {
flowDiagSolution = eclipseResultCase->defaultFlowDiagSolution(); flowDiagSolution = eclipseResultCase->defaultFlowDiagSolution();
@ -83,11 +80,9 @@ void RicShowContributingWellsFeature::onActionTriggered( bool isChecked )
CAF_ASSERT( collection.size() == 1 ); CAF_ASSERT( collection.size() == 1 );
RimSimWellInView* well = collection[0]; RimSimWellInView* well = collection[0];
RimEclipseView* eclipseView = nullptr; RimEclipseView* eclipseView = well->firstAncestorOrThisOfTypeAsserted<RimEclipseView>();
well->firstAncestorOrThisOfTypeAsserted( eclipseView );
RimEclipseResultCase* eclipseResultCase = nullptr; RimEclipseResultCase* eclipseResultCase = well->firstAncestorOrThisOfTypeAsserted<RimEclipseResultCase>();
well->firstAncestorOrThisOfTypeAsserted( eclipseResultCase );
RimEclipseView* modifiedView = RimEclipseView* modifiedView =
RicShowContributingWellsFeatureImpl::manipulateSelectedView( eclipseResultCase, well->name(), eclipseView->currentTimeStep() ); RicShowContributingWellsFeatureImpl::manipulateSelectedView( eclipseResultCase, well->name(), eclipseView->currentTimeStep() );

View File

@ -83,8 +83,7 @@ void RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells( Rim
CVF_ASSERT( selectedWell ); CVF_ASSERT( selectedWell );
if ( !selectedWell ) return; if ( !selectedWell ) return;
RimEclipseResultCase* eclipseResultCase = nullptr; RimEclipseResultCase* eclipseResultCase = selectedWell->firstAncestorOrThisOfTypeAsserted<RimEclipseResultCase>();
selectedWell->firstAncestorOrThisOfTypeAsserted( eclipseResultCase );
// Use the active flow diag solutions, or the first one as default // Use the active flow diag solutions, or the first one as default
RimFlowDiagSolution* flowDiagSolution = viewToModify->cellResult()->flowDiagSolution(); RimFlowDiagSolution* flowDiagSolution = viewToModify->cellResult()->flowDiagSolution();

View File

@ -97,24 +97,20 @@ void RicShowCumulativePhasePlotFeature::setupActionLook( QAction* actionToSetup
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimEclipseResultCase* RicShowCumulativePhasePlotFeature::getDataFromSimWell( RimSimWellInView* simWell, QString& wellName, int& timeStepIndex ) RimEclipseResultCase* RicShowCumulativePhasePlotFeature::getDataFromSimWell( RimSimWellInView* simWell, QString& wellName, int& timeStepIndex )
{ {
RimEclipseResultCase* resultCase = nullptr;
if ( simWell ) if ( simWell )
{ {
wellName = simWell->name(); wellName = simWell->name();
RimEclipseView* eclView = nullptr; auto eclView = simWell->firstAncestorOfType<RimEclipseView>();
simWell->firstAncestorOfType( eclView );
if ( eclView ) if ( eclView )
{ {
timeStepIndex = eclView->currentTimeStep(); timeStepIndex = eclView->currentTimeStep();
} }
simWell->firstAncestorOfType( resultCase ); return simWell->firstAncestorOfType<RimEclipseResultCase>();
} }
return resultCase; return nullptr;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -92,9 +92,7 @@ std::set<RimWellAllocationPlot*> RicShowTotalAllocationDataFeature::selectedWell
{ {
CVF_ASSERT( obj ); CVF_ASSERT( obj );
RimWellAllocationPlot* parentPlot = nullptr; RimWellAllocationPlot* parentPlot = obj->firstAncestorOrThisOfType<RimWellAllocationPlot>();
obj->firstAncestorOrThisOfType( parentPlot );
if ( parentPlot ) if ( parentPlot )
{ {
wellAllocPlots.insert( parentPlot ); wellAllocPlots.insert( parentPlot );

View File

@ -34,6 +34,7 @@
#include "cafPdmObjectHandle.h" #include "cafPdmObjectHandle.h"
#include "cafPdmUiPropertyViewDialog.h" #include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h" #include "cvfAssert.h"
@ -48,14 +49,9 @@ CAF_CMD_SOURCE_INIT( RicConvertAllFractureTemplatesToFieldFeature, "RicConvertAl
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicConvertAllFractureTemplatesToFieldFeature::onActionTriggered( bool isChecked ) void RicConvertAllFractureTemplatesToFieldFeature::onActionTriggered( bool isChecked )
{ {
auto objHandle = caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>(); RimFractureTemplateCollection* fracTempColl = caf::firstAncestorOfTypeFromSelectedObject<RimFractureTemplateCollection>();
if ( !objHandle ) return;
RimFractureTemplateCollection* fracTempColl = nullptr; std::vector<RimEllipseFractureTemplate*> ellipseFracTemplates = fracTempColl->descendantsIncludingThisOfType<RimEllipseFractureTemplate>();
objHandle->firstAncestorOrThisOfType( fracTempColl );
std::vector<RimEllipseFractureTemplate*> ellipseFracTemplates;
fracTempColl->descendantsIncludingThisOfType( ellipseFracTemplates );
for ( auto ellipseFracTemplate : ellipseFracTemplates ) for ( auto ellipseFracTemplate : ellipseFracTemplates )
{ {

View File

@ -37,6 +37,7 @@
#include "cvfAssert.h" #include "cvfAssert.h"
#include "cafSelectionManagerTools.h"
#include <QAction> #include <QAction>
#include <QFileInfo> #include <QFileInfo>
#include <QString> #include <QString>
@ -48,16 +49,10 @@ CAF_CMD_SOURCE_INIT( RicConvertAllFractureTemplatesToMetricFeature, "RicConvertA
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicConvertAllFractureTemplatesToMetricFeature::onActionTriggered( bool isChecked ) void RicConvertAllFractureTemplatesToMetricFeature::onActionTriggered( bool isChecked )
{ {
auto objHandle = caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>(); RimFractureTemplateCollection* fracTempColl = caf::firstAncestorOfTypeFromSelectedObject<RimFractureTemplateCollection>();
if ( !objHandle ) return;
RimFractureTemplateCollection* fracTempColl = nullptr;
objHandle->firstAncestorOrThisOfType( fracTempColl );
if ( !fracTempColl ) return; if ( !fracTempColl ) return;
std::vector<RimEllipseFractureTemplate*> ellipseFracTemplates; std::vector<RimEllipseFractureTemplate*> ellipseFracTemplates = fracTempColl->descendantsIncludingThisOfType<RimEllipseFractureTemplate>();
fracTempColl->descendantsIncludingThisOfType( ellipseFracTemplates );
for ( auto ellipseFracTemplate : ellipseFracTemplates ) for ( auto ellipseFracTemplate : ellipseFracTemplates )
{ {
if ( ellipseFracTemplate->fractureTemplateUnit() == RiaDefines::EclipseUnitSystem::UNITS_FIELD ) if ( ellipseFracTemplate->fractureTemplateUnit() == RiaDefines::EclipseUnitSystem::UNITS_FIELD )

View File

@ -36,6 +36,7 @@
#include "cafPdmObjectHandle.h" #include "cafPdmObjectHandle.h"
#include "cafPdmUiPropertyViewDialog.h" #include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h" #include "cvfAssert.h"
@ -50,19 +51,13 @@ CAF_CMD_SOURCE_INIT( RicCreateDuplicateTemplateInOtherUnitSystemFeature, "RicCon
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicCreateDuplicateTemplateInOtherUnitSystemFeature::onActionTriggered( bool isChecked ) void RicCreateDuplicateTemplateInOtherUnitSystemFeature::onActionTriggered( bool isChecked )
{ {
auto objHandle = caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>(); RimFractureTemplate* fractureTemplate = caf::firstAncestorOfTypeFromSelectedObject<RimFractureTemplate>();
if ( !objHandle ) return;
RimFractureTemplate* fractureTemplate = nullptr;
objHandle->firstAncestorOrThisOfType( fractureTemplate );
if ( !fractureTemplate ) return; if ( !fractureTemplate ) return;
RimFractureTemplateCollection* fractureTemplateCollection = nullptr;
fractureTemplate->firstAncestorOrThisOfType( fractureTemplateCollection );
auto copyOfTemplate = dynamic_cast<RimFractureTemplate*>( auto copyOfTemplate = dynamic_cast<RimFractureTemplate*>(
fractureTemplate->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); fractureTemplate->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
RimFractureTemplateCollection* fractureTemplateCollection = caf::firstAncestorOfTypeFromSelectedObject<RimFractureTemplateCollection>();
fractureTemplateCollection->addFractureTemplate( copyOfTemplate ); fractureTemplateCollection->addFractureTemplate( copyOfTemplate );
auto currentUnit = copyOfTemplate->fractureTemplateUnit(); auto currentUnit = copyOfTemplate->fractureTemplateUnit();
@ -90,11 +85,7 @@ void RicCreateDuplicateTemplateInOtherUnitSystemFeature::onActionTriggered( bool
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicCreateDuplicateTemplateInOtherUnitSystemFeature::setupActionLook( QAction* actionToSetup ) void RicCreateDuplicateTemplateInOtherUnitSystemFeature::setupActionLook( QAction* actionToSetup )
{ {
auto objHandle = caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>(); RimFractureTemplate* fractureTemplate = caf::firstAncestorOfTypeFromSelectedObject<RimFractureTemplate>();
if ( !objHandle ) return;
RimFractureTemplate* fractureTemplate = nullptr;
objHandle->firstAncestorOrThisOfType( fractureTemplate );
if ( !fractureTemplate ) return; if ( !fractureTemplate ) return;
QString destinationUnit; QString destinationUnit;

View File

@ -112,8 +112,7 @@ void RicCreateMultipleFracturesOptionItemUi::fieldChangedByUi( const caf::PdmFie
if ( m_baseKOneBased < m_topKOneBased ) m_topKOneBased = m_baseKOneBased; if ( m_baseKOneBased < m_topKOneBased ) m_topKOneBased = m_baseKOneBased;
} }
RiuCreateMultipleFractionsUi* parent = nullptr; RiuCreateMultipleFractionsUi* parent = firstAncestorOrThisOfType<RiuCreateMultipleFractionsUi>();
this->firstAncestorOrThisOfType( parent );
if ( parent ) if ( parent )
{ {
parent->updateButtonsEnableState(); parent->updateButtonsEnableState();

View File

@ -132,7 +132,7 @@ void RiuCreateMultipleFractionsUi::resetValues()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<RicCreateMultipleFracturesOptionItemUi*> RiuCreateMultipleFractionsUi::options() const std::vector<RicCreateMultipleFracturesOptionItemUi*> RiuCreateMultipleFractionsUi::options() const
{ {
return m_options.children(); return m_options.childrenByType();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -37,8 +37,7 @@ void RicDeleteOptionItemFeature::onActionTriggered( bool isChecked )
if ( !optionItems.empty() ) if ( !optionItems.empty() )
{ {
RiuCreateMultipleFractionsUi* multipleFractionUi = nullptr; RiuCreateMultipleFractionsUi* multipleFractionUi = optionItems[0]->firstAncestorOrThisOfTypeAsserted<RiuCreateMultipleFractionsUi>();
optionItems[0]->firstAncestorOrThisOfTypeAsserted( multipleFractionUi );
for ( auto optionItem : optionItems ) for ( auto optionItem : optionItems )
{ {

View File

@ -37,8 +37,7 @@ private:
template <typename T> template <typename T>
static QString nameForNewObject( const QString& namePattern ) static QString nameForNewObject( const QString& namePattern )
{ {
std::vector<T*> oldObjects; std::vector<T*> oldObjects = RimProject::current()->activeOilField()->descendantsIncludingThisOfType<T>();
RimProject::current()->activeOilField()->descendantsIncludingThisOfType( oldObjects );
size_t objectNum = oldObjects.size(); size_t objectNum = oldObjects.size();

View File

@ -64,8 +64,7 @@ void RicMeshFractureTemplateHelper<T>::selectFractureTemplateAndUpdate( RimFract
{ {
fractureTemplate->loadDataAndUpdate(); fractureTemplate->loadDataAndUpdate();
RimFractureTemplateCollection* templateCollection = nullptr; RimFractureTemplateCollection* templateCollection = fractureTemplate->firstAncestorOrThisOfTypeAsserted<RimFractureTemplateCollection>();
fractureTemplate->firstAncestorOrThisOfTypeAsserted( templateCollection );
templateCollection->updateConnectedEditors(); templateCollection->updateConnectedEditors();
RimProject* project = RimProject::current(); RimProject* project = RimProject::current();

View File

@ -53,8 +53,7 @@ void RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate( RimF
{ {
fractureTemplate->loadDataAndUpdate(); fractureTemplate->loadDataAndUpdate();
RimFractureTemplateCollection* templateCollection = nullptr; RimFractureTemplateCollection* templateCollection = fractureTemplate->firstAncestorOrThisOfTypeAsserted<RimFractureTemplateCollection>();
fractureTemplate->firstAncestorOrThisOfTypeAsserted( templateCollection );
templateCollection->updateConnectedEditors(); templateCollection->updateConnectedEditors();
RimProject* project = RimProject::current(); RimProject* project = RimProject::current();

View File

@ -62,7 +62,7 @@ void RicNewOptionItemFeature::onActionTriggered( bool isChecked )
if ( !optionItems.empty() ) if ( !optionItems.empty() )
{ {
selectedOptionItem = optionItems.front(); selectedOptionItem = optionItems.front();
selectedOptionItem->firstAncestorOrThisOfTypeAsserted( multipleFractionUi ); multipleFractionUi = selectedOptionItem->firstAncestorOrThisOfTypeAsserted<RiuCreateMultipleFractionsUi>();
} }
if ( !selectedOptionItem && multipleFractionUi && !multipleFractionUi->options().empty() ) if ( !selectedOptionItem && multipleFractionUi && !multipleFractionUi->options().empty() )

View File

@ -83,20 +83,17 @@ void RicNewSimWellFractureAtPosFeature::onActionTriggered( bool isChecked )
fracture->setClosestWellCoord( simWellItem->m_domainCoord, simWellItem->m_branchIndex ); fracture->setClosestWellCoord( simWellItem->m_domainCoord, simWellItem->m_branchIndex );
RimOilField* oilfield = nullptr; RimOilField* oilfield = RimProject::current()->activeOilField();
simWell->firstAncestorOrThisOfType( oilfield );
if ( !oilfield ) return; if ( !oilfield ) return;
std::vector<RimFracture*> oldFractures; std::vector<RimFracture*> oldFractures = oilfield->descendantsIncludingThisOfType<RimFracture>();
oilfield->descendantsIncludingThisOfType( oldFractures ); QString fracNum = QString( "%1" ).arg( oldFractures.size(), 2, 10, QChar( '0' ) );
QString fracNum = QString( "%1" ).arg( oldFractures.size(), 2, 10, QChar( '0' ) );
fracture->setName( QString( "Fracture_" ) + fracNum ); fracture->setName( QString( "Fracture_" ) + fracNum );
auto unitSet = RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN; auto unitSet = RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN;
{ {
RimEclipseResultCase* eclipseCase = nullptr; RimEclipseResultCase* eclipseCase = simWell->firstAncestorOrThisOfType<RimEclipseResultCase>();
simWell->firstAncestorOrThisOfType( eclipseCase );
if ( eclipseCase ) if ( eclipseCase )
{ {
unitSet = eclipseCase->eclipseCaseData()->unitsType(); unitSet = eclipseCase->eclipseCaseData()->unitsType();
@ -112,8 +109,7 @@ void RicNewSimWellFractureAtPosFeature::onActionTriggered( bool isChecked )
activeView->scheduleCreateDisplayModelAndRedraw(); activeView->scheduleCreateDisplayModelAndRedraw();
RimEclipseCase* eclipseCase = nullptr; auto eclipseCase = simWell->firstAncestorOrThisOfType<RimEclipseCase>();
simWell->firstAncestorOrThisOfType( eclipseCase );
if ( eclipseCase ) if ( eclipseCase )
{ {
proj->reloadCompletionTypeResultsForEclipseCase( eclipseCase ); proj->reloadCompletionTypeResultsForEclipseCase( eclipseCase );
@ -142,9 +138,7 @@ bool RicNewSimWellFractureAtPosFeature::isCommandEnabled()
auto objHandle = caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>(); auto objHandle = caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>();
if ( !objHandle ) return false; if ( !objHandle ) return false;
RimSimWellInView* eclipseWell = nullptr; RimSimWellInView* eclipseWell = objHandle->firstAncestorOrThisOfType<RimSimWellInView>();
objHandle->firstAncestorOrThisOfType( eclipseWell );
if ( eclipseWell ) if ( eclipseWell )
{ {
return true; return true;

View File

@ -57,8 +57,7 @@ void RicNewSimWellFractureFeature::onActionTriggered( bool isChecked )
auto objHandle = caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>(); auto objHandle = caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>();
if ( !objHandle ) return; if ( !objHandle ) return;
RimSimWellInView* eclipseWell = nullptr; auto eclipseWell = objHandle->firstAncestorOrThisOfType<RimSimWellInView>();
objHandle->firstAncestorOrThisOfType( eclipseWell );
RimSimWellFracture* fracture = new RimSimWellFracture(); RimSimWellFracture* fracture = new RimSimWellFracture();
if ( eclipseWell->simwellFractureCollection()->simwellFractures.empty() ) if ( eclipseWell->simwellFractureCollection()->simwellFractures.empty() )
@ -72,16 +71,14 @@ void RicNewSimWellFractureFeature::onActionTriggered( bool isChecked )
eclipseWell->simwellFractureCollection()->simwellFractures.push_back( fracture ); eclipseWell->simwellFractureCollection()->simwellFractures.push_back( fracture );
RimOilField* oilfield = nullptr; auto oilfield = objHandle->firstAncestorOrThisOfType<RimOilField>();
objHandle->firstAncestorOrThisOfType( oilfield );
if ( !oilfield ) return; if ( !oilfield ) return;
fracture->setName( RicFractureNameGenerator::nameForNewFracture() ); fracture->setName( RicFractureNameGenerator::nameForNewFracture() );
auto unitSet = RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN; auto unitSet = RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN;
{ {
RimEclipseResultCase* eclipseCase = nullptr; auto eclipseCase = objHandle->firstAncestorOrThisOfType<RimEclipseResultCase>();
objHandle->firstAncestorOrThisOfType( eclipseCase );
if ( eclipseCase ) if ( eclipseCase )
{ {
unitSet = eclipseCase->eclipseCaseData()->unitsType(); unitSet = eclipseCase->eclipseCaseData()->unitsType();
@ -96,8 +93,7 @@ void RicNewSimWellFractureFeature::onActionTriggered( bool isChecked )
eclipseWell->updateConnectedEditors(); eclipseWell->updateConnectedEditors();
RimEclipseCase* eclipseCase = nullptr; auto eclipseCase = objHandle->firstAncestorOrThisOfType<RimEclipseCase>();
objHandle->firstAncestorOrThisOfType( eclipseCase );
if ( eclipseCase ) if ( eclipseCase )
{ {
proj->reloadCompletionTypeResultsForEclipseCase( eclipseCase ); proj->reloadCompletionTypeResultsForEclipseCase( eclipseCase );
@ -126,9 +122,7 @@ bool RicNewSimWellFractureFeature::isCommandEnabled()
auto objHandle = caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>(); auto objHandle = caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>();
if ( !objHandle ) return false; if ( !objHandle ) return false;
RimSimWellInView* simWell = nullptr; auto simWell = objHandle->firstAncestorOrThisOfType<RimSimWellInView>();
objHandle->firstAncestorOrThisOfType( simWell );
if ( simWell ) if ( simWell )
{ {
return true; return true;

View File

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

View File

@ -72,9 +72,7 @@ RimWellPathFracture* RicNewWellPathFractureFeature::addFracture( gsl::not_null<R
CVF_ASSERT( wellPathGeometry ); CVF_ASSERT( wellPathGeometry );
if ( !wellPathGeometry ) return nullptr; if ( !wellPathGeometry ) return nullptr;
RimOilField* oilfield = nullptr; RimProject* project = RimProject::current();
fractureCollection->firstAncestorOrThisOfType( oilfield );
if ( !oilfield ) return nullptr;
RimWellPathFracture* fracture = new RimWellPathFracture(); RimWellPathFracture* fracture = new RimWellPathFracture();
fractureCollection->addFracture( fracture ); fractureCollection->addFracture( fracture );
@ -90,14 +88,12 @@ RimWellPathFracture* RicNewWellPathFractureFeature::addFracture( gsl::not_null<R
auto unitSet = wellPath->unitSystem(); auto unitSet = wellPath->unitSystem();
fracture->setFractureUnit( unitSet ); fracture->setFractureUnit( unitSet );
RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection()->firstFractureOfUnit( unitSet ); RimFractureTemplate* fracDef = project->activeOilField()->fractureDefinitionCollection()->firstFractureOfUnit( unitSet );
if ( fracDef ) if ( fracDef )
{ {
fracture->setFractureTemplate( fracDef ); fracture->setFractureTemplate( fracDef );
} }
RimProject* project = nullptr;
fractureCollection->firstAncestorOrThisOfType( project );
if ( project ) if ( project )
{ {
project->reloadCompletionTypeResultsInAllViews(); project->reloadCompletionTypeResultsInAllViews();
@ -119,8 +115,7 @@ void RicNewWellPathFractureFeature::onActionTriggered( bool isChecked )
RimWellPathFractureCollection* fractureColl = RicNewWellPathFractureFeature::selectedWellPathFractureCollection(); RimWellPathFractureCollection* fractureColl = RicNewWellPathFractureFeature::selectedWellPathFractureCollection();
if ( !fractureColl ) return; if ( !fractureColl ) return;
RimWellPath* wellPath = nullptr; auto wellPath = fractureColl->firstAncestorOrThisOfTypeAsserted<RimWellPath>();
fractureColl->firstAncestorOrThisOfTypeAsserted( wellPath );
double defaultMeasuredDepth = wellPath->uniqueStartMD(); double defaultMeasuredDepth = wellPath->uniqueStartMD();
RicNewWellPathFractureFeature::addFracture( wellPath, defaultMeasuredDepth ); RicNewWellPathFractureFeature::addFracture( wellPath, defaultMeasuredDepth );
@ -164,7 +159,7 @@ RimWellPathFractureCollection* RicNewWellPathFractureFeature::selectedWellPathFr
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>( pdmUiItem ); caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>( pdmUiItem );
if ( objHandle ) if ( objHandle )
{ {
objHandle->firstAncestorOrThisOfType( objToFind ); objToFind = objHandle->firstAncestorOrThisOfType<RimWellPathFractureCollection>();
} }
if ( objToFind == nullptr ) if ( objToFind == nullptr )

View File

@ -27,6 +27,7 @@
#include "cafPdmObjectGroup.h" #include "cafPdmObjectGroup.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include <QAction> #include <QAction>
#include <QString> #include <QString>
@ -99,13 +100,5 @@ void RicPasteEllipseFractureFeature::setupActionLook( QAction* actionToSetup )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimFractureTemplateCollection* RicPasteEllipseFractureFeature::fractureTemplateCollection() RimFractureTemplateCollection* RicPasteEllipseFractureFeature::fractureTemplateCollection()
{ {
RimFractureTemplateCollection* fractureTemplateColl = nullptr; return caf::firstAncestorOfTypeFromSelectedObject<RimFractureTemplateCollection>();
auto destinationObject = dynamic_cast<caf::PdmObjectHandle*>( caf::SelectionManager::instance()->selectedItem() );
if ( destinationObject )
{
destinationObject->firstAncestorOrThisOfType( fractureTemplateColl );
}
return fractureTemplateColl;
} }

View File

@ -27,6 +27,7 @@
#include "cafPdmObjectGroup.h" #include "cafPdmObjectGroup.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include <QAction> #include <QAction>
#include <QString> #include <QString>
@ -99,13 +100,5 @@ void RicPasteStimPlanFractureFeature::setupActionLook( QAction* actionToSetup )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimFractureTemplateCollection* RicPasteStimPlanFractureFeature::fractureTemplateCollection() RimFractureTemplateCollection* RicPasteStimPlanFractureFeature::fractureTemplateCollection()
{ {
RimFractureTemplateCollection* fractureTemplateColl = nullptr; return caf::firstAncestorOfTypeFromSelectedObject<RimFractureTemplateCollection>();
auto destinationObject = dynamic_cast<caf::PdmObjectHandle*>( caf::SelectionManager::instance()->selectedItem() );
if ( destinationObject )
{
destinationObject->firstAncestorOrThisOfType( fractureTemplateColl );
}
return fractureTemplateColl;
} }

View File

@ -31,6 +31,7 @@
#include "cafCmdFeatureManager.h" #include "cafCmdFeatureManager.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include <QAction> #include <QAction>
@ -65,11 +66,7 @@ void RicCreateGridCrossPlotFeature::onActionTriggered( bool isChecked )
} }
else else
{ {
caf::PdmObject* selectedObject = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() ); auto cellFilterView = caf::firstAncestorOfTypeFromSelectedObject<RimGridView>();
if ( !selectedObject ) return;
RimGridView* cellFilterView = nullptr;
selectedObject->firstAncestorOrThisOfType( cellFilterView );
if ( cellFilterView ) dataSet->setCellFilterView( cellFilterView ); if ( cellFilterView ) dataSet->setCellFilterView( cellFilterView );
} }

View File

@ -61,8 +61,7 @@ std::vector<VdeExportPart> RicHoloLensExportImpl::partsForExport( const RimGridV
{ {
std::vector<VdeExportPart> exportParts; std::vector<VdeExportPart> exportParts;
RimEclipseCase* rimEclipseCase = nullptr; RimEclipseCase* rimEclipseCase = view.firstAncestorOrThisOfType<RimEclipseCase>();
view.firstAncestorOrThisOfType( rimEclipseCase );
if ( view.viewer() ) if ( view.viewer() )
{ {

View File

@ -63,8 +63,7 @@ void RicAppendIntersectionBoxFeature::onActionTriggered( bool isChecked )
coll->updateConnectedEditors(); coll->updateConnectedEditors();
Riu3DMainWindowTools::selectAsCurrentItem( intersectionBox ); Riu3DMainWindowTools::selectAsCurrentItem( intersectionBox );
RimGridView* rimView = nullptr; RimGridView* rimView = coll->firstAncestorOrThisOfTypeAsserted<RimGridView>();
coll->firstAncestorOrThisOfTypeAsserted( rimView );
rimView->showGridCells( false ); rimView->showGridCells( false );
} }
} }
@ -83,14 +82,12 @@ void RicAppendIntersectionBoxFeature::setupActionLook( QAction* actionToSetup )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimIntersectionCollection* RicAppendIntersectionBoxFeature::intersectionCollection() RimIntersectionCollection* RicAppendIntersectionBoxFeature::intersectionCollection()
{ {
RimIntersectionCollection* intersectionBoxColl = nullptr;
std::vector<caf::PdmObjectHandle*> selectedObjects; std::vector<caf::PdmObjectHandle*> selectedObjects;
caf::SelectionManager::instance()->objectsByType( &selectedObjects ); caf::SelectionManager::instance()->objectsByType( &selectedObjects );
if ( selectedObjects.size() == 1 ) if ( selectedObjects.size() == 1 )
{ {
selectedObjects[0]->firstAncestorOrThisOfType( intersectionBoxColl ); return selectedObjects[0]->firstAncestorOrThisOfType<RimIntersectionCollection>();
} }
return intersectionBoxColl; return nullptr;
} }

View File

@ -58,8 +58,7 @@ void RicNewIntersectionViewFeature::onActionTriggered( bool isChecked )
{ {
if ( !intersection ) continue; if ( !intersection ) continue;
RimCase* rimCase = nullptr; RimCase* rimCase = intersection->firstAncestorOrThisOfType<RimCase>();
intersection->firstAncestorOrThisOfType( rimCase );
if ( rimCase ) if ( rimCase )
{ {
if ( intersection->direction() != RimExtrudedCurveIntersection::CrossSectionDirEnum::CS_VERTICAL ) if ( intersection->direction() != RimExtrudedCurveIntersection::CrossSectionDirEnum::CS_VERTICAL )

View File

@ -61,8 +61,7 @@ void RicExecuteLastUsedScriptFeature::onActionTriggered( bool isChecked )
{ {
RimScriptCollection* rootScriptCollection = RiaApplication::instance()->project()->scriptCollection(); RimScriptCollection* rootScriptCollection = RiaApplication::instance()->project()->scriptCollection();
std::vector<RimCalcScript*> scripts; std::vector<RimCalcScript*> scripts = rootScriptCollection->descendantsIncludingThisOfType<RimCalcScript>();
rootScriptCollection->descendantsIncludingThisOfType( scripts );
for ( auto c : scripts ) for ( auto c : scripts )
{ {
if ( c->absoluteFileName() == lastUsedScript ) if ( c->absoluteFileName() == lastUsedScript )

View File

@ -69,7 +69,7 @@ void RicNewPythonScriptFeature::onActionTriggered( bool isChecked )
{ {
QFileInfo existingScriptFileInfo( calcScript->absoluteFileName() ); QFileInfo existingScriptFileInfo( calcScript->absoluteFileName() );
fullPathNewScript = existingScriptFileInfo.absolutePath(); fullPathNewScript = existingScriptFileInfo.absolutePath();
calcScript->firstAncestorOrThisOfTypeAsserted( scriptColl ); scriptColl = calcScript->firstAncestorOrThisOfTypeAsserted<RimScriptCollection>();
} }
else if ( scriptColl ) else if ( scriptColl )
{ {

View File

@ -138,10 +138,8 @@ bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported( caf::PdmObjec
if ( dynamic_cast<RimSummaryMultiPlot*>( pdmObject ) ) return true; if ( dynamic_cast<RimSummaryMultiPlot*>( pdmObject ) ) return true;
// Copy support based combined logic // Copy support based combined logic
RimWellAllocationPlot* wellAllocPlot = nullptr; RimWellAllocationPlot* wellAllocPlot = pdmObject->firstAncestorOrThisOfType<RimWellAllocationPlot>();
RimWellRftPlot* rftPlot = nullptr; RimWellRftPlot* rftPlot = pdmObject->firstAncestorOrThisOfType<RimWellRftPlot>();
pdmObject->firstAncestorOrThisOfType( wellAllocPlot );
pdmObject->firstAncestorOrThisOfType( rftPlot );
if ( dynamic_cast<RimPlotCurve*>( pdmObject ) && !dynamic_cast<RimGridCrossPlotCurve*>( pdmObject ) ) if ( dynamic_cast<RimPlotCurve*>( pdmObject ) && !dynamic_cast<RimGridCrossPlotCurve*>( pdmObject ) )
{ {

View File

@ -89,12 +89,10 @@ RimIdenticalGridCaseGroup* RicPasteFeatureImpl::findGridCaseGroup( caf::PdmObjec
{ {
return dynamic_cast<RimIdenticalGridCaseGroup*>( objectHandle ); return dynamic_cast<RimIdenticalGridCaseGroup*>( objectHandle );
} }
else if ( dynamic_cast<RimCaseCollection*>( objectHandle ) || dynamic_cast<RimEclipseCase*>( objectHandle ) )
{
RimIdenticalGridCaseGroup* gridCaseGroup = nullptr;
objectHandle->firstAncestorOrThisOfType( gridCaseGroup );
return gridCaseGroup; if ( dynamic_cast<RimCaseCollection*>( objectHandle ) || dynamic_cast<RimEclipseCase*>( objectHandle ) )
{
return objectHandle->firstAncestorOrThisOfType<RimIdenticalGridCaseGroup>();
} }
return nullptr; return nullptr;

View File

@ -145,15 +145,13 @@ RimIntersectionCollection* RicPasteIntersectionsFeature::findIntersectionCollect
RimExtrudedCurveIntersection* intersection = dynamic_cast<RimExtrudedCurveIntersection*>( objectHandle ); RimExtrudedCurveIntersection* intersection = dynamic_cast<RimExtrudedCurveIntersection*>( objectHandle );
if ( intersection ) if ( intersection )
{ {
intersection->firstAncestorOrThisOfType( intersectionCollection ); return intersection->firstAncestorOrThisOfType<RimIntersectionCollection>();
return intersectionCollection;
} }
RimBoxIntersection* intersectionBox = dynamic_cast<RimBoxIntersection*>( objectHandle ); RimBoxIntersection* intersectionBox = dynamic_cast<RimBoxIntersection*>( objectHandle );
if ( intersectionBox ) if ( intersectionBox )
{ {
intersectionBox->firstAncestorOrThisOfType( intersectionCollection ); return intersectionBox->firstAncestorOrThisOfType<RimIntersectionCollection>();
return intersectionCollection;
} }
return nullptr; return nullptr;

View File

@ -163,8 +163,7 @@ void RicCloseCaseFeature::deleteEclipseCase( RimEclipseCase* eclipseCase )
// This is done because the views do not work well // This is done because the views do not work well
if ( caseGroup->caseCollection()->reservoirs.size() == 1 ) if ( caseGroup->caseCollection()->reservoirs.size() == 1 )
{ {
std::vector<caf::PdmObjectHandle*> children; std::vector<caf::PdmObjectHandle*> children = caseGroup->statisticsCaseCollection()->reservoirs.children();
caseGroup->statisticsCaseCollection()->reservoirs.children( &children );
for ( size_t i = children.size(); i-- > 0; ) for ( size_t i = children.size(); i-- > 0; )
{ {
@ -257,8 +256,7 @@ bool RicCloseCaseFeature::userConfirmedGridCaseGroupChange( const std::vector<Ri
for ( auto caseToDelete : casesToBeDeleted ) for ( auto caseToDelete : casesToBeDeleted )
{ {
RimIdenticalGridCaseGroup* gridCaseGroup = nullptr; RimIdenticalGridCaseGroup* gridCaseGroup = caseToDelete->firstAncestorOrThisOfType<RimIdenticalGridCaseGroup>();
caseToDelete->firstAncestorOrThisOfType( gridCaseGroup );
if ( gridCaseGroup && hasAnyStatisticsResults( gridCaseGroup ) ) if ( gridCaseGroup && hasAnyStatisticsResults( gridCaseGroup ) )
{ {

View File

@ -65,8 +65,7 @@ void RicCloseObservedDataFeature::deleteObservedSummaryData( const std::vector<R
multiPlot->updateConnectedEditors(); multiPlot->updateConnectedEditors();
} }
RimObservedDataCollection* observedDataCollection = nullptr; RimObservedDataCollection* observedDataCollection = observedData->firstAncestorOrThisOfTypeAsserted<RimObservedDataCollection>();
observedData->firstAncestorOrThisOfTypeAsserted( observedDataCollection );
observedDataCollection->removeObservedSummaryData( observedData ); observedDataCollection->removeObservedSummaryData( observedData );
delete observedData; delete observedData;
@ -83,8 +82,7 @@ void RicCloseObservedDataFeature::deleteObservedRmuRftData( const std::vector<Ri
for ( RimObservedFmuRftData* observedData : data ) for ( RimObservedFmuRftData* observedData : data )
{ {
RimObservedDataCollection* observedDataCollection = nullptr; RimObservedDataCollection* observedDataCollection = observedData->firstAncestorOrThisOfTypeAsserted<RimObservedDataCollection>();
observedData->firstAncestorOrThisOfTypeAsserted( observedDataCollection );
for ( RimWellRftPlot* plot : rftPlotColl->rftPlots() ) for ( RimWellRftPlot* plot : rftPlotColl->rftPlots() )
{ {

View File

@ -75,15 +75,13 @@ void RicCloseSummaryCaseFeature::deleteSummaryCases( std::vector<RimSummaryCase*
plotsToUpdate.insert( multiPlot ); plotsToUpdate.insert( multiPlot );
} }
std::vector<caf::PdmObjectHandle*> referringObjects; std::vector<caf::PdmObjectHandle*> referringObjects = summaryCase->objectsWithReferringPtrFields();
summaryCase->objectsWithReferringPtrFields( referringObjects );
for ( auto object : referringObjects ) for ( auto object : referringObjects )
{ {
if ( !object ) continue; if ( !object ) continue;
RimWellLogPlot* wellLogPlot = nullptr; RimWellLogPlot* wellLogPlot = object->firstAncestorOrThisOfType<RimWellLogPlot>();
object->firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot ) wellLogPlotsToDelete.insert( wellLogPlot ); if ( wellLogPlot ) wellLogPlotsToDelete.insert( wellLogPlot );
} }
} }

View File

@ -58,8 +58,7 @@ bool RicContourMapPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
{ {
RiuMainWindow::instance()->selectAsCurrentItem( contourMap ); RiuMainWindow::instance()->selectAsCurrentItem( contourMap );
RimGridView* view = nullptr; RimGridView* view = contourMap->firstAncestorOrThisOfTypeAsserted<RimGridView>();
contourMap->firstAncestorOrThisOfTypeAsserted( view );
if ( !view ) return false; if ( !view ) return false;
cvf::Vec2d pickedPoint; cvf::Vec2d pickedPoint;

View File

@ -50,14 +50,12 @@ void RicDeleteItemExec::redo()
caf::PdmChildArrayFieldHandle* listField = dynamic_cast<caf::PdmChildArrayFieldHandle*>( field ); caf::PdmChildArrayFieldHandle* listField = dynamic_cast<caf::PdmChildArrayFieldHandle*>( field );
if ( listField ) if ( listField )
{ {
std::vector<caf::PdmObjectHandle*> children; std::vector<caf::PdmObjectHandle*> children = listField->children();
listField->children( &children );
caf::PdmObjectHandle* obj = children[m_commandData.m_indexToObject]; caf::PdmObjectHandle* obj = children[m_commandData.m_indexToObject];
caf::SelectionManager::instance()->removeObjectFromAllSelections( obj ); caf::SelectionManager::instance()->removeObjectFromAllSelections( obj );
std::vector<caf::PdmObjectHandle*> referringObjects; std::vector<caf::PdmObjectHandle*> referringObjects = obj->objectsWithReferringPtrFields();
obj->objectsWithReferringPtrFields( referringObjects );
if ( m_commandData.m_deletedObjectAsXml().isEmpty() ) if ( m_commandData.m_deletedObjectAsXml().isEmpty() )
{ {

View File

@ -85,8 +85,7 @@ void RicDeleteItemFeature::deleteObject( caf::PdmObject* objectToDelete )
int indexToObject = -1; int indexToObject = -1;
std::vector<caf::PdmObjectHandle*> childObjects; std::vector<caf::PdmObjectHandle*> childObjects = childArrayFieldHandle->children();
childArrayFieldHandle->children( &childObjects );
for ( size_t i = 0; i < childObjects.size(); i++ ) for ( size_t i = 0; i < childObjects.size(); i++ )
{ {

View File

@ -45,8 +45,7 @@ void RicDeletePressureTableItemFeature::onActionTriggered( bool isChecked )
caf::SelectionManager::instance()->objectsByType( &items, caf::SelectionManager::FIRST_LEVEL ); caf::SelectionManager::instance()->objectsByType( &items, caf::SelectionManager::FIRST_LEVEL );
if ( !items.empty() ) if ( !items.empty() )
{ {
RimPressureTable* pressureTable = nullptr; RimPressureTable* pressureTable = items[0]->firstAncestorOrThisOfTypeAsserted<RimPressureTable>();
items[0]->firstAncestorOrThisOfTypeAsserted( pressureTable );
for ( RimPressureTableItem* attributeToDelete : items ) for ( RimPressureTableItem* attributeToDelete : items )
{ {
pressureTable->deleteItem( attributeToDelete ); pressureTable->deleteItem( attributeToDelete );

View File

@ -223,8 +223,7 @@ void RicDeleteSubItemsFeature::deleteSubItems( bool onlyDeleteUnchecked )
collection->updateConnectedEditors(); collection->updateConnectedEditors();
RimProject* proj = nullptr; RimProject* proj = RimProject::current();
collection->firstAncestorOrThisOfType( proj );
if ( proj ) proj->reloadCompletionTypeResultsInAllViews(); if ( proj ) proj->reloadCompletionTypeResultsInAllViews();
} }
} }

Some files were not shown because too many files have changed in this diff Show More