Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ CAF_CMD_SOURCE_INIT( RicDeleteCustomSegmentIntervalFeature, "RicDeleteCustomSegm
//--------------------------------------------------------------------------------------------------
bool RicDeleteCustomSegmentIntervalFeature::isCommandEnabled() const
{
if ( caf::SelectionManager::instance()->selectedItemOfType<RimCustomSegmentInterval>( caf::SelectionManager::FIRST_LEVEL ) )
if ( caf::SelectionManager::instance()->selectedItemOfType<RimCustomSegmentInterval>() )
{
return true;
}
Expand Down Expand Up @@ -75,7 +75,7 @@ bool RicDeleteCustomSegmentIntervalFeature::isCommandEnabled() const
//--------------------------------------------------------------------------------------------------
void RicDeleteCustomSegmentIntervalFeature::onActionTriggered( bool isChecked )
{
const auto intervals = caf::SelectionManager::instance()->objectsByType<RimCustomSegmentInterval>( caf::SelectionManager::FIRST_LEVEL );
const auto intervals = caf::SelectionManager::instance()->objectsByType<RimCustomSegmentInterval>();
RimCustomSegmentIntervalCollection* intervalCollection = nullptr;

if ( !intervals.empty() )
Expand Down Expand Up @@ -143,7 +143,7 @@ void RicDeleteCustomSegmentIntervalFeature::onActionTriggered( bool isChecked )
//--------------------------------------------------------------------------------------------------
void RicDeleteCustomSegmentIntervalFeature::setupActionLook( QAction* actionToSetup )
{
const auto intervals = caf::SelectionManager::instance()->objectsByType<RimCustomSegmentInterval>( caf::SelectionManager::FIRST_LEVEL );
const auto intervals = caf::SelectionManager::instance()->objectsByType<RimCustomSegmentInterval>();
if ( !intervals.empty() )
{
if ( intervals.size() == 1 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ CAF_CMD_SOURCE_INIT( RicDeleteDiameterRoughnessIntervalFeature, "RicDeleteDiamet
//--------------------------------------------------------------------------------------------------
bool RicDeleteDiameterRoughnessIntervalFeature::isCommandEnabled() const
{
if ( caf::SelectionManager::instance()->selectedItemOfType<RimDiameterRoughnessInterval>( caf::SelectionManager::FIRST_LEVEL ) )
if ( caf::SelectionManager::instance()->selectedItemOfType<RimDiameterRoughnessInterval>() )
{
return true;
}
Expand Down Expand Up @@ -75,7 +75,7 @@ bool RicDeleteDiameterRoughnessIntervalFeature::isCommandEnabled() const
//--------------------------------------------------------------------------------------------------
void RicDeleteDiameterRoughnessIntervalFeature::onActionTriggered( bool isChecked )
{
const auto intervals = caf::SelectionManager::instance()->objectsByType<RimDiameterRoughnessInterval>( caf::SelectionManager::FIRST_LEVEL );
const auto intervals = caf::SelectionManager::instance()->objectsByType<RimDiameterRoughnessInterval>();
RimDiameterRoughnessIntervalCollection* intervalCollection = nullptr;

if ( !intervals.empty() )
Expand Down Expand Up @@ -143,7 +143,7 @@ void RicDeleteDiameterRoughnessIntervalFeature::onActionTriggered( bool isChecke
//--------------------------------------------------------------------------------------------------
void RicDeleteDiameterRoughnessIntervalFeature::setupActionLook( QAction* actionToSetup )
{
const auto intervals = caf::SelectionManager::instance()->objectsByType<RimDiameterRoughnessInterval>( caf::SelectionManager::FIRST_LEVEL );
const auto intervals = caf::SelectionManager::instance()->objectsByType<RimDiameterRoughnessInterval>();
if ( !intervals.empty() )
{
if ( intervals.size() == 1 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ CAF_CMD_SOURCE_INIT( RicDeleteOptionItemFeature, "RicDeleteOptionItemFeature" );
//--------------------------------------------------------------------------------------------------
void RicDeleteOptionItemFeature::onActionTriggered( bool isChecked )
{
const auto optionItems =
caf::SelectionManager::instance()->objectsByType<RicCreateMultipleFracturesOptionItemUi>( caf::SelectionManager::FIRST_LEVEL );
const auto optionItems = caf::SelectionManager::instance()->objectsByType<RicCreateMultipleFracturesOptionItemUi>();

if ( !optionItems.empty() )
{
Expand Down Expand Up @@ -62,8 +61,7 @@ void RicDeleteOptionItemFeature::setupActionLook( QAction* actionToSetup )
//--------------------------------------------------------------------------------------------------
bool RicDeleteOptionItemFeature::isCommandEnabled() const
{
const auto optionItems =
caf::SelectionManager::instance()->objectsByType<RicCreateMultipleFracturesOptionItemUi>( caf::SelectionManager::FIRST_LEVEL );
const auto optionItems = caf::SelectionManager::instance()->objectsByType<RicCreateMultipleFracturesOptionItemUi>();

return !optionItems.empty();
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ void RicNewOptionItemFeature::onActionTriggered( bool isChecked )
RicCreateMultipleFracturesOptionItemUi* selectedOptionItem = nullptr;

{
const auto optionItems =
caf::SelectionManager::instance()->objectsByType<RicCreateMultipleFracturesOptionItemUi>( caf::SelectionManager::FIRST_LEVEL );
const auto optionItems = caf::SelectionManager::instance()->objectsByType<RicCreateMultipleFracturesOptionItemUi>();
if ( !optionItems.empty() )
{
selectedOptionItem = optionItems.front();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ CAF_CMD_SOURCE_INIT( RicDeletePressureTableItemFeature, "RicDeletePressureTableI
//--------------------------------------------------------------------------------------------------
bool RicDeletePressureTableItemFeature::isCommandEnabled() const
{
auto objects = caf::SelectionManager::instance()->objectsByType<RimPressureTableItem>( caf::SelectionManager::FIRST_LEVEL );
auto objects = caf::SelectionManager::instance()->objectsByType<RimPressureTableItem>();
return !objects.empty();
}

Expand All @@ -40,7 +40,7 @@ bool RicDeletePressureTableItemFeature::isCommandEnabled() const
//--------------------------------------------------------------------------------------------------
void RicDeletePressureTableItemFeature::onActionTriggered( bool isChecked )
{
auto objects = caf::SelectionManager::instance()->objectsByType<RimPressureTableItem>( caf::SelectionManager::FIRST_LEVEL );
auto objects = caf::SelectionManager::instance()->objectsByType<RimPressureTableItem>();
if ( !objects.empty() )
{
RimPressureTable* pressureTable = objects[0]->firstAncestorOrThisOfTypeAsserted<RimPressureTable>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<caf::PdmUiItem*> updatedSelection;
for ( auto item : items )
{
if ( dynamic_cast<RimPolylineTarget*>( item ) )
{
continue;
}
updatedSelection.push_back( item );
}
updatedSelection.push_back( target );

caf::SelectionManager::instance()->setSelectedItems( updatedSelection );
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<caf::PdmUiItem*> updatedSelection;
for ( auto item : items )
{
if ( dynamic_cast<RimWellPathTarget*>( item ) )
{
continue;
}
updatedSelection.push_back( item );
}
updatedSelection.push_back( target );

caf::SelectionManager::instance()->setSelectedItems( updatedSelection );
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CAF_CMD_SOURCE_INIT( RicDeletePolylineTargetFeature, "RicDeletePolylineTargetFea
//--------------------------------------------------------------------------------------------------
bool RicDeletePolylineTargetFeature::isCommandEnabled() const
{
const auto objects = caf::SelectionManager::instance()->objectsByType<RimPolylineTarget>( caf::SelectionManager::FIRST_LEVEL );
const auto objects = caf::SelectionManager::instance()->objectsByType<RimPolylineTarget>();
return !objects.empty();
}

Expand All @@ -41,7 +41,7 @@ bool RicDeletePolylineTargetFeature::isCommandEnabled() const
//--------------------------------------------------------------------------------------------------
void RicDeletePolylineTargetFeature::onActionTriggered( bool isChecked )
{
const auto targets = caf::SelectionManager::instance()->objectsByType<RimPolylineTarget>( caf::SelectionManager::FIRST_LEVEL );
const auto targets = caf::SelectionManager::instance()->objectsByType<RimPolylineTarget>();
if ( !targets.empty() )
{
RimPolylinePickerInterface* polylineDef = targets[0]->firstAncestorOrThisOfTypeAsserted<RimPolylinePickerInterface>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CAF_CMD_SOURCE_INIT( RicDeleteWellPathAttributeFeature, "RicDeleteWellPathAttrib
//--------------------------------------------------------------------------------------------------
bool RicDeleteWellPathAttributeFeature::isCommandEnabled() const
{
if ( caf::SelectionManager::instance()->selectedItemOfType<RimWellPathAttributeCollection>( caf::SelectionManager::FIRST_LEVEL ) )
if ( caf::SelectionManager::instance()->selectedItemOfType<RimWellPathAttribute>() )
{
return true;
}
Expand All @@ -50,7 +50,7 @@ bool RicDeleteWellPathAttributeFeature::isCommandEnabled() const
//--------------------------------------------------------------------------------------------------
void RicDeleteWellPathAttributeFeature::onActionTriggered( bool isChecked )
{
const auto attributes = caf::SelectionManager::instance()->objectsByType<RimWellPathAttribute>( caf::SelectionManager::FIRST_LEVEL );
const auto attributes = caf::SelectionManager::instance()->objectsByType<RimWellPathAttribute>();
RimWellPathAttributeCollection* wellPathAttributeCollection = nullptr;
if ( !attributes.empty() )
{
Expand Down Expand Up @@ -92,7 +92,7 @@ void RicDeleteWellPathAttributeFeature::onActionTriggered( bool isChecked )
//--------------------------------------------------------------------------------------------------
void RicDeleteWellPathAttributeFeature::setupActionLook( QAction* actionToSetup )
{
const auto attributes = caf::SelectionManager::instance()->objectsByType<RimWellPathAttribute>( caf::SelectionManager::FIRST_LEVEL );
const auto attributes = caf::SelectionManager::instance()->objectsByType<RimWellPathAttribute>();
if ( !attributes.empty() )
{
actionToSetup->setText( "Delete Attribute" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ CAF_CMD_SOURCE_INIT( RicDeleteWellPathTargetFeature, "RicDeleteWellPathTargetFea
//--------------------------------------------------------------------------------------------------
bool RicDeleteWellPathTargetFeature::isCommandEnabled() const
{
const auto targets =
caf::SelectionManager::instance()->objectsByType<RimWellPathTarget>( caf::SelectionManager::SelectionLevel::FIRST_LEVEL );
const auto targets = caf::SelectionManager::instance()->objectsByType<RimWellPathTarget>();
return !targets.empty();
}

Expand All @@ -42,8 +41,7 @@ bool RicDeleteWellPathTargetFeature::isCommandEnabled() const
//--------------------------------------------------------------------------------------------------
void RicDeleteWellPathTargetFeature::onActionTriggered( bool isChecked )
{
const auto targets =
caf::SelectionManager::instance()->objectsByType<RimWellPathTarget>( caf::SelectionManager::SelectionLevel::FIRST_LEVEL );
const auto targets = caf::SelectionManager::instance()->objectsByType<RimWellPathTarget>();
if ( !targets.empty() )
{
RimWellPathGeometryDef* wellGeomDef = targets[0]->firstAncestorOrThisOfTypeAsserted<RimWellPathGeometryDef>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CAF_CMD_SOURCE_INIT( RicNewWellPathAttributeFeature, "RicNewWellPathAttributeFea
bool RicNewWellPathAttributeFeature::isCommandEnabled() const
{
{
const auto objects = caf::SelectionManager::instance()->objectsByType<RimWellPathAttribute>( caf::SelectionManager::FIRST_LEVEL );
const auto objects = caf::SelectionManager::instance()->objectsByType<RimWellPathAttribute>();
if ( !objects.empty() )
{
return true;
Expand All @@ -58,8 +58,8 @@ bool RicNewWellPathAttributeFeature::isCommandEnabled() const
//--------------------------------------------------------------------------------------------------
void RicNewWellPathAttributeFeature::onActionTriggered( bool isChecked )
{
const auto attributes = caf::SelectionManager::instance()->objectsByType<RimWellPathAttribute>( caf::SelectionManager::FIRST_LEVEL );
RimWellPathAttribute* attribute = nullptr;
const auto attributes = caf::SelectionManager::instance()->objectsByType<RimWellPathAttribute>();
RimWellPathAttribute* attribute = nullptr;
if ( attributes.size() == 1u )
{
auto attributeCollection = attributes[0]->firstAncestorOrThisOfTypeAsserted<RimWellPathAttributeCollection>();
Expand Down Expand Up @@ -105,7 +105,7 @@ void RicNewWellPathAttributeFeature::onActionTriggered( bool isChecked )
//--------------------------------------------------------------------------------------------------
void RicNewWellPathAttributeFeature::setupActionLook( QAction* actionToSetup )
{
const auto attributes = caf::SelectionManager::instance()->objectsByType<RimWellPathAttribute>( caf::SelectionManager::FIRST_LEVEL );
const auto attributes = caf::SelectionManager::instance()->objectsByType<RimWellPathAttribute>();
if ( attributes.size() == 1u )
{
actionToSetup->setText( QString( "Insert New Attribute before %1" ).arg( attributes[0]->componentTypeLabel() ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,10 @@ CAF_CMD_SOURCE_INIT( RicNewWellPathListTargetFeature, "RicNewWellPathListTargetF
//--------------------------------------------------------------------------------------------------
bool RicNewWellPathListTargetFeature::isCommandEnabled() const
{
const auto selectedTargets = caf::SelectionManager::instance()->objectsByType<RimWellPathTarget>();
if ( !selectedTargets.empty() )
{
const auto attributes = caf::SelectionManager::instance()->objectsByType<RimWellPathGeometryDef>();
if ( !attributes.empty() )
{
return false;
}
}
{
const auto selectedTargets = caf::SelectionManager::instance()->objectsByType<RimWellPathTarget>( caf::SelectionManager::FIRST_LEVEL );
if ( !selectedTargets.empty() )
{
return true;
}
return true;
}

return false;
Expand All @@ -56,7 +47,7 @@ bool RicNewWellPathListTargetFeature::isCommandEnabled() const
//--------------------------------------------------------------------------------------------------
void RicNewWellPathListTargetFeature::onActionTriggered( bool isChecked )
{
const auto selectedTargets = caf::SelectionManager::instance()->objectsByType<RimWellPathTarget>( caf::SelectionManager::FIRST_LEVEL );
const auto selectedTargets = caf::SelectionManager::instance()->objectsByType<RimWellPathTarget>();
if ( !selectedTargets.empty() )
{
RimWellPathTarget* firstTarget = selectedTargets.front();
Expand Down Expand Up @@ -128,7 +119,7 @@ void RicNewWellPathListTargetFeature::onActionTriggered( bool isChecked )
return;
}

const auto geomDefs = caf::SelectionManager::instance()->objectsByType<RimWellPathGeometryDef>( caf::SelectionManager::FIRST_LEVEL );
const auto geomDefs = caf::SelectionManager::instance()->objectsByType<RimWellPathGeometryDef>();
if ( !geomDefs.empty() )
{
RimWellPathGeometryDef* wellGeomDef = geomDefs[0];
Expand Down Expand Up @@ -170,7 +161,7 @@ void RicNewWellPathListTargetFeature::onActionTriggered( bool isChecked )
//--------------------------------------------------------------------------------------------------
void RicNewWellPathListTargetFeature::setupActionLook( QAction* actionToSetup )
{
const auto selectedTargets = caf::SelectionManager::instance()->objectsByType<RimWellPathTarget>( caf::SelectionManager::FIRST_LEVEL );
const auto selectedTargets = caf::SelectionManager::instance()->objectsByType<RimWellPathTarget>();
if ( !selectedTargets.empty() )
{
auto firstTarget = selectedTargets.front();
Expand Down
6 changes: 2 additions & 4 deletions Fwk/AppFwk/cafCommand/cafCmdSelectionChangeExec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,15 @@ 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() );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void CmdSelectionChangeExec::undo()
{
SelectionManager::instance()->setSelectionAtLevelFromReferences( m_commandData->m_previousSelection.v(),
m_commandData->m_selectionLevel.v() );
SelectionManager::instance()->setSelectionFromReferences( m_commandData->m_previousSelection.v() );
}

//--------------------------------------------------------------------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions Fwk/AppFwk/cafCommand/cafCmdSelectionChangeExec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<QString>(), "previousSelection" );
CAF_PDM_InitField( &m_newSelection, "newSelection", std::vector<QString>(), "newSelection" );
}

PdmField<int> m_selectionLevel;
PdmField<std::vector<QString>> m_previousSelection;
PdmField<std::vector<QString>> m_newSelection;
};
Expand Down
Loading