From 610a315e14f8c4cdd7bddd79a6d070a8aabe2dab Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 6 Feb 2020 16:18:50 +0100 Subject: [PATCH] #5458 Add support for air gap and start at surface for modeled well paths --- .../RicExportSelectedWellPathsFeature.cpp | 9 +- .../ProjectDataModel/RimWellPath.cpp | 44 +++++++-- .../ProjectDataModel/RimWellPath.h | 9 +- .../RimWellPathGeometryDef.cpp | 96 ++++++++++++++----- .../ProjectDataModel/RimWellPathGeometryDef.h | 12 ++- 5 files changed, 130 insertions(+), 40 deletions(-) diff --git a/ApplicationCode/Commands/ExportCommands/RicExportSelectedWellPathsFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportSelectedWellPathsFeature.cpp index 60e0a3ddee..1745a196d0 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportSelectedWellPathsFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportSelectedWellPathsFeature.cpp @@ -80,7 +80,14 @@ void RicExportSelectedWellPathsFeature::writeWellPathGeometryToStream( QTextStre if ( modeledWellPath ) { useMdRkb = true; - rkb = modeledWellPath->geometryDefinition()->mdrkbAtFirstTarget(); + if ( modeledWellPath->geometryDefinition()->airGap() != 0.0 ) + { + rkb = modeledWellPath->geometryDefinition()->airGap(); + } + else + { + rkb = modeledWellPath->geometryDefinition()->mdrkbAtFirstTarget(); + } } } diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index 5293359909..fe20a33451 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -80,9 +80,13 @@ RimWellPath::RimWellPath() m_name.uiCapability()->setUiHidden( true ); m_name.xmlCapability()->disableIO(); + CAF_PDM_InitFieldNoDefault( &m_airGap, "AirGap", "Air Gap", "", "", "" ); + m_airGap.registerGetMethod( this, &RimWellPath::airGap ); + m_airGap.uiCapability()->setUiReadOnly( true ); + CAF_PDM_InitFieldNoDefault( &m_datumElevation, "DatumElevation", "Datum Elevation", "", "", "" ); + m_datumElevation.registerGetMethod( this, &RimWellPath::datumElevation ); m_datumElevation.uiCapability()->setUiReadOnly( true ); - m_datumElevation.xmlCapability()->disableIO(); CAF_PDM_InitFieldNoDefault( &m_unitSystem, "UnitSystem", "Unit System", "", "", "" ); m_unitSystem.uiCapability()->setUiReadOnly( true ); @@ -565,18 +569,16 @@ void RimWellPath::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& ui caf::PdmUiGroup* ssihubGroup = uiOrdering.addNewGroup( "Well Info" ); - ssihubGroup->add( &m_datumElevation ); - ssihubGroup->add( &m_unitSystem ); + if ( m_wellPath.notNull() && m_wellPath->rkbDiff() > 0.0 ) + { + ssihubGroup->add( &m_airGap ); + } if ( m_wellPath.notNull() && m_wellPath->hasDatumElevation() ) { - m_datumElevation = m_wellPath->datumElevation(); - m_datumElevation.uiCapability()->setUiHidden( false ); - } - else - { - m_datumElevation.uiCapability()->setUiHidden( true ); + ssihubGroup->add( &m_datumElevation ); } + ssihubGroup->add( &m_unitSystem ); caf::PdmUiGroup* formationFileInfoGroup = uiOrdering.addNewGroup( "Well Picks" ); formationFileInfoGroup->add( &m_wellPathFormationFilePath ); @@ -672,6 +674,30 @@ RiaEclipseUnitTools::UnitSystem RimWellPath::unitSystem() const return m_unitSystem(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimWellPath::airGap() const +{ + if ( m_wellPath.notNull() && m_wellPath->rkbDiff() > 0.0 ) + { + return m_wellPath->rkbDiff(); + } + return 0.0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimWellPath::datumElevation() const +{ + if ( m_wellPath.notNull() && m_wellPath->hasDatumElevation() ) + { + return m_wellPath->datumElevation(); + } + return 0.0; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index 0694a60724..0ccf5f039f 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -30,6 +30,7 @@ #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmPointer.h" +#include "cafPdmProxyValueField.h" // Include to make Pdm work for cvf::Color #include "cafPdmFieldCvfColor.h" @@ -84,6 +85,9 @@ public: void setUnitSystem( RiaEclipseUnitTools::UnitSystem unitSystem ); RiaEclipseUnitTools::UnitSystem unitSystem() const; + double airGap() const; + double datumElevation() const; + RigWellPath* wellPathGeometry(); const RigWellPath* wellPathGeometry() const; @@ -150,8 +154,9 @@ protected: // Fields protected: - caf::PdmField m_datumElevation; - caf::PdmField m_name; + caf::PdmProxyValueField m_airGap; + caf::PdmProxyValueField m_datumElevation; + caf::PdmField m_name; private: caf::PdmField m_simWellName; diff --git a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp index d03de33f6e..8d9b35fe09 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp @@ -36,6 +36,7 @@ #include "RiuViewerCommands.h" #include "cafCmdFeatureMenuBuilder.h" +#include "cafPdmUiDoubleValueEditor.h" #include "cafPdmUiLineEditor.h" #include "cafPdmUiPushButtonEditor.h" #include "cafPdmUiTableViewEditor.h" @@ -52,7 +53,7 @@ void caf::AppEnum::setUp() addItem( RimWellPathGeometryDef::START_FROM_OTHER_WELL, "START_FROM_OTHER_WELL", "Branch" ); addItem( RimWellPathGeometryDef::START_AT_AUTO_SURFACE, "START_AT_AUTO_SURFACE", "Auto Surface" ); - setDefault( RimWellPathGeometryDef::START_AT_FIRST_TARGET ); + setDefault( RimWellPathGeometryDef::START_AT_SURFACE ); } } // namespace caf @@ -75,8 +76,9 @@ RimWellPathGeometryDef::RimWellPathGeometryDef() "", "" ); - CAF_PDM_InitField( &m_mdrkbAtFirstTarget, "MdrkbAtFirstTarget", 0.0, "MDRKB at First Target", "", "", "" ); - + CAF_PDM_InitField( &m_airGap, "AirGap", 0.0, "Air Gap", "", "", "" ); + m_airGap.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); + CAF_PDM_InitField( &m_mdAtFirstTarget, "MdAtFirstTarget", 0.0, "MD at First Target", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_wellTargets, "WellPathTargets", "Well Targets", "", "", "" ); m_wellTargets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); // m_wellTargets.uiCapability()->setUiTreeHidden(true); @@ -97,14 +99,12 @@ RimWellPathGeometryDef::RimWellPathGeometryDef() "" ); RiaFieldhandleTools::disableWriteAndSetFieldHidden( &m_referencePointXyz_OBSOLETE ); - /// To be removed ? - CAF_PDM_InitFieldNoDefault( &m_wellStartType, "WellStartType", "Start Type", "", "", "" ); m_wellStartType.xmlCapability()->disableIO(); + + /// To be removed ? CAF_PDM_InitFieldNoDefault( &m_parentWell, "ParentWell", "Parent Well", "", "", "" ); m_parentWell.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_kickoffDepthOrMD, "KickoffDepthOrMD", 100.0, "Kickoff Depth", "", "", "" ); - m_kickoffDepthOrMD.xmlCapability()->disableIO(); } //-------------------------------------------------------------------------------------------------- @@ -132,12 +132,28 @@ void RimWellPathGeometryDef::setReferencePointXyz( const cvf::Vec3d& refPointXyz m_referencePointUtmXyd = xyd; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimWellPathGeometryDef::airGap() const +{ + return m_airGap; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathGeometryDef::setAirGap( double airGap ) +{ + m_airGap = airGap; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- double RimWellPathGeometryDef::mdrkbAtFirstTarget() const { - return m_mdrkbAtFirstTarget; + return m_mdAtFirstTarget; } //-------------------------------------------------------------------------------------------------- @@ -145,7 +161,7 @@ double RimWellPathGeometryDef::mdrkbAtFirstTarget() const //-------------------------------------------------------------------------------------------------- void RimWellPathGeometryDef::setMdrkbAtFirstTarget( double mdrkb ) { - m_mdrkbAtFirstTarget = mdrkb; + m_mdAtFirstTarget = mdrkb; } //-------------------------------------------------------------------------------------------------- @@ -166,6 +182,37 @@ cvf::ref RimWellPathGeometryDef::createWellPathGeometry() &( wellPathGeometry->m_wellPathPoints ), &( wellPathGeometry->m_measuredDepths ) ); + if ( m_airGap != 0.0 ) + { + wellPathGeometry->setDatumElevation( m_airGap ); + } + + if ( m_wellStartType == START_AT_SURFACE && !wellPathGeometry->m_wellPathPoints.empty() ) + { + cvf::Vec3d mslPoint = wellPathGeometry->m_wellPathPoints.front(); + mslPoint.z() = 0.0; + double depthDiff = mslPoint.z() - wellPathGeometry->m_wellPathPoints.front().z(); + if ( std::abs( depthDiff ) > 1.0e-8 ) + { + CAF_ASSERT( wellPathGeometry->m_wellPathPoints.size() == wellPathGeometry->m_measuredDepths.size() ); + + std::vector newPoints; + newPoints.reserve( wellPathGeometry->m_wellPathPoints.size() + 1 ); + std::vector newMds; + newMds.reserve( wellPathGeometry->m_measuredDepths.size() + 1 ); + + newPoints.push_back( mslPoint ); + newMds.push_back( 0.0 ); + for ( size_t i = 0; i < wellPathGeometry->m_wellPathPoints.size(); ++i ) + { + newPoints.push_back( wellPathGeometry->m_wellPathPoints[i] ); + newMds.push_back( wellPathGeometry->m_measuredDepths[i] + depthDiff ); + } + wellPathGeometry->m_wellPathPoints.swap( newPoints ); + wellPathGeometry->m_measuredDepths.swap( newMds ); + } + } + return wellPathGeometry; } //-------------------------------------------------------------------------------------------------- @@ -312,6 +359,8 @@ QList if ( fieldNeedingOptions == &m_wellStartType ) { + options.push_back( caf::PdmOptionItemInfo( "Start at Surface", RimWellPathGeometryDef::START_AT_SURFACE ) ); + options.push_back( caf::PdmOptionItemInfo( "Start at First Target", RimWellPathGeometryDef::START_AT_FIRST_TARGET ) ); } @@ -344,21 +393,12 @@ void RimWellPathGeometryDef::fieldChangedByUi( const caf::PdmFieldHandle* change void RimWellPathGeometryDef::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { uiOrdering.add( &m_wellStartType ); - if ( m_wellStartType == START_FROM_OTHER_WELL ) - { - uiOrdering.add( &m_parentWell ); - m_kickoffDepthOrMD.uiCapability()->setUiName( "Measured Depth" ); - uiOrdering.add( &m_kickoffDepthOrMD ); - } - - if ( m_wellStartType == START_AT_SURFACE ) - { - m_kickoffDepthOrMD.uiCapability()->setUiName( "Kick-Off Depth" ); - uiOrdering.add( &m_kickoffDepthOrMD ); - } - uiOrdering.add( &m_referencePointUtmXyd ); - uiOrdering.add( &m_mdrkbAtFirstTarget ); + uiOrdering.add( &m_airGap ); + if ( m_wellStartType == START_AT_FIRST_TARGET ) + { + uiOrdering.add( &m_mdAtFirstTarget ); + } uiOrdering.add( &m_wellTargets ); uiOrdering.add( &m_pickPointsEnabled ); uiOrdering.skipRemainingFields( true ); @@ -500,6 +540,16 @@ void RimWellPathGeometryDef::defineEditorAttribute( const caf::PdmFieldHandle* f QString::number( m_referencePointUtmXyd()[2], 'f', 2 ); } } + + if ( field == &m_airGap ) + { + auto uiDoubleValueEditorAttr = dynamic_cast( attribute ); + if ( uiDoubleValueEditorAttr ) + { + uiDoubleValueEditorAttr->m_decimals = 2; + uiDoubleValueEditorAttr->m_validator = new QDoubleValidator( 0.0, std::numeric_limits::max(), 2 ); + } + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.h b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.h index 20c0bc66ad..360af87958 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.h +++ b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.h @@ -52,6 +52,8 @@ public: cvf::Vec3d referencePointXyz() const; void setReferencePointXyz( const cvf::Vec3d& refPointXyz ); + double airGap() const; + void setAirGap( double airGap ); double mdrkbAtFirstTarget() const; void setMdrkbAtFirstTarget( double mdrkb ); @@ -100,16 +102,16 @@ private: caf::PdmField m_referencePointUtmXyd; caf::PdmField m_referencePointXyz_OBSOLETE; - caf::PdmField m_mdrkbAtFirstTarget; + caf::PdmField m_airGap; + + caf::PdmField m_mdAtFirstTarget; caf::PdmChildArrayField m_wellTargets; caf::PdmField m_pickPointsEnabled; - // TODO: Unused for now. Remove when dust settles - caf::PdmField> m_wellStartType; - caf::PdmField m_kickoffDepthOrMD; - caf::PdmPtrField m_parentWell; + // TODO: Unused for now. Remove when dust settles + caf::PdmPtrField m_parentWell; std::shared_ptr m_pickTargetsEventHandler; };