diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicDeleteCustomSegmentIntervalFeature.cpp b/ApplicationLibCode/Commands/CompletionCommands/RicDeleteCustomSegmentIntervalFeature.cpp index e0cbacf653e..d086577fbe2 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicDeleteCustomSegmentIntervalFeature.cpp +++ b/ApplicationLibCode/Commands/CompletionCommands/RicDeleteCustomSegmentIntervalFeature.cpp @@ -37,7 +37,7 @@ CAF_CMD_SOURCE_INIT( RicDeleteCustomSegmentIntervalFeature, "RicDeleteCustomSegm //-------------------------------------------------------------------------------------------------- bool RicDeleteCustomSegmentIntervalFeature::isCommandEnabled() const { - if ( caf::SelectionManager::instance()->selectedItemOfType( caf::SelectionManager::FIRST_LEVEL ) ) + if ( caf::SelectionManager::instance()->selectedItemOfType() ) { return true; } @@ -75,7 +75,7 @@ bool RicDeleteCustomSegmentIntervalFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicDeleteCustomSegmentIntervalFeature::onActionTriggered( bool isChecked ) { - const auto intervals = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + const auto intervals = caf::SelectionManager::instance()->objectsByType(); RimCustomSegmentIntervalCollection* intervalCollection = nullptr; if ( !intervals.empty() ) @@ -143,7 +143,7 @@ void RicDeleteCustomSegmentIntervalFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicDeleteCustomSegmentIntervalFeature::setupActionLook( QAction* actionToSetup ) { - const auto intervals = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + const auto intervals = caf::SelectionManager::instance()->objectsByType(); if ( !intervals.empty() ) { if ( intervals.size() == 1 ) diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicDeleteDiameterRoughnessIntervalFeature.cpp b/ApplicationLibCode/Commands/CompletionCommands/RicDeleteDiameterRoughnessIntervalFeature.cpp index d16026324d6..8f88d2f4e41 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicDeleteDiameterRoughnessIntervalFeature.cpp +++ b/ApplicationLibCode/Commands/CompletionCommands/RicDeleteDiameterRoughnessIntervalFeature.cpp @@ -37,7 +37,7 @@ CAF_CMD_SOURCE_INIT( RicDeleteDiameterRoughnessIntervalFeature, "RicDeleteDiamet //-------------------------------------------------------------------------------------------------- bool RicDeleteDiameterRoughnessIntervalFeature::isCommandEnabled() const { - if ( caf::SelectionManager::instance()->selectedItemOfType( caf::SelectionManager::FIRST_LEVEL ) ) + if ( caf::SelectionManager::instance()->selectedItemOfType() ) { return true; } @@ -75,7 +75,7 @@ bool RicDeleteDiameterRoughnessIntervalFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicDeleteDiameterRoughnessIntervalFeature::onActionTriggered( bool isChecked ) { - const auto intervals = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + const auto intervals = caf::SelectionManager::instance()->objectsByType(); RimDiameterRoughnessIntervalCollection* intervalCollection = nullptr; if ( !intervals.empty() ) @@ -143,7 +143,7 @@ void RicDeleteDiameterRoughnessIntervalFeature::onActionTriggered( bool isChecke //-------------------------------------------------------------------------------------------------- void RicDeleteDiameterRoughnessIntervalFeature::setupActionLook( QAction* actionToSetup ) { - const auto intervals = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + const auto intervals = caf::SelectionManager::instance()->objectsByType(); if ( !intervals.empty() ) { if ( intervals.size() == 1 ) diff --git a/ApplicationLibCode/Commands/FractureCommands/RicDeleteOptionItemFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicDeleteOptionItemFeature.cpp index 97b49d43216..0b22919fdf9 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicDeleteOptionItemFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicDeleteOptionItemFeature.cpp @@ -32,8 +32,7 @@ CAF_CMD_SOURCE_INIT( RicDeleteOptionItemFeature, "RicDeleteOptionItemFeature" ); //-------------------------------------------------------------------------------------------------- void RicDeleteOptionItemFeature::onActionTriggered( bool isChecked ) { - const auto optionItems = - caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + const auto optionItems = caf::SelectionManager::instance()->objectsByType(); if ( !optionItems.empty() ) { @@ -62,8 +61,7 @@ void RicDeleteOptionItemFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- bool RicDeleteOptionItemFeature::isCommandEnabled() const { - const auto optionItems = - caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + const auto optionItems = caf::SelectionManager::instance()->objectsByType(); return !optionItems.empty(); } diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewOptionItemFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicNewOptionItemFeature.cpp index 4ec23bb2789..80bc8b37e4c 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicNewOptionItemFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewOptionItemFeature.cpp @@ -49,8 +49,7 @@ void RicNewOptionItemFeature::onActionTriggered( bool isChecked ) RicCreateMultipleFracturesOptionItemUi* selectedOptionItem = nullptr; { - const auto optionItems = - caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + const auto optionItems = caf::SelectionManager::instance()->objectsByType(); if ( !optionItems.empty() ) { selectedOptionItem = optionItems.front(); diff --git a/ApplicationLibCode/Commands/RicDeletePressureTableItemFeature.cpp b/ApplicationLibCode/Commands/RicDeletePressureTableItemFeature.cpp index 21d578fd710..f315da409ab 100644 --- a/ApplicationLibCode/Commands/RicDeletePressureTableItemFeature.cpp +++ b/ApplicationLibCode/Commands/RicDeletePressureTableItemFeature.cpp @@ -31,7 +31,7 @@ CAF_CMD_SOURCE_INIT( RicDeletePressureTableItemFeature, "RicDeletePressureTableI //-------------------------------------------------------------------------------------------------- bool RicDeletePressureTableItemFeature::isCommandEnabled() const { - auto objects = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + auto objects = caf::SelectionManager::instance()->objectsByType(); return !objects.empty(); } @@ -40,7 +40,7 @@ bool RicDeletePressureTableItemFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicDeletePressureTableItemFeature::onActionTriggered( bool isChecked ) { - auto objects = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + auto objects = caf::SelectionManager::instance()->objectsByType(); if ( !objects.empty() ) { RimPressureTable* pressureTable = objects[0]->firstAncestorOrThisOfTypeAsserted(); diff --git a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp index 6bf4a98b484..0dd8f3267bb 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp @@ -158,7 +158,20 @@ void RicPolylineTarget3dEditor::slotSelectedIn3D() return; } - caf::SelectionManager::instance()->setSelectedItemAtLevel( target, caf::SelectionManager::FIRST_LEVEL ); + auto items = caf::SelectionManager::instance()->selectedItems(); + + std::vector updatedSelection; + for ( auto item : items ) + { + if ( dynamic_cast( item ) ) + { + continue; + } + updatedSelection.push_back( item ); + } + updatedSelection.push_back( target ); + + caf::SelectionManager::instance()->setSelectedItems( updatedSelection ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicWellTarget3dEditor.cpp b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicWellTarget3dEditor.cpp index af162301815..8ddaee93967 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicWellTarget3dEditor.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicWellTarget3dEditor.cpp @@ -333,7 +333,20 @@ void RicWellTarget3dEditor::slotSelectedIn3D() return; } - caf::SelectionManager::instance()->setSelectedItemAtLevel( target, caf::SelectionManager::FIRST_LEVEL ); + auto items = caf::SelectionManager::instance()->selectedItems(); + + std::vector updatedSelection; + for ( auto item : items ) + { + if ( dynamic_cast( item ) ) + { + continue; + } + updatedSelection.push_back( item ); + } + updatedSelection.push_back( target ); + + caf::SelectionManager::instance()->setSelectedItems( updatedSelection ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicDeletePolylineTargetFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicDeletePolylineTargetFeature.cpp index 961d90987e8..81c3659edaf 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicDeletePolylineTargetFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicDeletePolylineTargetFeature.cpp @@ -32,7 +32,7 @@ CAF_CMD_SOURCE_INIT( RicDeletePolylineTargetFeature, "RicDeletePolylineTargetFea //-------------------------------------------------------------------------------------------------- bool RicDeletePolylineTargetFeature::isCommandEnabled() const { - const auto objects = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + const auto objects = caf::SelectionManager::instance()->objectsByType(); return !objects.empty(); } @@ -41,7 +41,7 @@ bool RicDeletePolylineTargetFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicDeletePolylineTargetFeature::onActionTriggered( bool isChecked ) { - const auto targets = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + const auto targets = caf::SelectionManager::instance()->objectsByType(); if ( !targets.empty() ) { RimPolylinePickerInterface* polylineDef = targets[0]->firstAncestorOrThisOfTypeAsserted(); diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.cpp index 988f5087ff2..e40d0b9e6fb 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.cpp @@ -33,7 +33,7 @@ CAF_CMD_SOURCE_INIT( RicDeleteWellPathAttributeFeature, "RicDeleteWellPathAttrib //-------------------------------------------------------------------------------------------------- bool RicDeleteWellPathAttributeFeature::isCommandEnabled() const { - if ( caf::SelectionManager::instance()->selectedItemOfType( caf::SelectionManager::FIRST_LEVEL ) ) + if ( caf::SelectionManager::instance()->selectedItemOfType() ) { return true; } @@ -50,7 +50,7 @@ bool RicDeleteWellPathAttributeFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicDeleteWellPathAttributeFeature::onActionTriggered( bool isChecked ) { - const auto attributes = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + const auto attributes = caf::SelectionManager::instance()->objectsByType(); RimWellPathAttributeCollection* wellPathAttributeCollection = nullptr; if ( !attributes.empty() ) { @@ -92,7 +92,7 @@ void RicDeleteWellPathAttributeFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicDeleteWellPathAttributeFeature::setupActionLook( QAction* actionToSetup ) { - const auto attributes = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + const auto attributes = caf::SelectionManager::instance()->objectsByType(); if ( !attributes.empty() ) { actionToSetup->setText( "Delete Attribute" ); diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathTargetFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathTargetFeature.cpp index 4b2aed56668..f6928f0b1bc 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathTargetFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathTargetFeature.cpp @@ -32,8 +32,7 @@ CAF_CMD_SOURCE_INIT( RicDeleteWellPathTargetFeature, "RicDeleteWellPathTargetFea //-------------------------------------------------------------------------------------------------- bool RicDeleteWellPathTargetFeature::isCommandEnabled() const { - const auto targets = - caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::SelectionLevel::FIRST_LEVEL ); + const auto targets = caf::SelectionManager::instance()->objectsByType(); return !targets.empty(); } @@ -42,8 +41,7 @@ bool RicDeleteWellPathTargetFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicDeleteWellPathTargetFeature::onActionTriggered( bool isChecked ) { - const auto targets = - caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::SelectionLevel::FIRST_LEVEL ); + const auto targets = caf::SelectionManager::instance()->objectsByType(); if ( !targets.empty() ) { RimWellPathGeometryDef* wellGeomDef = targets[0]->firstAncestorOrThisOfTypeAsserted(); diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.cpp index 9f60fd6d13a..9ad83fd3dc5 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.cpp @@ -35,7 +35,7 @@ CAF_CMD_SOURCE_INIT( RicNewWellPathAttributeFeature, "RicNewWellPathAttributeFea bool RicNewWellPathAttributeFeature::isCommandEnabled() const { { - const auto objects = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + const auto objects = caf::SelectionManager::instance()->objectsByType(); if ( !objects.empty() ) { return true; @@ -58,8 +58,8 @@ bool RicNewWellPathAttributeFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicNewWellPathAttributeFeature::onActionTriggered( bool isChecked ) { - const auto attributes = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); - RimWellPathAttribute* attribute = nullptr; + const auto attributes = caf::SelectionManager::instance()->objectsByType(); + RimWellPathAttribute* attribute = nullptr; if ( attributes.size() == 1u ) { auto attributeCollection = attributes[0]->firstAncestorOrThisOfTypeAsserted(); @@ -105,7 +105,7 @@ void RicNewWellPathAttributeFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicNewWellPathAttributeFeature::setupActionLook( QAction* actionToSetup ) { - const auto attributes = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + const auto attributes = caf::SelectionManager::instance()->objectsByType(); 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 fe1f79a3739..c92955b8095 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathListTargetFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathListTargetFeature.cpp @@ -33,19 +33,10 @@ CAF_CMD_SOURCE_INIT( RicNewWellPathListTargetFeature, "RicNewWellPathListTargetF //-------------------------------------------------------------------------------------------------- bool RicNewWellPathListTargetFeature::isCommandEnabled() const { + const auto selectedTargets = caf::SelectionManager::instance()->objectsByType(); + if ( !selectedTargets.empty() ) { - const auto attributes = caf::SelectionManager::instance()->objectsByType(); - if ( !attributes.empty() ) - { - return false; - } - } - { - const auto selectedTargets = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); - if ( !selectedTargets.empty() ) - { - return true; - } + return true; } return false; @@ -56,7 +47,7 @@ bool RicNewWellPathListTargetFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicNewWellPathListTargetFeature::onActionTriggered( bool isChecked ) { - const auto selectedTargets = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + const auto selectedTargets = caf::SelectionManager::instance()->objectsByType(); if ( !selectedTargets.empty() ) { RimWellPathTarget* firstTarget = selectedTargets.front(); @@ -128,7 +119,7 @@ void RicNewWellPathListTargetFeature::onActionTriggered( bool isChecked ) return; } - const auto geomDefs = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + const auto geomDefs = caf::SelectionManager::instance()->objectsByType(); if ( !geomDefs.empty() ) { RimWellPathGeometryDef* wellGeomDef = geomDefs[0]; @@ -170,7 +161,7 @@ void RicNewWellPathListTargetFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicNewWellPathListTargetFeature::setupActionLook( QAction* actionToSetup ) { - const auto selectedTargets = caf::SelectionManager::instance()->objectsByType( caf::SelectionManager::FIRST_LEVEL ); + const auto selectedTargets = caf::SelectionManager::instance()->objectsByType(); if ( !selectedTargets.empty() ) { auto firstTarget = selectedTargets.front(); diff --git a/Fwk/AppFwk/cafCommand/cafCmdSelectionChangeExec.cpp b/Fwk/AppFwk/cafCommand/cafCmdSelectionChangeExec.cpp index 2b4d372091b..32a35d2e405 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdSelectionChangeExec.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdSelectionChangeExec.cpp @@ -55,8 +55,7 @@ QString CmdSelectionChangeExec::name() //-------------------------------------------------------------------------------------------------- void CmdSelectionChangeExec::redo() { - SelectionManager::instance()->setSelectionAtLevelFromReferences( m_commandData->m_newSelection.v(), - m_commandData->m_selectionLevel.v() ); + SelectionManager::instance()->setSelectionFromReferences( m_commandData->m_newSelection.v() ); } //-------------------------------------------------------------------------------------------------- @@ -64,8 +63,7 @@ void CmdSelectionChangeExec::redo() //-------------------------------------------------------------------------------------------------- void CmdSelectionChangeExec::undo() { - SelectionManager::instance()->setSelectionAtLevelFromReferences( m_commandData->m_previousSelection.v(), - m_commandData->m_selectionLevel.v() ); + SelectionManager::instance()->setSelectionFromReferences( m_commandData->m_previousSelection.v() ); } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafCommand/cafCmdSelectionChangeExec.h b/Fwk/AppFwk/cafCommand/cafCmdSelectionChangeExec.h index 6b10556e26b..d31fb18c860 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdSelectionChangeExec.h +++ b/Fwk/AppFwk/cafCommand/cafCmdSelectionChangeExec.h @@ -58,12 +58,10 @@ class CmdSelectionChangeExecData : public PdmObject "CmdSelectionChangeExecData tooltip", "CmdSelectionChangeExecData whatsthis" ); - CAF_PDM_InitFieldNoDefault( &m_selectionLevel, "selectionLevel", "selectionLevel" ); CAF_PDM_InitField( &m_previousSelection, "previousSelection", std::vector(), "previousSelection" ); CAF_PDM_InitField( &m_newSelection, "newSelection", std::vector(), "newSelection" ); } - PdmField m_selectionLevel; PdmField> m_previousSelection; PdmField> m_newSelection; }; diff --git a/Fwk/AppFwk/cafCommand/cafCmdSelectionHelper.cpp b/Fwk/AppFwk/cafCommand/cafCmdSelectionHelper.cpp index 97cd021bad3..df50465c699 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdSelectionHelper.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdSelectionHelper.cpp @@ -46,9 +46,9 @@ namespace caf //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void CmdSelectionHelper::executeSelectionCommand( const std::vector& selection, int selectionLevel ) +void CmdSelectionHelper::executeSelectionCommand( const std::vector& selection ) { - CmdSelectionChangeExec* selectionChangeExec = createSelectionCommand( selection, selectionLevel ); + CmdSelectionChangeExec* selectionChangeExec = createSelectionCommand( selection ); CmdExecCommandManager::instance()->processExecuteCommand( selectionChangeExec ); } @@ -56,15 +56,12 @@ void CmdSelectionHelper::executeSelectionCommand( const std::vector& selection, - int selectionLevel ) +CmdSelectionChangeExec* CmdSelectionHelper::createSelectionCommand( const std::vector& selection ) { CmdSelectionChangeExec* selectionChangeExec = new CmdSelectionChangeExec( SelectionManager::instance()->notificationCenter() ); - selectionChangeExec->commandData()->m_selectionLevel.v() = selectionLevel; - selectionChangeExec->commandData()->m_previousSelection.v() = - SelectionManager::instance()->selectionAsReferences( selectionLevel ); + selectionChangeExec->commandData()->m_previousSelection.v() = SelectionManager::instance()->selectionAsReferences(); for ( size_t i = 0; i < selection.size(); i++ ) { diff --git a/Fwk/AppFwk/cafCommand/cafCmdSelectionHelper.h b/Fwk/AppFwk/cafCommand/cafCmdSelectionHelper.h index b4aa251ff43..bbf554e3532 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdSelectionHelper.h +++ b/Fwk/AppFwk/cafCommand/cafCmdSelectionHelper.h @@ -46,9 +46,8 @@ class PdmObjectHandle; class CmdSelectionHelper { public: - static void executeSelectionCommand( const std::vector& selection, int selectionLevel ); - static CmdSelectionChangeExec* createSelectionCommand( const std::vector& selection, - int selectionLevel ); + static void executeSelectionCommand( const std::vector& selection ); + static CmdSelectionChangeExec* createSelectionCommand( const std::vector& selection ); }; } // end namespace caf diff --git a/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdDeleteItemFeature.cpp b/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdDeleteItemFeature.cpp index d4a11ff7025..d45619bc21a 100644 --- a/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdDeleteItemFeature.cpp +++ b/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdDeleteItemFeature.cpp @@ -63,7 +63,7 @@ CmdExecuteCommand* CmdDeleteItemFeature::createExecuteCommand() caf::PdmObjectHandle* currentPdmObject = nullptr; - const auto selectedItems = caf::SelectionManager::instance()->selectedItems( SelectionManager::FIRST_LEVEL ); + const auto selectedItems = caf::SelectionManager::instance()->selectedItems(); for ( size_t i = 0; i < selectedItems.size(); i++ ) { if ( dynamic_cast( selectedItems[i] ) ) @@ -103,8 +103,7 @@ CmdExecuteCommand* CmdDeleteItemFeature::createExecuteCommand() //-------------------------------------------------------------------------------------------------- bool CmdDeleteItemFeature::isCommandEnabled() const { - caf::PdmObject* currentPdmObject = dynamic_cast( - caf::SelectionManager::instance()->selectedItem( caf::SelectionManager::FIRST_LEVEL ) ); + caf::PdmObject* currentPdmObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); if ( !currentPdmObject ) return false; caf::PdmChildArrayFieldHandle* childArrayFieldHandle = diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp index 7bbf7a72a44..f06f591dd5b 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp @@ -156,15 +156,8 @@ std::vector PdmUiCommandSystemProxy::fieldsFromSelection( PdmFi std::vector items; - // Find all selected items at one level starting from the largest level. This is required to be able to modify - // multiple rows in the table editor. Items in the table editor use by default SelectionManager::FIRST_LEVEL - for ( int candidateSelectionLevel = SelectionManager::SECOND_LEVEL; - candidateSelectionLevel != SelectionManager::UNDEFINED; - candidateSelectionLevel-- ) - { - items = SelectionManager::instance()->selectedItems( candidateSelectionLevel ); - if ( !items.empty() ) break; - } + // Find all selected items to be able to modify multiple rows in the table editor + items = SelectionManager::instance()->selectedItems(); if ( items.size() < 2 ) return {}; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiSelection3dEditorVisualizer.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiSelection3dEditorVisualizer.cpp index 8700f04fe01..f637c4b087d 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiSelection3dEditorVisualizer.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiSelection3dEditorVisualizer.cpp @@ -94,14 +94,9 @@ void PdmUiSelection3dEditorVisualizer::onSelectionManagerSelectionChanged( const if ( !m_ownerViewer ) return; - std::set totalSelection; - for ( int selLevel : changedSelectionLevels ) - { - auto items = caf::SelectionManager::instance()->selectedItems( selLevel ); - totalSelection.insert( items.begin(), items.end() ); - } + auto items = caf::SelectionManager::instance()->selectedItems(); - for ( PdmUiItem* item : totalSelection ) + for ( PdmUiItem* item : items ) { QString editor3dTypeName = item->ui3dEditorTypeName( m_configName ); if ( !editor3dTypeName.isEmpty() ) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.cpp index 54ae27aeb70..b9340dd9d68 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.cpp @@ -62,9 +62,9 @@ caf::NotificationCenter* SelectionManager::notificationCenter() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector SelectionManager::selectedItems( int selectionLevel /*= 0*/ ) const +std::vector SelectionManager::selectedItems() const { - const auto& levelSelectionPairIt = m_selectionPrLevel.find( selectionLevel ); + const auto& levelSelectionPairIt = m_selectionPrLevel.find( 0 ); if ( levelSelectionPairIt == m_selectionPrLevel.end() ) return {}; @@ -131,52 +131,6 @@ void SelectionManager::extractInternalSelectionItems( const std::vector& items, int selectionLevel ) -{ - std::vector, PdmUiItem*>>& selection = m_selectionPrLevel[selectionLevel]; - std::vector, PdmUiItem*>> newSelection; - - extractInternalSelectionItems( items, &newSelection ); - - if ( newSelection != selection ) - { - selection = newSelection; - notifySelectionChanged( { selectionLevel } ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void SelectionManager::setSelection( const std::vector completeSelection ) -{ - std::map, PdmUiItem*>>> newCompleteSelectionMap; - std::map> newSelectionPrLevel; - - for ( const SelectionItem& item : completeSelection ) - { - newSelectionPrLevel[item.selectionLevel].push_back( item.item ); - } - - for ( auto& levelItemsPair : newSelectionPrLevel ) - { - std::vector, PdmUiItem*>>& newSelectionLevel = - newCompleteSelectionMap[levelItemsPair.first]; - extractInternalSelectionItems( levelItemsPair.second, &newSelectionLevel ); - } - - std::set changedLevels = findChangedLevels( newCompleteSelectionMap ); - - if ( !changedLevels.empty() ) - { - m_selectionPrLevel = newCompleteSelectionMap; - notifySelectionChanged( changedLevels ); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -216,9 +170,9 @@ std::set SelectionManager::findChangedLevels( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -PdmUiItem* SelectionManager::selectedItem( int selectionLevel /*= 0*/ ) const +PdmUiItem* SelectionManager::selectedItem() const { - const auto& levelSelectionPairIt = m_selectionPrLevel.find( selectionLevel ); + const auto& levelSelectionPairIt = m_selectionPrLevel.find( 0 ); if ( levelSelectionPairIt == m_selectionPrLevel.end() ) return nullptr; const auto& selection = levelSelectionPairIt->second; @@ -245,17 +199,6 @@ void SelectionManager::setSelectedItem( PdmUiItem* item ) setSelectedItems( singleSelection ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void SelectionManager::setSelectedItemAtLevel( PdmUiItem* item, int selectionLevel ) -{ - std::vector singleSelection; - singleSelection.push_back( item ); - - setSelectedItemsAtLevel( singleSelection, selectionLevel ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -267,9 +210,9 @@ SelectionManager::SelectionManager() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector SelectionManager::selectionAsReferences( int selectionLevel /*= 0*/ ) const +std::vector SelectionManager::selectionAsReferences() const { - const auto& levelSelectionPairIt = m_selectionPrLevel.find( selectionLevel ); + const auto& levelSelectionPairIt = m_selectionPrLevel.find( 0 ); if ( levelSelectionPairIt == m_selectionPrLevel.end() ) return {}; @@ -296,8 +239,7 @@ std::vector SelectionManager::selectionAsReferences( int selectionLevel //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void SelectionManager::setSelectionAtLevelFromReferences( const std::vector& referenceList, - int selectionLevel /*= 0*/ ) +void SelectionManager::setSelectionFromReferences( const std::vector& referenceList ) { std::vector uiItems; @@ -316,15 +258,15 @@ void SelectionManager::setSelectionAtLevelFromReferences( const std::vectorsecond.empty() ) - { - m_selectionPrLevel[selectionLevel].clear(); - - notifySelectionChanged( { selectionLevel } ); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h index 0db182a0f2b..d3d8eb0bd10 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h @@ -55,47 +55,27 @@ class PdmChildArrayFieldHandle; //================================================================================================== class SelectionManager { -public: - enum SelectionLevel - { - UNDEFINED = -1, - BASE_LEVEL = 0, - FIRST_LEVEL = 1, - SECOND_LEVEL = 2 - }; - public: static SelectionManager* instance(); - PdmUiItem* selectedItem( int selectionLevel = 0 ) const; - std::vector selectedItems( int selectionLevel = 0 ) const; + PdmUiItem* selectedItem() const; + std::vector selectedItems() const; void setSelectedItem( PdmUiItem* item ); - void setSelectedItemAtLevel( PdmUiItem* item, int selectionLevel ); - bool setSelectedItems( const std::vector& items ); - void setSelectedItemsAtLevel( const std::vector& items, int selectionLevel = 0 ); - - struct SelectionItem - { - PdmUiItem* item; - int selectionLevel; - }; - void setSelection( const std::vector completeSelection ); - std::vector selectionAsReferences( int selectionLevel = 0 ) const; - void setSelectionAtLevelFromReferences( const std::vector& referenceList, int selectionLevel ); + std::vector selectionAsReferences() const; + void setSelectionFromReferences( const std::vector& referenceList ); - bool isSelected( PdmUiItem* item, int selectionLevel ) const; + bool isSelected( PdmUiItem* item ) const; void clearAll(); - void clear( int selectionLevel ); void removeObjectFromAllSelections( PdmObjectHandle* pdmObject ); template - std::vector objectsByType( int selectionLevel = 0 ) const + std::vector objectsByType() const { - std::vector items = selectedItems( selectionLevel ); + std::vector items = selectedItems(); std::vector typedObjects; for ( size_t i = 0; i < items.size(); i++ ) @@ -110,9 +90,9 @@ class SelectionManager /// Returns the selected objects of the requested type if _all_ the selected objects are of the requested type template - std::vector objectsByTypeStrict( int selectionLevel = 0 ) const + std::vector objectsByTypeStrict() const { - std::vector items = selectedItems( selectionLevel ); + std::vector items = selectedItems(); std::vector typedObjects; for ( size_t i = 0; i < items.size(); i++ ) @@ -128,9 +108,9 @@ class SelectionManager } template - T* selectedItemOfType( int selectionLevel = 0 ) const + T* selectedItemOfType() const { - std::vector typedObjects = objectsByType( selectionLevel ); + std::vector typedObjects = objectsByType(); if ( !typedObjects.empty() ) { return typedObjects.front(); @@ -139,9 +119,9 @@ class SelectionManager } template - T* selectedItemAncestorOfType( int selectionLevel = 0 ) const + T* selectedItemAncestorOfType() const { - PdmUiItem* item = this->selectedItem( selectionLevel ); + PdmUiItem* item = this->selectedItem(); PdmObjectHandle* selectedObject = dynamic_cast( item ); if ( selectedObject ) { diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp index d3e4f10fc68..45724f7180c 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp @@ -366,7 +366,7 @@ bool PdmUiLineEditor::isMultipleFieldsWithSameKeywordSelected( PdmFieldHandle* e fieldsToUpdate.push_back( editorField ); // For current selection, find all fields with same keyword - const auto items = SelectionManager::instance()->selectedItems( SelectionManager::FIRST_LEVEL ); + const auto items = SelectionManager::instance()->selectedItems(); for ( size_t i = 0; i < items.size(); i++ ) { diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.cpp index e3ffc3534d4..b774c7cc168 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.cpp @@ -144,22 +144,6 @@ void PdmUiTableView::enableHeaderText( bool enable ) m_listViewEditor->enableHeaderText( enable ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void PdmUiTableView::setTableSelectionLevel( int selectionLevel ) -{ - m_listViewEditor->setTableSelectionLevel( selectionLevel ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void PdmUiTableView::setRowSelectionLevel( int selectionLevel ) -{ - m_listViewEditor->setRowSelectionLevel( selectionLevel ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.h index 1c41eba05fe..f3d11882c6a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.h @@ -65,8 +65,6 @@ class PdmUiTableView : public QWidget void setChildArrayField( PdmChildArrayFieldHandle* childArrayField ); void setUiConfigurationName( QString uiConfigName ); void enableHeaderText( bool enable ); - void setTableSelectionLevel( int selectionLevel ); - void setRowSelectionLevel( int selectionLevel ); PdmObjectHandle* pdmObjectFromModelIndex( const QModelIndex& mi ); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp index d8de4600e78..9121964f154 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp @@ -108,8 +108,6 @@ PdmUiTableViewEditor::PdmUiTableViewEditor() m_checkboxDelegate = new PdmUiCheckBoxDelegate(); - m_tableSelectionLevel = SelectionManager::BASE_LEVEL; - m_rowSelectionLevel = SelectionManager::FIRST_LEVEL; m_isBlockingSelectionManagerChanged = false; m_isUpdatingSelectionQModel = false; } @@ -189,8 +187,6 @@ void PdmUiTableViewEditor::configureAndUpdateUi( const QString& uiConfigName ) childArrayFH->ownerObject()->uiCapability()->editorAttribute( childArrayFH, uiConfigName, &editorAttrib ); editorAttribLoaded = true; - this->setTableSelectionLevel( editorAttrib.tableSelectionLevel ); - this->setRowSelectionLevel( editorAttrib.rowSelectionLevel ); this->enableHeaderText( editorAttrib.enableHeaderText ); QString styleSheetTable; @@ -339,22 +335,6 @@ void PdmUiTableViewEditor::enableHeaderText( bool enable ) m_tableHeadingIcon->setVisible( enable ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void PdmUiTableViewEditor::setTableSelectionLevel( int selectionLevel ) -{ - m_tableSelectionLevel = selectionLevel; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void PdmUiTableViewEditor::setRowSelectionLevel( int selectionLevel ) -{ - m_rowSelectionLevel = selectionLevel; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -362,10 +342,10 @@ void PdmUiTableViewEditor::onSelectionManagerSelectionChanged( const std::setisVisible() || m_isBlockingSelectionManagerChanged ) return; - if ( isSelectionRoleDefined() && ( changedSelectionLevels.count( m_rowSelectionLevel ) ) ) + if ( isSelectionRoleDefined() && ( changedSelectionLevels.count( 0 ) ) ) { QItemSelection totalSelection; - for ( auto item : SelectionManager::instance()->selectedItems( m_rowSelectionLevel ) ) + for ( auto item : SelectionManager::instance()->selectedItems() ) { PdmObject* pdmObj = dynamic_cast( item ); QItemSelection itemSelection = m_tableModelPdm->modelIndexFromPdmObject( pdmObj ); @@ -405,7 +385,7 @@ void PdmUiTableViewEditor::slotSelectionChanged( const QItemSelection& selected, //-------------------------------------------------------------------------------------------------- bool PdmUiTableViewEditor::isSelectionRoleDefined() const { - return m_rowSelectionLevel != SelectionManager::UNDEFINED; + return true; } //-------------------------------------------------------------------------------------------------- @@ -440,21 +420,20 @@ void PdmUiTableViewEditor::updateSelectionManagerFromTableSelection() } } - std::vector newCompleteSelection; + std::vector newCompleteSelection; for ( auto item : selectedRowObjects ) { - newCompleteSelection.push_back( { item, m_rowSelectionLevel } ); + newCompleteSelection.push_back( item ); } if ( childArrayFieldHandle() && childArrayFieldHandle()->ownerObject() ) { - newCompleteSelection.push_back( - { childArrayFieldHandle()->ownerObject()->uiCapability(), m_tableSelectionLevel } ); + newCompleteSelection.push_back( childArrayFieldHandle()->ownerObject()->uiCapability() ); } m_isBlockingSelectionManagerChanged = true; - SelectionManager::instance()->setSelection( newCompleteSelection ); + SelectionManager::instance()->setSelectedItems( newCompleteSelection ); m_isBlockingSelectionManagerChanged = false; } } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h index c0c81fee3a1..5ce155ef2f2 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h @@ -98,9 +98,7 @@ class PdmUiTableViewEditorAttribute : public PdmUiEditorAttribute }; PdmUiTableViewEditorAttribute() - : tableSelectionLevel( 0 ) - , rowSelectionLevel( 1 ) - , enableHeaderText( true ) + : enableHeaderText( true ) , minimumHeight( -1 ) , heightHint( -1 ) , alwaysEnforceResizePolicy( false ) @@ -109,8 +107,6 @@ class PdmUiTableViewEditorAttribute : public PdmUiEditorAttribute { } - int tableSelectionLevel; - int rowSelectionLevel; bool enableHeaderText; std::vector columnWidths; int minimumHeight; ///< Not used if If < 0 @@ -135,8 +131,6 @@ class PdmUiTableViewEditor : public PdmUiFieldEditorHandle, public SelectionChan ~PdmUiTableViewEditor() override; void enableHeaderText( bool enable ); - void setTableSelectionLevel( int selectionLevel ); - void setRowSelectionLevel( int selectionLevel ); PdmObjectHandle* pdmObjectFromModelIndex( const QModelIndex& mi ); QTableView* tableView(); @@ -173,8 +167,6 @@ private slots: PdmUiCheckBoxDelegate* m_checkboxDelegate; bool m_useDefaultContextMenu; - int m_tableSelectionLevel; - int m_rowSelectionLevel; bool m_isBlockingSelectionManagerChanged; bool m_isUpdatingSelectionQModel; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp index b44a2a8cafa..5d25c0c7512 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp @@ -404,7 +404,7 @@ void PdmUiTreeViewEditor::customMenuRequested( QPoint pos ) //-------------------------------------------------------------------------------------------------- PdmChildArrayFieldHandle* PdmUiTreeViewEditor::currentChildArrayFieldHandle() { - PdmUiItem* currentSelectedItem = SelectionManager::instance()->selectedItem( SelectionManager::FIRST_LEVEL ); + PdmUiItem* currentSelectedItem = SelectionManager::instance()->selectedItem(); PdmUiFieldHandle* uiFieldHandle = dynamic_cast( currentSelectedItem ); if ( uiFieldHandle )