From 082d6500ad64bf60666615ddd3fa06b89eb87ef0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 9 May 2021 08:07:16 +0200 Subject: [PATCH] #7446 MLW: Add "Create Well Path Lateral" to well in Project Tree --- .../WellPathCommands/CMakeLists_files.cmake | 2 + .../RicNewWellPathLateralAtDepthFeature.cpp | 52 ++++++++++------ .../RicNewWellPathLateralAtDepthFeature.h | 7 ++- .../RicNewWellPathLateralFeature.cpp | 60 +++++++++++++++++++ .../RicNewWellPathLateralFeature.h | 34 +++++++++++ .../RimContextCommandBuilder.cpp | 2 + .../ProjectDataModel/RimWellPathTieIn.cpp | 3 +- 7 files changed, 138 insertions(+), 22 deletions(-) create mode 100644 ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathLateralFeature.cpp create mode 100644 ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathLateralFeature.h diff --git a/ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake index 37fc24aec5..a62daf62de 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake @@ -21,6 +21,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineTargetFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicDeletePolylineTargetFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicImportWellMeasurementsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathLateralAtDepthFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathLateralFeature.h ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/Ric3dObjectEditorHandle.h ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulator.h ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicWellTarget3dEditor.h @@ -52,6 +53,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineTargetFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicDeletePolylineTargetFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportWellMeasurementsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathLateralAtDepthFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathLateralFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/Ric3dObjectEditorHandle.cpp ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulator.cpp ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicWellTarget3dEditor.cpp diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathLateralAtDepthFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathLateralAtDepthFeature.cpp index 8eda19e1c3..adb9bff4fd 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathLateralAtDepthFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathLateralAtDepthFeature.cpp @@ -67,24 +67,45 @@ void RicNewWellPathLateralAtDepthFeature::onActionTriggered( bool isChecked ) RimWellPath* parentWellPath = wellPathSelItem->m_wellpath; CVF_ASSERT( parentWellPath ); + double parentWellMD = wellPathSelItem->m_measuredDepth; + + createLateralAtMeasuredDepth( parentWellPath, parentWellMD ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewWellPathLateralAtDepthFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Create Well Path Lateral at this Depth" ); + actionToSetup->setIcon( QIcon( ":/Well.svg" ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPath* RicNewWellPathLateralAtDepthFeature::createLateralAtMeasuredDepth( RimWellPath* parentWellPath, + double parentWellMD ) +{ RimProject* project = RimProject::current(); RimWellPathCollection* wellPathColl = RimTools::wellPathCollection(); if ( project && wellPathColl ) { - double parentWellMD = wellPathSelItem->m_measuredDepth; - auto newModeledWellPath = new RimModeledWellPath(); - auto [pointVector, measuredDepths] = - parentWellPath->wellPathGeometry() - ->clippedPointSubset( parentWellPath->wellPathGeometry()->measuredDepths().front(), parentWellMD ); - if ( pointVector.size() < 2u ) return; + if ( parentWellPath->wellPathGeometry() && parentWellPath->wellPathGeometry()->measuredDepths().size() > 2 ) + { + auto [pointVector, measuredDepths] = + parentWellPath->wellPathGeometry() + ->clippedPointSubset( parentWellPath->wellPathGeometry()->measuredDepths().front(), parentWellMD ); + + newModeledWellPath->geometryDefinition()->setMdAtFirstTarget( measuredDepths.back() ); + newModeledWellPath->geometryDefinition()->setFixedWellPathPoints( pointVector ); + newModeledWellPath->geometryDefinition()->setFixedMeasuredDepths( measuredDepths ); + } newModeledWellPath->geometryDefinition()->setIsAttachedToParentWell( true ); - newModeledWellPath->geometryDefinition()->setMdAtFirstTarget( measuredDepths.back() ); newModeledWellPath->geometryDefinition()->setUseAutoGeneratedTargetAtSeaLevel( false ); - newModeledWellPath->geometryDefinition()->setFixedWellPathPoints( pointVector ); - newModeledWellPath->geometryDefinition()->setFixedMeasuredDepths( measuredDepths ); auto nameOfNewWell = updateNameOfParentAndFindNameOfSideStep( parentWellPath ); newModeledWellPath->setName( nameOfNewWell ); @@ -102,16 +123,11 @@ void RicNewWellPathLateralAtDepthFeature::onActionTriggered( bool isChecked ) project->scheduleCreateDisplayModelAndRedrawAllViews(); Riu3DMainWindowTools::selectAsCurrentItem( newModeledWellPath->geometryDefinition() ); - } -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicNewWellPathLateralAtDepthFeature::setupActionLook( QAction* actionToSetup ) -{ - actionToSetup->setText( "Create Well Path Lateral at this Depth" ); - actionToSetup->setIcon( QIcon( ":/Well.svg" ) ); + return newModeledWellPath; + } + + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathLateralAtDepthFeature.h b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathLateralAtDepthFeature.h index 89659b8e86..5d456c9107 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathLateralAtDepthFeature.h +++ b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathLateralAtDepthFeature.h @@ -30,13 +30,14 @@ class RicNewWellPathLateralAtDepthFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; -protected: - // Overrides +public: bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; + static RimWellPath* createLateralAtMeasuredDepth( RimWellPath* parentWellPath, double parentWellMD ); + private: static RiuWellPathSelectionItem* wellPathSelectionItem(); - QString updateNameOfParentAndFindNameOfSideStep( RimWellPath* parentwWellPath ); + static QString updateNameOfParentAndFindNameOfSideStep( RimWellPath* parentwWellPath ); }; diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathLateralFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathLateralFeature.cpp new file mode 100644 index 0000000000..211277521e --- /dev/null +++ b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathLateralFeature.cpp @@ -0,0 +1,60 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicNewWellPathLateralFeature.h" + +#include "RicNewWellPathLateralAtDepthFeature.h" + +#include "RimWellPath.h" + +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT( RicNewWellPathLateralFeature, "RicNewWellPathLateralFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewWellPathLateralFeature::isCommandEnabled() +{ + RimWellPath* wellPath = caf::SelectionManager::instance()->selectedItemOfType(); + + return wellPath != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewWellPathLateralFeature::onActionTriggered( bool isChecked ) +{ + RimWellPath* parentWellPath = caf::SelectionManager::instance()->selectedItemOfType(); + if ( !parentWellPath ) return; + + double measuredDepth = 0.0; + RicNewWellPathLateralAtDepthFeature::createLateralAtMeasuredDepth( parentWellPath, measuredDepth ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewWellPathLateralFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Create Well Path Lateral" ); + actionToSetup->setIcon( QIcon( ":/Well.svg" ) ); +} diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathLateralFeature.h b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathLateralFeature.h new file mode 100644 index 0000000000..0789991c6f --- /dev/null +++ b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathLateralFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicNewWellPathLateralFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index aa5febfda4..8c66043fa0 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -358,7 +358,9 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() else if ( dynamic_cast( firstUiItem ) ) { menuBuilder << "RicNewEditableWellPathFeature"; + menuBuilder << "RicNewWellPathLateralFeature"; menuBuilder << "RicNewWellPathIntersectionFeature"; + appendCreateCompletions( menuBuilder ); menuBuilder.addSeparator(); appendImportMenu( menuBuilder ); diff --git a/ApplicationLibCode/ProjectDataModel/RimWellPathTieIn.cpp b/ApplicationLibCode/ProjectDataModel/RimWellPathTieIn.cpp index 7e58d0bb3b..1939690678 100644 --- a/ApplicationLibCode/ProjectDataModel/RimWellPathTieIn.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimWellPathTieIn.cpp @@ -113,7 +113,8 @@ void RimWellPathTieIn::updateFirstTargetFromParentWell() if ( !parentWellPath ) return; auto modeledWellPath = dynamic_cast( m_childWell() ); - if ( modeledWellPath && modeledWellPath->geometryDefinition() ) + if ( modeledWellPath && modeledWellPath->geometryDefinition() && parentWellPath->wellPathGeometry() && + parentWellPath->wellPathGeometry()->measuredDepths().size() > 2 ) { auto [pointVector, measuredDepths] = parentWellPath->wellPathGeometry()