(#657) Improved 3D view commands and context menu creation

This commit is contained in:
Magne Sjaastad
2015-11-19 18:57:32 +01:00
parent f3a1f21e87
commit 115e0cb660
6 changed files with 51 additions and 72 deletions

View File

@@ -57,8 +57,13 @@
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include "cafCmdFeatureManager.h"
#include "cafCmdFeature.h"
#include <vector>
#include <QMenu>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -207,6 +212,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
{
commandIds << "RicNewWellLogFileCurveFeature";
commandIds << "RicNewWellLogCurveExtractionFeature";
commandIds << "RicNewWellPathCrossSectionFeature";
commandIds << "RicWellPathDeleteFeature";
}
else if (dynamic_cast<RimCalcScript*>(uiItem))
@@ -291,3 +297,27 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
return commandIds;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimContextCommandBuilder::appendCommandsToMenu(const QStringList& commandIds, QMenu* menu)
{
CVF_ASSERT(menu);
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
for (int i = 0; i < commandIds.size(); i++)
{
caf::CmdFeature* feature = commandManager->getCommandFeature(commandIds[i].toStdString());
CVF_ASSERT(feature);
if (feature->canFeatureBeExecuted())
{
QAction* act = commandManager->action(commandIds[i]);
CVF_ASSERT(act);
menu->addAction(act);
}
}
}