#3187 Update Well Path Attributes to have a list of inch-values for diameter.

This commit is contained in:
Gaute Lindkvist 2018-08-30 13:54:00 +02:00
parent b603c5948e
commit 46c5bbf4c6
2 changed files with 96 additions and 9 deletions

View File

@ -17,6 +17,12 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#include "RimWellPathAttribute.h" #include "RimWellPathAttribute.h"
#include "RimWellPathAttributeCurve.h"
#include "RimWellPathAttributeCollection.h"
#include "RimWellPath.h"
#include "cafPdmUiComboBoxEditor.h"
CAF_PDM_SOURCE_INIT(RimWellPathAttribute, "WellPathAttribute"); CAF_PDM_SOURCE_INIT(RimWellPathAttribute, "WellPathAttribute");
namespace caf namespace caf
@ -25,11 +31,14 @@ template<>
void caf::AppEnum<RimWellPathAttribute::AttributeType>::setUp() void caf::AppEnum<RimWellPathAttribute::AttributeType>::setUp()
{ {
addItem(RimWellPathAttribute::AttributeCasing, "CASING", "Casing"); addItem(RimWellPathAttribute::AttributeCasing, "CASING", "Casing");
addItem(RimWellPathAttribute::AttributeLining, "LINING", "Lining"); addItem(RimWellPathAttribute::AttributeLiner, "LINER", "Liner");
setDefault(RimWellPathAttribute::AttributeCasing); setDefault(RimWellPathAttribute::AttributeCasing);
} }
} }
double RimWellPathAttribute::MAX_DIAMETER_IN_INCHES = 30.0;
double RimWellPathAttribute::MIN_DIAMETER_IN_INCHES = 7.0;
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -39,7 +48,8 @@ RimWellPathAttribute::RimWellPathAttribute()
CAF_PDM_InitFieldNoDefault(&m_type, "AttributeType", "Type ", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_type, "AttributeType", "Type ", "", "", "");
CAF_PDM_InitField(&m_depthStart, "DepthStart", 0.0, "Depth Start", "", "", ""); CAF_PDM_InitField(&m_depthStart, "DepthStart", 0.0, "Depth Start", "", "", "");
CAF_PDM_InitField(&m_depthEnd, "DepthEnd", 0.0, "Depth End", "", "", ""); CAF_PDM_InitField(&m_depthEnd, "DepthEnd", 0.0, "Depth End", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_label, "Label", "Label", "", "", ""); CAF_PDM_InitField(&m_diameterInInches, "DiameterInInches", MAX_DIAMETER_IN_INCHES, "Diameter", "", "", "");
m_diameterInInches.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName());
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -74,12 +84,75 @@ double RimWellPathAttribute::depthEnd() const
return m_depthEnd(); return m_depthEnd();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimWellPathAttribute::diameterInInches() const
{
return m_diameterInInches;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimWellPathAttribute::label() const QString RimWellPathAttribute::label() const
{ {
return m_label(); if (m_type == AttributeCasing)
{
return QString("Casing %1").arg(diameterLabel());
}
else
{
return QString("Liner %1").arg(diameterLabel());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellPathAttribute::diameterLabel() const
{
return generateInchesLabel(m_diameterInInches());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimWellPathAttribute::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> options;
if (fieldNeedingOptions == &m_type)
{
options.push_back(caf::PdmOptionItemInfo(AttributeTypeEnum::uiText(AttributeCasing), AttributeCasing));
options.push_back(caf::PdmOptionItemInfo(AttributeTypeEnum::uiText(AttributeLiner), AttributeLiner));
}
else if (fieldNeedingOptions == &m_diameterInInches)
{
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 };
for (double value : values)
{
options.push_back(caf::PdmOptionItemInfo(generateInchesLabel(value), value));
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellPathAttribute::generateInchesLabel(double diameter)
{
double integerPart = 0.0;
double fraction = modf(diameter, &integerPart);
int numerator = static_cast<int>(std::round(fraction / 0.125));
if (numerator > 0)
{
return QString("%1 %2/8\"").arg(static_cast<int>(integerPart)).arg(numerator);
}
return QString("%1\"").arg(static_cast<int>(integerPart));
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -93,9 +166,15 @@ void RimWellPathAttribute::fieldChangedByUi(const caf::PdmFieldHandle* changedFi
{ {
if (m_type() == AttributeCasing) if (m_type() == AttributeCasing)
{ {
m_depthEnd = 0; m_depthStart = 0;
} }
} }
{
RimWellPathAttributeCollection* collection = nullptr;
this->firstAncestorOrThisOfTypeAsserted(collection);
collection->updateAllReferringTracks();
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -103,5 +182,5 @@ void RimWellPathAttribute::fieldChangedByUi(const caf::PdmFieldHandle* changedFi
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellPathAttribute::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) void RimWellPathAttribute::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{ {
m_depthEnd.uiCapability()->setUiReadOnly(m_type() == AttributeCasing); m_depthStart.uiCapability()->setUiReadOnly(m_type() == AttributeCasing);
} }

View File

@ -29,10 +29,13 @@ class RimWellPathAttribute : public caf::PdmObject
{ {
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
public: public:
static double MAX_DIAMETER_IN_INCHES;
static double MIN_DIAMETER_IN_INCHES;
enum AttributeType enum AttributeType
{ {
AttributeCasing, AttributeCasing,
AttributeLining AttributeLiner
}; };
typedef caf::AppEnum<AttributeType> AttributeTypeEnum; typedef caf::AppEnum<AttributeType> AttributeTypeEnum;
@ -42,15 +45,20 @@ public:
AttributeType type() const; AttributeType type() const;
double depthStart() const; double depthStart() const;
double depthEnd() const; double depthEnd() const;
double diameterInInches() const;
QString label() const; QString label() const;
QString diameterLabel() const;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
private: private:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; static QString generateInchesLabel(double diameter);
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
caf::PdmField<AttributeTypeEnum> m_type; caf::PdmField<AttributeTypeEnum> m_type;
caf::PdmField<double> m_depthStart; caf::PdmField<double> m_depthStart;
caf::PdmField<double> m_depthEnd; caf::PdmField<double> m_depthEnd;
caf::PdmField<QString> m_label; caf::PdmField<double> m_diameterInInches;
}; };