diff --git a/ApplicationLibCode/Commands/CompletionCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/CompletionCommands/CMakeLists_files.cmake index 43c5f0afad..44cdd07802 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/CompletionCommands/CMakeLists_files.cmake @@ -1,6 +1,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicEditPerforationCollectionFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesLateralsFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicFishbonesCreateHelper.h ${CMAKE_CURRENT_LIST_DIR}/RicNewFishbonesSubsAtMeasuredDepthFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewFishbonesSubsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalFeature.h @@ -20,6 +21,7 @@ set(SOURCE_GROUP_HEADER_FILES set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicEditPerforationCollectionFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesLateralsFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicFishbonesCreateHelper.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewFishbonesSubsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalFeature.cpp diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicFishbonesCreateHelper.cpp b/ApplicationLibCode/Commands/CompletionCommands/RicFishbonesCreateHelper.cpp new file mode 100644 index 0000000000..a33750c3d5 --- /dev/null +++ b/ApplicationLibCode/Commands/CompletionCommands/RicFishbonesCreateHelper.cpp @@ -0,0 +1,110 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2025 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 "RicFishbonesCreateHelper.h" + +#include "RicNewFishbonesSubsFeature.h" +#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h" + +#include "RimFishbones.h" +#include "RimFishbonesCollection.h" +#include "RimProject.h" +#include "RimTools.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" + +#include "Riu3DMainWindowTools.h" +#include "RiuMainWindow.h" + +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFishbones* RicFishbonesCreateHelper::createAndConfigureFishbones( RimFishbonesCollection* fishbonesCollection, + const RimFishbonesDefines::RicFishbonesSystemParameters& customParameters, + double measuredDepth ) +{ + if ( !fishbonesCollection ) return nullptr; + + RimWellPath* wellPath = fishbonesCollection->firstAncestorOrThisOfTypeAsserted(); + if ( !RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem( wellPath ) ) return nullptr; + + auto* obj = new RimFishbones; + fishbonesCollection->appendFishbonesSubs( obj ); + + obj->setSystemParameters( customParameters.lateralsPerSub, + customParameters.lateralLength, + customParameters.holeDiameter, + customParameters.buildAngle, + customParameters.icdsPerSub ); + + obj->setMeasuredDepthAndCount( measuredDepth, customParameters.spacing, 13 ); + + finalizeFishbonesCreation( obj, fishbonesCollection ); + + return obj; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFishbonesCreateHelper::setupFishbonesSubMenu( QAction* actionToSetup, const QString& actionText ) +{ + auto icon = QIcon( ":/FishBoneGroup16x16.png" ); + actionToSetup->setIcon( icon ); + actionToSetup->setText( actionText ); + + auto subMenu = new QMenu; + + { + auto action = subMenu->addAction( "Drilling Standard" ); + action->setIcon( icon ); + } + + { + auto action = subMenu->addAction( "Drilling Extended" ); + action->setIcon( icon ); + } + { + auto action = subMenu->addAction( "Acid Jetting" ); + action->setIcon( icon ); + } + + actionToSetup->setMenu( subMenu ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFishbonesCreateHelper::finalizeFishbonesCreation( RimFishbones* fishbones, RimFishbonesCollection* fishbonesCollection ) +{ + RicNewFishbonesSubsFeature::adjustWellPathScaling( fishbonesCollection ); + + if ( auto wellPathCollection = RimTools::wellPathCollection() ) + { + wellPathCollection->uiCapability()->updateConnectedEditors(); + } + + Riu3DMainWindowTools::selectAsCurrentItem( fishbones ); + + RimProject* proj = RimProject::current(); + proj->reloadCompletionTypeResultsInAllViews(); +} diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicFishbonesCreateHelper.h b/ApplicationLibCode/Commands/CompletionCommands/RicFishbonesCreateHelper.h new file mode 100644 index 0000000000..3c73e28f85 --- /dev/null +++ b/ApplicationLibCode/Commands/CompletionCommands/RicFishbonesCreateHelper.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2025 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 "RimFishbonesDefines.h" + +class RimFishbones; +class RimFishbonesCollection; +class RimWellPath; +class QAction; +class QMenu; +class QString; + +//================================================================================================== +/// Helper class for common fishbones creation functionality +//================================================================================================== +class RicFishbonesCreateHelper +{ +public: + static RimFishbones* createAndConfigureFishbones( RimFishbonesCollection* fishbonesCollection, + const RimFishbonesDefines::RicFishbonesSystemParameters& customParameters, + double measuredDepth ); + + static void setupFishbonesSubMenu( QAction* actionToSetup, const QString& actionText ); + +private: + static void finalizeFishbonesCreation( RimFishbones* fishbones, RimFishbonesCollection* fishbonesCollection ); +}; diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp b/ApplicationLibCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp index cc43cebee3..93bd2d34e7 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp +++ b/ApplicationLibCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp @@ -18,6 +18,9 @@ #include "RicNewFishbonesSubsAtMeasuredDepthFeature.h" +#include "RiaLogging.h" + +#include "RicFishbonesCreateHelper.h" #include "RicNewFishbonesSubsFeature.h" #include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h" @@ -48,30 +51,20 @@ void RicNewFishbonesSubsAtMeasuredDepthFeature::onActionTriggered( bool isChecke //-------------------------------------------------------------------------------------------------- void RicNewFishbonesSubsAtMeasuredDepthFeature::setupActionLook( QAction* actionToSetup ) { - auto icon = QIcon( ":/FishBoneGroup16x16.png" ); - actionToSetup->setIcon( icon ); - actionToSetup->setText( "Create Fishbones at this Depth" ); + RicFishbonesCreateHelper::setupFishbonesSubMenu( actionToSetup, "Create Fishbones at this Depth" ); - auto subMenu = new QMenu; + QMenu* subMenu = actionToSetup->menu(); + auto actions = subMenu->actions(); + if ( actions.size() < 3 ) { - auto action = subMenu->addAction( "Drilling Standard" ); - action->setIcon( icon ); - connect( action, &QAction::triggered, this, &RicNewFishbonesSubsAtMeasuredDepthFeature::onDrillingStandard ); + RiaLogging::error( "RicNewFishbonesSubsAtMeasuredDepthFeature::setupActionLook: Unexpected number of actions in submenu." ); + return; } - { - auto action = subMenu->addAction( "Drilling Extended" ); - action->setIcon( icon ); - connect( action, &QAction::triggered, this, &RicNewFishbonesSubsAtMeasuredDepthFeature::onDrillingExtended ); - } - { - auto action = subMenu->addAction( "Acid Jetting" ); - action->setIcon( icon ); - connect( action, &QAction::triggered, this, &RicNewFishbonesSubsAtMeasuredDepthFeature::onAcidJetting ); - } - - actionToSetup->setMenu( subMenu ); + connect( actions[0], &QAction::triggered, this, &RicNewFishbonesSubsAtMeasuredDepthFeature::onDrillingStandard ); + connect( actions[1], &QAction::triggered, this, &RicNewFishbonesSubsAtMeasuredDepthFeature::onDrillingExtended ); + connect( actions[2], &QAction::triggered, this, &RicNewFishbonesSubsAtMeasuredDepthFeature::onAcidJetting ); } //-------------------------------------------------------------------------------------------------- @@ -93,26 +86,7 @@ void RicNewFishbonesSubsAtMeasuredDepthFeature::createFishbones( const RimFishbo RimWellPath* wellPath = wellPathSelItem->m_wellpath; CVF_ASSERT( wellPath ); - if ( !RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem( wellPath ) ) return; - - auto* obj = new RimFishbones; - wellPath->fishbonesCollection()->appendFishbonesSubs( obj ); - - obj->setSystemParameters( customParameters.lateralsPerSub, - customParameters.lateralLength, - customParameters.holeDiameter, - customParameters.buildAngle, - customParameters.icdsPerSub ); - - obj->setMeasuredDepthAndCount( wellPathSelItem->m_measuredDepth, 12.5, 13 ); - - RicNewFishbonesSubsFeature::adjustWellPathScaling( wellPath->fishbonesCollection() ); - - wellPath->updateConnectedEditors(); - Riu3DMainWindowTools::selectAsCurrentItem( obj ); - - RimProject* proj = RimProject::current(); - proj->reloadCompletionTypeResultsInAllViews(); + RicFishbonesCreateHelper::createAndConfigureFishbones( wellPath->fishbonesCollection(), customParameters, wellPathSelItem->m_measuredDepth ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp b/ApplicationLibCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp index ecd8e48998..05763db954 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp +++ b/ApplicationLibCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp @@ -18,6 +18,7 @@ #include "RicNewFishbonesSubsFeature.h" +#include "RicFishbonesCreateHelper.h" #include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h" #include "RiaApplication.h" @@ -87,38 +88,17 @@ void RicNewFishbonesSubsFeature::createFishbones( const RimFishbonesDefines::Ric CVF_ASSERT( fishbonesCollection ); RimWellPath* wellPath = fishbonesCollection->firstAncestorOrThisOfTypeAsserted(); - if ( !RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem( wellPath ) ) return; - - auto* obj = new RimFishbones; - fishbonesCollection->appendFishbonesSubs( obj ); - - obj->setSystemParameters( customParameters.lateralsPerSub, - customParameters.lateralLength, - customParameters.holeDiameter, - customParameters.buildAngle, - customParameters.icdsPerSub ); + double measuredDepth = 100; double wellPathTipMd = wellPath->uniqueEndMD(); if ( wellPathTipMd != HUGE_VAL ) { double startMd = wellPathTipMd - 150 - 100; if ( startMd < 100 ) startMd = 100; - - obj->setMeasuredDepthAndCount( startMd, 12.5, 13 ); + measuredDepth = startMd; } - RicNewFishbonesSubsFeature::adjustWellPathScaling( fishbonesCollection ); - - RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection(); - if ( wellPathCollection ) - { - wellPathCollection->uiCapability()->updateConnectedEditors(); - } - - RiuMainWindow::instance()->selectAsCurrentItem( obj ); - - RimProject* proj = RimProject::current(); - proj->reloadCompletionTypeResultsInAllViews(); + RicFishbonesCreateHelper::createAndConfigureFishbones( fishbonesCollection, customParameters, measuredDepth ); } //-------------------------------------------------------------------------------------------------- @@ -161,30 +141,19 @@ RimFishbonesCollection* RicNewFishbonesSubsFeature::selectedFishbonesCollection( //-------------------------------------------------------------------------------------------------- void RicNewFishbonesSubsFeature::setupActionLook( QAction* actionToSetup ) { - auto icon = QIcon( ":/FishBoneGroup16x16.png" ); - actionToSetup->setIcon( icon ); - actionToSetup->setText( "Create Fishbones" ); - - auto subMenu = new QMenu; + RicFishbonesCreateHelper::setupFishbonesSubMenu( actionToSetup, "Create Fishbones" ); + QMenu* subMenu = actionToSetup->menu(); + auto actions = subMenu->actions(); + if ( actions.size() < 3 ) { - auto action = subMenu->addAction( "Drilling Standard" ); - action->setIcon( icon ); - connect( action, &QAction::triggered, this, &RicNewFishbonesSubsFeature::onDrillingStandard ); + RiaLogging::error( "RicNewFishbonesSubsAtMeasuredDepthFeature::setupActionLook: Unexpected number of actions in submenu." ); + return; } - { - auto action = subMenu->addAction( "Drilling Extended" ); - action->setIcon( icon ); - connect( action, &QAction::triggered, this, &RicNewFishbonesSubsFeature::onDrillingExtended ); - } - { - auto action = subMenu->addAction( "Acid Jetting" ); - action->setIcon( icon ); - connect( action, &QAction::triggered, this, &RicNewFishbonesSubsFeature::onAcidJetting ); - } - - actionToSetup->setMenu( subMenu ); + connect( actions[0], &QAction::triggered, this, &RicNewFishbonesSubsFeature::onDrillingStandard ); + connect( actions[1], &QAction::triggered, this, &RicNewFishbonesSubsFeature::onDrillingExtended ); + connect( actions[2], &QAction::triggered, this, &RicNewFishbonesSubsFeature::onAcidJetting ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFishbonesDefines.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFishbonesDefines.cpp index 8f26df57cb..9a74c2cc8d 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFishbonesDefines.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFishbonesDefines.cpp @@ -64,7 +64,7 @@ void caf::AppEnum::setUp() //-------------------------------------------------------------------------------------------------- RimFishbonesDefines::RicFishbonesSystemParameters RimFishbonesDefines::drillingStandardParameters() { - return { .lateralsPerSub = 3, .lateralLength = 11.0, .holeDiameter = 12.5, .buildAngle = 6.0, .icdsPerSub = 3 }; + return { .lateralsPerSub = 3, .lateralLength = 11.0, .holeDiameter = 12.5, .buildAngle = 6.0, .icdsPerSub = 3, .spacing = 12.5 }; } //-------------------------------------------------------------------------------------------------- @@ -72,7 +72,7 @@ RimFishbonesDefines::RicFishbonesSystemParameters RimFishbonesDefines::drillingS //-------------------------------------------------------------------------------------------------- RimFishbonesDefines::RicFishbonesSystemParameters RimFishbonesDefines::drillingExtendedParameters() { - return { .lateralsPerSub = 3, .lateralLength = 18.0, .holeDiameter = 12.5, .buildAngle = 4.0, .icdsPerSub = 3 }; + return { .lateralsPerSub = 3, .lateralLength = 18.0, .holeDiameter = 12.5, .buildAngle = 4.0, .icdsPerSub = 3, .spacing = 18.5 }; } //-------------------------------------------------------------------------------------------------- @@ -80,5 +80,5 @@ RimFishbonesDefines::RicFishbonesSystemParameters RimFishbonesDefines::drillingE //-------------------------------------------------------------------------------------------------- RimFishbonesDefines::RicFishbonesSystemParameters RimFishbonesDefines::acidJettingParameters() { - return { .lateralsPerSub = 4, .lateralLength = 12.0, .holeDiameter = 15.0, .buildAngle = 6.0, .icdsPerSub = 4 }; + return { .lateralsPerSub = 4, .lateralLength = 12.0, .holeDiameter = 15.0, .buildAngle = 6.0, .icdsPerSub = 4, .spacing = 12.5 }; } diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFishbonesDefines.h b/ApplicationLibCode/ProjectDataModel/Completions/RimFishbonesDefines.h index 519b71173f..a2723e8ed6 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFishbonesDefines.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFishbonesDefines.h @@ -54,6 +54,7 @@ struct RicFishbonesSystemParameters double holeDiameter; double buildAngle; int icdsPerSub; + double spacing; }; RicFishbonesSystemParameters drillingStandardParameters();