2018-08-06 00:52:02 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2019-01-09 08:21:38 -06:00
|
|
|
// Copyright (C) 2018- Equinor ASA
|
2018-08-06 00:52:02 -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.
|
|
|
|
//
|
|
|
|
// 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 "RimWellPathAttribute.h"
|
|
|
|
|
2018-10-11 09:03:49 -05:00
|
|
|
#include "RiaColorTables.h"
|
2018-10-05 03:26:26 -05:00
|
|
|
#include "RigWellPath.h"
|
2018-10-10 09:57:43 -05:00
|
|
|
|
|
|
|
#include "RimProject.h"
|
2018-08-30 06:54:00 -05:00
|
|
|
#include "RimWellPath.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimWellPathAttributeCollection.h"
|
2018-08-30 06:54:00 -05:00
|
|
|
|
|
|
|
#include "cafPdmUiComboBoxEditor.h"
|
|
|
|
|
2018-08-30 07:03:58 -05:00
|
|
|
#include <cmath>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_SOURCE_INIT( RimWellPathAttribute, "WellPathAttribute" );
|
2018-08-06 00:52:02 -05:00
|
|
|
|
2018-08-30 06:54:00 -05:00
|
|
|
double RimWellPathAttribute::MAX_DIAMETER_IN_INCHES = 30.0;
|
|
|
|
double RimWellPathAttribute::MIN_DIAMETER_IN_INCHES = 7.0;
|
|
|
|
|
2018-08-06 00:52:02 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellPathAttribute::RimWellPathAttribute()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_InitObject( "RimWellPathAttribute", "", "", "" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_type, "CompletionType", "Type ", "", "", "" );
|
|
|
|
CAF_PDM_InitField( &m_startMD, "DepthStart", -1.0, "Start MD", "", "", "" );
|
|
|
|
CAF_PDM_InitField( &m_endMD, "DepthEnd", -1.0, "End MD", "", "", "" );
|
|
|
|
CAF_PDM_InitField( &m_diameterInInches, "DiameterInInches", MAX_DIAMETER_IN_INCHES, "Diameter", "", "", "" );
|
2020-04-24 00:13:33 -05:00
|
|
|
m_type = RiaDefines::WellPathComponentType::CASING;
|
2019-09-06 03:40:57 -05:00
|
|
|
m_diameterInInches.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
|
2018-08-06 00:52:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:13:38 -06:00
|
|
|
RimWellPathAttribute::~RimWellPathAttribute()
|
|
|
|
{
|
|
|
|
}
|
2018-08-06 00:52:02 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-09 04:06:10 -05:00
|
|
|
double RimWellPathAttribute::diameterInInches() const
|
2018-08-06 00:52:02 -05:00
|
|
|
{
|
2018-10-09 04:06:10 -05:00
|
|
|
return m_diameterInInches;
|
2018-08-06 00:52:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-09 04:06:10 -05:00
|
|
|
QString RimWellPathAttribute::diameterLabel() const
|
2018-08-06 00:52:02 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return generateInchesLabel( m_diameterInInches() );
|
2018-08-06 00:52:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
bool RimWellPathAttribute::operator<( const RimWellPathAttribute& rhs ) const
|
2018-08-06 00:52:02 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( componentType() != rhs.componentType() )
|
2018-10-09 04:06:10 -05:00
|
|
|
{
|
2018-10-09 06:42:03 -05:00
|
|
|
return componentType() < rhs.componentType();
|
2018-10-09 04:06:10 -05:00
|
|
|
}
|
|
|
|
return endMD() > rhs.endMD();
|
2018-08-06 00:52:02 -05:00
|
|
|
}
|
|
|
|
|
2018-08-30 06:54:00 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-10-06 05:37:16 -05:00
|
|
|
void RimWellPathAttribute::setDepthsFromWellPath( gsl::not_null<const RimWellPath*> wellPath )
|
2018-08-30 06:54:00 -05:00
|
|
|
{
|
2021-01-04 04:09:01 -06:00
|
|
|
m_startMD = wellPath->uniqueStartMD();
|
|
|
|
m_endMD = wellPath->uniqueEndMD();
|
2018-08-30 06:54:00 -05:00
|
|
|
}
|
|
|
|
|
2018-08-06 00:52:02 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-11-22 05:57:11 -06:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimWellPathAttribute::isEnabled() const
|
|
|
|
{
|
|
|
|
RimWellPathAttributeCollection* collection = nullptr;
|
2019-09-06 03:40:57 -05:00
|
|
|
this->firstAncestorOrThisOfTypeAsserted( collection );
|
2018-11-22 05:57:11 -06:00
|
|
|
return collection->isChecked();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-08-06 00:52:02 -05:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-09 06:42:03 -05:00
|
|
|
RiaDefines::WellPathComponentType RimWellPathAttribute::componentType() const
|
2018-08-06 00:52:02 -05:00
|
|
|
{
|
2018-10-09 04:06:10 -05:00
|
|
|
return m_type();
|
2018-10-05 08:59:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-10 09:57:43 -05:00
|
|
|
QString RimWellPathAttribute::componentLabel() const
|
2018-10-05 08:59:19 -05:00
|
|
|
{
|
2018-10-10 09:57:43 -05:00
|
|
|
QString fullLabel = componentTypeLabel();
|
2020-04-24 00:13:33 -05:00
|
|
|
if ( m_type() == RiaDefines::WellPathComponentType::CASING || m_type() == RiaDefines::WellPathComponentType::LINER )
|
2018-10-10 09:57:43 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
fullLabel += QString( " %1" ).arg( diameterLabel() );
|
2018-10-10 09:57:43 -05:00
|
|
|
}
|
|
|
|
return fullLabel;
|
2018-08-30 06:54:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-10 09:57:43 -05:00
|
|
|
QString RimWellPathAttribute::componentTypeLabel() const
|
2018-08-30 06:54:00 -05:00
|
|
|
{
|
2018-10-10 09:57:43 -05:00
|
|
|
return m_type().uiText();
|
2018-08-30 06:54:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-10 09:57:43 -05:00
|
|
|
cvf::Color3f RimWellPathAttribute::defaultComponentColor() const
|
2018-08-30 06:54:00 -05:00
|
|
|
{
|
2018-10-11 09:03:49 -05:00
|
|
|
return RiaColorTables::wellPathComponentColors()[componentType()];
|
2018-10-03 08:57:09 -05:00
|
|
|
}
|
|
|
|
|
2018-10-05 03:26:26 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-10 09:57:43 -05:00
|
|
|
double RimWellPathAttribute::startMD() const
|
2018-10-05 03:26:26 -05:00
|
|
|
{
|
2018-10-10 09:57:43 -05:00
|
|
|
return m_startMD();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
double RimWellPathAttribute::endMD() const
|
|
|
|
{
|
|
|
|
return m_endMD();
|
2018-10-09 04:06:10 -05:00
|
|
|
}
|
|
|
|
|
2019-10-28 07:53:54 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::set<double> RimWellPathAttribute::supportedDiameters( RiaDefines::WellPathComponentType type )
|
|
|
|
{
|
2020-04-24 00:13:33 -05:00
|
|
|
CAF_ASSERT( type == RiaDefines::WellPathComponentType::CASING || type == RiaDefines::WellPathComponentType::LINER );
|
2019-10-28 07:53:54 -05:00
|
|
|
std::set<double> values;
|
2020-04-24 00:13:33 -05:00
|
|
|
if ( type == RiaDefines::WellPathComponentType::CASING )
|
2019-10-28 07:53:54 -05:00
|
|
|
{
|
2020-11-06 03:46:38 -06:00
|
|
|
values = { MAX_DIAMETER_IN_INCHES,
|
|
|
|
26.0,
|
|
|
|
22.0,
|
|
|
|
20.0,
|
|
|
|
18.0 + 5.0 / 8.0,
|
|
|
|
16.0,
|
|
|
|
14.0,
|
|
|
|
13.0 + 3.0 / 8.0,
|
|
|
|
10.0 + 3.0 / 4.0,
|
|
|
|
9.0 + 7.0 / 8.0,
|
|
|
|
9.0 + 5.0 / 8.0,
|
|
|
|
MIN_DIAMETER_IN_INCHES };
|
2019-10-28 07:53:54 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-06 03:46:38 -06:00
|
|
|
values = { 9.0 + 7.0 / 8.0, 9.0 + 5.0 / 8.0, 7.0, 5.5, 5.0, 4.5, 3.5 };
|
2019-10-28 07:53:54 -05:00
|
|
|
}
|
|
|
|
return values;
|
|
|
|
}
|
|
|
|
|
2018-10-09 04:06:10 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimWellPathAttribute::isDiameterSupported() const
|
|
|
|
{
|
2020-04-24 00:13:33 -05:00
|
|
|
return m_type() == RiaDefines::WellPathComponentType::CASING || m_type() == RiaDefines::WellPathComponentType::LINER;
|
2018-10-05 03:26:26 -05:00
|
|
|
}
|
|
|
|
|
2018-10-03 08:57:09 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:43:15 -06:00
|
|
|
QList<caf::PdmOptionItemInfo>
|
|
|
|
RimWellPathAttribute::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
|
2018-10-03 08:57:09 -05:00
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> options;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( fieldNeedingOptions == &m_type )
|
2018-10-09 04:06:10 -05:00
|
|
|
{
|
2020-11-06 03:46:38 -06:00
|
|
|
std::set<RiaDefines::WellPathComponentType> supportedTypes = { RiaDefines::WellPathComponentType::CASING,
|
|
|
|
RiaDefines::WellPathComponentType::LINER,
|
|
|
|
RiaDefines::WellPathComponentType::PACKER };
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RiaDefines::WellPathComponentType type : supportedTypes )
|
2018-10-09 04:06:10 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
options.push_back( caf::PdmOptionItemInfo( CompletionTypeEnum::uiText( type ), type ) );
|
2018-10-09 04:06:10 -05:00
|
|
|
}
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( fieldNeedingOptions == &m_diameterInInches )
|
2018-08-30 06:54:00 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( isDiameterSupported() )
|
2018-10-03 08:57:09 -05:00
|
|
|
{
|
2019-10-28 07:53:54 -05:00
|
|
|
std::set<double> values = supportedDiameters( m_type() );
|
|
|
|
|
|
|
|
for ( auto it = values.rbegin(); it != values.rend(); ++it )
|
2018-10-03 08:57:09 -05:00
|
|
|
{
|
2019-10-28 07:53:54 -05:00
|
|
|
options.push_back( caf::PdmOptionItemInfo( generateInchesLabel( *it ), *it ) );
|
2018-10-03 08:57:09 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2018-08-30 06:54:00 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
options.push_back( caf::PdmOptionItemInfo( "N/A", MAX_DIAMETER_IN_INCHES ) );
|
2018-08-30 06:54:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
QString RimWellPathAttribute::generateInchesLabel( double diameter )
|
2018-08-30 06:54:00 -05:00
|
|
|
{
|
|
|
|
double integerPart = 0.0;
|
2019-09-06 03:40:57 -05:00
|
|
|
double fraction = modf( diameter, &integerPart );
|
2018-08-30 06:54:00 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
int numerator = static_cast<int>( std::round( 8.0 * fraction ) );
|
2018-08-30 06:54:00 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( numerator > 0 )
|
2018-08-30 06:54:00 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return QString( "%1 %2/8\"" ).arg( static_cast<int>( integerPart ) ).arg( numerator );
|
2018-08-30 06:54:00 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
return QString( "%1\"" ).arg( static_cast<int>( integerPart ) );
|
2018-08-06 00:52:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimWellPathAttribute::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
|
|
|
const QVariant& oldValue,
|
|
|
|
const QVariant& newValue )
|
2018-08-06 00:52:02 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( changedField == &m_type )
|
2018-08-06 00:52:02 -05:00
|
|
|
{
|
2020-04-24 00:13:33 -05:00
|
|
|
if ( m_type() == RiaDefines::WellPathComponentType::CASING )
|
2018-08-06 00:52:02 -05:00
|
|
|
{
|
2018-10-05 03:26:26 -05:00
|
|
|
RimWellPath* wellPath = nullptr;
|
2019-09-06 03:40:57 -05:00
|
|
|
this->firstAncestorOrThisOfTypeAsserted( wellPath );
|
2020-10-06 05:37:16 -05:00
|
|
|
m_startMD = wellPath->startMD();
|
2019-10-28 07:53:54 -05:00
|
|
|
|
|
|
|
if ( !supportedDiameters( m_type() ).count( m_diameterInInches() ) )
|
|
|
|
{
|
|
|
|
m_diameterInInches = *( supportedDiameters( m_type() ).begin() );
|
|
|
|
}
|
|
|
|
}
|
2020-04-24 00:13:33 -05:00
|
|
|
else if ( m_type() == RiaDefines::WellPathComponentType::LINER )
|
2019-10-28 07:53:54 -05:00
|
|
|
{
|
|
|
|
if ( !supportedDiameters( m_type() ).count( m_diameterInInches() ) )
|
|
|
|
{
|
|
|
|
m_diameterInInches = *( supportedDiameters( m_type() ).rbegin() );
|
|
|
|
}
|
2018-08-06 00:52:02 -05:00
|
|
|
}
|
2020-04-24 00:13:33 -05:00
|
|
|
else if ( m_type() == RiaDefines::WellPathComponentType::PACKER )
|
2018-11-22 04:58:37 -06:00
|
|
|
{
|
2018-12-05 01:23:06 -06:00
|
|
|
m_endMD = m_startMD + 1;
|
2018-11-22 04:58:37 -06:00
|
|
|
}
|
2018-08-06 00:52:02 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( changedField == &m_startMD )
|
2018-11-21 04:37:04 -06:00
|
|
|
{
|
2020-04-24 00:13:33 -05:00
|
|
|
if ( m_type() == RiaDefines::WellPathComponentType::PACKER )
|
2018-11-21 04:37:04 -06:00
|
|
|
{
|
2018-12-05 01:23:06 -06:00
|
|
|
m_endMD = m_startMD + 1;
|
2018-11-21 04:37:04 -06:00
|
|
|
}
|
|
|
|
}
|
2018-08-30 06:54:00 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
RimWellPathAttributeCollection* collection = nullptr;
|
2019-09-06 03:40:57 -05:00
|
|
|
this->firstAncestorOrThisOfTypeAsserted( collection );
|
2018-08-30 06:54:00 -05:00
|
|
|
collection->updateAllReferringTracks();
|
|
|
|
}
|
2018-10-10 09:57:43 -05:00
|
|
|
{
|
|
|
|
RimProject* proj;
|
2019-09-06 03:40:57 -05:00
|
|
|
this->firstAncestorOrThisOfTypeAsserted( proj );
|
2018-10-10 09:57:43 -05:00
|
|
|
proj->reloadCompletionTypeResultsInAllViews();
|
|
|
|
}
|
2018-08-06 00:52:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimWellPathAttribute::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
|
|
|
{
|
2020-04-24 00:13:33 -05:00
|
|
|
bool startDepthAvailable = m_type() != RiaDefines::WellPathComponentType::CASING;
|
2018-10-03 08:57:09 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_startMD.uiCapability()->setUiReadOnly( !startDepthAvailable );
|
|
|
|
m_diameterInInches.uiCapability()->setUiReadOnly( !isDiameterSupported() );
|
2018-08-06 00:52:02 -05:00
|
|
|
}
|