mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#657) Improved 3D view commands and context menu creation
This commit is contained in:
parent
f3a1f21e87
commit
115e0cb660
@ -19,9 +19,12 @@
|
||||
|
||||
#include "RicNewWellPathCrossSectionFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimCrossSection.h"
|
||||
#include "RimCrossSectionCollection.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimView.h"
|
||||
|
||||
#include "cafCmdExecCommandManager.h"
|
||||
#include "cafSelectionManager.h"
|
||||
@ -36,7 +39,6 @@ CAF_CMD_SOURCE_INIT(RicNewWellPathCrossSectionFeature, "RicNewWellPathCrossSecti
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicNewWellPathCrossSectionFeature::RicNewWellPathCrossSectionFeature()
|
||||
: m_view(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -54,7 +56,8 @@ bool RicNewWellPathCrossSectionFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewWellPathCrossSectionFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
if (!m_view) return;
|
||||
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||
if (!activeView) return;
|
||||
|
||||
std::vector<RimWellPath*> collection;
|
||||
caf::SelectionManager::instance()->objectsByType(&collection);
|
||||
@ -62,7 +65,7 @@ void RicNewWellPathCrossSectionFeature::onActionTriggered(bool isChecked)
|
||||
|
||||
RimWellPath* wellPath = collection[0];
|
||||
|
||||
RicNewWellPathCrossSectionFeatureCmd* cmd = new RicNewWellPathCrossSectionFeatureCmd(m_view->crossSectionCollection, wellPath);
|
||||
RicNewWellPathCrossSectionFeatureCmd* cmd = new RicNewWellPathCrossSectionFeatureCmd(activeView->crossSectionCollection, wellPath);
|
||||
caf::CmdExecCommandManager::instance()->processExecuteCommand(cmd);
|
||||
}
|
||||
|
||||
@ -75,14 +78,6 @@ void RicNewWellPathCrossSectionFeature::setupActionLook(QAction* actionToSetup)
|
||||
actionToSetup->setText("New Cross Section");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewWellPathCrossSectionFeature::setView(RimView* view)
|
||||
{
|
||||
m_view = view;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RimView.h"
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
#include "cafCmdExecuteCommand.h"
|
||||
#include "cafPdmPointer.h"
|
||||
@ -59,16 +57,11 @@ class RicNewWellPathCrossSectionFeature : public caf::CmdFeature
|
||||
public:
|
||||
RicNewWellPathCrossSectionFeature();
|
||||
|
||||
void setView(RimView* view);
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimView> m_view;
|
||||
};
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
class QMenu;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
@ -28,5 +30,6 @@
|
||||
class RimContextCommandBuilder
|
||||
{
|
||||
public:
|
||||
static QStringList commandsFromSelection();
|
||||
static QStringList commandsFromSelection();
|
||||
static void appendCommandsToMenu(const QStringList& commandIds, QMenu* menu);
|
||||
};
|
||||
|
@ -55,8 +55,7 @@ public:
|
||||
void appendPartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
||||
|
||||
protected:
|
||||
//virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
//virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName);
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
virtual caf::PdmFieldHandle* objectToggleField();
|
||||
|
||||
private:
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
#include "RimCellRangeFilter.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimContextCommandBuilder.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipsePropertyFilter.h"
|
||||
@ -136,7 +137,6 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
if (m_viewer->rayPick(winPosX, winPosY, &hitItems))
|
||||
{
|
||||
extractIntersectionData(hitItems, &localIntersectionPoint, &firstHitPart, &faceIndex, &nncFirstHitPart, NULL);
|
||||
updateSelectionFromPickedPart(firstHitPart);
|
||||
}
|
||||
|
||||
if (firstHitPart && faceIndex != cvf::UNDEFINED_UINT)
|
||||
@ -222,6 +222,8 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
}
|
||||
}
|
||||
|
||||
QStringList commandIds;
|
||||
|
||||
// Well log curve creation commands
|
||||
if (firstHitPart && firstHitPart->sourceInfo())
|
||||
{
|
||||
@ -233,26 +235,11 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
RimWellPath* wellPath = wellPathSourceInfo->wellPath();
|
||||
if (wellPath)
|
||||
{
|
||||
caf::SelectionManager::instance()->setSelectedItem(wellPath);
|
||||
|
||||
RicNewWellLogFileCurveFeature* newWellLogFileCurveFeature = dynamic_cast<RicNewWellLogFileCurveFeature*>(commandManager->getCommandFeature("RicNewWellLogFileCurveFeature"));
|
||||
if (newWellLogFileCurveFeature && newWellLogFileCurveFeature->canFeatureBeExecuted())
|
||||
{
|
||||
menu.addAction(newWellLogFileCurveFeature->action());
|
||||
}
|
||||
|
||||
RicNewWellLogCurveExtractionFeature* newExtractionCurveFeature = dynamic_cast<RicNewWellLogCurveExtractionFeature*>(commandManager->getCommandFeature("RicNewWellLogCurveExtractionFeature"));
|
||||
if (newExtractionCurveFeature && newExtractionCurveFeature->canFeatureBeExecuted())
|
||||
{
|
||||
menu.addAction(newExtractionCurveFeature->action());
|
||||
}
|
||||
|
||||
RicNewWellPathCrossSectionFeature* newWellPathCrossSectionFeature = dynamic_cast<RicNewWellPathCrossSectionFeature*>(commandManager->getCommandFeature("RicNewWellPathCrossSectionFeature"));
|
||||
if (newWellPathCrossSectionFeature)
|
||||
{
|
||||
newWellPathCrossSectionFeature->setView(m_reservoirView);
|
||||
|
||||
menu.addAction(newWellPathCrossSectionFeature->action());
|
||||
}
|
||||
commandIds << "RicNewWellLogFileCurveFeature";
|
||||
commandIds << "RicNewWellLogCurveExtractionFeature";
|
||||
commandIds << "RicNewWellPathCrossSectionFeature";
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,11 +251,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
{
|
||||
caf::SelectionManager::instance()->setSelectedItem(well);
|
||||
|
||||
RicNewSimWellCrossSectionFeature* newSimWellCrossSectionFeature = dynamic_cast<RicNewSimWellCrossSectionFeature*>(commandManager->getCommandFeature("RicNewSimWellCrossSectionFeature"));
|
||||
if (newSimWellCrossSectionFeature && newSimWellCrossSectionFeature->canFeatureBeExecuted())
|
||||
{
|
||||
menu.addAction(newSimWellCrossSectionFeature->action());
|
||||
}
|
||||
commandIds << "RicNewSimWellCrossSectionFeature";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -276,38 +259,14 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
// View Link commands
|
||||
if (!firstHitPart)
|
||||
{
|
||||
QStringList commandIds;
|
||||
|
||||
commandIds << "RicLinkViewFeature";
|
||||
commandIds << "RicUnLinkViewFeature";
|
||||
commandIds << "RicShowLinkOptionsFeature";
|
||||
commandIds << "RicSetMasterViewFeature";
|
||||
|
||||
bool firstLinkAction = true;
|
||||
|
||||
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
|
||||
for (int i = 0; i < commandIds.size(); i++)
|
||||
{
|
||||
caf::CmdFeature* feature = commandManager->getCommandFeature(commandIds[i].toStdString());
|
||||
if (feature->canFeatureBeExecuted())
|
||||
{
|
||||
QAction* act = commandManager->action(commandIds[i]);
|
||||
CVF_ASSERT(act);
|
||||
|
||||
if (firstLinkAction)
|
||||
{
|
||||
if (menu.actions().size() > 0)
|
||||
{
|
||||
menu.addSeparator();
|
||||
}
|
||||
firstLinkAction = false;
|
||||
}
|
||||
|
||||
menu.addAction(act);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RimContextCommandBuilder::appendCommandsToMenu(commandIds, &menu);
|
||||
|
||||
if (menu.actions().size() > 0)
|
||||
{
|
||||
menu.exec(event->globalPos());
|
||||
|
Loading…
Reference in New Issue
Block a user