#2164 Intersections: Make context command for Azimuth/Dip intersection

This commit is contained in:
Unknown 2017-11-21 18:57:05 +01:00
parent ff9cd86491
commit 3ed9874876
4 changed files with 194 additions and 0 deletions

View File

@ -9,6 +9,7 @@ ${CEE_CURRENT_LIST_DIR}RicAppendIntersectionFeature.h
${CEE_CURRENT_LIST_DIR}RicNewSimWellIntersectionFeature.h
${CEE_CURRENT_LIST_DIR}RicNewWellPathIntersectionFeature.h
${CEE_CURRENT_LIST_DIR}RicNewPolylineIntersectionFeature.h
${CEE_CURRENT_LIST_DIR}RicNewAzimuthDipIntersectionFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -16,6 +17,7 @@ ${CEE_CURRENT_LIST_DIR}RicAppendIntersectionFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewSimWellIntersectionFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewWellPathIntersectionFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewPolylineIntersectionFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewAzimuthDipIntersectionFeature.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,127 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicNewAzimuthDipIntersectionFeature.h"
#include "RiaApplication.h"
#include "RimCase.h"
#include "RimIntersection.h"
#include "RimIntersectionCollection.h"
#include "RimView.h"
#include "RiuMainWindow.h"
#include "RiuSelectionManager.h"
#include "RiuViewer.h"
#include "cafCmdExecCommandManager.h"
#include "cafDisplayCoordTransform.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicNewAzimuthDipIntersectionFeature, "RicNewAzimuthDipIntersectionFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicNewAzimuthDipIntersectionFeature::RicNewAzimuthDipIntersectionFeature()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewAzimuthDipIntersectionFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewAzimuthDipIntersectionFeature::onActionTriggered(bool isChecked)
{
RimView* activeView = RiaApplication::instance()->activeReservoirView();
if (!activeView) return;
RicNewAzimuthDipIntersectionFeatureCmd* cmd = new RicNewAzimuthDipIntersectionFeatureCmd(activeView->crossSectionCollection);
caf::CmdExecCommandManager::instance()->processExecuteCommand(cmd);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewAzimuthDipIntersectionFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setIcon(QIcon(":/CrossSection16x16.png"));
actionToSetup->setText("Azimuth and Dip Intersection");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicNewAzimuthDipIntersectionFeatureCmd::RicNewAzimuthDipIntersectionFeatureCmd(RimIntersectionCollection* intersectionCollection)
: CmdExecuteCommand(NULL),
m_intersectionCollection(intersectionCollection)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicNewAzimuthDipIntersectionFeatureCmd::~RicNewAzimuthDipIntersectionFeatureCmd()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicNewAzimuthDipIntersectionFeatureCmd::name()
{
return "Start Azimuth and Dip Intersection";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewAzimuthDipIntersectionFeatureCmd::redo()
{
CVF_ASSERT(m_intersectionCollection);
RimIntersection* intersection = new RimIntersection();
intersection->name = "Azimuth and Dip";
intersection->type = RimIntersection::CS_AZIMUTHLINE;
intersection->inputTwoAzimuthPointsFromViewerEnabled = true;
m_intersectionCollection->appendIntersection(intersection);
RiuSelectionManager::instance()->deleteAllItems();
RiuMainWindow::instance()->selectAsCurrentItem(intersection);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewAzimuthDipIntersectionFeatureCmd::undo()
{
}

View File

@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicViewerEventInterface.h"
#include "cafCmdExecuteCommand.h"
#include "cafPdmPointer.h"
class RimIntersectionCollection;
//==================================================================================================
///
//==================================================================================================
class RicNewAzimuthDipIntersectionFeatureCmd : public caf::CmdExecuteCommand
{
public:
explicit RicNewAzimuthDipIntersectionFeatureCmd(RimIntersectionCollection* intersectionCollection);
virtual ~RicNewAzimuthDipIntersectionFeatureCmd();
virtual QString name() override;
virtual void redo() override;
virtual void undo() override;
private:
caf::PdmPointer<RimIntersectionCollection> m_intersectionCollection;
};
//==================================================================================================
///
//==================================================================================================
class RicNewAzimuthDipIntersectionFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
RicNewAzimuthDipIntersectionFeature();
protected:
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -223,6 +223,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
if (menu.actions().size() > 0) menu.addSeparator();
menu.addAction(caf::CmdFeatureManager::instance()->action("RicNewPolylineIntersectionFeature"));
menu.addAction(caf::CmdFeatureManager::instance()->action("RicNewAzimuthDipIntersectionFeature"));
menu.addAction(caf::CmdFeatureManager::instance()->action("RicIntersectionBoxAtPosFeature"));
menu.addAction(caf::CmdFeatureManager::instance()->action("RicIntersectionBoxXSliceFeature"));
menu.addAction(caf::CmdFeatureManager::instance()->action("RicIntersectionBoxYSliceFeature"));