2018-08-06 00:52:02 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2018 - 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 "RimWellPathAttribute.h"
|
|
|
|
|
2018-10-05 03:26:26 -05:00
|
|
|
#include "RigWellPath.h"
|
2018-08-30 06:54:00 -05:00
|
|
|
#include "RimWellPathAttributeCollection.h"
|
|
|
|
#include "RimWellPath.h"
|
|
|
|
|
|
|
|
#include "cafPdmUiComboBoxEditor.h"
|
|
|
|
|
2018-08-30 07:03:58 -05:00
|
|
|
#include <cmath>
|
|
|
|
|
2018-08-06 00:52:02 -05:00
|
|
|
CAF_PDM_SOURCE_INIT(RimWellPathAttribute, "WellPathAttribute");
|
|
|
|
|
|
|
|
namespace caf
|
|
|
|
{
|
|
|
|
template<>
|
|
|
|
void caf::AppEnum<RimWellPathAttribute::AttributeType>::setUp()
|
|
|
|
{
|
|
|
|
addItem(RimWellPathAttribute::AttributeCasing, "CASING", "Casing");
|
2018-08-30 06:54:00 -05:00
|
|
|
addItem(RimWellPathAttribute::AttributeLiner, "LINER", "Liner");
|
2018-10-03 08:57:09 -05:00
|
|
|
addItem(RimWellPathAttribute::AttributePacker, "PACKER", "Packer");
|
2018-08-06 00:52:02 -05:00
|
|
|
setDefault(RimWellPathAttribute::AttributeCasing);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("RimWellPathAttribute", "", "", "");
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_type, "AttributeType", "Type ", "", "", "");
|
2018-10-05 03:26:26 -05:00
|
|
|
CAF_PDM_InitField(&m_depthStart, "DepthStart", -1.0, "Start MD", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_depthEnd, "DepthEnd", -1.0, "End MD", "", "", "");
|
2018-08-30 06:54:00 -05:00
|
|
|
CAF_PDM_InitField(&m_diameterInInches, "DiameterInInches", MAX_DIAMETER_IN_INCHES, "Diameter", "", "", "");
|
|
|
|
m_diameterInInches.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName());
|
2018-08-06 00:52:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellPathAttribute::~RimWellPathAttribute()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellPathAttribute::AttributeType RimWellPathAttribute::type() const
|
|
|
|
{
|
|
|
|
return m_type();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
double RimWellPathAttribute::depthStart() const
|
|
|
|
{
|
|
|
|
return m_depthStart();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
double RimWellPathAttribute::depthEnd() const
|
|
|
|
{
|
|
|
|
return m_depthEnd();
|
|
|
|
}
|
|
|
|
|
2018-08-30 06:54:00 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
double RimWellPathAttribute::diameterInInches() const
|
|
|
|
{
|
|
|
|
return m_diameterInInches;
|
|
|
|
}
|
|
|
|
|
2018-08-06 00:52:02 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimWellPathAttribute::label() const
|
|
|
|
{
|
2018-08-30 06:54:00 -05:00
|
|
|
if (m_type == AttributeCasing)
|
|
|
|
{
|
|
|
|
return QString("Casing %1").arg(diameterLabel());
|
|
|
|
}
|
2018-10-03 08:57:09 -05:00
|
|
|
else if (m_type == AttributeLiner)
|
2018-08-30 06:54:00 -05:00
|
|
|
{
|
|
|
|
return QString("Liner %1").arg(diameterLabel());
|
|
|
|
}
|
2018-10-03 08:57:09 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_type().uiText();
|
|
|
|
}
|
2018-08-30 06:54:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimWellPathAttribute::diameterLabel() const
|
|
|
|
{
|
2018-10-03 08:57:09 -05:00
|
|
|
return generateInchesLabel(m_diameterInInches());
|
2018-08-30 06:54:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-03 08:57:09 -05:00
|
|
|
bool RimWellPathAttribute::operator<(const RimWellPathAttribute& rhs) const
|
2018-08-30 06:54:00 -05:00
|
|
|
{
|
2018-10-03 08:57:09 -05:00
|
|
|
if (type() != rhs.type())
|
2018-08-30 06:54:00 -05:00
|
|
|
{
|
2018-10-03 08:57:09 -05:00
|
|
|
return type() < rhs.type();
|
2018-08-30 06:54:00 -05:00
|
|
|
}
|
2018-10-03 08:57:09 -05:00
|
|
|
return depthEnd() > rhs.depthEnd();
|
|
|
|
}
|
|
|
|
|
2018-10-05 03:26:26 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPathAttribute::setDepthsFromWellPath(const RimWellPath* wellPath)
|
|
|
|
{
|
|
|
|
m_depthStart = wellPath->wellPathGeometry()->measureDepths().front();
|
|
|
|
m_depthEnd = wellPath->wellPathGeometry()->measureDepths().back();
|
|
|
|
}
|
|
|
|
|
2018-10-03 08:57:09 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QList<caf::PdmOptionItemInfo> RimWellPathAttribute::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
|
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> options;
|
|
|
|
if (fieldNeedingOptions == &m_diameterInInches)
|
2018-08-30 06:54:00 -05:00
|
|
|
{
|
2018-10-03 08:57:09 -05:00
|
|
|
if (m_type() == AttributeCasing || m_type() == AttributeLiner)
|
|
|
|
{
|
|
|
|
std::vector<double> values = { MAX_DIAMETER_IN_INCHES, 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 };
|
2018-08-30 06:54:00 -05:00
|
|
|
|
2018-10-03 08:57:09 -05:00
|
|
|
for (double value : values)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(generateInchesLabel(value), value));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2018-08-30 06:54:00 -05:00
|
|
|
{
|
2018-10-03 08:57:09 -05:00
|
|
|
options.push_back(caf::PdmOptionItemInfo("N/A", MAX_DIAMETER_IN_INCHES));
|
2018-08-30 06:54:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimWellPathAttribute::generateInchesLabel(double diameter)
|
|
|
|
{
|
|
|
|
double integerPart = 0.0;
|
|
|
|
double fraction = modf(diameter, &integerPart);
|
|
|
|
|
2018-08-30 07:03:58 -05:00
|
|
|
int numerator = static_cast<int>(std::round(8.0 * fraction));
|
2018-08-30 06:54:00 -05:00
|
|
|
|
|
|
|
if (numerator > 0)
|
|
|
|
{
|
|
|
|
return QString("%1 %2/8\"").arg(static_cast<int>(integerPart)).arg(numerator);
|
|
|
|
}
|
|
|
|
return QString("%1\"").arg(static_cast<int>(integerPart));
|
2018-08-06 00:52:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPathAttribute::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
|
|
|
const QVariant& oldValue,
|
|
|
|
const QVariant& newValue)
|
|
|
|
{
|
|
|
|
if (changedField == &m_type)
|
|
|
|
{
|
|
|
|
if (m_type() == AttributeCasing)
|
|
|
|
{
|
2018-10-05 03:26:26 -05:00
|
|
|
RimWellPath* wellPath = nullptr;
|
|
|
|
this->firstAncestorOrThisOfTypeAsserted(wellPath);
|
|
|
|
m_depthStart = wellPath->wellPathGeometry()->measureDepths().front();
|
2018-08-06 00:52:02 -05:00
|
|
|
}
|
|
|
|
}
|
2018-08-30 06:54:00 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
RimWellPathAttributeCollection* collection = nullptr;
|
|
|
|
this->firstAncestorOrThisOfTypeAsserted(collection);
|
|
|
|
collection->updateAllReferringTracks();
|
|
|
|
}
|
2018-08-06 00:52:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPathAttribute::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
2018-10-05 03:26:26 -05:00
|
|
|
{
|
2018-10-03 08:57:09 -05:00
|
|
|
bool startDepthAvailable = m_type() != AttributeCasing;
|
|
|
|
bool endDepthAvailable = true;
|
|
|
|
bool diameterAvailable = m_type() == AttributeCasing || m_type() == AttributeLiner;
|
|
|
|
|
|
|
|
m_depthStart.uiCapability()->setUiReadOnly(!startDepthAvailable);
|
|
|
|
m_depthEnd.uiCapability()->setUiReadOnly(!endDepthAvailable);
|
|
|
|
m_diameterInInches.uiCapability()->setUiReadOnly(!diameterAvailable);
|
2018-08-06 00:52:02 -05:00
|
|
|
}
|