#4316 Fix context menu with multiple selected well paths

This commit is contained in:
Gaute Lindkvist
2019-04-12 09:08:38 +02:00
parent 53f7edf320
commit c82a4a5537
8 changed files with 171 additions and 77 deletions

View File

@@ -95,9 +95,13 @@ void RicNewFishbonesSubsFeature::onActionTriggered(bool isChecked)
//--------------------------------------------------------------------------------------------------
RimFishbonesCollection* RicNewFishbonesSubsFeature::selectedFishbonesCollection()
{
std::vector<caf::PdmUiItem*> allSelectedItems;
caf::SelectionManager::instance()->selectedItems(allSelectedItems);
if (allSelectedItems.size() != 1u) return false;
RimFishbonesCollection* objToFind = nullptr;
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
caf::PdmUiItem* pdmUiItem = allSelectedItems.front();
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(pdmUiItem);
if (objHandle)

View File

@@ -83,31 +83,29 @@ void RicNewPerforationIntervalFeature::setupActionLook(QAction* actionToSetup)
///
//--------------------------------------------------------------------------------------------------
RimPerforationCollection* RicNewPerforationIntervalFeature::selectedPerforationCollection()
{
RimPerforationCollection* objToFind = nullptr;
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
{
std::vector<caf::PdmUiItem*> selectedItems;
caf::SelectionManager::instance()->selectedItems(selectedItems);
if (selectedItems.size() != 1u) return nullptr;
caf::PdmUiItem* pdmUiItem = selectedItems.front();
RimPerforationCollection* perforationCollection = nullptr;
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(pdmUiItem);
if (objHandle)
{
objHandle->firstAncestorOrThisOfType(objToFind);
}
objHandle->firstAncestorOrThisOfType(perforationCollection);
if (perforationCollection)
return perforationCollection;
RimWellPath* wellPath = dynamic_cast<RimWellPath*>(objHandle);
if (wellPath)
return wellPath->perforationIntervalCollection();
if (objToFind == nullptr)
{
std::vector<RimWellPath*> wellPaths;
caf::SelectionManager::instance()->objectsByType(&wellPaths);
if (!wellPaths.empty())
{
return wellPaths[0]->perforationIntervalCollection();
}
RimWellPathCompletions* completions = caf::SelectionManager::instance()->selectedItemOfType<RimWellPathCompletions>();
if (completions)
{
return completions->perforationCollection();
}
}
return objToFind;
return nullptr;
}

View File

@@ -18,7 +18,11 @@ CAF_CMD_SOURCE_INIT(RicNewValveFeature, "RicNewValveFeature");
//--------------------------------------------------------------------------------------------------
bool RicNewValveFeature::isCommandEnabled()
{
const RimPerforationInterval* perfInterval = caf::SelectionManager::instance()->selectedItemOfType<RimPerforationInterval>();
std::vector<caf::PdmUiItem*> allSelectedItems;
caf::SelectionManager::instance()->selectedItems(allSelectedItems);
if (allSelectedItems.size() != 1u) return false;
const RimPerforationInterval* perfInterval = dynamic_cast<RimPerforationInterval*>(allSelectedItems.front());
return perfInterval != nullptr;
}