From ae8446073b5a6e9bbfa699622a528bbeda4e2832 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 8 Apr 2025 12:53:14 +0200 Subject: [PATCH] Refactors selection handling for improved code clarity Modernize the interface to selection system. Create and return data instead of populating incoming parameters. --- .../Application/RiaGuiApplication.cpp | 5 +-- .../Summary/RiaSummaryPlotTemplateTools.cpp | 15 ++----- .../RicOpenInTextEditorFeature.cpp | 10 ++--- .../RicNewFishbonesSubsFeature.cpp | 10 ++--- .../RicNewPerforationIntervalFeature.cpp | 3 +- .../CompletionCommands/RicNewValveFeature.cpp | 7 ++- ...lPathImportPerforationIntervalsFeature.cpp | 10 +---- ...tCompletionsForVisibleWellPathsFeature.cpp | 14 +++--- ...RicWellPathExportCompletionDataFeature.cpp | 5 +-- .../RicAppendIntersectionFeature.cpp | 3 +- ...ppendSeparateIntersectionResultFeature.cpp | 3 +- ...pyIntersectionsToAllViewsInCaseFeature.cpp | 7 ++- .../RicNewSimWellIntersectionFeature.cpp | 5 +-- .../RicNewWellPathIntersectionFeature.cpp | 13 +++--- .../EclipseWell/RicEclipseWellFeatureImpl.cpp | 5 +-- ...ApplyPropertyFilterAsCellResultFeature.cpp | 16 ++----- .../RicComputeStatisticsFeature.cpp | 5 +-- .../RicEclipseCaseNewGroupFeature.cpp | 7 +-- .../RicEclipsePropertyFilterFeatureImpl.cpp | 10 +---- .../RicNewStatisticsCaseFeature.cpp | 8 +--- .../ExportCommands/RicExportCarfin.cpp | 10 +---- .../ExportCommands/RicExportFaultsFeature.cpp | 11 +---- .../RicSaveEclipseInputPropertyFeature.cpp | 5 +-- ...aveEclipseResultAsInputPropertyFeature.cpp | 20 +-------- .../RicPlotProductionRateFeature.cpp | 10 +---- .../RicShowContributingWellsFeature.cpp | 16 +++---- .../RicShowTotalAllocationDataFeature.cpp | 4 +- .../RicShowWellAllocationPlotFeature.cpp | 16 ++----- .../RicDeleteOptionItemFeature.cpp | 8 ++-- .../RicNewOptionItemFeature.cpp | 4 +- .../RicNewStimPlanModelFeature.cpp | 3 +- .../RicNewWellPathFractureFeature.cpp | 10 ++--- .../RicGeoMechPropertyFilterFeatureImpl.cpp | 10 +---- .../RicAppendIntersectionBoxFeature.cpp | 6 +-- .../RicExecuteScriptForCasesFeature.cpp | 8 +--- .../RicScriptFeatureImpl.cpp | 10 +---- .../RicCopyReferencesToClipboardFeature.cpp | 10 +---- .../RicCutReferencesToClipboardFeature.cpp | 10 +---- ...ummaryCurvesForSummaryAddressesFeature.cpp | 9 +--- ...endSummaryCurvesForSummaryCasesFeature.cpp | 15 ++----- ...RicAppendSummaryPlotsForObjectsFeature.cpp | 3 +- ...SummaryPlotsForSummaryAddressesFeature.cpp | 5 +-- ...pendSummaryPlotsForSummaryCasesFeature.cpp | 10 +---- .../RicNewMultiPlotFeature.cpp | 10 ++--- .../RicNewSummaryMultiPlotFeature.cpp | 16 +++---- .../RicNewSummaryMultiPlotFeature.h | 2 +- ...wSummaryMultiPlotFromDataVectorFeature.cpp | 4 +- ...RicNewSummaryPlotFromDataVectorFeature.cpp | 4 +- .../RicSplitMultiPlotFeature.cpp | 6 +-- .../RicCreateNewPlotFromTemplateFeature.cpp | 15 +++---- .../RicDeletePlotTemplateFeature.cpp | 15 ++----- .../RicRenamePlotTemplateFeature.cpp | 13 +----- .../RicSetAsDefaultTemplateFeature.cpp | 7 +-- .../Commands/RicCloseCaseFeature.cpp | 4 +- .../Commands/RicCloseObservedDataFeature.cpp | 14 ++---- .../Commands/RicCloseSummaryCaseFeature.cpp | 12 ++--- .../Commands/RicCloseSummaryCaseFeature.h | 2 +- ...RicCloseSummaryCaseInCollectionFeature.cpp | 15 ++----- .../RicCreateSummaryEnsembleFeature.cpp | 7 +-- .../Commands/RicDeleteItemFeature.cpp | 12 ++--- .../RicDeletePressureTableItemFeature.cpp | 12 +++-- .../Commands/RicDeleteSubItemsFeature.cpp | 15 ++----- .../RicDeleteSummaryCaseCollectionFeature.cpp | 6 +-- ...icDeleteWellMeasurementFilePathFeature.cpp | 6 +-- .../Commands/RicFlyToObjectFeature.cpp | 5 +-- .../RicImportElementPropertyFeature.cpp | 7 ++- .../Commands/RicImportObservedDataFeature.cpp | 7 +-- .../RicImportObservedFmuDataFeature.cpp | 7 +-- .../RicImportPressureDepthDataFeature.cpp | 7 +-- .../RicNewStatisticsContourMapFeature.cpp | 10 +---- .../Commands/RicNewViewFeature.cpp | 44 +++---------------- .../RicNewViewForGridEnsembleFeature.cpp | 10 +---- .../Commands/RicReloadCaseFeature.cpp | 17 ++----- .../RicReloadFormationNamesFeature.cpp | 13 ++---- .../RicReloadPressureDepthDataFeature.cpp | 4 +- .../Commands/RicReloadSummaryCaseFeature.cpp | 17 ++----- .../RicReloadWellMeasurementsFeature.cpp | 6 +-- ...RicReloadWellPathFormationNamesFeature.cpp | 16 +++---- .../Commands/RicReplaceCaseFeature.cpp | 13 +----- .../RicShowDataSourcesForRealization.cpp | 11 ++--- .../RicStackSelectedCurvesFeature.cpp | 6 +-- .../RicUnstackSelectedCurvesFeature.cpp | 9 ++-- .../Commands/RicWellLogTools.cpp | 12 +++-- .../RicWellMeasurementImportTools.cpp | 3 +- .../RicNewSeismicDifferenceFeature.cpp | 10 ++--- .../RicNewSeismicViewFeature.cpp | 12 +---- ...cSeismicSectionFromIntersectionFeature.cpp | 11 +---- .../RicAsciiExportSummaryPlotFeature.cpp | 7 ++- ...rSourceSteppingEnsembleCurveSetFeature.cpp | 8 +--- ...ClearSourceSteppingSummaryCurveFeature.cpp | 8 +--- .../RicNewDefaultSummaryPlotFeature.cpp | 4 +- ...tSourceSteppingEnsembleCurveSetFeature.cpp | 8 +--- ...icSetSourceSteppingSummaryCurveFeature.cpp | 7 +-- .../RicMoveItemsToTopFeature.cpp | 8 +--- .../RicToggleItemsFeatureImpl.cpp | 13 ++---- .../RicToggleItemsOnOthersOffFeature.cpp | 6 +-- .../Commands/ViewLink/RicLinkViewFeature.cpp | 4 +- .../ViewLink/RicShowAllLinkedViewsFeature.cpp | 6 +-- .../Ric3dWellLogCurveDeleteFeature.cpp | 8 +--- .../RicAddWellLogToPlotFeature.cpp | 4 +- .../RicAsciiExportWellLogPlotFeature.cpp | 5 +-- .../RicChangeDataSourceFeature.cpp | 6 +-- .../RicDeleteSubPlotFeature.cpp | 18 ++++---- .../WellLogCommands/RicDeleteSubPlotFeature.h | 4 +- .../WellLogCommands/RicNewPltPlotFeature.cpp | 5 +-- .../RicNewWellLogCalculatedCurveFeature.cpp | 6 +-- .../RicNewWellLogPlotTrackFeature.cpp | 4 +- .../RicWellLogPlotCurveFeatureImpl.cpp | 4 +- .../RicDeletePolylineTargetFeature.cpp | 8 +--- .../RicDeleteWellPathAttributeFeature.cpp | 21 +++------ .../RicDeleteWellPathFeature.cpp | 10 ++--- .../RicDeleteWellPathTargetFeature.cpp | 10 ++--- .../RicIntersectionPickEventHandler.cpp | 4 +- .../RicNewEditableWellPathFeature.cpp | 12 ++--- .../RicNewPolylineTargetFeature.cpp | 16 +++---- .../RicNewWellPathAttributeFeature.cpp | 11 ++--- .../RicNewWellPathListTargetFeature.cpp | 24 ++++------ .../RicPasteModeledWellPathFeature.cpp | 4 +- .../RimContextCommandBuilder.cpp | 3 +- .../ProjectDataModel/RimEclipseView.cpp | 3 +- .../RiaProjectInfoCommands.cpp | 3 +- .../UserInterface/RiuDragDrop.cpp | 3 +- .../UserInterface/RiuMainWindow.cpp | 2 +- .../UserInterface/RiuTreeViewEventFilter.cpp | 4 +- .../cafCommand/cafCmdSelectionHelper.cpp | 4 +- .../AddAndDelete/cafCmdDeleteItemFeature.cpp | 10 ++--- .../cafToggleItemsFeatureImpl.cpp | 10 ++--- .../cafToggleItemsOnOthersOffFeature.cpp | 6 +-- .../cafPdmUiCommandSystemProxy.cpp | 2 +- .../cafPdmUiSelection3dEditorVisualizer.cpp | 3 +- .../cafPdmUiCore/cafSelectionManager.cpp | 22 ++++++---- .../cafPdmUiCore/cafSelectionManager.h | 37 +++++++++------- .../cafPdmUiCore/cafSelectionManagerTools.h | 12 ++--- .../cafUserInterface/cafPdmUiLineEditor.cpp | 3 +- .../cafPdmUiTableViewEditor.cpp | 5 +-- GrpcInterface/RiaGrpcProjectService.cpp | 4 +- 136 files changed, 357 insertions(+), 870 deletions(-) diff --git a/ApplicationLibCode/Application/RiaGuiApplication.cpp b/ApplicationLibCode/Application/RiaGuiApplication.cpp index 8480cf1bf5..ca7be412d2 100644 --- a/ApplicationLibCode/Application/RiaGuiApplication.cpp +++ b/ApplicationLibCode/Application/RiaGuiApplication.cpp @@ -1520,10 +1520,7 @@ void RiaGuiApplication::applyGuiPreferences( const RiaPreferences* } } - std::vector uiEditorsToUpdate; - caf::SelectionManager::instance()->selectedItems( uiEditorsToUpdate ); - - for ( caf::PdmUiItem* uiItem : uiEditorsToUpdate ) + for ( caf::PdmUiItem* uiItem : caf::SelectionManager::instance()->selectedItems() ) { uiItem->updateConnectedEditors(); } diff --git a/ApplicationLibCode/Application/Tools/Summary/RiaSummaryPlotTemplateTools.cpp b/ApplicationLibCode/Application/Tools/Summary/RiaSummaryPlotTemplateTools.cpp index ff5e4a380e..d9851b5f3a 100644 --- a/ApplicationLibCode/Application/Tools/Summary/RiaSummaryPlotTemplateTools.cpp +++ b/ApplicationLibCode/Application/Tools/Summary/RiaSummaryPlotTemplateTools.cpp @@ -486,10 +486,7 @@ std::vector RicSummaryPlotTemplateTools::selectDefaultPlotTemplates( st //-------------------------------------------------------------------------------------------------- std::vector RicSummaryPlotTemplateTools::selectedSummaryCases() { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - - return objects; + return caf::SelectionManager::instance()->objectsByType(); } //-------------------------------------------------------------------------------------------------- @@ -497,10 +494,7 @@ std::vector RicSummaryPlotTemplateTools::selectedSummaryCases() //-------------------------------------------------------------------------------------------------- std::vector RicSummaryPlotTemplateTools::selectedSummaryEnsembles() { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - - return objects; + return caf::SelectionManager::instance()->objectsByType(); } //-------------------------------------------------------------------------------------------------- @@ -508,10 +502,7 @@ std::vector RicSummaryPlotTemplateTools::selectedSummaryEns //-------------------------------------------------------------------------------------------------- std::vector RicSummaryPlotTemplateTools::selectedSummaryAddressCollections() { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - - return objects; + return caf::SelectionManager::instance()->objectsByType(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicOpenInTextEditorFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicOpenInTextEditorFeature.cpp index 42e300119c..62fec6bf61 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicOpenInTextEditorFeature.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicOpenInTextEditorFeature.cpp @@ -61,19 +61,17 @@ void RicOpenInTextEditorFeature::openFileInTextEditor( const QString& filePath, //-------------------------------------------------------------------------------------------------- void RicOpenInTextEditorFeature::onActionTriggered( bool isChecked ) { - std::vector uiItems; - caf::SelectionManager::instance()->selectedItems( uiItems ); - QString filePath; - if ( !uiItems.empty() ) + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); + if ( !selectedItems.empty() ) { - if ( auto templateFileItem = dynamic_cast( uiItems.front() ) ) + if ( auto templateFileItem = dynamic_cast( selectedItems.front() ) ) { filePath = templateFileItem->absoluteFilePath(); } - if ( auto pressureDepthData = dynamic_cast( uiItems.front() ) ) + if ( auto pressureDepthData = dynamic_cast( selectedItems.front() ) ) { filePath = pressureDepthData->filePath(); } diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp b/ApplicationLibCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp index 57745d4bdf..ecd8e48998 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp +++ b/ApplicationLibCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp @@ -126,13 +126,12 @@ void RicNewFishbonesSubsFeature::createFishbones( const RimFishbonesDefines::Ric //-------------------------------------------------------------------------------------------------- RimFishbonesCollection* RicNewFishbonesSubsFeature::selectedFishbonesCollection() { - std::vector allSelectedItems; - caf::SelectionManager::instance()->selectedItems( allSelectedItems ); - if ( allSelectedItems.size() != 1u ) return nullptr; + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); + if ( selectedItems.size() != 1u ) return nullptr; RimFishbonesCollection* objToFind = nullptr; - caf::PdmUiItem* pdmUiItem = allSelectedItems.front(); + caf::PdmUiItem* pdmUiItem = selectedItems.front(); auto* objHandle = dynamic_cast( pdmUiItem ); if ( objHandle ) @@ -142,8 +141,7 @@ RimFishbonesCollection* RicNewFishbonesSubsFeature::selectedFishbonesCollection( if ( objToFind == nullptr ) { - std::vector wellPaths; - caf::SelectionManager::instance()->objectsByType( &wellPaths ); + auto wellPaths = caf::SelectionManager::instance()->objectsByType(); if ( !wellPaths.empty() ) { return wellPaths[0]->fishbonesCollection(); diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicNewPerforationIntervalFeature.cpp b/ApplicationLibCode/Commands/CompletionCommands/RicNewPerforationIntervalFeature.cpp index b643b18762..bdc4ccc729 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicNewPerforationIntervalFeature.cpp +++ b/ApplicationLibCode/Commands/CompletionCommands/RicNewPerforationIntervalFeature.cpp @@ -84,8 +84,7 @@ void RicNewPerforationIntervalFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- RimPerforationCollection* RicNewPerforationIntervalFeature::selectedPerforationCollection() { - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); if ( selectedItems.size() != 1u ) return nullptr; caf::PdmUiItem* pdmUiItem = selectedItems.front(); diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicNewValveFeature.cpp b/ApplicationLibCode/Commands/CompletionCommands/RicNewValveFeature.cpp index f450a565ff..dbe7eac82f 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicNewValveFeature.cpp +++ b/ApplicationLibCode/Commands/CompletionCommands/RicNewValveFeature.cpp @@ -18,11 +18,10 @@ CAF_CMD_SOURCE_INIT( RicNewValveFeature, "RicNewValveFeature" ); //-------------------------------------------------------------------------------------------------- bool RicNewValveFeature::isCommandEnabled() const { - std::vector allSelectedItems; - caf::SelectionManager::instance()->selectedItems( allSelectedItems ); - if ( allSelectedItems.size() != 1u ) return false; + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); + if ( selectedItems.size() != 1u ) return false; - const RimPerforationInterval* perfInterval = dynamic_cast( allSelectedItems.front() ); + const RimPerforationInterval* perfInterval = dynamic_cast( selectedItems.front() ); return perfInterval != nullptr; } diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.cpp b/ApplicationLibCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.cpp index 5c711cb70a..77d505c19f 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.cpp +++ b/ApplicationLibCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.cpp @@ -124,13 +124,5 @@ void RicWellPathImportPerforationIntervalsFeature::setupActionLook( QAction* act //-------------------------------------------------------------------------------------------------- RimWellPathCollection* RicWellPathImportPerforationIntervalsFeature::selectedWellPathCollection() { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - - if ( objects.size() == 1 ) - { - return objects[0]; - } - - return nullptr; + return caf::SelectionManager::instance()->selectedItemOfType(); } diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp index 52dc3f982b..6d8ede91bb 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp @@ -40,9 +40,9 @@ CAF_CMD_SOURCE_INIT( RicExportCompletionsForVisibleWellPathsFeature, "RicExportC //-------------------------------------------------------------------------------------------------- bool RicExportCompletionsForVisibleWellPathsFeature::isCommandEnabled() const { - bool foundWellPathCollection = false; - std::vector selectedObjects; - caf::SelectionManager::instance()->objectsByType( &selectedObjects ); + bool foundWellPathCollection = false; + + const auto selectedObjects = caf::SelectionManager::instance()->objectsByType(); for ( caf::PdmObject* object : selectedObjects ) { RimWellPathCollection* wellPathCollection = object->firstAncestorOrThisOfType(); @@ -97,14 +97,10 @@ std::vector RicExportCompletionsForVisibleWellPathsFeature::visibl } { - std::vector wellPathCollections; - caf::SelectionManager::instance()->objectsByType( &wellPathCollections ); - + auto wellPathCollections = caf::SelectionManager::instance()->objectsByType(); if ( wellPathCollections.empty() ) { - std::vector selectedWellPaths; - caf::SelectionManager::instance()->objectsByType( &selectedWellPaths ); - + const auto selectedWellPaths = caf::SelectionManager::instance()->objectsByType(); if ( !selectedWellPaths.empty() ) { RimWellPathCollection* parent = selectedWellPaths[0]->firstAncestorOrThisOfType(); diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp index a864ff7fe1..b2130c06ae 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp @@ -222,8 +222,5 @@ void RicWellPathExportCompletionDataFeature::setupActionLook( QAction* actionToS //-------------------------------------------------------------------------------------------------- std::vector RicWellPathExportCompletionDataFeature::selectedWellPaths() { - std::vector wellPaths; - caf::SelectionManager::instance()->objectsByType( &wellPaths ); - - return wellPaths; + return caf::SelectionManager::instance()->objectsByType(); } diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp b/ApplicationLibCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp index 58e988fd00..cd73052149 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp @@ -39,8 +39,7 @@ CAF_CMD_SOURCE_INIT( RicAppendIntersectionFeature, "RicAppendIntersectionFeature //-------------------------------------------------------------------------------------------------- void RicAppendIntersectionFeature::onActionTriggered( bool isChecked ) { - std::vector collection; - caf::SelectionManager::instance()->objectsByType( &collection ); + const auto collection = caf::SelectionManager::instance()->objectsByType(); CVF_ASSERT( collection.size() == 1 ); RimIntersectionCollection* intersectionCollection = collection[0]->firstAncestorOrThisOfType(); diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicAppendSeparateIntersectionResultFeature.cpp b/ApplicationLibCode/Commands/CrossSectionCommands/RicAppendSeparateIntersectionResultFeature.cpp index afadba72d0..f4e64d7240 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/RicAppendSeparateIntersectionResultFeature.cpp +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicAppendSeparateIntersectionResultFeature.cpp @@ -37,8 +37,7 @@ CAF_CMD_SOURCE_INIT( RicAppendSeparateIntersectionResultFeature, "RicAppendSepar //-------------------------------------------------------------------------------------------------- void RicAppendSeparateIntersectionResultFeature::onActionTriggered( bool isChecked ) { - std::vector collection; - caf::SelectionManager::instance()->objectsByType( &collection ); + const auto collection = caf::SelectionManager::instance()->objectsByType(); CVF_ASSERT( collection.size() == 1 ); RimIntersectionResultsDefinitionCollection* intersectionResCollection = diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp b/ApplicationLibCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp index ee0412fcb3..e4d394770e 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp @@ -188,10 +188,9 @@ std::vector selectedIntersectionBoxes() //-------------------------------------------------------------------------------------------------- SelectionComposition selectionComposition() { - std::vector allSelectedObjects; - caf::SelectionManager::instance()->selectedItems( allSelectedObjects ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); - RimCase* gridCase = commonGridCase( allSelectedObjects ); + RimCase* gridCase = commonGridCase( selectedItems ); if ( gridCase && gridCase->gridViews().size() > 1 ) { RimIntersectionCollection* selColl = selectedIntersectionCollection(); @@ -200,7 +199,7 @@ SelectionComposition selectionComposition() if ( selColl ) { - if ( allSelectedObjects.size() == 1 ) return SEL_COLLECTION; + if ( selectedItems.size() == 1 ) return SEL_COLLECTION; } else { diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp index bb14330f78..fa02d66269 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp @@ -38,10 +38,7 @@ CAF_CMD_SOURCE_INIT( RicNewSimWellIntersectionFeature, "RicNewSimWellIntersectio //-------------------------------------------------------------------------------------------------- void RicNewSimWellIntersectionFeature::onActionTriggered( bool isChecked ) { - std::vector simWells; - caf::SelectionManager::instance()->objectsByType( &simWells ); - - for ( auto simWell : simWells ) + for ( auto simWell : caf::SelectionManager::instance()->objectsByType() ) { RimEclipseView* eclView = simWell->firstAncestorOrThisOfTypeAsserted(); diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp index 2504e77e3a..e30a12ae70 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp @@ -50,14 +50,11 @@ void RicNewWellPathIntersectionFeature::onActionTriggered( bool isChecked ) RimGridView* activeView = RiaApplication::instance()->activeMainOrComparisonGridView(); if ( !activeView ) return; - std::vector collection; - caf::SelectionManager::instance()->objectsByType( &collection ); - CVF_ASSERT( collection.size() == 1 ); - - RimWellPath* wellPath = collection[0]; - - RicNewWellPathIntersectionFeatureCmd* cmd = new RicNewWellPathIntersectionFeatureCmd( activeView->intersectionCollection(), wellPath ); - caf::CmdExecCommandManager::instance()->processExecuteCommand( cmd ); + if ( auto wellPath = caf::SelectionManager::instance()->selectedItemOfType() ) + { + RicNewWellPathIntersectionFeatureCmd* cmd = new RicNewWellPathIntersectionFeatureCmd( activeView->intersectionCollection(), wellPath ); + caf::CmdExecCommandManager::instance()->processExecuteCommand( cmd ); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/EclipseCommands/EclipseWell/RicEclipseWellFeatureImpl.cpp b/ApplicationLibCode/Commands/EclipseCommands/EclipseWell/RicEclipseWellFeatureImpl.cpp index f608894755..e37c92d8b4 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/EclipseWell/RicEclipseWellFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/EclipseCommands/EclipseWell/RicEclipseWellFeatureImpl.cpp @@ -39,8 +39,5 @@ bool RicEclipseWellFeatureImpl::isAnyWellSelected() //-------------------------------------------------------------------------------------------------- std::vector RicEclipseWellFeatureImpl::selectedWells() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - - return selection; + return caf::SelectionManager::instance()->objectsByType(); } diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicApplyPropertyFilterAsCellResultFeature.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicApplyPropertyFilterAsCellResultFeature.cpp index 511369b8ee..fb0589424e 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicApplyPropertyFilterAsCellResultFeature.cpp +++ b/ApplicationLibCode/Commands/EclipseCommands/RicApplyPropertyFilterAsCellResultFeature.cpp @@ -40,9 +40,7 @@ CAF_CMD_SOURCE_INIT( RicApplyPropertyFilterAsCellResultFeature, "RicApplyPropert bool RicApplyPropertyFilterAsCellResultFeature::isCommandEnabled() const { { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - + const auto objects = caf::SelectionManager::instance()->objectsByType(); if ( objects.size() == 1 ) { return true; @@ -50,9 +48,7 @@ bool RicApplyPropertyFilterAsCellResultFeature::isCommandEnabled() const } { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - + const auto objects = caf::SelectionManager::instance()->objectsByType(); if ( objects.size() == 1 ) { return true; @@ -68,9 +64,7 @@ bool RicApplyPropertyFilterAsCellResultFeature::isCommandEnabled() const void RicApplyPropertyFilterAsCellResultFeature::onActionTriggered( bool isChecked ) { { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - + const auto objects = caf::SelectionManager::instance()->objectsByType(); if ( objects.size() == 1 ) { RimEclipsePropertyFilter* propertyFilter = objects[0]; @@ -89,9 +83,7 @@ void RicApplyPropertyFilterAsCellResultFeature::onActionTriggered( bool isChecke } { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - + const auto objects = caf::SelectionManager::instance()->objectsByType(); if ( objects.size() == 1 ) { RimGeoMechPropertyFilter* propertyFilter = objects[0]; diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicComputeStatisticsFeature.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicComputeStatisticsFeature.cpp index fc157b7075..f7184ebd9a 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicComputeStatisticsFeature.cpp +++ b/ApplicationLibCode/Commands/EclipseCommands/RicComputeStatisticsFeature.cpp @@ -80,8 +80,5 @@ void RicComputeStatisticsFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- std::vector RicComputeStatisticsFeature::selectedCases() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - - return selection; + return caf::SelectionManager::instance()->objectsByType(); } diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicEclipseCaseNewGroupFeature.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicEclipseCaseNewGroupFeature.cpp index e8befa4b5d..5bb9f0dcd9 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicEclipseCaseNewGroupFeature.cpp +++ b/ApplicationLibCode/Commands/EclipseCommands/RicEclipseCaseNewGroupFeature.cpp @@ -36,11 +36,8 @@ CAF_CMD_SOURCE_INIT( RicEclipseCaseNewGroupFeature, "RicEclipseCaseNewGroupFeatu //-------------------------------------------------------------------------------------------------- bool RicEclipseCaseNewGroupFeature::isCommandEnabled() const { - std::vector caseSelection; - caf::SelectionManager::instance()->objectsByType( &caseSelection ); - - std::vector caseCollSelection; - caf::SelectionManager::instance()->objectsByType( &caseCollSelection ); + const auto caseSelection = caf::SelectionManager::instance()->objectsByType(); + const auto caseCollSelection = caf::SelectionManager::instance()->objectsByType(); return !caseSelection.empty() || !caseCollSelection.empty(); } diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp index 14a6694c57..9472bd3275 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp @@ -40,10 +40,7 @@ //-------------------------------------------------------------------------------------------------- std::vector RicEclipsePropertyFilterFeatureImpl::selectedPropertyFilters() { - std::vector propertyFilters; - caf::SelectionManager::instance()->objectsByType( &propertyFilters ); - - return propertyFilters; + return caf::SelectionManager::instance()->objectsByType(); } //-------------------------------------------------------------------------------------------------- @@ -51,10 +48,7 @@ std::vector RicEclipsePropertyFilterFeatureImpl::sele //-------------------------------------------------------------------------------------------------- std::vector RicEclipsePropertyFilterFeatureImpl::selectedPropertyFilterCollections() { - std::vector propertyFilterCollections; - caf::SelectionManager::instance()->objectsByType( &propertyFilterCollections ); - - return propertyFilterCollections; + return caf::SelectionManager::instance()->objectsByType(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.cpp index e3802967d2..ea2a9ce12f 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.cpp +++ b/ApplicationLibCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.cpp @@ -70,17 +70,13 @@ void RicNewStatisticsCaseFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- caf::PdmUiItem* RicNewStatisticsCaseFeature::selectedValidUIItem() { - std::vector statisticsCaseCollections; - caf::SelectionManager::instance()->objectsByType( &statisticsCaseCollections ); - + const auto statisticsCaseCollections = caf::SelectionManager::instance()->objectsByType(); if ( !statisticsCaseCollections.empty() ) { return statisticsCaseCollections[0]; } - std::vector caseCollections; - caf::SelectionManager::instance()->objectsByType( &caseCollections ); - + const auto caseCollections = caf::SelectionManager::instance()->objectsByType(); if ( !caseCollections.empty() ) { if ( RimIdenticalGridCaseGroup::isStatisticsCaseCollection( caseCollections[0] ) ) diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportCarfin.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportCarfin.cpp index 8d43308cf6..20b8efdd8b 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportCarfin.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportCarfin.cpp @@ -134,13 +134,5 @@ void RicExportCarfin::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- RimEclipseCase* RicExportCarfin::selectedCase() { - std::vector selectedObjects; - caf::SelectionManager::instance()->objectsByType( &selectedObjects ); - - if ( selectedObjects.size() == 1 ) - { - return selectedObjects[0]; - } - - return nullptr; + return caf::SelectionManager::instance()->selectedItemOfType(); } diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportFaultsFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportFaultsFeature.cpp index 4c81b3945b..77be4e2c0b 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportFaultsFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportFaultsFeature.cpp @@ -46,11 +46,7 @@ CAF_CMD_SOURCE_INIT( RicExportFaultsFeature, "RicExportFaultsFeature" ); //-------------------------------------------------------------------------------------------------- bool RicExportFaultsFeature::isCommandEnabled() const { - std::vector selectedFaults; - - caf::SelectionManager::instance()->objectsByType( &selectedFaults ); - - return ( !selectedFaults.empty() ); + return ( !caf::SelectionManager::instance()->objectsByType().empty() ); } //-------------------------------------------------------------------------------------------------- @@ -60,10 +56,7 @@ void RicExportFaultsFeature::onActionTriggered( bool isChecked ) { disableModelChangeContribution(); - std::vector selectedFaults; - - caf::SelectionManager::instance()->objectsByType( &selectedFaults ); - + const auto selectedFaults = caf::SelectionManager::instance()->objectsByType(); if ( selectedFaults.empty() ) return; QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallbackToProjectFolder( "FAULTS" ); diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp index e5812e5dce..3591976cc3 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp @@ -152,8 +152,5 @@ void RicSaveEclipseInputPropertyFeature::setupActionLook( QAction* actionToSetup //-------------------------------------------------------------------------------------------------- RimEclipseInputProperty* RicSaveEclipseInputPropertyFeature::selectedInputProperty() const { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - - return !selection.empty() ? selection[0] : nullptr; + return caf::SelectionManager::instance()->selectedItemOfType(); } diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyFeature.cpp index 0f77d533ff..a211703d51 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyFeature.cpp @@ -44,15 +44,7 @@ bool RicSaveEclipseResultAsInputPropertyFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- RimEclipseView* RicSaveEclipseResultAsInputPropertyFeature::selectedEclipseView() const { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - - if ( !selection.empty() ) - { - return selection[0]; - } - - return nullptr; + return caf::SelectionManager::instance()->selectedItemOfType(); } //-------------------------------------------------------------------------------------------------- @@ -60,15 +52,7 @@ RimEclipseView* RicSaveEclipseResultAsInputPropertyFeature::selectedEclipseView( //-------------------------------------------------------------------------------------------------- RimEclipseCellColors* RicSaveEclipseResultAsInputPropertyFeature::selectedEclipseCellColors() const { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - - if ( !selection.empty() ) - { - return selection[0]; - } - - return nullptr; + return caf::SelectionManager::instance()->selectedItemOfType(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp b/ApplicationLibCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp index 749ec13cfe..bf81272ee4 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp +++ b/ApplicationLibCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp @@ -54,10 +54,7 @@ CAF_CMD_SOURCE_INIT( RicPlotProductionRateFeature, "RicPlotProductionRateFeature //-------------------------------------------------------------------------------------------------- bool RicPlotProductionRateFeature::isCommandEnabled() const { - std::vector collection; - caf::SelectionManager::instance()->objectsByType( &collection ); - - for ( RimSimWellInView* well : collection ) + for ( RimSimWellInView* well : caf::SelectionManager::instance()->objectsByType() ) { auto summaryCase = RimSimWellInViewTools::summaryCaseForWell( well ); if ( summaryCase ) @@ -80,12 +77,9 @@ void RicPlotProductionRateFeature::onActionTriggered( bool isChecked ) RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr; if ( !sumCaseColl ) return; - std::vector collection; - caf::SelectionManager::instance()->objectsByType( &collection ); - RimSummaryPlot* summaryPlotToSelect = nullptr; - for ( RimSimWellInView* well : collection ) + for ( RimSimWellInView* well : caf::SelectionManager::instance()->objectsByType() ) { auto summaryCase = RimSimWellInViewTools::summaryCaseForWell( well ); if ( !summaryCase ) continue; diff --git a/ApplicationLibCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp b/ApplicationLibCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp index cb623ac95d..412f42f5b9 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp +++ b/ApplicationLibCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp @@ -40,12 +40,9 @@ CAF_CMD_SOURCE_INIT( RicShowContributingWellsFeature, "RicShowContributingWellsF //-------------------------------------------------------------------------------------------------- bool RicShowContributingWellsFeature::isCommandEnabled() const { - std::vector collection; - caf::SelectionManager::instance()->objectsByType( &collection ); - if ( collection.size() == 1 ) + if ( auto well = caf::SelectionManager::instance()->selectedItemOfType() ) { - RimSimWellInView* well = collection[0]; - RimEclipseView* eclipseView = well->firstAncestorOrThisOfType(); + RimEclipseView* eclipseView = well->firstAncestorOrThisOfType(); if ( eclipseView ) { @@ -74,13 +71,10 @@ bool RicShowContributingWellsFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicShowContributingWellsFeature::onActionTriggered( bool isChecked ) { - std::vector collection; - caf::SelectionManager::instance()->objectsByType( &collection ); + auto well = caf::SelectionManager::instance()->selectedItemOfType(); + if ( !well ) return; - CAF_ASSERT( collection.size() == 1 ); - - RimSimWellInView* well = collection[0]; - RimEclipseView* eclipseView = well->firstAncestorOrThisOfTypeAsserted(); + RimEclipseView* eclipseView = well->firstAncestorOrThisOfTypeAsserted(); RimEclipseResultCase* eclipseResultCase = well->firstAncestorOrThisOfTypeAsserted(); diff --git a/ApplicationLibCode/Commands/FlowCommands/RicShowTotalAllocationDataFeature.cpp b/ApplicationLibCode/Commands/FlowCommands/RicShowTotalAllocationDataFeature.cpp index 620c5fc5b8..30a7535528 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicShowTotalAllocationDataFeature.cpp +++ b/ApplicationLibCode/Commands/FlowCommands/RicShowTotalAllocationDataFeature.cpp @@ -81,9 +81,7 @@ std::set RicShowTotalAllocationDataFeature::selectedWell { std::set wellAllocPlots; - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - for ( auto obj : objects ) + for ( auto obj : caf::SelectionManager::instance()->objectsByType() ) { CVF_ASSERT( obj ); diff --git a/ApplicationLibCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp b/ApplicationLibCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp index 983428c0b3..0f3038c36a 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp +++ b/ApplicationLibCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp @@ -45,17 +45,12 @@ CAF_CMD_SOURCE_INIT( RicShowWellAllocationPlotFeature, "RicShowWellAllocationPlo //-------------------------------------------------------------------------------------------------- bool RicShowWellAllocationPlotFeature::isCommandEnabled() const { - std::vector simWellCollection; - caf::SelectionManager::instance()->objectsByType( &simWellCollection ); - - if ( !simWellCollection.empty() ) + if ( !caf::SelectionManager::instance()->objectsByType().empty() ) { return true; } - std::vector wellPathCollection; - caf::SelectionManager::instance()->objectsByType( &wellPathCollection ); - + const auto wellPathCollection = caf::SelectionManager::instance()->objectsByType(); if ( wellPathCollection.empty() ) return false; Rim3dView* view = RiaApplication::instance()->activeMainOrComparisonGridView(); @@ -73,11 +68,8 @@ bool RicShowWellAllocationPlotFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicShowWellAllocationPlotFeature::onActionTriggered( bool isChecked ) { - std::vector collection; - caf::SelectionManager::instance()->objectsByType( &collection ); - - std::vector wellPathCollection; - caf::SelectionManager::instance()->objectsByType( &wellPathCollection ); + const auto collection = caf::SelectionManager::instance()->objectsByType(); + const auto wellPathCollection = caf::SelectionManager::instance()->objectsByType(); RimSimWellInView* simWell = nullptr; diff --git a/ApplicationLibCode/Commands/FractureCommands/RicDeleteOptionItemFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicDeleteOptionItemFeature.cpp index bb5e1354ec..97b49d4321 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicDeleteOptionItemFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicDeleteOptionItemFeature.cpp @@ -32,8 +32,8 @@ CAF_CMD_SOURCE_INIT( RicDeleteOptionItemFeature, "RicDeleteOptionItemFeature" ); //-------------------------------------------------------------------------------------------------- void RicDeleteOptionItemFeature::onActionTriggered( bool isChecked ) { - std::vector optionItems; - caf::SelectionManager::instance()->objectsByType( &optionItems, caf::SelectionManager::FIRST_LEVEL ); + const auto optionItems = + caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); if ( !optionItems.empty() ) { @@ -62,8 +62,8 @@ void RicDeleteOptionItemFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- bool RicDeleteOptionItemFeature::isCommandEnabled() const { - std::vector optionItems; - caf::SelectionManager::instance()->objectsByType( &optionItems, caf::SelectionManager::FIRST_LEVEL ); + const auto optionItems = + caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); return !optionItems.empty(); } diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewOptionItemFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicNewOptionItemFeature.cpp index 0f92fc5cf5..4ec23bb278 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicNewOptionItemFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewOptionItemFeature.cpp @@ -49,8 +49,8 @@ void RicNewOptionItemFeature::onActionTriggered( bool isChecked ) RicCreateMultipleFracturesOptionItemUi* selectedOptionItem = nullptr; { - std::vector optionItems; - caf::SelectionManager::instance()->objectsByType( &optionItems, caf::SelectionManager::FIRST_LEVEL ); + const auto optionItems = + caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); if ( !optionItems.empty() ) { selectedOptionItem = optionItems.front(); diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanModelFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanModelFeature.cpp index 5b78dd20e9..99f4e2b3fd 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanModelFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanModelFeature.cpp @@ -137,8 +137,7 @@ bool RicNewStimPlanModelFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- RimStimPlanModelCollection* RicNewStimPlanModelFeature::selectedStimPlanModelCollection() { - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); if ( selectedItems.size() != 1u ) return nullptr; caf::PdmUiItem* pdmUiItem = selectedItems.front(); diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp index 2e274e9d7a..9320e19f0b 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp @@ -145,13 +145,12 @@ bool RicNewWellPathFractureFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- RimWellPathFractureCollection* RicNewWellPathFractureFeature::selectedWellPathFractureCollection() { - std::vector allSelectedItems; - caf::SelectionManager::instance()->selectedItems( allSelectedItems ); - if ( allSelectedItems.size() != 1u ) return nullptr; + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); + if ( selectedItems.size() != 1u ) return nullptr; RimWellPathFractureCollection* objToFind = nullptr; - caf::PdmUiItem* pdmUiItem = allSelectedItems.front(); + caf::PdmUiItem* pdmUiItem = selectedItems.front(); caf::PdmObjectHandle* objHandle = dynamic_cast( pdmUiItem ); if ( objHandle ) @@ -161,8 +160,7 @@ RimWellPathFractureCollection* RicNewWellPathFractureFeature::selectedWellPathFr if ( objToFind == nullptr ) { - std::vector wellPaths; - caf::SelectionManager::instance()->objectsByType( &wellPaths ); + auto wellPaths = caf::SelectionManager::instance()->objectsByType(); if ( !wellPaths.empty() ) { return wellPaths[0]->fractureCollection(); diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterFeatureImpl.cpp b/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterFeatureImpl.cpp index 9e9abb5e45..2a71cbbbc1 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterFeatureImpl.cpp @@ -38,10 +38,7 @@ //-------------------------------------------------------------------------------------------------- std::vector RicGeoMechPropertyFilterFeatureImpl::selectedPropertyFilters() { - std::vector propertyFilters; - caf::SelectionManager::instance()->objectsByType( &propertyFilters ); - - return propertyFilters; + return caf::SelectionManager::instance()->objectsByType(); } //-------------------------------------------------------------------------------------------------- @@ -49,10 +46,7 @@ std::vector RicGeoMechPropertyFilterFeatureImpl::sele //-------------------------------------------------------------------------------------------------- std::vector RicGeoMechPropertyFilterFeatureImpl::selectedPropertyFilterCollections() { - std::vector propertyFilterCollections; - caf::SelectionManager::instance()->objectsByType( &propertyFilterCollections ); - - return propertyFilterCollections; + return caf::SelectionManager::instance()->objectsByType(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp b/ApplicationLibCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp index 754858b8d6..36d58fe3da 100644 --- a/ApplicationLibCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp +++ b/ApplicationLibCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp @@ -81,11 +81,9 @@ void RicAppendIntersectionBoxFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- RimIntersectionCollection* RicAppendIntersectionBoxFeature::intersectionCollection() { - std::vector selectedObjects; - caf::SelectionManager::instance()->objectsByType( &selectedObjects ); - if ( selectedObjects.size() == 1 ) + if ( auto selectedObject = caf::SelectionManager::instance()->selectedItemOfType() ) { - return selectedObjects[0]->firstAncestorOrThisOfType(); + return selectedObject->firstAncestorOrThisOfType(); } return nullptr; diff --git a/ApplicationLibCode/Commands/OctaveScriptCommands/RicExecuteScriptForCasesFeature.cpp b/ApplicationLibCode/Commands/OctaveScriptCommands/RicExecuteScriptForCasesFeature.cpp index 5cf7273114..ab57bed9dd 100644 --- a/ApplicationLibCode/Commands/OctaveScriptCommands/RicExecuteScriptForCasesFeature.cpp +++ b/ApplicationLibCode/Commands/OctaveScriptCommands/RicExecuteScriptForCasesFeature.cpp @@ -39,9 +39,7 @@ CAF_CMD_SOURCE_INIT( RicExecuteScriptForCasesFeature, "RicExecuteScriptForCasesF //-------------------------------------------------------------------------------------------------- bool RicExecuteScriptForCasesFeature::isCommandEnabled() const { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - + const auto selection = caf::SelectionManager::instance()->objectsByType(); return !selection.empty(); } @@ -84,9 +82,7 @@ void RicExecuteScriptForCasesFeature::onActionTriggered( bool isChecked ) QStringList arguments = RimCalcScript::createCommandLineArguments( scriptAbsolutePath ); std::vector caseIdsInSelection; { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - + const auto selection = caf::SelectionManager::instance()->objectsByType(); for ( RimCase* rimCase : selection ) { caseIdsInSelection.push_back( rimCase->caseId() ); diff --git a/ApplicationLibCode/Commands/OctaveScriptCommands/RicScriptFeatureImpl.cpp b/ApplicationLibCode/Commands/OctaveScriptCommands/RicScriptFeatureImpl.cpp index baa1d164a5..292a71283c 100644 --- a/ApplicationLibCode/Commands/OctaveScriptCommands/RicScriptFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/OctaveScriptCommands/RicScriptFeatureImpl.cpp @@ -28,10 +28,7 @@ //-------------------------------------------------------------------------------------------------- std::vector RicScriptFeatureImpl::selectedScripts() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - - return selection; + return caf::SelectionManager::instance()->objectsByType(); } //-------------------------------------------------------------------------------------------------- @@ -39,8 +36,5 @@ std::vector RicScriptFeatureImpl::selectedScripts() //-------------------------------------------------------------------------------------------------- std::vector RicScriptFeatureImpl::selectedScriptCollections() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - - return selection; + return caf::SelectionManager::instance()->objectsByType(); } diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp index 83bf35ea71..9b08552ec2 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp @@ -67,10 +67,7 @@ void RicCopyReferencesToClipboardFeature::onActionTriggered( bool isChecked ) std::vector referenceList; - std::vector selectedFormationNamesCollObjs; - caf::SelectionManager::instance()->objectsByType( &selectedFormationNamesCollObjs ); - - for ( caf::PdmObject* pdmObject : selectedFormationNamesCollObjs ) + for ( caf::PdmObject* pdmObject : caf::SelectionManager::instance()->objectsByType() ) { if ( RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported( pdmObject ) ) { @@ -106,10 +103,7 @@ void RicCopyReferencesToClipboardFeature::setupActionLook( QAction* actionToSetu //-------------------------------------------------------------------------------------------------- bool RicCopyReferencesToClipboardFeature::isAnyCopyableObjectSelected() { - std::vector selectedFormationNamesCollObjs; - caf::SelectionManager::instance()->objectsByType( &selectedFormationNamesCollObjs ); - - for ( caf::PdmObject* pdmObject : selectedFormationNamesCollObjs ) + for ( caf::PdmObject* pdmObject : caf::SelectionManager::instance()->objectsByType() ) { if ( RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported( pdmObject ) ) { diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCutReferencesToClipboardFeature.cpp b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCutReferencesToClipboardFeature.cpp index 7f17e059c7..4bb8352b11 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCutReferencesToClipboardFeature.cpp +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCutReferencesToClipboardFeature.cpp @@ -52,10 +52,7 @@ void RicCutReferencesToClipboardFeature::onActionTriggered( bool isChecked ) std::vector referenceList; - std::vector selectedFormationNamesCollObjs; - caf::SelectionManager::instance()->objectsByType( &selectedFormationNamesCollObjs ); - - for ( caf::PdmObject* pdmObject : selectedFormationNamesCollObjs ) + for ( caf::PdmObject* pdmObject : caf::SelectionManager::instance()->objectsByType() ) { if ( RicCutReferencesToClipboardFeature::isCuttingOfObjectSupported( pdmObject ) ) { @@ -91,10 +88,7 @@ void RicCutReferencesToClipboardFeature::setupActionLook( QAction* actionToSetup //-------------------------------------------------------------------------------------------------- bool RicCutReferencesToClipboardFeature::isAnyCuttableObjectSelected() { - std::vector selectedFormationNamesCollObjs; - caf::SelectionManager::instance()->objectsByType( &selectedFormationNamesCollObjs ); - - for ( caf::PdmObject* pdmObject : selectedFormationNamesCollObjs ) + for ( caf::PdmObject* pdmObject : caf::SelectionManager::instance()->objectsByType() ) { if ( RicCutReferencesToClipboardFeature::isCuttingOfObjectSupported( pdmObject ) ) { diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryAddressesFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryAddressesFeature.cpp index b780b148e2..23a884cdaf 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryAddressesFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryAddressesFeature.cpp @@ -71,12 +71,5 @@ void RicAppendSummaryCurvesForSummaryAddressesFeature::setupActionLook( QAction* //-------------------------------------------------------------------------------------------------- std::vector RicAppendSummaryCurvesForSummaryAddressesFeature::selectedAddresses() { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - - // Make the object type general to match the expected type for handleDroppedObjects(); - std::vector generalObjects; - generalObjects.insert( generalObjects.begin(), objects.begin(), objects.end() ); - - return generalObjects; + return caf::SelectionManager::instance()->objectsByType(); } diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryCasesFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryCasesFeature.cpp index f96ba92d0a..6ac1e378ff 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryCasesFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryCasesFeature.cpp @@ -77,18 +77,11 @@ std::vector RicAppendSummaryCurvesForSummaryCasesFeature: // Make the object type general to match the expected type for handleDroppedObjects(); std::vector objects; - { - std::vector summaryCases; - caf::SelectionManager::instance()->objectsByType( &summaryCases ); + const auto summaryCases = caf::SelectionManager::instance()->objectsByType(); + objects.insert( objects.begin(), summaryCases.begin(), summaryCases.end() ); - objects.insert( objects.begin(), summaryCases.begin(), summaryCases.end() ); - } - { - std::vector ensembles; - caf::SelectionManager::instance()->objectsByType( &ensembles ); - - objects.insert( objects.begin(), ensembles.begin(), ensembles.end() ); - } + const auto ensembles = caf::SelectionManager::instance()->objectsByType(); + objects.insert( objects.begin(), ensembles.begin(), ensembles.end() ); return objects; } diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.cpp index 55b1229342..674ada5639 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.cpp @@ -209,8 +209,7 @@ void RicAppendSummaryPlotsForObjectsFeature::setupActionLook( QAction* actionToS //-------------------------------------------------------------------------------------------------- std::vector RicAppendSummaryPlotsForObjectsFeature::selectedCollections() { - std::vector sumAddressCollections; - caf::SelectionManager::instance()->objectsByType( &sumAddressCollections ); + const auto sumAddressCollections = caf::SelectionManager::instance()->objectsByType(); if ( sumAddressCollections.size() == 1 ) { diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryAddressesFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryAddressesFeature.cpp index 2d238b2458..5856c6158b 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryAddressesFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryAddressesFeature.cpp @@ -92,8 +92,5 @@ void RicAppendSummaryPlotsForSummaryAddressesFeature::setupActionLook( QAction* //-------------------------------------------------------------------------------------------------- std::vector RicAppendSummaryPlotsForSummaryAddressesFeature::selectedAddresses() { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - - return objects; + return caf::SelectionManager::instance()->objectsByType(); } diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.cpp index c8665e2435..497fef9344 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.cpp @@ -75,10 +75,7 @@ void RicAppendSummaryPlotsForSummaryCasesFeature::setupActionLook( QAction* acti //-------------------------------------------------------------------------------------------------- std::vector RicAppendSummaryPlotsForSummaryCasesFeature::selectedCases() { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - - return objects; + return caf::SelectionManager::instance()->objectsByType(); } //-------------------------------------------------------------------------------------------------- @@ -86,8 +83,5 @@ std::vector RicAppendSummaryPlotsForSummaryCasesFeature::select //-------------------------------------------------------------------------------------------------- std::vector RicAppendSummaryPlotsForSummaryCasesFeature::selectedEnsembles() { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - - return objects; + return caf::SelectionManager::instance()->objectsByType(); } diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewMultiPlotFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewMultiPlotFeature.cpp index e95ab5d6df..be6a937a11 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewMultiPlotFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewMultiPlotFeature.cpp @@ -69,10 +69,9 @@ bool RicNewMultiPlotFeature::isCommandEnabled() const { auto plots = selectedPlots(); - std::vector selectedUiItems; - caf::SelectionManager::instance()->selectedItems( selectedUiItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); - return !plots.empty() && plots.size() == selectedUiItems.size(); + return !plots.empty() && plots.size() == selectedItems.size(); } //-------------------------------------------------------------------------------------------------- @@ -103,11 +102,8 @@ void RicNewMultiPlotFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- std::vector RicNewMultiPlotFeature::selectedPlots() { - std::vector uiItems; - caf::SelectionManager::instance()->selectedItems( uiItems ); - std::vector plots; - for ( caf::PdmUiItem* uiItem : uiItems ) + for ( caf::PdmUiItem* uiItem : caf::SelectionManager::instance()->selectedItems() ) { RimPlot* plotInterface = dynamic_cast( uiItem ); // Special case for all well log tracks which currently need to be in Well Log Plot for diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.cpp index 2e236472e0..d1202cc85c 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.cpp @@ -39,10 +39,9 @@ CAF_CMD_SOURCE_INIT( RicNewSummaryMultiPlotFeature, "RicNewSummaryMultiPlotFeatu //-------------------------------------------------------------------------------------------------- bool RicNewSummaryMultiPlotFeature::isCommandEnabled() const { - std::vector selectedUiItems; - caf::SelectionManager::instance()->selectedItems( selectedUiItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); - if ( selectedCollection( selectedUiItems ) ) return true; + if ( selectedCollection( selectedItems ) ) return true; std::vector selectedIndividualSummaryCases; std::vector selectedEnsembles; @@ -54,13 +53,12 @@ bool RicNewSummaryMultiPlotFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicNewSummaryMultiPlotFeature::onActionTriggered( bool isChecked ) { - std::vector selectedUiItems; - caf::SelectionManager::instance()->selectedItems( selectedUiItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); std::vector selectedIndividualSummaryCases; std::vector selectedEnsembles; - RimSummaryMultiPlotCollection* coll = selectedCollection( selectedUiItems ); + RimSummaryMultiPlotCollection* coll = selectedCollection( selectedItems ); if ( coll ) { auto ensembles = RimProject::current()->summaryGroups(); @@ -95,7 +93,7 @@ void RicNewSummaryMultiPlotFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryMultiPlotCollection* RicNewSummaryMultiPlotFeature::selectedCollection( std::vector& items ) +RimSummaryMultiPlotCollection* RicNewSummaryMultiPlotFeature::selectedCollection( const std::vector& items ) { for ( caf::PdmUiItem* uiItem : items ) { @@ -113,12 +111,12 @@ bool RicNewSummaryMultiPlotFeature::selectedCases( std::vector* { CAF_ASSERT( selectedIndividualSummaryCases && selectedEnsembles ); - caf::SelectionManager::instance()->objectsByTypeStrict( selectedEnsembles ); + *selectedIndividualSummaryCases = caf::SelectionManager::instance()->objectsByTypeStrict(); if ( !selectedEnsembles->empty() ) { return true; } // Second try selected summary cases - caf::SelectionManager::instance()->objectsByTypeStrict( selectedIndividualSummaryCases ); + *selectedEnsembles = caf::SelectionManager::instance()->objectsByTypeStrict(); return !selectedIndividualSummaryCases->empty(); } diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.h index eaa029493e..963769453d 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.h +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.h @@ -41,7 +41,7 @@ protected: void setupActionLook( QAction* actionToSetup ) override; private: - static RimSummaryMultiPlotCollection* selectedCollection( std::vector& items ); + static RimSummaryMultiPlotCollection* selectedCollection( const std::vector& items ); static bool selectedCases( std::vector* selectedIndividualSummaryCases, std::vector* selectedEnsembles ); diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.cpp index 09ca662de0..e1d662d482 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.cpp @@ -42,9 +42,7 @@ CAF_CMD_SOURCE_INIT( RicNewSummaryMultiPlotFromDataVectorFeature, "RicNewSummary //-------------------------------------------------------------------------------------------------- bool RicNewSummaryMultiPlotFromDataVectorFeature::isCommandEnabled() const { - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); - + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); std::vector selectedAddressItems = caf::selectedObjectsByType(); unsigned int nEnsembles = 0; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromDataVectorFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromDataVectorFeature.cpp index cc8ea6d5e4..982f352798 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromDataVectorFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromDataVectorFeature.cpp @@ -40,9 +40,7 @@ CAF_CMD_SOURCE_INIT( RicNewSummaryPlotFromDataVectorFeature, "RicNewSummaryPlotF //-------------------------------------------------------------------------------------------------- bool RicNewSummaryPlotFromDataVectorFeature::isCommandEnabled() const { - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); - + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); std::vector selectedAddressItems = caf::selectedObjectsByType(); unsigned int nEnsembles = 0; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicSplitMultiPlotFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSplitMultiPlotFeature.cpp index 8bcd3bdc55..3057ad694f 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicSplitMultiPlotFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSplitMultiPlotFeature.cpp @@ -105,10 +105,8 @@ RimSummaryPlot* RicSplitMultiPlotFeature::getSelectedPlot() const if ( plot == nullptr ) { - std::vector selectedUiItems; - caf::SelectionManager::instance()->selectedItems( selectedUiItems ); - - if ( !selectedUiItems.empty() ) plot = dynamic_cast( selectedUiItems[0] ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); + if ( !selectedItems.empty() ) plot = dynamic_cast( selectedItems[0] ); } return plot; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.cpp index 15f6b54a79..0d5da59da2 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.cpp +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.cpp @@ -46,11 +46,10 @@ CAF_CMD_SOURCE_INIT( RicCreateNewPlotFromTemplateFeature, "RicCreateNewPlotFromT //-------------------------------------------------------------------------------------------------- bool RicCreateNewPlotFromTemplateFeature::isCommandEnabled() const { - std::vector uiItems; - caf::SelectionManager::instance()->selectedItems( uiItems ); - if ( uiItems.size() != 1 ) return false; + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); + if ( selectedItems.size() != 1 ) return false; - RimPlotTemplateFileItem* file = dynamic_cast( uiItems[0] ); + RimPlotTemplateFileItem* file = dynamic_cast( selectedItems[0] ); return ( file != nullptr ); } @@ -59,12 +58,10 @@ bool RicCreateNewPlotFromTemplateFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicCreateNewPlotFromTemplateFeature::onActionTriggered( bool isChecked ) { - std::vector uiItems; - caf::SelectionManager::instance()->selectedItems( uiItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); + if ( selectedItems.size() != 1 ) return; - if ( uiItems.size() != 1 ) return; - - RimPlotTemplateFileItem* file = dynamic_cast( uiItems[0] ); + RimPlotTemplateFileItem* file = dynamic_cast( selectedItems[0] ); if ( file == nullptr ) return; RimSummaryMultiPlot* plot = nullptr; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicDeletePlotTemplateFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicDeletePlotTemplateFeature.cpp index ef39e3b52d..de2ad9a835 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicDeletePlotTemplateFeature.cpp +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicDeletePlotTemplateFeature.cpp @@ -40,12 +40,8 @@ CAF_CMD_SOURCE_INIT( RicDeletePlotTemplateFeature, "RicDeletePlotTemplateFeature //-------------------------------------------------------------------------------------------------- bool RicDeletePlotTemplateFeature::isCommandEnabled() const { - std::vector uiItems; - caf::SelectionManager::instance()->selectedItems( uiItems ); - if ( uiItems.size() != 1 ) return false; - - RimPlotTemplateFileItem* file = dynamic_cast( uiItems[0] ); - return ( file != nullptr ); + auto object = caf::SelectionManager::instance()->selectedItemOfType(); + return object != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -53,12 +49,7 @@ bool RicDeletePlotTemplateFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicDeletePlotTemplateFeature::onActionTriggered( bool isChecked ) { - std::vector uiItems; - caf::SelectionManager::instance()->selectedItems( uiItems ); - - if ( uiItems.size() != 1 ) return; - - RimPlotTemplateFileItem* file = dynamic_cast( uiItems[0] ); + auto file = caf::SelectionManager::instance()->selectedItemOfType(); if ( file == nullptr ) return; QWidget* parent = RiuPlotMainWindow::instance(); diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicRenamePlotTemplateFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicRenamePlotTemplateFeature.cpp index efb1ce4630..c943be379d 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicRenamePlotTemplateFeature.cpp +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicRenamePlotTemplateFeature.cpp @@ -38,11 +38,7 @@ CAF_CMD_SOURCE_INIT( RicRenamePlotTemplateFeature, "RicRenamePlotTemplateFeature //-------------------------------------------------------------------------------------------------- bool RicRenamePlotTemplateFeature::isCommandEnabled() const { - std::vector uiItems; - caf::SelectionManager::instance()->selectedItems( uiItems ); - if ( uiItems.size() != 1 ) return false; - - RimPlotTemplateFileItem* file = dynamic_cast( uiItems[0] ); + auto file = caf::SelectionManager::instance()->selectedItemOfType(); return ( file != nullptr ); } @@ -51,12 +47,7 @@ bool RicRenamePlotTemplateFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicRenamePlotTemplateFeature::onActionTriggered( bool isChecked ) { - std::vector uiItems; - caf::SelectionManager::instance()->selectedItems( uiItems ); - - if ( uiItems.size() != 1 ) return; - - RimPlotTemplateFileItem* file = dynamic_cast( uiItems[0] ); + auto file = caf::SelectionManager::instance()->selectedItemOfType(); if ( file == nullptr ) return; QFileInfo fi( file->absoluteFilePath() ); diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSetAsDefaultTemplateFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSetAsDefaultTemplateFeature.cpp index c7674eade3..110c9692be 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSetAsDefaultTemplateFeature.cpp +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSetAsDefaultTemplateFeature.cpp @@ -78,10 +78,5 @@ void RicSetAsDefaultTemplateFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- RimPlotTemplateFileItem* RicSetAsDefaultTemplateFeature::selectedTemplate() const { - std::vector uiItems; - caf::SelectionManager::instance()->selectedItems( uiItems ); - if ( uiItems.size() != 1 ) return nullptr; - - RimPlotTemplateFileItem* file = dynamic_cast( uiItems[0] ); - return file; + return caf::SelectionManager::instance()->selectedItemOfType(); } diff --git a/ApplicationLibCode/Commands/RicCloseCaseFeature.cpp b/ApplicationLibCode/Commands/RicCloseCaseFeature.cpp index 57bb4269eb..fff727cd58 100644 --- a/ApplicationLibCode/Commands/RicCloseCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicCloseCaseFeature.cpp @@ -114,9 +114,7 @@ void RicCloseCaseFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- std::vector RicCloseCaseFeature::selectedCases() const { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - return selection; + return caf::SelectionManager::instance()->objectsByType(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/RicCloseObservedDataFeature.cpp b/ApplicationLibCode/Commands/RicCloseObservedDataFeature.cpp index be58b42565..bf24809a63 100644 --- a/ApplicationLibCode/Commands/RicCloseObservedDataFeature.cpp +++ b/ApplicationLibCode/Commands/RicCloseObservedDataFeature.cpp @@ -99,11 +99,8 @@ void RicCloseObservedDataFeature::deleteObservedRmuRftData( const std::vector summarySelection; - caf::SelectionManager::instance()->objectsByType( &summarySelection ); - - std::vector fmuRftSelection; - caf::SelectionManager::instance()->objectsByType( &fmuRftSelection ); + const auto summarySelection = caf::SelectionManager::instance()->objectsByType(); + const auto fmuRftSelection = caf::SelectionManager::instance()->objectsByType(); if ( summarySelection.empty() && fmuRftSelection.empty() ) { @@ -125,11 +122,8 @@ bool RicCloseObservedDataFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicCloseObservedDataFeature::onActionTriggered( bool isChecked ) { - std::vector summarySelection; - caf::SelectionManager::instance()->objectsByType( &summarySelection ); - - std::vector fmuRftSelection; - caf::SelectionManager::instance()->objectsByType( &fmuRftSelection ); + const auto summarySelection = caf::SelectionManager::instance()->objectsByType(); + const auto fmuRftSelection = caf::SelectionManager::instance()->objectsByType(); CVF_ASSERT( !( summarySelection.empty() && fmuRftSelection.empty() ) ); diff --git a/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.cpp b/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.cpp index df87110afc..b3080b770d 100644 --- a/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.cpp @@ -60,7 +60,7 @@ void RicCloseSummaryCaseFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicCloseSummaryCaseFeature::deleteSummaryCases( std::vector& cases ) +void RicCloseSummaryCaseFeature::deleteSummaryCases( std::vector cases ) { RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection(); RimSummaryCaseMainCollection* summaryCaseMainCollection = RiaSummaryTools::summaryCaseMainCollection(); @@ -105,9 +105,7 @@ void RicCloseSummaryCaseFeature::deleteSummaryCases( std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - + const auto selection = caf::SelectionManager::instance()->objectsByType(); if ( selection.empty() ) { return false; @@ -128,9 +126,5 @@ bool RicCloseSummaryCaseFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicCloseSummaryCaseFeature::onActionTriggered( bool isChecked ) { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - CVF_ASSERT( !selection.empty() ); - - RicCloseSummaryCaseFeature::deleteSummaryCases( selection ); + RicCloseSummaryCaseFeature::deleteSummaryCases( caf::SelectionManager::instance()->objectsByType() ); } diff --git a/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.h b/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.h index 6b19002ce3..71c519e01b 100644 --- a/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.h +++ b/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.h @@ -33,7 +33,7 @@ class RicCloseSummaryCaseFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; public: - static void deleteSummaryCases( std::vector& cases ); + static void deleteSummaryCases( std::vector cases ); protected: bool isCommandEnabled() const override; diff --git a/ApplicationLibCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp b/ApplicationLibCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp index 46c658c49c..d1bc2f7f1b 100644 --- a/ApplicationLibCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp +++ b/ApplicationLibCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp @@ -55,11 +55,8 @@ void RicCloseSummaryCaseInCollectionFeature::setupActionLook( QAction* actionToS //-------------------------------------------------------------------------------------------------- bool RicCloseSummaryCaseInCollectionFeature::isCommandEnabled() const { - std::vector summaryCaseMainCollections; - caf::SelectionManager::instance()->objectsByType( &summaryCaseMainCollections ); - - std::vector summaryCaseCollections; - caf::SelectionManager::instance()->objectsByType( &summaryCaseCollections ); + auto summaryCaseMainCollections = caf::SelectionManager::instance()->objectsByType(); + auto summaryCaseCollections = caf::SelectionManager::instance()->objectsByType(); summaryCaseCollections.erase( std::remove_if( summaryCaseCollections.begin(), summaryCaseCollections.end(), @@ -75,18 +72,14 @@ bool RicCloseSummaryCaseInCollectionFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicCloseSummaryCaseInCollectionFeature::onActionTriggered( bool isChecked ) { - std::vector summaryCaseMainCollections; - caf::SelectionManager::instance()->objectsByType( &summaryCaseMainCollections ); - + auto summaryCaseMainCollections = caf::SelectionManager::instance()->objectsByType(); if ( !summaryCaseMainCollections.empty() ) { std::vector allSummaryCases = summaryCaseMainCollections[0]->allSummaryCases(); RicCloseSummaryCaseFeature::deleteSummaryCases( allSummaryCases ); } - std::vector summaryCaseCollections; - caf::SelectionManager::instance()->objectsByType( &summaryCaseCollections ); - + auto summaryCaseCollections = caf::SelectionManager::instance()->objectsByType(); for ( RimSummaryEnsemble* summaryCaseCollection : summaryCaseCollections ) { std::vector collectionSummaryCases = summaryCaseCollection->allSummaryCases(); diff --git a/ApplicationLibCode/Commands/RicCreateSummaryEnsembleFeature.cpp b/ApplicationLibCode/Commands/RicCreateSummaryEnsembleFeature.cpp index 65c5eaf642..089e9a143f 100644 --- a/ApplicationLibCode/Commands/RicCreateSummaryEnsembleFeature.cpp +++ b/ApplicationLibCode/Commands/RicCreateSummaryEnsembleFeature.cpp @@ -33,9 +33,7 @@ CAF_CMD_SOURCE_INIT( RicCreateSummaryEnsembleFeature, "RicCreateSummaryEnsembleF //-------------------------------------------------------------------------------------------------- bool RicCreateSummaryEnsembleFeature::isCommandEnabled() const { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - + const auto selection = caf::SelectionManager::instance()->objectsByType(); return !selection.empty(); } @@ -44,8 +42,7 @@ bool RicCreateSummaryEnsembleFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicCreateSummaryEnsembleFeature::onActionTriggered( bool isChecked ) { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); + const auto selection = caf::SelectionManager::instance()->objectsByType(); if ( selection.empty() ) return; RicImportEnsembleFeature::createSummaryEnsemble( selection ); diff --git a/ApplicationLibCode/Commands/RicDeleteItemFeature.cpp b/ApplicationLibCode/Commands/RicDeleteItemFeature.cpp index b8f1ab2019..97e82c774d 100644 --- a/ApplicationLibCode/Commands/RicDeleteItemFeature.cpp +++ b/ApplicationLibCode/Commands/RicDeleteItemFeature.cpp @@ -37,12 +37,11 @@ CAF_CMD_SOURCE_INIT( RicDeleteItemFeature, "RicDeleteItemFeature" ); //-------------------------------------------------------------------------------------------------- bool RicDeleteItemFeature::isCommandEnabled() const { - std::vector items; - caf::SelectionManager::instance()->selectedItems( items ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); - if ( items.empty() ) return false; + if ( selectedItems.empty() ) return false; - for ( caf::PdmUiItem* item : items ) + for ( caf::PdmUiItem* item : selectedItems ) { auto* currentPdmObject = dynamic_cast( item ); if ( !currentPdmObject ) return false; @@ -61,10 +60,7 @@ bool RicDeleteItemFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicDeleteItemFeature::onActionTriggered( bool isChecked ) { - std::vector items; - caf::SelectionManager::instance()->selectedItems( items ); - - for ( caf::PdmUiItem* item : items ) + for ( caf::PdmUiItem* item : caf::SelectionManager::instance()->selectedItems() ) { auto* currentPdmObject = dynamic_cast( item ); if ( !currentPdmObject ) continue; diff --git a/ApplicationLibCode/Commands/RicDeletePressureTableItemFeature.cpp b/ApplicationLibCode/Commands/RicDeletePressureTableItemFeature.cpp index 7e05dc9bee..21d578fd71 100644 --- a/ApplicationLibCode/Commands/RicDeletePressureTableItemFeature.cpp +++ b/ApplicationLibCode/Commands/RicDeletePressureTableItemFeature.cpp @@ -31,8 +31,7 @@ CAF_CMD_SOURCE_INIT( RicDeletePressureTableItemFeature, "RicDeletePressureTableI //-------------------------------------------------------------------------------------------------- bool RicDeletePressureTableItemFeature::isCommandEnabled() const { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects, caf::SelectionManager::FIRST_LEVEL ); + auto objects = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); return !objects.empty(); } @@ -41,12 +40,11 @@ bool RicDeletePressureTableItemFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicDeletePressureTableItemFeature::onActionTriggered( bool isChecked ) { - std::vector items; - caf::SelectionManager::instance()->objectsByType( &items, caf::SelectionManager::FIRST_LEVEL ); - if ( !items.empty() ) + auto objects = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + if ( !objects.empty() ) { - RimPressureTable* pressureTable = items[0]->firstAncestorOrThisOfTypeAsserted(); - for ( RimPressureTableItem* attributeToDelete : items ) + RimPressureTable* pressureTable = objects[0]->firstAncestorOrThisOfTypeAsserted(); + for ( RimPressureTableItem* attributeToDelete : objects ) { pressureTable->deleteItem( attributeToDelete ); } diff --git a/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp b/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp index 25869712e0..8339aa275f 100644 --- a/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp +++ b/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp @@ -49,12 +49,10 @@ bool RicDeleteSubItemsFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- bool RicDeleteSubItemsFeature::canCommandBeEnabled() { - std::vector items; - caf::SelectionManager::instance()->selectedItems( items ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); + if ( selectedItems.empty() ) return false; - if ( items.empty() ) return false; - - for ( auto* item : items ) + for ( auto* item : selectedItems ) { if ( !RicDeleteSubItemsFeature::hasDeletableSubItems( item ) ) return false; } @@ -134,12 +132,7 @@ bool RicDeleteSubItemsFeature::hasDeletableSubItems( caf::PdmUiItem* uiItem ) //-------------------------------------------------------------------------------------------------- void RicDeleteSubItemsFeature::deleteSubItems( bool onlyDeleteUnchecked ) { - std::vector items; - caf::SelectionManager::instance()->selectedItems( items ); - - CVF_ASSERT( !items.empty() ); - - for ( auto item : items ) + for ( auto item : caf::SelectionManager::instance()->selectedItems() ) { if ( !RicDeleteSubItemsFeature::hasDeletableSubItems( item ) ) continue; diff --git a/ApplicationLibCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp b/ApplicationLibCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp index bdafe3224d..df3561d5aa 100644 --- a/ApplicationLibCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp +++ b/ApplicationLibCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp @@ -68,8 +68,7 @@ void RicDeleteSummaryCaseCollectionFeature::deleteSummaryCaseCollection( RimSumm //-------------------------------------------------------------------------------------------------- bool RicDeleteSummaryCaseCollectionFeature::isCommandEnabled() const { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); + auto selection = caf::SelectionManager::instance()->objectsByType(); selection.erase( std::remove_if( selection.begin(), selection.end(), @@ -83,8 +82,7 @@ bool RicDeleteSummaryCaseCollectionFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicDeleteSummaryCaseCollectionFeature::onActionTriggered( bool isChecked ) { - std::vector ensembles; - caf::SelectionManager::instance()->objectsByType( &ensembles ); + const auto ensembles = caf::SelectionManager::instance()->objectsByType(); if ( ensembles.empty() ) return; QMessageBox msgBox; diff --git a/ApplicationLibCode/Commands/RicDeleteWellMeasurementFilePathFeature.cpp b/ApplicationLibCode/Commands/RicDeleteWellMeasurementFilePathFeature.cpp index 7f7be234c4..e6c82c3f5e 100644 --- a/ApplicationLibCode/Commands/RicDeleteWellMeasurementFilePathFeature.cpp +++ b/ApplicationLibCode/Commands/RicDeleteWellMeasurementFilePathFeature.cpp @@ -32,8 +32,7 @@ CAF_CMD_SOURCE_INIT( RicDeleteWellMeasurementFilePathFeature, "RicDeleteWellMeas //-------------------------------------------------------------------------------------------------- bool RicDeleteWellMeasurementFilePathFeature::isCommandEnabled() const { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); + const auto objects = caf::SelectionManager::instance()->objectsByType(); return !objects.empty(); } @@ -42,8 +41,7 @@ bool RicDeleteWellMeasurementFilePathFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicDeleteWellMeasurementFilePathFeature::onActionTriggered( bool isChecked ) { - std::vector selectedFilePaths; - caf::SelectionManager::instance()->objectsByType( &selectedFilePaths ); + const auto selectedFilePaths = caf::SelectionManager::instance()->objectsByType(); if ( selectedFilePaths.empty() ) return; RimWellMeasurementFilePath* filePath = selectedFilePaths[0]; diff --git a/ApplicationLibCode/Commands/RicFlyToObjectFeature.cpp b/ApplicationLibCode/Commands/RicFlyToObjectFeature.cpp index 17749309a7..0ed12364e6 100644 --- a/ApplicationLibCode/Commands/RicFlyToObjectFeature.cpp +++ b/ApplicationLibCode/Commands/RicFlyToObjectFeature.cpp @@ -105,10 +105,7 @@ cvf::BoundingBox RicFlyToObjectFeature::boundingBoxForSelectedObjects() { cvf::BoundingBox bb; - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - - for ( auto obj : objects ) + for ( auto obj : caf::SelectionManager::instance()->objectsByType() ) { if ( obj ) { diff --git a/ApplicationLibCode/Commands/RicImportElementPropertyFeature.cpp b/ApplicationLibCode/Commands/RicImportElementPropertyFeature.cpp index 3560318b0b..d1791c37f3 100644 --- a/ApplicationLibCode/Commands/RicImportElementPropertyFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportElementPropertyFeature.cpp @@ -40,14 +40,13 @@ CAF_CMD_SOURCE_INIT( RicImportElementPropertyFeature, "RicImportElementPropertyF //-------------------------------------------------------------------------------------------------- void RicImportElementPropertyFeature::onActionTriggered( bool isChecked ) { - std::vector uiItems; - caf::SelectionManager::instance()->selectedItems( uiItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); RimGeoMechCase* geomCase = nullptr; - if ( !uiItems.empty() ) + if ( !selectedItems.empty() ) { - geomCase = dynamic_cast( uiItems[0] ); + geomCase = dynamic_cast( selectedItems[0] ); } if ( geomCase == nullptr ) diff --git a/ApplicationLibCode/Commands/RicImportObservedDataFeature.cpp b/ApplicationLibCode/Commands/RicImportObservedDataFeature.cpp index 4118607d6f..9baee2463d 100644 --- a/ApplicationLibCode/Commands/RicImportObservedDataFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportObservedDataFeature.cpp @@ -93,11 +93,8 @@ void RicImportObservedDataFeature::selectObservedDataFileInDialog() //-------------------------------------------------------------------------------------------------- bool RicImportObservedDataFeature::isCommandEnabled() const { - std::vector selectionObservedDataCollection; - caf::SelectionManager::instance()->objectsByType( &selectionObservedDataCollection ); - - std::vector selectionObservedData; - caf::SelectionManager::instance()->objectsByType( &selectionObservedData ); + const auto selectionObservedDataCollection = caf::SelectionManager::instance()->objectsByType(); + const auto selectionObservedData = caf::SelectionManager::instance()->objectsByType(); return ( !selectionObservedDataCollection.empty() || !selectionObservedData.empty() ); } diff --git a/ApplicationLibCode/Commands/RicImportObservedFmuDataFeature.cpp b/ApplicationLibCode/Commands/RicImportObservedFmuDataFeature.cpp index 93baf65df8..1672ad18b8 100644 --- a/ApplicationLibCode/Commands/RicImportObservedFmuDataFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportObservedFmuDataFeature.cpp @@ -96,11 +96,8 @@ void RicImportObservedFmuDataFeature::selectObservedDataPathInDialog() //-------------------------------------------------------------------------------------------------- bool RicImportObservedFmuDataFeature::isCommandEnabled() const { - std::vector selectionObservedDataCollection; - caf::SelectionManager::instance()->objectsByType( &selectionObservedDataCollection ); - - std::vector selectionObservedData; - caf::SelectionManager::instance()->objectsByType( &selectionObservedData ); + const auto selectionObservedDataCollection = caf::SelectionManager::instance()->objectsByType(); + const auto selectionObservedData = caf::SelectionManager::instance()->objectsByType(); return ( !selectionObservedDataCollection.empty() || !selectionObservedData.empty() ); } diff --git a/ApplicationLibCode/Commands/RicImportPressureDepthDataFeature.cpp b/ApplicationLibCode/Commands/RicImportPressureDepthDataFeature.cpp index 39f9408b76..c76942ed8e 100644 --- a/ApplicationLibCode/Commands/RicImportPressureDepthDataFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportPressureDepthDataFeature.cpp @@ -77,11 +77,8 @@ void RicImportPressureDepthDataFeature::selectPressureDepthDataPathInDialog() //-------------------------------------------------------------------------------------------------- bool RicImportPressureDepthDataFeature::isCommandEnabled() const { - std::vector selectionObservedDataCollection; - caf::SelectionManager::instance()->objectsByType( &selectionObservedDataCollection ); - - std::vector selectionObservedData; - caf::SelectionManager::instance()->objectsByType( &selectionObservedData ); + const auto selectionObservedDataCollection = caf::SelectionManager::instance()->objectsByType(); + const auto selectionObservedData = caf::SelectionManager::instance()->objectsByType(); return ( !selectionObservedDataCollection.empty() || !selectionObservedData.empty() ); } diff --git a/ApplicationLibCode/Commands/RicNewStatisticsContourMapFeature.cpp b/ApplicationLibCode/Commands/RicNewStatisticsContourMapFeature.cpp index 42f43aef3b..3d2566199a 100644 --- a/ApplicationLibCode/Commands/RicNewStatisticsContourMapFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewStatisticsContourMapFeature.cpp @@ -78,13 +78,5 @@ void RicNewStatisticsContourMapFeature::setupActionLook( QAction* actionToSetup //-------------------------------------------------------------------------------------------------- RimEclipseCaseEnsemble* RicNewStatisticsContourMapFeature::selectedEclipseCaseEnsemble() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - - if ( !selection.empty() ) - { - return selection[0]; - } - - return nullptr; + return caf::SelectionManager::instance()->selectedItemOfType(); } diff --git a/ApplicationLibCode/Commands/RicNewViewFeature.cpp b/ApplicationLibCode/Commands/RicNewViewFeature.cpp index 76d8d237f1..4668bbe153 100644 --- a/ApplicationLibCode/Commands/RicNewViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewViewFeature.cpp @@ -159,15 +159,7 @@ Rim3dView* RicNewViewFeature::createReservoirView( RimEclipseCase* eclipseCase, //-------------------------------------------------------------------------------------------------- RimEclipseCase* RicNewViewFeature::selectedEclipseCase() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - - if ( !selection.empty() ) - { - return selection[0]; - } - - return nullptr; + return caf::SelectionManager::instance()->selectedItemOfType(); } //-------------------------------------------------------------------------------------------------- @@ -175,15 +167,7 @@ RimEclipseCase* RicNewViewFeature::selectedEclipseCase() //-------------------------------------------------------------------------------------------------- RimGeoMechCase* RicNewViewFeature::selectedGeoMechCase() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - - if ( !selection.empty() ) - { - return selection[0]; - } - - return nullptr; + return caf::SelectionManager::instance()->selectedItemOfType(); } //-------------------------------------------------------------------------------------------------- @@ -191,9 +175,7 @@ RimGeoMechCase* RicNewViewFeature::selectedGeoMechCase() //-------------------------------------------------------------------------------------------------- RimEclipseView* RicNewViewFeature::selectedEclipseView() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - + const auto selection = caf::SelectionManager::instance()->objectsByType(); for ( RimEclipseView* view : selection ) { if ( dynamic_cast( view ) == nullptr ) @@ -210,10 +192,7 @@ RimEclipseView* RicNewViewFeature::selectedEclipseView() //-------------------------------------------------------------------------------------------------- RimEclipseViewCollection* RicNewViewFeature::selectedEclipseViewCollection() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - if ( !selection.empty() ) return selection[0]; - return nullptr; + return caf::SelectionManager::instance()->selectedItemOfType(); } //-------------------------------------------------------------------------------------------------- @@ -221,10 +200,7 @@ RimEclipseViewCollection* RicNewViewFeature::selectedEclipseViewCollection() //-------------------------------------------------------------------------------------------------- RimEclipseCaseEnsemble* RicNewViewFeature::selectedEclipseCaseEnsemble() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - if ( !selection.empty() ) return selection[0]; - return nullptr; + return caf::SelectionManager::instance()->selectedItemOfType(); } //-------------------------------------------------------------------------------------------------- @@ -232,13 +208,5 @@ RimEclipseCaseEnsemble* RicNewViewFeature::selectedEclipseCaseEnsemble() //-------------------------------------------------------------------------------------------------- RimGeoMechView* RicNewViewFeature::selectedGeoMechView() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - - if ( !selection.empty() ) - { - return selection[0]; - } - - return nullptr; + return caf::SelectionManager::instance()->selectedItemOfType(); } diff --git a/ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.cpp b/ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.cpp index a6c1ac470f..dd897a32e2 100644 --- a/ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.cpp @@ -84,13 +84,5 @@ void RicNewViewForGridEnsembleFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- RimEclipseCaseEnsemble* RicNewViewForGridEnsembleFeature::selectedEclipseCaseEnsemble() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - - if ( !selection.empty() ) - { - return selection[0]; - } - - return nullptr; + return caf::SelectionManager::instance()->selectedItemOfType(); } diff --git a/ApplicationLibCode/Commands/RicReloadCaseFeature.cpp b/ApplicationLibCode/Commands/RicReloadCaseFeature.cpp index c7d2bc744e..13cc2c98fa 100644 --- a/ApplicationLibCode/Commands/RicReloadCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicReloadCaseFeature.cpp @@ -39,17 +39,8 @@ CAF_CMD_SOURCE_INIT( RicReloadCaseFeature, "RicReloadCaseFeature" ); //-------------------------------------------------------------------------------------------------- bool RicReloadCaseFeature::isCommandEnabled() const { - std::vector selectedFormationNamesCollObjs; - caf::SelectionManager::instance()->objectsByType( &selectedFormationNamesCollObjs ); - for ( caf::PdmObject* pdmObject : selectedFormationNamesCollObjs ) - { - if ( dynamic_cast( pdmObject ) ) - { - return true; - } - } - - return false; + const auto eclipseCases = caf::SelectionManager::instance()->objectsByType(); + return !eclipseCases.empty(); } //-------------------------------------------------------------------------------------------------- @@ -57,9 +48,7 @@ bool RicReloadCaseFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicReloadCaseFeature::onActionTriggered( bool isChecked ) { - std::vector selectedEclipseCases; - caf::SelectionManager::instance()->objectsByType( &selectedEclipseCases ); - + const auto selectedEclipseCases = caf::SelectionManager::instance()->objectsByType(); RiaGuiApplication::clearAllSelections(); for ( RimEclipseCase* selectedCase : selectedEclipseCases ) diff --git a/ApplicationLibCode/Commands/RicReloadFormationNamesFeature.cpp b/ApplicationLibCode/Commands/RicReloadFormationNamesFeature.cpp index d2c48377b2..aabe41fb00 100644 --- a/ApplicationLibCode/Commands/RicReloadFormationNamesFeature.cpp +++ b/ApplicationLibCode/Commands/RicReloadFormationNamesFeature.cpp @@ -34,10 +34,8 @@ CAF_CMD_SOURCE_INIT( RicReloadFormationNamesFeature, "RicReloadFormationNamesFea //-------------------------------------------------------------------------------------------------- bool RicReloadFormationNamesFeature::isCommandEnabled() const { - std::vector selectedFormationNamesObjs; - caf::SelectionManager::instance()->objectsByType( &selectedFormationNamesObjs ); - std::vector selectedFormationNamesCollObjs; - caf::SelectionManager::instance()->objectsByType( &selectedFormationNamesCollObjs ); + const auto selectedFormationNamesObjs = caf::SelectionManager::instance()->objectsByType(); + const auto selectedFormationNamesCollObjs = caf::SelectionManager::instance()->objectsByType(); return ( !selectedFormationNamesObjs.empty() || !selectedFormationNamesCollObjs.empty() ); } @@ -47,9 +45,7 @@ bool RicReloadFormationNamesFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicReloadFormationNamesFeature::onActionTriggered( bool isChecked ) { - std::vector selectedFormationNamesCollObjs; - caf::SelectionManager::instance()->objectsByType( &selectedFormationNamesCollObjs ); - + const auto selectedFormationNamesCollObjs = caf::SelectionManager::instance()->objectsByType(); if ( !selectedFormationNamesCollObjs.empty() ) { selectedFormationNamesCollObjs[0]->readAllFormationNames(); @@ -61,8 +57,7 @@ void RicReloadFormationNamesFeature::onActionTriggered( bool isChecked ) return; } - std::vector selectedFormationNamesObjs; - caf::SelectionManager::instance()->objectsByType( &selectedFormationNamesObjs ); + const auto selectedFormationNamesObjs = caf::SelectionManager::instance()->objectsByType(); for ( RimFormationNames* fnames : selectedFormationNamesObjs ) { QString errorMessage; diff --git a/ApplicationLibCode/Commands/RicReloadPressureDepthDataFeature.cpp b/ApplicationLibCode/Commands/RicReloadPressureDepthDataFeature.cpp index c6ef911caa..fd962bc5fa 100644 --- a/ApplicationLibCode/Commands/RicReloadPressureDepthDataFeature.cpp +++ b/ApplicationLibCode/Commands/RicReloadPressureDepthDataFeature.cpp @@ -33,9 +33,7 @@ CAF_CMD_SOURCE_INIT( RicReloadPressureDepthDataFeature, "RicReloadPressureDepthD //-------------------------------------------------------------------------------------------------- void RicReloadPressureDepthDataFeature::onActionTriggered( bool isChecked ) { - std::vector pressureDepthDataObjects; - caf::SelectionManager::instance()->objectsByType( &pressureDepthDataObjects ); - + const auto pressureDepthDataObjects = caf::SelectionManager::instance()->objectsByType(); for ( RimPressureDepthData* pressureDepthData : pressureDepthDataObjects ) { pressureDepthData->createRftReaderInterface(); diff --git a/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp b/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp index f6781b6dba..149cf0d67b 100644 --- a/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp @@ -72,22 +72,16 @@ void RicReloadSummaryCaseFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- std::vector RicReloadSummaryCaseFeature::selectedSummaryCases() { - std::vector mainCollectionSelection; - caf::SelectionManager::instance()->objectsByType( &mainCollectionSelection ); - + const auto mainCollectionSelection = caf::SelectionManager::instance()->objectsByType(); if ( !mainCollectionSelection.empty() ) { return mainCollectionSelection[0]->allSummaryCases(); } - std::vector caseSelection; - caf::SelectionManager::instance()->objectsByType( &caseSelection ); + std::vector caseSelection = caf::SelectionManager::instance()->objectsByType(); { - std::vector collectionSelection; - caf::SelectionManager::instance()->objectsByType( &collectionSelection ); - - for ( auto collection : collectionSelection ) + for ( auto collection : caf::SelectionManager::instance()->objectsByType() ) { std::vector summaryCaseCollection = collection->allSummaryCases(); caseSelection.insert( caseSelection.end(), summaryCaseCollection.begin(), summaryCaseCollection.end() ); @@ -95,10 +89,7 @@ std::vector RicReloadSummaryCaseFeature::selectedSummaryCases() } { - std::vector collectionSelection; - caf::SelectionManager::instance()->objectsByType( &collectionSelection ); - - for ( auto collection : collectionSelection ) + for ( auto collection : caf::SelectionManager::instance()->objectsByType() ) { std::vector observedCases = collection->allObservedSummaryData(); caseSelection.insert( caseSelection.end(), observedCases.begin(), observedCases.end() ); diff --git a/ApplicationLibCode/Commands/RicReloadWellMeasurementsFeature.cpp b/ApplicationLibCode/Commands/RicReloadWellMeasurementsFeature.cpp index 19a11e3c44..0d8863fea6 100644 --- a/ApplicationLibCode/Commands/RicReloadWellMeasurementsFeature.cpp +++ b/ApplicationLibCode/Commands/RicReloadWellMeasurementsFeature.cpp @@ -36,8 +36,7 @@ CAF_CMD_SOURCE_INIT( RicReloadWellMeasurementsFeature, "RicReloadWellMeasurement //-------------------------------------------------------------------------------------------------- bool RicReloadWellMeasurementsFeature::isCommandEnabled() const { - std::vector filePaths; - caf::SelectionManager::instance()->objectsByType( &filePaths ); + const auto filePaths = caf::SelectionManager::instance()->objectsByType(); return !filePaths.empty(); } @@ -46,8 +45,7 @@ bool RicReloadWellMeasurementsFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicReloadWellMeasurementsFeature::onActionTriggered( bool isChecked ) { - std::vector filePaths; - caf::SelectionManager::instance()->objectsByType( &filePaths ); + const auto filePaths = caf::SelectionManager::instance()->objectsByType(); if ( filePaths.empty() ) return; RicWellMeasurementImportTools::removeWellMeasurementsFromFiles( filePaths ); diff --git a/ApplicationLibCode/Commands/RicReloadWellPathFormationNamesFeature.cpp b/ApplicationLibCode/Commands/RicReloadWellPathFormationNamesFeature.cpp index 978b808da1..85eb22da02 100644 --- a/ApplicationLibCode/Commands/RicReloadWellPathFormationNamesFeature.cpp +++ b/ApplicationLibCode/Commands/RicReloadWellPathFormationNamesFeature.cpp @@ -33,13 +33,10 @@ CAF_CMD_SOURCE_INIT( RicReloadWellPathFormationNamesFeature, "RicReloadWellPathF //-------------------------------------------------------------------------------------------------- bool RicReloadWellPathFormationNamesFeature::isCommandEnabled() const { - std::vector wellPaths; - caf::SelectionManager::instance()->objectsByType( &wellPaths ); + const auto wellPaths = caf::SelectionManager::instance()->objectsByType(); + const auto wellPathCollections = caf::SelectionManager::instance()->objectsByType(); - std::vector wellPathCollection; - caf::SelectionManager::instance()->objectsByType( &wellPathCollection ); - - return ( !wellPaths.empty() || !wellPathCollection.empty() ); + return ( !wellPaths.empty() || !wellPathCollections.empty() ); } //-------------------------------------------------------------------------------------------------- @@ -47,11 +44,8 @@ bool RicReloadWellPathFormationNamesFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicReloadWellPathFormationNamesFeature::onActionTriggered( bool isChecked ) { - std::vector wellPaths; - caf::SelectionManager::instance()->objectsByType( &wellPaths ); - - std::vector wellPathCollections; - caf::SelectionManager::instance()->objectsByType( &wellPathCollections ); + const auto wellPaths = caf::SelectionManager::instance()->objectsByType(); + const auto wellPathCollections = caf::SelectionManager::instance()->objectsByType(); if ( !wellPaths.empty() ) { diff --git a/ApplicationLibCode/Commands/RicReplaceCaseFeature.cpp b/ApplicationLibCode/Commands/RicReplaceCaseFeature.cpp index 79ee7812f3..c692e7f0de 100644 --- a/ApplicationLibCode/Commands/RicReplaceCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicReplaceCaseFeature.cpp @@ -51,17 +51,8 @@ CAF_CMD_SOURCE_INIT( RicReplaceCaseFeature, "RicReplaceCaseFeature" ); //-------------------------------------------------------------------------------------------------- bool RicReplaceCaseFeature::isCommandEnabled() const { - std::vector selectedFormationNamesCollObjs; - caf::SelectionManager::instance()->objectsByType( &selectedFormationNamesCollObjs ); - for ( caf::PdmObject* pdmObject : selectedFormationNamesCollObjs ) - { - if ( dynamic_cast( pdmObject ) ) - { - return true; - } - } - - return false; + const auto objects = caf::SelectionManager::instance()->objectsByType(); + return !objects.empty(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.cpp b/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.cpp index f444d933e1..d95c932e4c 100644 --- a/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.cpp +++ b/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.cpp @@ -41,9 +41,7 @@ void RicShowDataSourcesForRealization::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- bool RicShowDataSourcesForRealization::isCommandChecked() const { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - + const auto selection = caf::SelectionManager::instance()->objectsByType(); if ( !selection.empty() ) { return selection.front()->showVectorItemsInProjectTree(); @@ -57,8 +55,7 @@ bool RicShowDataSourcesForRealization::isCommandChecked() const //-------------------------------------------------------------------------------------------------- bool RicShowDataSourcesForRealization::isCommandEnabled() const { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); + const auto selection = caf::SelectionManager::instance()->objectsByType(); for ( RimSummaryCase* summaryCase : selection ) { @@ -75,9 +72,7 @@ bool RicShowDataSourcesForRealization::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicShowDataSourcesForRealization::onActionTriggered( bool isChecked ) { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - + const auto selection = caf::SelectionManager::instance()->objectsByType(); if ( selection.empty() ) return; bool enableDataSources = !selection.front()->showVectorItemsInProjectTree(); diff --git a/ApplicationLibCode/Commands/RicStackSelectedCurvesFeature.cpp b/ApplicationLibCode/Commands/RicStackSelectedCurvesFeature.cpp index 1de7543764..5bbc7aad84 100644 --- a/ApplicationLibCode/Commands/RicStackSelectedCurvesFeature.cpp +++ b/ApplicationLibCode/Commands/RicStackSelectedCurvesFeature.cpp @@ -99,8 +99,7 @@ caf::PdmScriptResponse RicStackSelectedCurvesFeature::execute() //-------------------------------------------------------------------------------------------------- bool RicStackSelectedCurvesFeature::isCommandEnabled() const { - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); auto plotCurves = plotCurvesFromSelection( selectedItems ); @@ -116,8 +115,7 @@ bool RicStackSelectedCurvesFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicStackSelectedCurvesFeature::onActionTriggered( bool isChecked ) { - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); auto plotCurves = plotCurvesFromSelection( selectedItems ); auto unstackedPlotCurves = subsetOfPlotCurvesFromStacking( plotCurves, false ); diff --git a/ApplicationLibCode/Commands/RicUnstackSelectedCurvesFeature.cpp b/ApplicationLibCode/Commands/RicUnstackSelectedCurvesFeature.cpp index 155940e3d7..e04ee11fe5 100644 --- a/ApplicationLibCode/Commands/RicUnstackSelectedCurvesFeature.cpp +++ b/ApplicationLibCode/Commands/RicUnstackSelectedCurvesFeature.cpp @@ -61,10 +61,8 @@ caf::PdmScriptResponse RicUnstackSelectedCurvesFeature::execute() //-------------------------------------------------------------------------------------------------- bool RicUnstackSelectedCurvesFeature::isCommandEnabled() const { - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); - - auto plotCurves = RicStackSelectedCurvesFeature::plotCurvesFromSelection( selectedItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); + auto plotCurves = RicStackSelectedCurvesFeature::plotCurvesFromSelection( selectedItems ); if ( plotCurves.size() != selectedItems.size() ) return false; @@ -78,8 +76,7 @@ bool RicUnstackSelectedCurvesFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicUnstackSelectedCurvesFeature::onActionTriggered( bool isChecked ) { - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); auto plotCurves = RicStackSelectedCurvesFeature::plotCurvesFromSelection( selectedItems ); auto unstackedPlotCurves = RicStackSelectedCurvesFeature::subsetOfPlotCurvesFromStacking( plotCurves, true ); diff --git a/ApplicationLibCode/Commands/RicWellLogTools.cpp b/ApplicationLibCode/Commands/RicWellLogTools.cpp index 194105b432..ed16c9bde2 100644 --- a/ApplicationLibCode/Commands/RicWellLogTools.cpp +++ b/ApplicationLibCode/Commands/RicWellLogTools.cpp @@ -65,10 +65,9 @@ RimSimWellInView* RicWellLogTools::selectedSimulationWell( int* branchIndex ) } else { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); ( *branchIndex ) = 0; - return !selection.empty() ? selection[0] : nullptr; + + return caf::SelectionManager::instance()->selectedItemOfType(); } } @@ -162,11 +161,10 @@ void RicWellLogTools::addWellLogChannelsToPlotTrack( RimWellLogTrack* plotTrack, //-------------------------------------------------------------------------------------------------- RimWellPath* RicWellLogTools::selectedWellPathWithLog() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - if ( !selection.empty() ) + const auto selection = caf::SelectionManager::instance()->objectsByType(); + + for ( const auto& wellPath : selection ) { - RimWellPath* wellPath = selection[0]; if ( !wellPath->wellLogs().empty() ) { return wellPath; diff --git a/ApplicationLibCode/Commands/RicWellMeasurementImportTools.cpp b/ApplicationLibCode/Commands/RicWellMeasurementImportTools.cpp index 8f5438705a..5e11fc935d 100644 --- a/ApplicationLibCode/Commands/RicWellMeasurementImportTools.cpp +++ b/ApplicationLibCode/Commands/RicWellMeasurementImportTools.cpp @@ -153,8 +153,7 @@ void RicWellMeasurementImportTools::deleteAllEmptyMeasurementCurves() //-------------------------------------------------------------------------------------------------- RimWellPathCollection* RicWellMeasurementImportTools::selectedWellPathCollection() { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); + const auto objects = caf::SelectionManager::instance()->objectsByType(); if ( objects.size() == 1 ) { diff --git a/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicDifferenceFeature.cpp b/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicDifferenceFeature.cpp index 39df6fa9da..86c8d065af 100644 --- a/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicDifferenceFeature.cpp +++ b/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicDifferenceFeature.cpp @@ -87,15 +87,13 @@ void RicNewSeismicDifferenceFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- std::vector RicNewSeismicDifferenceFeature::selectedSeismic() { - std::vector uiItems; - caf::SelectionManager::instance()->selectedItems( uiItems ); - - if ( uiItems.size() != 2 ) return {}; + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); + if ( selectedItems.size() != 2 ) return {}; std::vector seismicItems; - RimSeismicData* seismic1 = dynamic_cast( uiItems[0] ); - RimSeismicData* seismic2 = dynamic_cast( uiItems[1] ); + RimSeismicData* seismic1 = dynamic_cast( selectedItems[0] ); + RimSeismicData* seismic2 = dynamic_cast( selectedItems[1] ); if ( seismic1 == nullptr ) return {}; if ( seismic2 == nullptr ) return {}; diff --git a/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicViewFeature.cpp b/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicViewFeature.cpp index f8158a2e69..1f4c780007 100644 --- a/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicViewFeature.cpp +++ b/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicViewFeature.cpp @@ -56,17 +56,7 @@ bool RicNewSeismicViewFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicNewSeismicViewFeature::onActionTriggered( bool isChecked ) { - std::vector uiItems; - caf::SelectionManager::instance()->selectedItems( uiItems ); - - RimSeismicData* selectedData = nullptr; - - if ( !uiItems.empty() ) - { - selectedData = dynamic_cast( uiItems[0] ); - } - - createSeismicView( selectedData ); + createSeismicView( caf::SelectionManager::instance()->selectedItemOfType() ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/SeismicCommands/RicSeismicSectionFromIntersectionFeature.cpp b/ApplicationLibCode/Commands/SeismicCommands/RicSeismicSectionFromIntersectionFeature.cpp index 180db89511..d336436825 100644 --- a/ApplicationLibCode/Commands/SeismicCommands/RicSeismicSectionFromIntersectionFeature.cpp +++ b/ApplicationLibCode/Commands/SeismicCommands/RicSeismicSectionFromIntersectionFeature.cpp @@ -124,14 +124,5 @@ void RicSeismicSectionFromIntersectionFeature::setupActionLook( QAction* actionT //-------------------------------------------------------------------------------------------------- RimExtrudedCurveIntersection* RicSeismicSectionFromIntersectionFeature::getSelectedIntersection() const { - std::vector selectedUiItems; - caf::SelectionManager::instance()->selectedItems( selectedUiItems ); - - RimExtrudedCurveIntersection* intersection = nullptr; - - if ( !selectedUiItems.empty() ) - { - intersection = dynamic_cast( selectedUiItems[0] ); - } - return intersection; + return caf::SelectionManager::instance()->selectedItemOfType(); } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.cpp index 93a3e6997e..836ca7832b 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.cpp @@ -49,11 +49,10 @@ void RicAsciiExportSummaryPlotFeature::onActionTriggered( bool isChecked ) { disableModelChangeContribution(); - std::vector selectedSummaryPlots; - caf::SelectionManager::instance()->objectsByType( &selectedSummaryPlots ); - QString defaultDir = defaultExportDir(); + const auto selectedSummaryPlots = caf::SelectionManager::instance()->objectsByType(); - RiaPreferencesSummary* prefs = RiaPreferencesSummary::current(); + QString defaultDir = defaultExportDir(); + RiaPreferencesSummary* prefs = RiaPreferencesSummary::current(); // Ask user about resampling auto result = RicResampleDialog::openDialog(); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicClearSourceSteppingEnsembleCurveSetFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicClearSourceSteppingEnsembleCurveSetFeature.cpp index aaf9b7529f..4ff0c748d6 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicClearSourceSteppingEnsembleCurveSetFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicClearSourceSteppingEnsembleCurveSetFeature.cpp @@ -37,9 +37,7 @@ CAF_CMD_SOURCE_INIT( RicClearSourceSteppingEnsembleCurveSetFeature, "RicClearSou //-------------------------------------------------------------------------------------------------- bool RicClearSourceSteppingEnsembleCurveSetFeature::isCommandEnabled() const { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - + const auto objects = caf::SelectionManager::instance()->objectsByType(); if ( objects.size() == 1 ) { auto c = objects[0]; @@ -63,9 +61,7 @@ bool RicClearSourceSteppingEnsembleCurveSetFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicClearSourceSteppingEnsembleCurveSetFeature::onActionTriggered( bool isChecked ) { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - + const auto objects = caf::SelectionManager::instance()->objectsByType(); if ( objects.size() == 1 ) { auto c = objects[0]; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicClearSourceSteppingSummaryCurveFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicClearSourceSteppingSummaryCurveFeature.cpp index bba0b6243d..1fe6c458ef 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicClearSourceSteppingSummaryCurveFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicClearSourceSteppingSummaryCurveFeature.cpp @@ -37,9 +37,7 @@ CAF_CMD_SOURCE_INIT( RicClearSourceSteppingSummaryCurveFeature, "RicClearSourceS //-------------------------------------------------------------------------------------------------- bool RicClearSourceSteppingSummaryCurveFeature::isCommandEnabled() const { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - + const auto objects = caf::SelectionManager::instance()->objectsByType(); if ( objects.size() == 1 ) { auto c = objects[0]; @@ -63,9 +61,7 @@ bool RicClearSourceSteppingSummaryCurveFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicClearSourceSteppingSummaryCurveFeature::onActionTriggered( bool isChecked ) { - std::vector summaryCurves; - caf::SelectionManager::instance()->objectsByType( &summaryCurves ); - + const auto summaryCurves = caf::SelectionManager::instance()->objectsByType(); if ( summaryCurves.size() == 1 ) { auto c = summaryCurves[0]; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.cpp index 5a2af9a933..588b2795c2 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.cpp @@ -56,13 +56,13 @@ void extractPlotObjectsFromSelection( std::vector* selected CAF_ASSERT( selectedIndividualSummaryCases && selectedEnsembles ); // First try selected ensembles - caf::SelectionManager::instance()->objectsByTypeStrict( selectedEnsembles ); + *selectedEnsembles = caf::SelectionManager::instance()->objectsByTypeStrict(); if ( !selectedEnsembles->empty() ) { return; } // Second try selected summary cases - caf::SelectionManager::instance()->objectsByTypeStrict( selectedIndividualSummaryCases ); + *selectedIndividualSummaryCases = caf::SelectionManager::instance()->objectsByTypeStrict(); if ( !selectedIndividualSummaryCases->empty() ) { return; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSetSourceSteppingEnsembleCurveSetFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSetSourceSteppingEnsembleCurveSetFeature.cpp index 9523929aa3..17c57114f1 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSetSourceSteppingEnsembleCurveSetFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSetSourceSteppingEnsembleCurveSetFeature.cpp @@ -36,9 +36,7 @@ CAF_CMD_SOURCE_INIT( RicSetSourceSteppingEnsembleCurveSetFeature, "RicSetSourceS //-------------------------------------------------------------------------------------------------- bool RicSetSourceSteppingEnsembleCurveSetFeature::isCommandEnabled() const { - std::vector ensembleCurveSets; - caf::SelectionManager::instance()->objectsByType( &ensembleCurveSets ); - + const auto ensembleCurveSets = caf::SelectionManager::instance()->objectsByType(); if ( ensembleCurveSets.size() == 1 ) { auto c = ensembleCurveSets[0]; @@ -61,9 +59,7 @@ bool RicSetSourceSteppingEnsembleCurveSetFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicSetSourceSteppingEnsembleCurveSetFeature::onActionTriggered( bool isChecked ) { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - + const auto objects = caf::SelectionManager::instance()->objectsByType(); if ( objects.size() == 1 ) { auto c = objects[0]; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSetSourceSteppingSummaryCurveFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSetSourceSteppingSummaryCurveFeature.cpp index 6c6c331a8e..bb051ae55b 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSetSourceSteppingSummaryCurveFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSetSourceSteppingSummaryCurveFeature.cpp @@ -36,8 +36,7 @@ CAF_CMD_SOURCE_INIT( RicSetSourceSteppingSummaryCurveFeature, "RicSetSourceStepp //-------------------------------------------------------------------------------------------------- bool RicSetSourceSteppingSummaryCurveFeature::isCommandEnabled() const { - std::vector summaryCurves; - caf::SelectionManager::instance()->objectsByType( &summaryCurves ); + const auto summaryCurves = caf::SelectionManager::instance()->objectsByType(); if ( summaryCurves.size() == 1 ) { @@ -61,9 +60,7 @@ bool RicSetSourceSteppingSummaryCurveFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicSetSourceSteppingSummaryCurveFeature::onActionTriggered( bool isChecked ) { - std::vector summaryCurves; - caf::SelectionManager::instance()->objectsByType( &summaryCurves ); - + const auto summaryCurves = caf::SelectionManager::instance()->objectsByType(); if ( summaryCurves.size() == 1 ) { auto c = summaryCurves[0]; diff --git a/ApplicationLibCode/Commands/ToggleCommands/RicMoveItemsToTopFeature.cpp b/ApplicationLibCode/Commands/ToggleCommands/RicMoveItemsToTopFeature.cpp index 1efa1f2279..0b51dd44b7 100644 --- a/ApplicationLibCode/Commands/ToggleCommands/RicMoveItemsToTopFeature.cpp +++ b/ApplicationLibCode/Commands/ToggleCommands/RicMoveItemsToTopFeature.cpp @@ -42,9 +42,7 @@ bool RicMoveItemsToTopFeature::isCommandEnabled() const { using namespace caf; - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); - + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); if ( !selectedItems.empty() ) { auto pdmObject = RicMoveItemsToTopFeature::objectHandleFromUiItem( selectedItems[0] ); @@ -65,9 +63,7 @@ void RicMoveItemsToTopFeature::onActionTriggered( bool isChecked ) { using namespace caf; - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); - + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); if ( !selectedItems.empty() ) { auto pdmObject = RicMoveItemsToTopFeature::objectHandleFromUiItem( selectedItems[0] ); diff --git a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp index 89eb3d92be..d9716bf06b 100644 --- a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp @@ -42,9 +42,7 @@ //-------------------------------------------------------------------------------------------------- bool RicToggleItemsFeatureImpl::isToggleCommandsAvailable() { - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); - + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); if ( selectedItems.size() == 1 ) { caf::PdmUiTreeOrdering* treeItem = findTreeItemFromSelectedUiItem( selectedItems[0] ); @@ -87,8 +85,7 @@ bool RicToggleItemsFeatureImpl::isToggleCommandsAvailable() //-------------------------------------------------------------------------------------------------- bool RicToggleItemsFeatureImpl::isToggleCommandsForSubItems() { - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); return isToggleCommandsAvailable() && selectedItems.size() == 1; } @@ -163,8 +160,7 @@ void RicToggleItemsFeatureImpl::setObjectToggleStateForSelection( SelectionToggl //-------------------------------------------------------------------------------------------------- QString RicToggleItemsFeatureImpl::findCollectionName( SelectionToggleType state ) { - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); if ( state != TOGGLE && selectedItems.size() == 1 ) { caf::PdmUiTreeOrdering* treeItem = findTreeItemFromSelectedUiItem( selectedItems[0] ); @@ -262,8 +258,7 @@ std::vector*> RicToggleItemsFeatureImpl::findToggleFieldsFro { std::vector*> fields; - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); if ( state != TOGGLE && selectedItems.size() == 1 ) { // If only one item is selected, loop over its children, and toggle them instead of the diff --git a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.cpp b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.cpp index 3783e57015..6d68ce597b 100644 --- a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.cpp +++ b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.cpp @@ -35,8 +35,7 @@ CAF_CMD_SOURCE_INIT( RicToggleItemsOnOthersOffFeature, "RicToggleItemsOnOthersOf //-------------------------------------------------------------------------------------------------- bool RicToggleItemsOnOthersOffFeature::isCommandEnabled() const { - std::vector selectedObjects; - caf::SelectionManager::instance()->objectsByType( &selectedObjects ); + const auto selectedObjects = caf::SelectionManager::instance()->objectsByType(); caf::PdmFieldHandle* commonParent = commonParentForAllSelections( selectedObjects ); std::vector children = childObjects( commonParent ); @@ -49,8 +48,7 @@ bool RicToggleItemsOnOthersOffFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicToggleItemsOnOthersOffFeature::onActionTriggered( bool isChecked ) { - std::vector selectedObjects; - caf::SelectionManager::instance()->objectsByType( &selectedObjects ); + const auto selectedObjects = caf::SelectionManager::instance()->objectsByType(); // First toggle off all siblings caf::PdmFieldHandle* commonParent = commonParentForAllSelections( selectedObjects ); diff --git a/ApplicationLibCode/Commands/ViewLink/RicLinkViewFeature.cpp b/ApplicationLibCode/Commands/ViewLink/RicLinkViewFeature.cpp index 5fdc7f3234..dcced21cf6 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicLinkViewFeature.cpp +++ b/ApplicationLibCode/Commands/ViewLink/RicLinkViewFeature.cpp @@ -61,9 +61,7 @@ public: return true; } - std::vector selectedGridViews; - - caf::SelectionManager::instance()->objectsByTypeStrict( &selectedGridViews ); + const auto selectedGridViews = caf::SelectionManager::instance()->objectsByTypeStrict(); for ( auto gridView : selectedGridViews ) { if ( !gridView ) continue; diff --git a/ApplicationLibCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp b/ApplicationLibCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp index 87c4446d96..1c227df1a1 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp +++ b/ApplicationLibCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp @@ -42,11 +42,9 @@ bool RicShowAllLinkedViewsFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicShowAllLinkedViewsFeature::onActionTriggered( bool isChecked ) { - std::vector linkedViews; - caf::SelectionManager::instance()->objectsByType( &linkedViews ); + auto linkedViews = caf::SelectionManager::instance()->objectsByType(); + auto managedViews = caf::SelectionManager::instance()->objectsByType(); - std::vector managedViews; - caf::SelectionManager::instance()->objectsByType( &managedViews ); for ( auto& managedView : managedViews ) { RimViewLinker* rimLinked = managedView->firstAncestorOrThisOfTypeAsserted(); diff --git a/ApplicationLibCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.cpp index ed61f623c2..743c4ad522 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.cpp @@ -34,9 +34,7 @@ CAF_CMD_SOURCE_INIT( Ric3dWellLogCurveDeleteFeature, "Ric3dWellLogCurveDeleteFea //-------------------------------------------------------------------------------------------------- bool Ric3dWellLogCurveDeleteFeature::isCommandEnabled() const { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - + auto objects = caf::SelectionManager::instance()->objectsByType(); return !objects.empty(); } @@ -45,9 +43,7 @@ bool Ric3dWellLogCurveDeleteFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void Ric3dWellLogCurveDeleteFeature::onActionTriggered( bool isChecked ) { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - + auto objects = caf::SelectionManager::instance()->objectsByType(); if ( objects.empty() ) return; Rim3dWellLogCurve* firstCurve = objects[0]; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp index 65a98d92f4..5a4230db9f 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp @@ -118,7 +118,5 @@ void RicAddWellLogToPlotFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- std::vector RicAddWellLogToPlotFeature::selectedWellLogs() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - return selection; + return caf::SelectionManager::instance()->objectsByType(); } diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicAsciiExportWellLogPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicAsciiExportWellLogPlotFeature.cpp index b8ed95f337..0d0fc04609 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicAsciiExportWellLogPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicAsciiExportWellLogPlotFeature.cpp @@ -46,9 +46,8 @@ void RicAsciiExportWellLogPlotFeature::onActionTriggered( bool isChecked ) { disableModelChangeContribution(); - std::vector selectedWellLogPlots; - caf::SelectionManager::instance()->objectsByType( &selectedWellLogPlots ); - QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallbackToProjectFolder( "PLOT_ASCIIEXPORT_DIR" ); + auto selectedWellLogPlots = caf::SelectionManager::instance()->objectsByType(); + QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallbackToProjectFolder( "PLOT_ASCIIEXPORT_DIR" ); caf::ProgressInfo pi( selectedWellLogPlots.size(), QString( "Exporting plot data to ASCII" ) ); size_t progress = 0; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicChangeDataSourceFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicChangeDataSourceFeature.cpp index a046d60cf1..ba471f3910 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicChangeDataSourceFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicChangeDataSourceFeature.cpp @@ -57,8 +57,7 @@ bool RicChangeDataSourceFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicChangeDataSourceFeature::onActionTriggered( bool isChecked ) { - std::vector selectedObjects; - caf::SelectionManager::instance()->objectsByType( &selectedObjects ); + const auto selectedObjects = caf::SelectionManager::instance()->objectsByType(); std::vector curves; std::vector tracks; @@ -92,9 +91,8 @@ void RicChangeDataSourceFeature::setupActionLook( QAction* actionToSetup ) bool RicChangeDataSourceFeature::selectedTracksAndCurves( std::vector* curves, std::vector* tracks ) { CVF_ASSERT( curves && tracks ); - std::vector selectedObjects; - caf::SelectionManager::instance()->objectsByType( &selectedObjects ); + const auto selectedObjects = caf::SelectionManager::instance()->objectsByType(); if ( selectedObjects.empty() ) return false; for ( caf::PdmObject* selectedObject : selectedObjects ) diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp index 1dfec8002a..a4e8a6450d 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp @@ -54,8 +54,7 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked ) { if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return; - std::vector selection; - getSelection( selection ); + std::vector selection = getSelection(); std::set alteredPlotWindows; @@ -98,8 +97,7 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked ) void RicDeleteSubPlotFeature::setupActionLook( QAction* actionToSetup ) { QString actionText; - std::vector selection; - getSelection( selection ); + std::vector selection = getSelection(); size_t tracksSelected = 0u; for ( RimPlot* object : selection ) @@ -130,8 +128,9 @@ void RicDeleteSubPlotFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicDeleteSubPlotFeature::getSelection( std::vector& selection ) const +std::vector RicDeleteSubPlotFeature::getSelection() const { + std::vector selection; if ( sender() ) { QVariant userData = this->userData(); @@ -144,8 +143,10 @@ void RicDeleteSubPlotFeature::getSelection( std::vector& selection ) c if ( selection.empty() ) { - caf::SelectionManager::instance()->objectsByType( &selection ); + selection = caf::SelectionManager::instance()->objectsByType(); } + + return selection; } //-------------------------------------------------------------------------------------------------- @@ -153,10 +154,7 @@ void RicDeleteSubPlotFeature::getSelection( std::vector& selection ) c //-------------------------------------------------------------------------------------------------- bool RicDeleteSubPlotFeature::isAnyDeletablePlotSelected() const { - std::vector selection; - getSelection( selection ); - - for ( RimPlot* plot : selection ) + for ( RimPlot* plot : getSelection() ) { if ( !plot ) continue; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.h index 6c75d58172..0bc65e0284 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.h @@ -38,6 +38,6 @@ protected: void setupActionLook( QAction* actionToSetup ) override; private: - void getSelection( std::vector& selection ) const; - bool isAnyDeletablePlotSelected() const; + std::vector getSelection() const; + bool isAnyDeletablePlotSelected() const; }; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp index cf49d1beb2..d997fb9bf7 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp @@ -167,10 +167,9 @@ RimSimWellInView* RicNewPltPlotFeature::selectedSimulationWell( int* branchIndex } else { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); ( *branchIndex ) = 0; - return !selection.empty() ? selection[0] : nullptr; + + return caf::SelectionManager::instance()->selectedItemOfType(); } } diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogCalculatedCurveFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogCalculatedCurveFeature.cpp index 0bdceba08a..00fb8c8f91 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogCalculatedCurveFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogCalculatedCurveFeature.cpp @@ -40,8 +40,7 @@ CAF_CMD_SOURCE_INIT( RicNewWellLogCalculatedCurveFeature, "RicNewWellLogCalculat //-------------------------------------------------------------------------------------------------- bool RicNewWellLogCalculatedCurveFeature::isCommandEnabled() const { - std::vector wellLogCurves; - caf::SelectionManager::instance()->objectsByType( &wellLogCurves ); + const auto wellLogCurves = caf::SelectionManager::instance()->objectsByType(); return ( caf::SelectionManager::instance()->selectedItemOfType() != nullptr || wellLogCurves.size() == 2 ); } @@ -58,8 +57,7 @@ void RicNewWellLogCalculatedCurveFeature::onActionTriggered( bool isChecked ) } else { - std::vector wellLogCurves; - caf::SelectionManager::instance()->objectsByType( &wellLogCurves ); + const auto wellLogCurves = caf::SelectionManager::instance()->objectsByType(); if ( wellLogCurves.size() != 2 ) return; RimWellLogTrack* wellLogTrack = wellLogCurves[0]->firstAncestorOrThisOfType(); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.cpp index 47bc5baed1..60dcc14feb 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.cpp @@ -82,7 +82,5 @@ void RicNewWellLogPlotTrackFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- RimWellLogPlot* RicNewWellLogPlotTrackFeature::selectedWellLogPlot() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - return !selection.empty() ? selection[0] : nullptr; + return caf::SelectionManager::instance()->selectedItemOfType(); } diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicWellLogPlotCurveFeatureImpl.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicWellLogPlotCurveFeatureImpl.cpp index fb0deb8796..ac90fee5c5 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicWellLogPlotCurveFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicWellLogPlotCurveFeatureImpl.cpp @@ -51,9 +51,7 @@ std::vector RicWellLogPlotCurveFeatureImpl::selectedWellLogCur std::set uniqueCurves; { - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); - + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); for ( caf::PdmUiItem* selectedItem : selectedItems ) { caf::PdmObjectHandle* objHandle = dynamic_cast( selectedItem ); diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicDeletePolylineTargetFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicDeletePolylineTargetFeature.cpp index 274d3b0cb0..961d90987e 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicDeletePolylineTargetFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicDeletePolylineTargetFeature.cpp @@ -32,9 +32,7 @@ CAF_CMD_SOURCE_INIT( RicDeletePolylineTargetFeature, "RicDeletePolylineTargetFea //-------------------------------------------------------------------------------------------------- bool RicDeletePolylineTargetFeature::isCommandEnabled() const { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects, caf::SelectionManager::FIRST_LEVEL ); - + const auto objects = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); return !objects.empty(); } @@ -43,9 +41,7 @@ bool RicDeletePolylineTargetFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicDeletePolylineTargetFeature::onActionTriggered( bool isChecked ) { - std::vector targets; - caf::SelectionManager::instance()->objectsByType( &targets, caf::SelectionManager::FIRST_LEVEL ); - + const auto targets = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); if ( !targets.empty() ) { RimPolylinePickerInterface* polylineDef = targets[0]->firstAncestorOrThisOfTypeAsserted(); diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.cpp index 5326be8b8f..988f5087ff 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.cpp @@ -33,20 +33,13 @@ CAF_CMD_SOURCE_INIT( RicDeleteWellPathAttributeFeature, "RicDeleteWellPathAttrib //-------------------------------------------------------------------------------------------------- bool RicDeleteWellPathAttributeFeature::isCommandEnabled() const { + if ( caf::SelectionManager::instance()->selectedItemOfType( caf::SelectionManager::FIRST_LEVEL ) ) { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects, caf::SelectionManager::FIRST_LEVEL ); - - if ( !objects.empty() ) - { - return true; - } + return true; } + if ( caf::SelectionManager::instance()->selectedItemOfType() ) { - if ( caf::SelectionManager::instance()->selectedItemOfType() ) - { - return true; - } + return true; } return false; @@ -57,8 +50,7 @@ bool RicDeleteWellPathAttributeFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicDeleteWellPathAttributeFeature::onActionTriggered( bool isChecked ) { - std::vector attributes; - caf::SelectionManager::instance()->objectsByType( &attributes, caf::SelectionManager::FIRST_LEVEL ); + const auto attributes = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); RimWellPathAttributeCollection* wellPathAttributeCollection = nullptr; if ( !attributes.empty() ) { @@ -100,8 +92,7 @@ void RicDeleteWellPathAttributeFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicDeleteWellPathAttributeFeature::setupActionLook( QAction* actionToSetup ) { - std::vector attributes; - caf::SelectionManager::instance()->objectsByType( &attributes, caf::SelectionManager::FIRST_LEVEL ); + const auto attributes = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); if ( !attributes.empty() ) { actionToSetup->setText( "Delete Attribute" ); diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathFeature.cpp index 185a3ec548..d1c8e145fe 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathFeature.cpp @@ -33,10 +33,8 @@ CAF_CMD_SOURCE_INIT( RicDeleteWellPathFeature, "RicDeleteWellPathFeature" ); //-------------------------------------------------------------------------------------------------- bool RicDeleteWellPathFeature::isCommandEnabled() const { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - - return !objects.empty(); + const auto wellPaths = caf::SelectionManager::instance()->objectsByType(); + return !wellPaths.empty(); } //-------------------------------------------------------------------------------------------------- @@ -44,9 +42,7 @@ bool RicDeleteWellPathFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicDeleteWellPathFeature::onActionTriggered( bool isChecked ) { - std::vector wellPaths; - caf::SelectionManager::instance()->objectsByType( &wellPaths ); - + const auto wellPaths = caf::SelectionManager::instance()->objectsByType(); if ( !wellPaths.empty() ) { auto wpc = RimTools::wellPathCollection(); diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathTargetFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathTargetFeature.cpp index 737d85fd8c..8481cac8dc 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathTargetFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathTargetFeature.cpp @@ -32,10 +32,8 @@ CAF_CMD_SOURCE_INIT( RicDeleteWellPathTargetFeature, "RicDeleteWellPathTargetFea //-------------------------------------------------------------------------------------------------- bool RicDeleteWellPathTargetFeature::isCommandEnabled() const { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects, caf::SelectionManager::FIRST_LEVEL ); - - return !objects.empty(); + const auto targets = caf::SelectionManager::instance()->objectsByType(); + return !targets.empty(); } //-------------------------------------------------------------------------------------------------- @@ -43,9 +41,7 @@ bool RicDeleteWellPathTargetFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicDeleteWellPathTargetFeature::onActionTriggered( bool isChecked ) { - std::vector targets; - caf::SelectionManager::instance()->objectsByType( &targets, caf::SelectionManager::FIRST_LEVEL ); - + const auto targets = caf::SelectionManager::instance()->objectsByType(); if ( !targets.empty() ) { RimWellPathGeometryDef* wellGeomDef = targets[0]->firstAncestorOrThisOfTypeAsserted(); diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicIntersectionPickEventHandler.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicIntersectionPickEventHandler.cpp index b699df4383..719e4b2c3e 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicIntersectionPickEventHandler.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicIntersectionPickEventHandler.cpp @@ -41,9 +41,7 @@ RicIntersectionPickEventHandler* RicIntersectionPickEventHandler::instance() //-------------------------------------------------------------------------------------------------- bool RicIntersectionPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eventObject ) { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - + const auto selection = caf::SelectionManager::instance()->objectsByType(); if ( selection.size() != 1 ) return false; RimExtrudedCurveIntersection* intersection = selection[0]; diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicNewEditableWellPathFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicNewEditableWellPathFeature.cpp index a497d1c130..e7ca45c9aa 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicNewEditableWellPathFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicNewEditableWellPathFeature.cpp @@ -46,19 +46,15 @@ CAF_CMD_SOURCE_INIT( RicNewEditableWellPathFeature, "RicNewEditableWellPathFeatu bool RicNewEditableWellPathFeature::isCommandEnabled() const { { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - - if ( !objects.empty() ) + const auto targets = caf::SelectionManager::instance()->objectsByType(); + if ( !targets.empty() ) { return true; } } { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - - if ( !objects.empty() ) + const auto wellPathColl = caf::SelectionManager::instance()->objectsByType(); + if ( !wellPathColl.empty() ) { return true; } diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicNewPolylineTargetFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicNewPolylineTargetFeature.cpp index 0bf3de1c30..46ee306a97 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicNewPolylineTargetFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicNewPolylineTargetFeature.cpp @@ -37,19 +37,15 @@ CAF_CMD_SOURCE_INIT( RicNewPolylineTargetFeature, "RicNewPolylineTargetFeature" bool RicNewPolylineTargetFeature::isCommandEnabled() const { { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - + const auto objects = caf::SelectionManager::instance()->objectsByType(); if ( !objects.empty() ) { return true; } } { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects, caf::SelectionManager::FIRST_LEVEL ); - - if ( !objects.empty() ) + const auto selectedTargets = caf::SelectionManager::instance()->objectsByType(); + if ( !selectedTargets.empty() ) { return true; } @@ -63,8 +59,7 @@ bool RicNewPolylineTargetFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicNewPolylineTargetFeature::onActionTriggered( bool isChecked ) { - std::vector selectedTargets; - caf::SelectionManager::instance()->objectsByType( &selectedTargets, caf::SelectionManager::FIRST_LEVEL ); + const auto selectedTargets = caf::SelectionManager::instance()->objectsByType(); if ( !selectedTargets.empty() ) { auto firstTarget = selectedTargets.front(); @@ -111,8 +106,7 @@ void RicNewPolylineTargetFeature::onActionTriggered( bool isChecked ) return; } - std::vector polylineDefs; - caf::SelectionManager::instance()->objectsByType( &polylineDefs ); + const auto polylineDefs = caf::SelectionManager::instance()->objectsByType(); if ( !polylineDefs.empty() ) { auto* polylineDef = polylineDefs[0]; diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.cpp index c4dc11447e..9f60fd6d13 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.cpp @@ -35,9 +35,7 @@ CAF_CMD_SOURCE_INIT( RicNewWellPathAttributeFeature, "RicNewWellPathAttributeFea bool RicNewWellPathAttributeFeature::isCommandEnabled() const { { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects, caf::SelectionManager::FIRST_LEVEL ); - + const auto objects = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); if ( !objects.empty() ) { return true; @@ -60,9 +58,7 @@ bool RicNewWellPathAttributeFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicNewWellPathAttributeFeature::onActionTriggered( bool isChecked ) { - std::vector attributes; - caf::SelectionManager::instance()->objectsByType( &attributes, caf::SelectionManager::FIRST_LEVEL ); - + const auto attributes = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); RimWellPathAttribute* attribute = nullptr; if ( attributes.size() == 1u ) { @@ -109,8 +105,7 @@ void RicNewWellPathAttributeFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicNewWellPathAttributeFeature::setupActionLook( QAction* actionToSetup ) { - std::vector attributes; - caf::SelectionManager::instance()->objectsByType( &attributes, caf::SelectionManager::FIRST_LEVEL ); + const auto attributes = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); if ( attributes.size() == 1u ) { actionToSetup->setText( QString( "Insert New Attribute before %1" ).arg( attributes[0]->componentTypeLabel() ) ); diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathListTargetFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathListTargetFeature.cpp index 2a91eb36e7..fe1f79a373 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathListTargetFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathListTargetFeature.cpp @@ -34,19 +34,15 @@ CAF_CMD_SOURCE_INIT( RicNewWellPathListTargetFeature, "RicNewWellPathListTargetF bool RicNewWellPathListTargetFeature::isCommandEnabled() const { { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - - if ( !objects.empty() ) + const auto attributes = caf::SelectionManager::instance()->objectsByType(); + if ( !attributes.empty() ) { - return true; + return false; } } { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects, caf::SelectionManager::FIRST_LEVEL ); - - if ( !objects.empty() ) + const auto selectedTargets = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + if ( !selectedTargets.empty() ) { return true; } @@ -60,8 +56,7 @@ bool RicNewWellPathListTargetFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicNewWellPathListTargetFeature::onActionTriggered( bool isChecked ) { - std::vector selectedTargets; - caf::SelectionManager::instance()->objectsByType( &selectedTargets, caf::SelectionManager::FIRST_LEVEL ); + const auto selectedTargets = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); if ( !selectedTargets.empty() ) { RimWellPathTarget* firstTarget = selectedTargets.front(); @@ -133,8 +128,7 @@ void RicNewWellPathListTargetFeature::onActionTriggered( bool isChecked ) return; } - std::vector geomDefs; - caf::SelectionManager::instance()->objectsByType( &geomDefs ); + const auto geomDefs = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); if ( !geomDefs.empty() ) { RimWellPathGeometryDef* wellGeomDef = geomDefs[0]; @@ -176,9 +170,7 @@ void RicNewWellPathListTargetFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicNewWellPathListTargetFeature::setupActionLook( QAction* actionToSetup ) { - std::vector selectedTargets; - caf::SelectionManager::instance()->objectsByType( &selectedTargets, caf::SelectionManager::FIRST_LEVEL ); - + const auto selectedTargets = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); if ( !selectedTargets.empty() ) { auto firstTarget = selectedTargets.front(); diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicPasteModeledWellPathFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicPasteModeledWellPathFeature.cpp index 519609f6bd..cba8dc063a 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicPasteModeledWellPathFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicPasteModeledWellPathFeature.cpp @@ -44,9 +44,7 @@ bool RicPasteModeledWellPathFeature::isCommandEnabled() const { if ( !modeledWellPathsFromClipboard().empty() ) return true; { - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - + const auto objects = caf::SelectionManager::instance()->objectsByType(); if ( !objects.empty() ) { return true; diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 37b2cb81e8..335d8d887b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -190,8 +190,7 @@ //-------------------------------------------------------------------------------------------------- caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { - std::vector uiItems; - caf::SelectionManager::instance()->selectedItems( uiItems ); + const auto uiItems = caf::SelectionManager::instance()->selectedItems(); caf::PdmUiItem* firstUiItem = nullptr; { diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 5e1e4e6cbb..816f3f4c31 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -840,8 +840,7 @@ void RimEclipseView::onCreateDisplayModel() // PdmUiTreeViewEditor::updateSelectionManager(), // PdmUiTreeViewEditor::enableSelectionManagerUpdating - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); curveSet->cellFilterViewUpdated(); diff --git a/ApplicationLibCode/SocketInterface/RiaProjectInfoCommands.cpp b/ApplicationLibCode/SocketInterface/RiaProjectInfoCommands.cpp index e0718f80e4..0a108d21d7 100644 --- a/ApplicationLibCode/SocketInterface/RiaProjectInfoCommands.cpp +++ b/ApplicationLibCode/SocketInterface/RiaProjectInfoCommands.cpp @@ -119,8 +119,7 @@ public: bool interpretCommand( RiaSocketServer* server, const QList& args, QDataStream& socketStream ) override { { - std::vector cases; - caf::SelectionManager::instance()->objectsByType( &cases ); + std::vector cases = caf::SelectionManager::instance()->objectsByType(); std::vector caseIds; std::vector caseNames; diff --git a/ApplicationLibCode/UserInterface/RiuDragDrop.cpp b/ApplicationLibCode/UserInterface/RiuDragDrop.cpp index b6f04e70b7..ccb41a7883 100644 --- a/ApplicationLibCode/UserInterface/RiuDragDrop.cpp +++ b/ApplicationLibCode/UserInterface/RiuDragDrop.cpp @@ -667,8 +667,7 @@ void RiuDragDrop::objectGroupFromModelIndexes( caf::PdmUiTreeView* uiTreeView, c //-------------------------------------------------------------------------------------------------- std::vector> RiuDragDrop::objectHandlesFromSelection() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); + const auto selection = caf::SelectionManager::instance()->objectsByType(); std::vector> objectHandles; diff --git a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp index 7bf1d33ca5..72dc34a1d0 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp @@ -1963,7 +1963,7 @@ void RiuMainWindow::slotAnimationSliderMoved( int newValue ) //-------------------------------------------------------------------------------------------------- void RiuMainWindow::selectedCases( std::vector& cases ) { - caf::SelectionManager::instance()->objectsByType( &cases ); + cases = caf::SelectionManager::instance()->objectsByType(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuTreeViewEventFilter.cpp b/ApplicationLibCode/UserInterface/RiuTreeViewEventFilter.cpp index 5fa1974f36..5d43b90234 100644 --- a/ApplicationLibCode/UserInterface/RiuTreeViewEventFilter.cpp +++ b/ApplicationLibCode/UserInterface/RiuTreeViewEventFilter.cpp @@ -110,9 +110,7 @@ bool RiuTreeViewEventFilter::eventFilter( QObject* obj, QEvent* event ) { QKeyEvent* keyEvent = static_cast( event ); - std::vector uiItems; - caf::SelectionManager::instance()->selectedItems( uiItems ); - + const auto uiItems = caf::SelectionManager::instance()->selectedItems(); if ( !uiItems.empty() ) { std::vector matches; diff --git a/Fwk/AppFwk/cafCommand/cafCmdSelectionHelper.cpp b/Fwk/AppFwk/cafCommand/cafCmdSelectionHelper.cpp index 7b3e9863cb..97cd021bad 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdSelectionHelper.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdSelectionHelper.cpp @@ -63,8 +63,8 @@ CmdSelectionChangeExec* CmdSelectionHelper::createSelectionCommand( const std::v new CmdSelectionChangeExec( SelectionManager::instance()->notificationCenter() ); selectionChangeExec->commandData()->m_selectionLevel.v() = selectionLevel; - SelectionManager::instance()->selectionAsReferences( selectionChangeExec->commandData()->m_previousSelection.v(), - selectionLevel ); + selectionChangeExec->commandData()->m_previousSelection.v() = + SelectionManager::instance()->selectionAsReferences( selectionLevel ); for ( size_t i = 0; i < selection.size(); i++ ) { diff --git a/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdDeleteItemFeature.cpp b/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdDeleteItemFeature.cpp index e26b765b5f..d4a11ff702 100644 --- a/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdDeleteItemFeature.cpp +++ b/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdDeleteItemFeature.cpp @@ -57,20 +57,18 @@ CAF_CMD_SOURCE_INIT( CmdDeleteItemFeature, "PdmListField_DeleteItem" ); //-------------------------------------------------------------------------------------------------- CmdExecuteCommand* CmdDeleteItemFeature::createExecuteCommand() { - std::vector items; - SelectionManager::instance()->selectedItems( items, SelectionManager::FIRST_LEVEL ); - caf::PdmChildArrayFieldHandle* childArrayFieldHandle = caf::SelectionManager::instance()->activeChildArrayFieldHandle(); if ( !childArrayFieldHandle ) return nullptr; caf::PdmObjectHandle* currentPdmObject = nullptr; - for ( size_t i = 0; i < items.size(); i++ ) + const auto selectedItems = caf::SelectionManager::instance()->selectedItems( SelectionManager::FIRST_LEVEL ); + for ( size_t i = 0; i < selectedItems.size(); i++ ) { - if ( dynamic_cast( items[i] ) ) + if ( dynamic_cast( selectedItems[i] ) ) { - currentPdmObject = dynamic_cast( items[i] )->objectHandle(); + currentPdmObject = dynamic_cast( selectedItems[i] )->objectHandle(); } } diff --git a/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsFeatureImpl.cpp b/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsFeatureImpl.cpp index 7994eb173d..53c94f7797 100644 --- a/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsFeatureImpl.cpp +++ b/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsFeatureImpl.cpp @@ -56,9 +56,7 @@ namespace caf //-------------------------------------------------------------------------------------------------- bool ToggleItemsFeatureImpl::isToggleCommandsAvailable() { - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); - + auto selectedItems = caf::SelectionManager::instance()->selectedItems(); if ( selectedItems.size() == 1 ) { caf::PdmUiTreeOrdering* treeItem = findTreeItemFromSelectedUiItem( selectedItems[0] ); @@ -102,8 +100,7 @@ bool ToggleItemsFeatureImpl::isToggleCommandsAvailable() //-------------------------------------------------------------------------------------------------- bool ToggleItemsFeatureImpl::isToggleCommandsForSubItems() { - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); if ( isToggleCommandsAvailable() && selectedItems.size() == 1 ) { return true; @@ -116,8 +113,7 @@ bool ToggleItemsFeatureImpl::isToggleCommandsForSubItems() //-------------------------------------------------------------------------------------------------- void ToggleItemsFeatureImpl::setObjectToggleStateForSelection( SelectionToggleType state ) { - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); if ( state != TOGGLE && selectedItems.size() == 1 ) { // If only one item is selected, loop over its children, and toggle them instead of the diff --git a/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsOnOthersOffFeature.cpp b/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsOnOthersOffFeature.cpp index e9444595ac..a8e89e22d6 100644 --- a/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsOnOthersOffFeature.cpp +++ b/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsOnOthersOffFeature.cpp @@ -54,8 +54,7 @@ CAF_CMD_SOURCE_INIT( ToggleItemsOnOthersOffFeature, "cafToggleItemsOnOthersOffFe //-------------------------------------------------------------------------------------------------- bool ToggleItemsOnOthersOffFeature::isCommandEnabled() const { - std::vector selectedObjects; - caf::SelectionManager::instance()->objectsByType( &selectedObjects ); + auto selectedObjects = caf::SelectionManager::instance()->objectsByType(); caf::PdmFieldHandle* commonParent = verifySameParentForSelection( selectedObjects ); std::vector children = childObjects( commonParent ); @@ -69,8 +68,7 @@ bool ToggleItemsOnOthersOffFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void ToggleItemsOnOthersOffFeature::onActionTriggered( bool isChecked ) { - std::vector selectedObjects; - caf::SelectionManager::instance()->objectsByType( &selectedObjects ); + auto selectedObjects = caf::SelectionManager::instance()->objectsByType(); // First toggle off all siblings diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp index 421255ce32..7bbf7a72a4 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp @@ -162,7 +162,7 @@ std::vector PdmUiCommandSystemProxy::fieldsFromSelection( PdmFi candidateSelectionLevel != SelectionManager::UNDEFINED; candidateSelectionLevel-- ) { - SelectionManager::instance()->selectedItems( items, candidateSelectionLevel ); + items = SelectionManager::instance()->selectedItems( candidateSelectionLevel ); if ( !items.empty() ) break; } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiSelection3dEditorVisualizer.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiSelection3dEditorVisualizer.cpp index 8b5b807ac7..8700f04fe0 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiSelection3dEditorVisualizer.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiSelection3dEditorVisualizer.cpp @@ -97,8 +97,7 @@ void PdmUiSelection3dEditorVisualizer::onSelectionManagerSelectionChanged( const std::set totalSelection; for ( int selLevel : changedSelectionLevels ) { - std::vector items; - caf::SelectionManager::instance()->selectedItems( items, selLevel ); + auto items = caf::SelectionManager::instance()->selectedItems( selLevel ); totalSelection.insert( items.begin(), items.end() ); } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.cpp index a834a77b0e..54ae27aeb7 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.cpp @@ -62,14 +62,15 @@ caf::NotificationCenter* SelectionManager::notificationCenter() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void SelectionManager::selectedItems( std::vector& items, int selectionLevel /*= 0*/ ) +std::vector SelectionManager::selectedItems( int selectionLevel /*= 0*/ ) const { const auto& levelSelectionPairIt = m_selectionPrLevel.find( selectionLevel ); - if ( levelSelectionPairIt == m_selectionPrLevel.end() ) return; + if ( levelSelectionPairIt == m_selectionPrLevel.end() ) return {}; - std::vector, PdmUiItem*>>& selection = levelSelectionPairIt->second; + const auto& selection = levelSelectionPairIt->second; + std::vector items; for ( size_t i = 0; i < selection.size(); i++ ) { if ( selection[i].first.notNull() ) @@ -77,6 +78,8 @@ void SelectionManager::selectedItems( std::vector& items, int select items.push_back( selection[i].second ); } } + + return items; } //-------------------------------------------------------------------------------------------------- @@ -213,12 +216,12 @@ std::set SelectionManager::findChangedLevels( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -PdmUiItem* SelectionManager::selectedItem( int selectionLevel /*= 0*/ ) +PdmUiItem* SelectionManager::selectedItem( int selectionLevel /*= 0*/ ) const { const auto& levelSelectionPairIt = m_selectionPrLevel.find( selectionLevel ); if ( levelSelectionPairIt == m_selectionPrLevel.end() ) return nullptr; - std::vector, PdmUiItem*>>& selection = levelSelectionPairIt->second; + const auto& selection = levelSelectionPairIt->second; if ( selection.size() == 1 ) { @@ -264,14 +267,15 @@ SelectionManager::SelectionManager() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void SelectionManager::selectionAsReferences( std::vector& referenceList, int selectionLevel /*= 0*/ ) const +std::vector SelectionManager::selectionAsReferences( int selectionLevel /*= 0*/ ) const { const auto& levelSelectionPairIt = m_selectionPrLevel.find( selectionLevel ); - if ( levelSelectionPairIt == m_selectionPrLevel.end() ) return; + if ( levelSelectionPairIt == m_selectionPrLevel.end() ) return {}; - const std::vector, PdmUiItem*>>& selection = levelSelectionPairIt->second; + const auto& selection = levelSelectionPairIt->second; + std::vector referenceList; for ( size_t i = 0; i < selection.size(); i++ ) { if ( !selection[i].first.isNull() ) @@ -285,6 +289,8 @@ void SelectionManager::selectionAsReferences( std::vector& referenceLis } } } + + return referenceList; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h index 96acde4c0f..0db182a0f2 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h @@ -67,8 +67,8 @@ public: public: static SelectionManager* instance(); - PdmUiItem* selectedItem( int selectionLevel = 0 ); - void selectedItems( std::vector& items, int selectionLevel = 0 ); + PdmUiItem* selectedItem( int selectionLevel = 0 ) const; + std::vector selectedItems( int selectionLevel = 0 ) const; void setSelectedItem( PdmUiItem* item ); void setSelectedItemAtLevel( PdmUiItem* item, int selectionLevel ); @@ -83,7 +83,7 @@ public: }; void setSelection( const std::vector completeSelection ); - void selectionAsReferences( std::vector& referenceList, int selectionLevel = 0 ) const; + std::vector selectionAsReferences( int selectionLevel = 0 ) const; void setSelectionAtLevelFromReferences( const std::vector& referenceList, int selectionLevel ); bool isSelected( PdmUiItem* item, int selectionLevel ) const; @@ -93,41 +93,44 @@ public: void removeObjectFromAllSelections( PdmObjectHandle* pdmObject ); template - void objectsByType( std::vector* typedObjects, int selectionLevel = 0 ) + std::vector objectsByType( int selectionLevel = 0 ) const { - std::vector items; - this->selectedItems( items, selectionLevel ); + std::vector items = selectedItems( selectionLevel ); + + std::vector typedObjects; for ( size_t i = 0; i < items.size(); i++ ) { T* obj = dynamic_cast( items[i] ); - if ( obj ) typedObjects->push_back( obj ); + if ( obj ) typedObjects.push_back( obj ); } + + return typedObjects; } /// Returns the selected objects of the requested type if _all_ the selected objects are of the requested type template - void objectsByTypeStrict( std::vector* typedObjects, int selectionLevel = 0 ) + std::vector objectsByTypeStrict( int selectionLevel = 0 ) const { - std::vector items; - this->selectedItems( items, selectionLevel ); + std::vector items = selectedItems( selectionLevel ); + + std::vector typedObjects; for ( size_t i = 0; i < items.size(); i++ ) { T* obj = dynamic_cast( items[i] ); if ( !obj ) { - typedObjects->clear(); - break; + return {}; } - typedObjects->push_back( obj ); + typedObjects.push_back( obj ); } + return typedObjects; } template - T* selectedItemOfType( int selectionLevel = 0 ) + T* selectedItemOfType( int selectionLevel = 0 ) const { - std::vector typedObjects; - this->objectsByType( &typedObjects, selectionLevel ); + std::vector typedObjects = objectsByType( selectionLevel ); if ( !typedObjects.empty() ) { return typedObjects.front(); @@ -136,7 +139,7 @@ public: } template - T* selectedItemAncestorOfType( int selectionLevel = 0 ) + T* selectedItemAncestorOfType( int selectionLevel = 0 ) const { PdmUiItem* item = this->selectedItem( selectionLevel ); PdmObjectHandle* selectedObject = dynamic_cast( item ); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManagerTools.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManagerTools.h index b92aaaf286..ad87628e59 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManagerTools.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManagerTools.h @@ -69,10 +69,8 @@ template template [[nodiscard]] std::vector selectedObjectsByType() { - std::vector objectByType; - caf::SelectionManager::instance()->objectsByType( &objectByType ); - - return objectByType; + using UnderlyingType = typename std::remove_pointer::type; + return caf::SelectionManager::instance()->objectsByType(); } //-------------------------------------------------------------------------------------------------- @@ -82,10 +80,8 @@ template template [[nodiscard]] std::vector selectedObjectsByTypeStrict() { - std::vector objectByType; - caf::SelectionManager::instance()->objectsByTypeStrict( &objectByType ); - - return objectByType; + using UnderlyingType = typename std::remove_pointer::type; + return caf::SelectionManager::instance()->objectsByTypeStrict(); } } // end namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp index 90221584c0..a46d6b2965 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp @@ -346,8 +346,7 @@ bool PdmUiLineEditor::isMultipleFieldsWithSameKeywordSelected( PdmFieldHandle* e fieldsToUpdate.push_back( editorField ); // For current selection, find all fields with same keyword - std::vector items; - SelectionManager::instance()->selectedItems( items, SelectionManager::FIRST_LEVEL ); + const auto items = SelectionManager::instance()->selectedItems( SelectionManager::FIRST_LEVEL ); for ( size_t i = 0; i < items.size(); i++ ) { diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp index 797c32f473..d8de4600e7 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp @@ -364,11 +364,8 @@ void PdmUiTableViewEditor::onSelectionManagerSelectionChanged( const std::set items; - SelectionManager::instance()->selectedItems( items, m_rowSelectionLevel ); - QItemSelection totalSelection; - for ( auto item : items ) + for ( auto item : SelectionManager::instance()->selectedItems( m_rowSelectionLevel ) ) { PdmObject* pdmObj = dynamic_cast( item ); QItemSelection itemSelection = m_tableModelPdm->modelIndexFromPdmObject( pdmObj ); diff --git a/GrpcInterface/RiaGrpcProjectService.cpp b/GrpcInterface/RiaGrpcProjectService.cpp index 12c073d455..28b89e3cfc 100644 --- a/GrpcInterface/RiaGrpcProjectService.cpp +++ b/GrpcInterface/RiaGrpcProjectService.cpp @@ -57,9 +57,7 @@ Status RiaGrpcProjectService::GetCurrentCase( ServerContext* context, const rips //-------------------------------------------------------------------------------------------------- Status RiaGrpcProjectService::GetSelectedCases( ServerContext* context, const rips::Empty* request, rips::CaseInfoArray* reply ) { - std::vector cases; - caf::SelectionManager::instance()->objectsByType( &cases ); - + const auto cases = caf::SelectionManager::instance()->objectsByType(); if ( cases.empty() ) { return Status( grpc::NOT_FOUND, "No cases selected" );