diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathDeleteFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathDeleteFeature.cpp index 42a1636946..9ee57e1033 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathDeleteFeature.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathDeleteFeature.cpp @@ -29,6 +29,7 @@ namespace caf { + CAF_CMD_SOURCE_INIT(RicWellPathDeleteFeature, "RicWellPathDeleteFeature"); @@ -40,7 +41,7 @@ bool RicWellPathDeleteFeature::isCommandEnabled() std::vector objects; caf::SelectionManager::instance()->objectsByType(&objects); - if (objects.size() == 1) + if (objects.size() > 0) { return true; } @@ -58,13 +59,17 @@ void RicWellPathDeleteFeature::onActionTriggered(bool isChecked) if (objects.size() == 0) return; - RimWellPath* wellPath = objects[0]; + RimWellPath* firstWellPath = objects[0]; - RimWellPathCollection* wellPathCollection = NULL; - wellPath->firstAncestorOrThisOfType(wellPathCollection); + RimWellPathCollection* wellPathCollection = nullptr; + firstWellPath->firstAncestorOrThisOfType(wellPathCollection); + if (!wellPathCollection) return; - wellPathCollection->removeWellPath(wellPath);; - delete wellPath; + for (RimWellPath* wellPath : objects) + { + wellPathCollection->removeWellPath(wellPath);; + delete wellPath; + } wellPathCollection->uiCapability()->updateConnectedEditors(); wellPathCollection->scheduleGeometryRegenAndRedrawViews(); @@ -75,7 +80,7 @@ void RicWellPathDeleteFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicWellPathDeleteFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setText("Delete Well Path"); + actionToSetup->setText("Delete Well Path(s)"); actionToSetup->setIcon(QIcon(":/Erase.png")); } diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index efbd89e3f1..28e82c0b20 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -224,8 +224,6 @@ QStringList RimContextCommandBuilder::commandsFromSelection() commandIds << "RicNewWellLogCurveExtractionFeature"; commandIds << "RicNewWellPathIntersectionFeature"; commandIds << "RicNewWellPathFractureFeature"; - commandIds << "Separator"; - commandIds << "RicWellPathDeleteFeature"; } else if (dynamic_cast(uiItem)) { @@ -492,6 +490,14 @@ QStringList RimContextCommandBuilder::commandsFromSelection() commandIds << "RicDeleteItemFeature"; } + if (caf::CmdFeatureManager::instance()->getCommandFeature("RicWellPathDeleteFeature")->canFeatureBeExecuted()) + { + // Special delete command for Well paths + // Placed here to fit context menu location of general delete feature + commandIds << "Separator"; + commandIds << "RicWellPathDeleteFeature"; + } + if ( caf::CmdFeatureManager::instance()->getCommandFeature("RicCloseCaseFeature")->canFeatureBeExecuted() ) { commandIds << "Separator";