Skip to content

Commit b57767d

Browse files
authored
Add feature to set parent well
1 parent 7e60a41 commit b57767d

File tree

8 files changed

+238
-4
lines changed

8 files changed

+238
-4
lines changed

ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ set(SOURCE_GROUP_HEADER_FILES
3131
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.h
3232
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.h
3333
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateWellPathFeature.h
34+
${CMAKE_CURRENT_LIST_DIR}/RicSetParentWellPathFeature.h
3435
)
3536

3637
set(SOURCE_GROUP_SOURCE_FILES
@@ -66,6 +67,7 @@ set(SOURCE_GROUP_SOURCE_FILES
6667
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.cpp
6768
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.cpp
6869
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateWellPathFeature.cpp
70+
${CMAKE_CURRENT_LIST_DIR}/RicSetParentWellPathFeature.cpp
6971
)
7072

7173
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/////////////////////////////////////////////////////////////////////////////////
2+
//
3+
// Copyright (C) 2024 Equinor ASA
4+
//
5+
// ResInsight is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
11+
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
// FITNESS FOR A PARTICULAR PURPOSE.
13+
//
14+
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
15+
// for more details.
16+
//
17+
/////////////////////////////////////////////////////////////////////////////////
18+
19+
#include "RicSetParentWellPathFeature.h"
20+
21+
#include "RigWellPath.h"
22+
23+
#include "RimTools.h"
24+
#include "RimWellPath.h"
25+
#include "RimWellPathCollection.h"
26+
#include "RimWellPathTieIn.h"
27+
28+
#include "RiuMainWindow.h"
29+
30+
#include "cafPdmUiPropertyViewDialog.h"
31+
#include "cafSelectionManager.h"
32+
33+
#include <QAction>
34+
35+
CAF_PDM_SOURCE_INIT( RicSelectWellPathUi, "RicSelectWellPathUi" );
36+
37+
//--------------------------------------------------------------------------------------------------
38+
///
39+
//--------------------------------------------------------------------------------------------------
40+
RicSelectWellPathUi::RicSelectWellPathUi()
41+
{
42+
CAF_PDM_InitObject( "RicSelectWellPathUi" );
43+
44+
CAF_PDM_InitFieldNoDefault( &m_selectedWellPath, "SelectedWellPath", "Well Path" );
45+
}
46+
47+
//--------------------------------------------------------------------------------------------------
48+
///
49+
//--------------------------------------------------------------------------------------------------
50+
void RicSelectWellPathUi::setWellPaths( const std::vector<RimWellPath*>& wellPaths )
51+
{
52+
m_wellPaths = wellPaths;
53+
}
54+
55+
//--------------------------------------------------------------------------------------------------
56+
///
57+
//--------------------------------------------------------------------------------------------------
58+
void RicSelectWellPathUi::setSelectedWell( RimWellPath* selectedWell )
59+
{
60+
m_selectedWellPath = selectedWell;
61+
}
62+
63+
//--------------------------------------------------------------------------------------------------
64+
///
65+
//--------------------------------------------------------------------------------------------------
66+
RimWellPath* RicSelectWellPathUi::wellPath() const
67+
{
68+
return m_selectedWellPath();
69+
}
70+
71+
//--------------------------------------------------------------------------------------------------
72+
///
73+
//--------------------------------------------------------------------------------------------------
74+
QList<caf::PdmOptionItemInfo> RicSelectWellPathUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
75+
{
76+
QList<caf::PdmOptionItemInfo> options;
77+
78+
options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) );
79+
80+
RimTools::optionItemsForSpecifiedWellPaths( m_wellPaths, &options );
81+
return options;
82+
}
83+
84+
CAF_CMD_SOURCE_INIT( RicSetParentWellPathFeature, "RicSetParentWellPathFeature" );
85+
86+
//--------------------------------------------------------------------------------------------------
87+
///
88+
//--------------------------------------------------------------------------------------------------
89+
void RicSetParentWellPathFeature::onActionTriggered( bool isChecked )
90+
{
91+
auto selectedWellPath = caf::SelectionManager::instance()->selectedItemOfType<RimWellPath>();
92+
if ( !selectedWellPath ) return;
93+
94+
auto wpc = RimTools::wellPathCollection();
95+
if ( !wpc ) return;
96+
97+
std::vector<RimWellPath*> wellPathCandidates;
98+
for ( auto w : wpc->allWellPaths() )
99+
{
100+
if ( w != selectedWellPath ) wellPathCandidates.push_back( w );
101+
}
102+
103+
RicSelectWellPathUi ui;
104+
ui.setWellPaths( wellPathCandidates );
105+
106+
RimWellPath* parentWell = nullptr;
107+
if ( selectedWellPath->wellPathTieIn() ) parentWell = selectedWellPath->wellPathTieIn()->parentWell();
108+
ui.setSelectedWell( parentWell );
109+
110+
caf::PdmUiPropertyViewDialog propertyDialog( nullptr, &ui, "Select Parent Well", "" );
111+
propertyDialog.resize( QSize( 400, 200 ) );
112+
113+
if ( propertyDialog.exec() == QDialog::Accepted )
114+
{
115+
auto parentWellPath = ui.wellPath();
116+
117+
double tieInMeasuredDepth = 0.0;
118+
if ( parentWellPath )
119+
{
120+
if ( !parentWellPath->wellPathGeometry() || parentWellPath->wellPathGeometry()->measuredDepths().size() < 2 ) return;
121+
if ( selectedWellPath->wellPathGeometry()->wellPathPoints().empty() ) return;
122+
123+
auto headOfLateral = selectedWellPath->wellPathGeometry()->wellPathPoints().front();
124+
125+
cvf::Vec3d p1, p2;
126+
parentWellPath->wellPathGeometry()->twoClosestPoints( headOfLateral, &p1, &p2 );
127+
128+
tieInMeasuredDepth = parentWellPath->wellPathGeometry()->closestMeasuredDepth( p1 );
129+
}
130+
131+
selectedWellPath->connectWellPaths( parentWellPath, tieInMeasuredDepth );
132+
133+
wpc->rebuildWellPathNodes();
134+
wpc->scheduleRedrawAffectedViews();
135+
wpc->updateAllRequiredEditors();
136+
137+
RiuMainWindow::instance()->setExpanded( selectedWellPath );
138+
RiuMainWindow::instance()->selectAsCurrentItem( selectedWellPath );
139+
}
140+
}
141+
142+
//--------------------------------------------------------------------------------------------------
143+
///
144+
//--------------------------------------------------------------------------------------------------
145+
void RicSetParentWellPathFeature::setupActionLook( QAction* actionToSetup )
146+
{
147+
actionToSetup->setText( "Set Parent Well Path" );
148+
actionToSetup->setIcon( QIcon( ":/Well.svg" ) );
149+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/////////////////////////////////////////////////////////////////////////////////
2+
//
3+
// Copyright (C) 2024 Equinor ASA
4+
//
5+
// ResInsight is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
11+
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
// FITNESS FOR A PARTICULAR PURPOSE.
13+
//
14+
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
15+
// for more details.
16+
//
17+
/////////////////////////////////////////////////////////////////////////////////
18+
19+
#pragma once
20+
21+
#include "cafCmdFeature.h"
22+
#include "cafPdmObject.h"
23+
#include "cafPdmPtrField.h"
24+
25+
#include <QList>
26+
27+
#include <vector>
28+
29+
namespace caf
30+
{
31+
class PdmOptionItemInfo;
32+
}
33+
34+
class RimWellPath;
35+
36+
class RicSelectWellPathUi : public caf::PdmObject
37+
{
38+
CAF_PDM_HEADER_INIT;
39+
40+
public:
41+
RicSelectWellPathUi();
42+
43+
void setWellPaths( const std::vector<RimWellPath*>& wellPaths );
44+
void setSelectedWell( RimWellPath* selectedWell );
45+
46+
RimWellPath* wellPath() const;
47+
48+
protected:
49+
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
50+
51+
private:
52+
caf::PdmPtrField<RimWellPath*> m_selectedWellPath;
53+
std::vector<RimWellPath*> m_wellPaths;
54+
};
55+
56+
//==================================================================================================
57+
///
58+
//==================================================================================================
59+
class RicSetParentWellPathFeature : public caf::CmdFeature
60+
{
61+
CAF_CMD_HEADER_INIT;
62+
63+
protected:
64+
void onActionTriggered( bool isChecked ) override;
65+
void setupActionLook( QAction* actionToSetup ) override;
66+
};

ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,11 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
389389
{
390390
menuBuilder << "RicNewEditableWellPathFeature";
391391
menuBuilder << "RicNewWellPathLateralFeature";
392-
menuBuilder << "RicLinkWellPathFeature";
393392
menuBuilder << "RicDuplicateWellPathFeature";
394393

394+
menuBuilder.addSeparator();
395+
menuBuilder << "RicSetParentWellPathFeature";
396+
395397
menuBuilder.addSeparator();
396398
menuBuilder << "RicNewWellPathIntersectionFeature";
397399

@@ -421,6 +423,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
421423
menuBuilder.subMenuEnd();
422424
menuBuilder.addSeparator();
423425

426+
menuBuilder << "RicLinkWellPathFeature";
424427
menuBuilder << "RicDeleteWellPathFeature";
425428

426429
menuBuilder.addSeparator();

ApplicationLibCode/ProjectDataModel/RimTools.h

-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,5 @@ class RimTools
8282

8383
static void timeStepsForCase( RimCase* gridCase, QList<caf::PdmOptionItemInfo>* options );
8484

85-
private:
8685
static void optionItemsForSpecifiedWellPaths( const std::vector<RimWellPath*>& wellPaths, QList<caf::PdmOptionItemInfo>* options );
8786
};

ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class RimWellPath : public caf::PdmObject, public RimWellPathComponentInterface
170170
std::vector<RimWellPath*> wellPathLaterals() const;
171171

172172
RimWellPathTieIn* wellPathTieIn() const;
173-
void connectWellPaths( RimWellPath* childWell, double tieInMeasuredDepth );
173+
void connectWellPaths( RimWellPath* parentWell, double tieInMeasuredDepth );
174174

175175
protected:
176176
// Override PdmObject

ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTieIn.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
#include "RiuMainWindow.h"
3232

33-
#include "RigWellPathGeometryTools.h"
3433
#include "cafPdmUiDoubleSliderEditor.h"
34+
#include "cafPdmUiLabelEditor.h"
3535

3636
CAF_PDM_SOURCE_INIT( RimWellPathTieIn, "RimWellPathTieIn" );
3737

@@ -42,7 +42,14 @@ RimWellPathTieIn::RimWellPathTieIn()
4242
{
4343
CAF_PDM_InitObject( "Well Path Tie In", ":/NotDefined.png", "", "Well Path Tie In description" );
4444

45+
CAF_PDM_InitFieldNoDefault( &m_infoLabel, "InfoLabel", "Use right-click menu of well to set parent well." );
46+
m_infoLabel.uiCapability()->setUiEditorTypeName( caf::PdmUiLabelEditor::uiEditorTypeName() );
47+
m_infoLabel.xmlCapability()->disableIO();
48+
m_infoLabel.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
49+
4550
CAF_PDM_InitFieldNoDefault( &m_parentWell, "ParentWellPath", "Parent Well Path" );
51+
m_parentWell.uiCapability()->setUiReadOnly( true );
52+
4653
CAF_PDM_InitFieldNoDefault( &m_childWell, "ChildWellPath", "ChildWellPath" );
4754
CAF_PDM_InitFieldNoDefault( &m_tieInMeasuredDepth, "TieInMeasuredDepth", "Tie In Measured Depth" );
4855
m_tieInMeasuredDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
@@ -161,6 +168,7 @@ const RimWellPathValve* RimWellPathTieIn::outletValve() const
161168
void RimWellPathTieIn::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
162169
{
163170
auto tieInGroup = uiOrdering.addNewGroup( "Tie In Settings" );
171+
tieInGroup->add( &m_infoLabel );
164172
tieInGroup->add( &m_parentWell );
165173
if ( m_parentWell() != nullptr )
166174
{
@@ -187,6 +195,11 @@ void RimWellPathTieIn::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
187195
//--------------------------------------------------------------------------------------------------
188196
void RimWellPathTieIn::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
189197
{
198+
// TODO: It is not possible to change the parent well from the UI as the field is set to read only. Refactor and possibly delete this
199+
// method.
200+
// https://github.com/OPM/ResInsight/issues/11312
201+
// https://github.com/OPM/ResInsight/issues/11313
202+
190203
if ( changedField == &m_parentWell )
191204
{
192205
updateFirstTargetFromParentWell();

ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTieIn.h

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class RimWellPathTieIn : public caf::PdmObject
5555
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
5656

5757
private:
58+
caf::PdmField<QString> m_infoLabel;
59+
5860
caf::PdmPtrField<RimWellPath*> m_parentWell;
5961
caf::PdmPtrField<RimWellPath*> m_childWell;
6062
caf::PdmField<double> m_tieInMeasuredDepth;

0 commit comments

Comments
 (0)