2018-07-03 01:42:31 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2019-01-09 08:21:38 -06:00
|
|
|
// Copyright (C) 2018- Equinor ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2018-07-03 01:42:31 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2018-07-03 01:42:31 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2018-07-03 01:42:31 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
2019-11-19 01:50:03 -06:00
|
|
|
|
2018-07-03 01:42:31 -05:00
|
|
|
#include "RimWellPathGeometryDef.h"
|
|
|
|
|
2019-11-19 01:50:03 -06:00
|
|
|
#include "WellPathCommands/PointTangentManipulator/RicWellPathGeometry3dEditor.h"
|
2018-11-05 07:28:07 -06:00
|
|
|
#include "WellPathCommands/RicCreateWellTargetsPickEventHandler.h"
|
2018-07-03 01:42:31 -05:00
|
|
|
|
2020-02-11 01:21:13 -06:00
|
|
|
#include "RiaApplication.h"
|
2018-11-05 07:28:07 -06:00
|
|
|
#include "RiaFieldHandleTools.h"
|
|
|
|
#include "RiaJCurveCalculator.h"
|
|
|
|
#include "RiaLogging.h"
|
2018-09-11 01:36:14 -05:00
|
|
|
#include "RiaOffshoreSphericalCoords.h"
|
2018-11-05 07:28:07 -06:00
|
|
|
#include "RiaPolyArcLineSampler.h"
|
|
|
|
#include "RiaSCurveCalculator.h"
|
|
|
|
|
|
|
|
#include "RigWellPath.h"
|
2018-09-11 01:36:14 -05:00
|
|
|
|
2018-07-03 01:42:31 -05:00
|
|
|
#include "RimModeledWellPath.h"
|
2020-02-11 01:21:13 -06:00
|
|
|
#include "RimProject.h"
|
2018-11-05 07:28:07 -06:00
|
|
|
#include "RimWellPathTarget.h"
|
2018-08-29 09:03:31 -05:00
|
|
|
|
|
|
|
#include "RiuViewerCommands.h"
|
2018-11-05 07:28:07 -06:00
|
|
|
|
|
|
|
#include "cafCmdFeatureMenuBuilder.h"
|
2020-02-06 09:18:50 -06:00
|
|
|
#include "cafPdmUiDoubleValueEditor.h"
|
2019-11-18 02:42:09 -06:00
|
|
|
#include "cafPdmUiLineEditor.h"
|
2018-11-05 07:28:07 -06:00
|
|
|
#include "cafPdmUiPushButtonEditor.h"
|
|
|
|
#include "cafPdmUiTableViewEditor.h"
|
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
2018-09-11 01:36:14 -05:00
|
|
|
#include "cvfGeometryTools.h"
|
2018-11-05 07:28:07 -06:00
|
|
|
|
2018-07-03 01:42:31 -05:00
|
|
|
namespace caf
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
template <>
|
|
|
|
void caf::AppEnum<RimWellPathGeometryDef::WellStartType>::setUp()
|
2018-07-03 01:42:31 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
addItem( RimWellPathGeometryDef::START_AT_FIRST_TARGET, "START_AT_FIRST_TARGET", "Start at First Target" );
|
|
|
|
addItem( RimWellPathGeometryDef::START_AT_SURFACE, "START_AT_SURFACE", "Start at Surface" );
|
2018-07-03 01:42:31 -05:00
|
|
|
|
2020-02-06 09:18:50 -06:00
|
|
|
setDefault( RimWellPathGeometryDef::START_AT_SURFACE );
|
2018-07-03 01:42:31 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
} // namespace caf
|
2018-07-03 01:42:31 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_SOURCE_INIT( RimWellPathGeometryDef, "WellPathGeometryDef" );
|
2018-07-03 01:42:31 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-07-03 01:42:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellPathGeometryDef::RimWellPathGeometryDef()
|
2019-09-06 03:40:57 -05:00
|
|
|
: m_pickTargetsEventHandler( new RicCreateWellTargetsPickEventHandler( this ) )
|
2018-07-03 01:42:31 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_InitObject( "Well Targets", ":/WellTargets.png", "", "" );
|
|
|
|
|
|
|
|
this->setUi3dEditorTypeName( RicWellPathGeometry3dEditor::uiEditorTypeName() );
|
2020-02-12 04:43:15 -06:00
|
|
|
CAF_PDM_InitField( &m_referencePointUtmXyd, "ReferencePosUtmXyd", cvf::Vec3d( 0, 0, 0 ), "UTM Reference Point", "", "", "" );
|
2019-09-06 03:40:57 -05:00
|
|
|
|
2020-02-06 09:18:50 -06:00
|
|
|
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", "", "", "" );
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_wellTargets, "WellPathTargets", "Well Targets", "", "", "" );
|
|
|
|
m_wellTargets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() );
|
|
|
|
m_wellTargets.uiCapability()->setUiTreeChildrenHidden( true );
|
|
|
|
m_wellTargets.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
|
|
|
|
m_wellTargets.uiCapability()->setCustomContextMenuEnabled( true );
|
|
|
|
|
|
|
|
CAF_PDM_InitField( &m_pickPointsEnabled, "m_pickPointsEnabled", false, "", "", "", "" );
|
|
|
|
caf::PdmUiPushButtonEditor::configureEditorForField( &m_pickPointsEnabled );
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_wellStartType, "WellStartType", "Start Type", "", "", "" );
|
2018-07-03 01:42:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-07-03 01:42:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:13:38 -06:00
|
|
|
RimWellPathGeometryDef::~RimWellPathGeometryDef()
|
|
|
|
{
|
|
|
|
}
|
2018-07-03 01:42:31 -05:00
|
|
|
|
2018-09-11 02:31:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-09-11 02:31:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::Vec3d RimWellPathGeometryDef::referencePointXyz() const
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::Vec3d xyz( m_referencePointUtmXyd() );
|
|
|
|
xyz.z() = -xyz.z();
|
2018-09-11 02:31:50 -05:00
|
|
|
return xyz;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-09-11 02:31:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimWellPathGeometryDef::setReferencePointXyz( const cvf::Vec3d& refPointXyz )
|
2018-09-11 02:31:50 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::Vec3d xyd( refPointXyz );
|
|
|
|
xyd.z() = -xyd.z();
|
2018-09-11 02:31:50 -05:00
|
|
|
m_referencePointUtmXyd = xyd;
|
|
|
|
}
|
|
|
|
|
2020-02-06 09:18:50 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
double RimWellPathGeometryDef::airGap() const
|
|
|
|
{
|
|
|
|
return m_airGap;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPathGeometryDef::setAirGap( double airGap )
|
|
|
|
{
|
|
|
|
m_airGap = airGap;
|
|
|
|
}
|
|
|
|
|
2018-10-31 08:55:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
double RimWellPathGeometryDef::mdrkbAtFirstTarget() const
|
|
|
|
{
|
2020-02-06 09:18:50 -06:00
|
|
|
return m_mdAtFirstTarget;
|
2018-10-31 08:55:27 -05:00
|
|
|
}
|
|
|
|
|
2018-11-16 04:35:13 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-11-16 04:35:13 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimWellPathGeometryDef::setMdrkbAtFirstTarget( double mdrkb )
|
2018-11-16 04:35:13 -06:00
|
|
|
{
|
2020-02-06 09:18:50 -06:00
|
|
|
m_mdAtFirstTarget = mdrkb;
|
2018-11-16 04:35:13 -06:00
|
|
|
}
|
|
|
|
|
2018-07-03 01:42:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-07-03 01:42:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::ref<RigWellPath> RimWellPathGeometryDef::createWellPathGeometry()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::ref<RigWellPath> wellPathGeometry = new RigWellPath;
|
2018-09-28 07:06:56 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaLineArcWellPathCalculator wellPathCalculator = lineArcWellPathCalculator();
|
2018-09-28 07:06:56 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( wellPathCalculator.lineArcEndpoints().size() < 2 ) return wellPathGeometry;
|
2018-07-03 01:42:31 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaPolyArcLineSampler arcLineSampler( wellPathCalculator.startTangent(), wellPathCalculator.lineArcEndpoints() );
|
2018-07-03 01:42:31 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
arcLineSampler.sampledPointsAndMDs( 30,
|
|
|
|
false,
|
|
|
|
&( wellPathGeometry->m_wellPathPoints ),
|
|
|
|
&( wellPathGeometry->m_measuredDepths ) );
|
2018-07-03 01:42:31 -05:00
|
|
|
|
2020-02-06 09:18:50 -06:00
|
|
|
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<cvf::Vec3d> newPoints;
|
|
|
|
newPoints.reserve( wellPathGeometry->m_wellPathPoints.size() + 1 );
|
|
|
|
std::vector<double> 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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-03 01:42:31 -05:00
|
|
|
return wellPathGeometry;
|
|
|
|
}
|
2018-09-26 05:38:53 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-09-26 05:38:53 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<RiaWellPlanCalculator::WellPlanSegment> RimWellPathGeometryDef::wellPlan() const
|
|
|
|
{
|
2018-09-28 07:06:56 -05:00
|
|
|
RiaLineArcWellPathCalculator wellPathCalculator = lineArcWellPathCalculator();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaWellPlanCalculator wpCalc( wellPathCalculator.startTangent(), wellPathCalculator.lineArcEndpoints() );
|
2018-09-28 07:06:56 -05:00
|
|
|
|
2018-09-26 05:38:53 -05:00
|
|
|
return wpCalc.wellPlan();
|
|
|
|
}
|
2018-07-03 01:42:31 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-07-03 01:42:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPathGeometryDef::updateWellPathVisualization()
|
|
|
|
{
|
|
|
|
RimModeledWellPath* modWellPath;
|
2019-09-06 03:40:57 -05:00
|
|
|
this->firstAncestorOrThisOfTypeAsserted( modWellPath );
|
2018-07-03 01:42:31 -05:00
|
|
|
modWellPath->updateWellPathVisualization();
|
|
|
|
}
|
|
|
|
|
2018-10-02 08:55:28 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-10-02 08:55:28 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
std::pair<RimWellPathTarget*, RimWellPathTarget*>
|
|
|
|
RimWellPathGeometryDef::findActiveTargetsAroundInsertionPoint( const RimWellPathTarget* targetToInsertBefore )
|
2018-10-02 08:55:28 -05:00
|
|
|
{
|
|
|
|
RimWellPathTarget* before = nullptr;
|
|
|
|
RimWellPathTarget* after = nullptr;
|
|
|
|
|
|
|
|
bool foundTarget = false;
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( const auto& wt : m_wellTargets )
|
2018-10-02 08:55:28 -05:00
|
|
|
{
|
|
|
|
if ( wt == targetToInsertBefore )
|
|
|
|
{
|
|
|
|
foundTarget = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( wt->isEnabled() && !after && foundTarget ) after = wt;
|
|
|
|
|
|
|
|
if ( wt->isEnabled() && !foundTarget ) before = wt;
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
return {before, after};
|
2018-10-02 08:55:28 -05:00
|
|
|
}
|
|
|
|
|
2018-07-03 01:42:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-07-03 01:42:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:43:15 -06:00
|
|
|
void RimWellPathGeometryDef::insertTarget( const RimWellPathTarget* targetToInsertBefore, RimWellPathTarget* targetToInsert )
|
2018-07-03 01:42:31 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
size_t index = m_wellTargets.index( targetToInsertBefore );
|
|
|
|
if ( index < m_wellTargets.size() )
|
|
|
|
m_wellTargets.insert( index, targetToInsert );
|
|
|
|
else
|
|
|
|
m_wellTargets.push_back( targetToInsert );
|
2018-07-03 01:42:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-07-03 01:42:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimWellPathGeometryDef::deleteTarget( RimWellPathTarget* targetTodelete )
|
2018-07-03 01:42:31 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_wellTargets.removeChildObject( targetTodelete );
|
2018-07-03 01:42:31 -05:00
|
|
|
delete targetTodelete;
|
|
|
|
}
|
|
|
|
|
2018-07-31 04:44:15 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-08-06 00:52:02 -05:00
|
|
|
///
|
2018-07-31 04:44:15 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPathGeometryDef::appendTarget()
|
|
|
|
{
|
|
|
|
RimWellPathTarget* wellPathTarget = nullptr;
|
2019-09-06 03:40:57 -05:00
|
|
|
|
2018-07-31 04:44:15 -05:00
|
|
|
auto targets = m_wellTargets.childObjects();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( targets.empty() )
|
2018-07-31 04:44:15 -05:00
|
|
|
{
|
|
|
|
wellPathTarget = new RimWellPathTarget;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
wellPathTarget = dynamic_cast<RimWellPathTarget*>(
|
|
|
|
targets.back()->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
2018-07-31 04:44:15 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
|
|
|
|
if ( wellPathTarget )
|
2018-07-31 04:44:15 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_wellTargets.push_back( wellPathTarget );
|
2018-07-31 04:44:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-14 07:23:55 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-08-14 07:23:55 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
const RimWellPathTarget* RimWellPathGeometryDef::firstActiveTarget() const
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( const RimWellPathTarget* target : m_wellTargets )
|
2018-08-14 07:23:55 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( target->isEnabled() )
|
2018-08-14 07:23:55 -05:00
|
|
|
{
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-08-14 07:23:55 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
const RimWellPathTarget* RimWellPathGeometryDef::lastActiveTarget() const
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !m_wellTargets.size() ) return nullptr;
|
2018-08-14 07:23:55 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( int tIdx = static_cast<int>( m_wellTargets.size() - 1 ); tIdx >= 0; --tIdx )
|
2018-08-14 07:23:55 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_wellTargets[tIdx]->isEnabled() )
|
2018-08-14 07:23:55 -05:00
|
|
|
{
|
|
|
|
return m_wellTargets[tIdx];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-08-29 09:03:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-08-29 09:03:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimWellPathGeometryDef::enableTargetPointPicking( bool isEnabling )
|
2018-08-29 09:03:31 -05:00
|
|
|
{
|
2019-02-11 06:46:48 -06:00
|
|
|
m_pickPointsEnabled = isEnabling;
|
|
|
|
this->updateConnectedEditors();
|
2018-08-29 09:03:31 -05:00
|
|
|
}
|
|
|
|
|
2018-07-04 09:49:04 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-07-04 09:49:04 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
QList<caf::PdmOptionItemInfo>
|
|
|
|
RimWellPathGeometryDef::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
|
2018-07-04 09:49:04 -05:00
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> options;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( fieldNeedingOptions == &m_wellStartType )
|
2018-07-04 09:49:04 -05:00
|
|
|
{
|
2020-02-06 09:18:50 -06:00
|
|
|
options.push_back( caf::PdmOptionItemInfo( "Start at Surface", RimWellPathGeometryDef::START_AT_SURFACE ) );
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
options.push_back(
|
|
|
|
caf::PdmOptionItemInfo( "Start at First Target", RimWellPathGeometryDef::START_AT_FIRST_TARGET ) );
|
2018-07-04 09:49:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
2018-07-03 01:42:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-07-03 01:42:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimWellPathGeometryDef::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
|
|
|
const QVariant& oldValue,
|
|
|
|
const QVariant& newValue )
|
2018-07-03 01:42:31 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( &m_referencePointUtmXyd == changedField )
|
2018-07-03 01:42:31 -05:00
|
|
|
{
|
|
|
|
std::cout << "fieldChanged" << std::endl;
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( changedField == &m_pickPointsEnabled )
|
2018-08-29 09:03:31 -05:00
|
|
|
{
|
2019-02-11 06:46:48 -06:00
|
|
|
this->updateConnectedEditors();
|
2018-08-29 09:03:31 -05:00
|
|
|
}
|
2018-07-03 01:42:31 -05:00
|
|
|
|
|
|
|
updateWellPathVisualization();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-07-03 01:42:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimWellPathGeometryDef::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
2018-07-03 01:42:31 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
uiOrdering.add( &m_wellStartType );
|
2020-02-06 09:18:50 -06:00
|
|
|
uiOrdering.add( &m_referencePointUtmXyd );
|
|
|
|
uiOrdering.add( &m_airGap );
|
|
|
|
if ( m_wellStartType == START_AT_FIRST_TARGET )
|
2018-07-03 01:42:31 -05:00
|
|
|
{
|
2020-02-06 09:18:50 -06:00
|
|
|
uiOrdering.add( &m_mdAtFirstTarget );
|
2018-07-03 01:42:31 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
uiOrdering.add( &m_wellTargets );
|
|
|
|
uiOrdering.add( &m_pickPointsEnabled );
|
|
|
|
uiOrdering.skipRemainingFields( true );
|
2018-07-03 01:42:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-07-03 01:42:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimWellPathGeometryDef::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName )
|
2018-07-03 01:42:31 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
uiTreeOrdering.skipRemainingChildren( true );
|
2018-07-03 01:42:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-07-03 01:42:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-07-31 01:44:37 -05:00
|
|
|
std::vector<RimWellPathTarget*> RimWellPathGeometryDef::activeWellTargets() const
|
2018-07-03 01:42:31 -05:00
|
|
|
{
|
2018-07-31 01:44:37 -05:00
|
|
|
std::vector<RimWellPathTarget*> active;
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( const auto& wt : m_wellTargets )
|
2018-07-31 01:44:37 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( wt->isEnabled() )
|
2018-07-31 01:44:37 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
active.push_back( wt );
|
2018-07-31 01:44:37 -05:00
|
|
|
}
|
|
|
|
}
|
2018-07-04 09:49:04 -05:00
|
|
|
|
2018-07-31 01:44:37 -05:00
|
|
|
return active;
|
|
|
|
}
|
2018-07-04 09:49:04 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-07-04 09:49:04 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-28 07:06:56 -05:00
|
|
|
RiaLineArcWellPathCalculator RimWellPathGeometryDef::lineArcWellPathCalculator() const
|
2018-07-04 09:49:04 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<RimWellPathTarget*> wellTargets = activeWellTargets();
|
2018-07-31 01:44:37 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<RiaLineArcWellPathCalculator::WellTarget> targetDatas;
|
2018-09-28 07:06:56 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( auto wellTarget : wellTargets )
|
2018-07-04 09:49:04 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
targetDatas.push_back( wellTarget->wellTargetData() );
|
2018-07-04 09:49:04 -05:00
|
|
|
}
|
2018-09-28 07:06:56 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaLineArcWellPathCalculator wellPathCalculator( referencePointXyz(), targetDatas );
|
2020-02-12 04:43:15 -06:00
|
|
|
const std::vector<RiaLineArcWellPathCalculator::WellTargetStatus>& targetStatuses =
|
|
|
|
wellPathCalculator.targetStatuses();
|
2018-09-28 07:06:56 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( size_t tIdx = 0; tIdx < wellTargets.size(); ++tIdx )
|
2018-07-04 09:49:04 -05:00
|
|
|
{
|
2019-11-18 02:42:09 -06:00
|
|
|
wellTargets[tIdx]->flagRadius1AsIncorrect( targetStatuses[tIdx].isRadius1Editable, false, 0 );
|
|
|
|
wellTargets[tIdx]->flagRadius2AsIncorrect( targetStatuses[tIdx].isRadius2Editable, false, 0 );
|
2018-09-28 07:06:56 -05:00
|
|
|
|
|
|
|
if ( targetStatuses[tIdx].hasDerivedTangent )
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
wellTargets[tIdx]->setDerivedTangent( targetStatuses[tIdx].resultAzimuth,
|
|
|
|
targetStatuses[tIdx].resultInclination );
|
2018-09-28 07:06:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( targetStatuses[tIdx].hasOverriddenRadius1 )
|
|
|
|
{
|
2019-11-18 02:42:09 -06:00
|
|
|
wellTargets[tIdx]->flagRadius1AsIncorrect( targetStatuses[tIdx].isRadius1Editable,
|
|
|
|
true,
|
|
|
|
targetStatuses[tIdx].resultRadius1 );
|
2018-09-28 07:06:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( targetStatuses[tIdx].hasOverriddenRadius2 )
|
|
|
|
{
|
2019-11-18 02:42:09 -06:00
|
|
|
wellTargets[tIdx]->flagRadius2AsIncorrect( targetStatuses[tIdx].isRadius2Editable,
|
|
|
|
true,
|
|
|
|
targetStatuses[tIdx].resultRadius2 );
|
2018-09-28 07:06:56 -05:00
|
|
|
}
|
2018-07-04 09:49:04 -05:00
|
|
|
}
|
2018-09-28 07:06:56 -05:00
|
|
|
|
|
|
|
return wellPathCalculator;
|
2018-07-04 09:49:04 -05:00
|
|
|
}
|
|
|
|
|
2018-07-03 01:42:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-07-03 01:42:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimWellPathGeometryDef::defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu,
|
|
|
|
QMenu* menu,
|
|
|
|
QWidget* fieldEditorWidget )
|
2018-07-03 01:42:31 -05:00
|
|
|
{
|
|
|
|
caf::CmdFeatureMenuBuilder menuBuilder;
|
2019-09-06 03:40:57 -05:00
|
|
|
|
2018-07-03 01:42:31 -05:00
|
|
|
menuBuilder << "RicNewWellPathListTargetFeature";
|
|
|
|
menuBuilder << "Separator";
|
|
|
|
menuBuilder << "RicDeleteWellPathTargetFeature";
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
menuBuilder.appendToMenu( menu );
|
2018-07-03 01:42:31 -05:00
|
|
|
}
|
2018-08-29 09:03:31 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-08-29 09:03:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimWellPathGeometryDef::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
|
|
|
QString uiConfigName,
|
|
|
|
caf::PdmUiEditorAttribute* attribute )
|
2018-08-29 09:03:31 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( field == &m_pickPointsEnabled )
|
2018-08-29 09:03:31 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmUiPushButtonEditorAttribute* pbAttribute = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
|
2018-08-29 09:03:31 -05:00
|
|
|
if ( pbAttribute )
|
|
|
|
{
|
|
|
|
if ( !m_pickPointsEnabled )
|
|
|
|
{
|
|
|
|
pbAttribute->m_buttonText = "Start Picking Targets";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pbAttribute->m_buttonText = "Stop Picking Targets";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( field == &m_wellTargets )
|
2018-08-29 09:03:31 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
auto tvAttribute = dynamic_cast<caf::PdmUiTableViewEditorAttribute*>( attribute );
|
|
|
|
if ( tvAttribute )
|
2018-08-29 09:03:31 -05:00
|
|
|
{
|
2018-10-31 03:31:53 -05:00
|
|
|
tvAttribute->resizePolicy = caf::PdmUiTableViewEditorAttribute::RESIZE_TO_FIT_CONTENT;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_pickPointsEnabled )
|
2018-10-31 03:31:53 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
tvAttribute->baseColor.setRgb( 255, 220, 255 );
|
2018-10-31 03:31:53 -05:00
|
|
|
tvAttribute->alwaysEnforceResizePolicy = true;
|
|
|
|
}
|
2018-08-29 09:03:31 -05:00
|
|
|
}
|
|
|
|
}
|
2019-11-18 02:42:09 -06:00
|
|
|
|
|
|
|
if ( field == &m_referencePointUtmXyd )
|
|
|
|
{
|
|
|
|
auto uiDisplayStringAttr = dynamic_cast<caf::PdmUiLineEditorAttributeUiDisplayString*>( attribute );
|
|
|
|
|
|
|
|
if ( uiDisplayStringAttr )
|
|
|
|
{
|
|
|
|
uiDisplayStringAttr->m_displayString = QString::number( m_referencePointUtmXyd()[0], 'f', 2 ) + " " +
|
|
|
|
QString::number( m_referencePointUtmXyd()[1], 'f', 2 ) + " " +
|
|
|
|
QString::number( m_referencePointUtmXyd()[2], 'f', 2 );
|
|
|
|
}
|
|
|
|
}
|
2020-02-06 09:18:50 -06:00
|
|
|
|
|
|
|
if ( field == &m_airGap )
|
|
|
|
{
|
|
|
|
auto uiDoubleValueEditorAttr = dynamic_cast<caf::PdmUiDoubleValueEditorAttribute*>( attribute );
|
|
|
|
if ( uiDoubleValueEditorAttr )
|
|
|
|
{
|
|
|
|
uiDoubleValueEditorAttr->m_decimals = 2;
|
|
|
|
uiDoubleValueEditorAttr->m_validator = new QDoubleValidator( 0.0, std::numeric_limits<double>::max(), 2 );
|
|
|
|
}
|
|
|
|
}
|
2018-08-29 09:03:31 -05:00
|
|
|
}
|
2018-09-11 02:31:50 -05:00
|
|
|
|
2019-02-11 06:46:48 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimWellPathGeometryDef::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
|
2019-02-11 06:46:48 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RicWellPathGeometry3dEditorAttribute* attrib = dynamic_cast<RicWellPathGeometry3dEditorAttribute*>( attribute );
|
|
|
|
if ( attrib )
|
2019-02-11 06:46:48 -06:00
|
|
|
{
|
|
|
|
attrib->pickEventHandler = m_pickTargetsEventHandler;
|
|
|
|
attrib->enablePicking = m_pickPointsEnabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-11 02:31:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-09-11 02:31:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPathGeometryDef::initAfterRead()
|
|
|
|
{
|
2020-02-11 01:21:13 -06:00
|
|
|
if ( RiaApplication::instance()->project()->isProjectFileVersionEqualOrOlderThan( "2019.12.1" ) )
|
|
|
|
{
|
|
|
|
m_wellStartType = START_AT_FIRST_TARGET;
|
|
|
|
}
|
2018-09-11 02:31:50 -05:00
|
|
|
}
|