Add feature to set parent well

This commit is contained in:
Magne Sjaastad authored and GitHub committed 2024-03-25 10:19:31 +01:00
1 parent 7e60a4185b
commit b57767d895
8 files changed
+238 -4

No files matched your search

@@ -31,6 +31,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.h
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.h
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateWellPathFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicSetParentWellPathFeature.h
)
set(SOURCE_GROUP_SOURCE_FILES
@@ -66,6 +67,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.cpp
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateWellPathFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSetParentWellPathFeature.cpp
)
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
@@ -0,0 +1,149 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicSetParentWellPathFeature.h"
#include "RigWellPath.h"
#include "RimTools.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RimWellPathTieIn.h"
#include "RiuMainWindow.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_PDM_SOURCE_INIT( RicSelectWellPathUi, "RicSelectWellPathUi" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSelectWellPathUi::RicSelectWellPathUi()
{
CAF_PDM_InitObject( "RicSelectWellPathUi" );
CAF_PDM_InitFieldNoDefault( &m_selectedWellPath, "SelectedWellPath", "Well Path" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSelectWellPathUi::setWellPaths( const std::vector<RimWellPath*>& wellPaths )
{
m_wellPaths = wellPaths;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSelectWellPathUi::setSelectedWell( RimWellPath* selectedWell )
{
m_selectedWellPath = selectedWell;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPath* RicSelectWellPathUi::wellPath() const
{
return m_selectedWellPath();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RicSelectWellPathUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
QList<caf::PdmOptionItemInfo> options;
options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) );
RimTools::optionItemsForSpecifiedWellPaths( m_wellPaths, &options );
return options;
}
CAF_CMD_SOURCE_INIT( RicSetParentWellPathFeature, "RicSetParentWellPathFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSetParentWellPathFeature::onActionTriggered( bool isChecked )
{
auto selectedWellPath = caf::SelectionManager::instance()->selectedItemOfType<RimWellPath>();
if ( !selectedWellPath ) return;
auto wpc = RimTools::wellPathCollection();
if ( !wpc ) return;
std::vector<RimWellPath*> wellPathCandidates;
for ( auto w : wpc->allWellPaths() )
{
if ( w != selectedWellPath ) wellPathCandidates.push_back( w );
}
RicSelectWellPathUi ui;
ui.setWellPaths( wellPathCandidates );
RimWellPath* parentWell = nullptr;
if ( selectedWellPath->wellPathTieIn() ) parentWell = selectedWellPath->wellPathTieIn()->parentWell();
ui.setSelectedWell( parentWell );
caf::PdmUiPropertyViewDialog propertyDialog( nullptr, &ui, "Select Parent Well", "" );
propertyDialog.resize( QSize( 400, 200 ) );
if ( propertyDialog.exec() == QDialog::Accepted )
{
auto parentWellPath = ui.wellPath();
double tieInMeasuredDepth = 0.0;
if ( parentWellPath )
{
if ( !parentWellPath->wellPathGeometry() || parentWellPath->wellPathGeometry()->measuredDepths().size() < 2 ) return;
if ( selectedWellPath->wellPathGeometry()->wellPathPoints().empty() ) return;
auto headOfLateral = selectedWellPath->wellPathGeometry()->wellPathPoints().front();
cvf::Vec3d p1, p2;
parentWellPath->wellPathGeometry()->twoClosestPoints( headOfLateral, &p1, &p2 );
tieInMeasuredDepth = parentWellPath->wellPathGeometry()->closestMeasuredDepth( p1 );
}
selectedWellPath->connectWellPaths( parentWellPath, tieInMeasuredDepth );
wpc->rebuildWellPathNodes();
wpc->scheduleRedrawAffectedViews();
wpc->updateAllRequiredEditors();
RiuMainWindow::instance()->setExpanded( selectedWellPath );
RiuMainWindow::instance()->selectAsCurrentItem( selectedWellPath );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSetParentWellPathFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Set Parent Well Path" );
actionToSetup->setIcon( QIcon( ":/Well.svg" ) );
}
@@ -0,0 +1,66 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include <QList>
#include <vector>
namespace caf
{
class PdmOptionItemInfo;
}
class RimWellPath;
class RicSelectWellPathUi : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RicSelectWellPathUi();
void setWellPaths( const std::vector<RimWellPath*>& wellPaths );
void setSelectedWell( RimWellPath* selectedWell );
RimWellPath* wellPath() const;
protected:
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
private:
caf::PdmPtrField<RimWellPath*> m_selectedWellPath;
std::vector<RimWellPath*> m_wellPaths;
};
//==================================================================================================
///
//==================================================================================================
class RicSetParentWellPathFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};