From 46c5bbf4c6664844e03e52f9a509002f230b7146 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 30 Aug 2018 13:54:00 +0200 Subject: [PATCH] #3187 Update Well Path Attributes to have a list of inch-values for diameter. --- .../ProjectDataModel/RimWellPathAttribute.cpp | 89 +++++++++++++++++-- .../ProjectDataModel/RimWellPathAttribute.h | 16 +++- 2 files changed, 96 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellPathAttribute.cpp b/ApplicationCode/ProjectDataModel/RimWellPathAttribute.cpp index 5545af03d0..bd1fe15cab 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathAttribute.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathAttribute.cpp @@ -17,6 +17,12 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimWellPathAttribute.h" +#include "RimWellPathAttributeCurve.h" +#include "RimWellPathAttributeCollection.h" +#include "RimWellPath.h" + +#include "cafPdmUiComboBoxEditor.h" + CAF_PDM_SOURCE_INIT(RimWellPathAttribute, "WellPathAttribute"); namespace caf @@ -25,11 +31,14 @@ template<> void caf::AppEnum::setUp() { addItem(RimWellPathAttribute::AttributeCasing, "CASING", "Casing"); - addItem(RimWellPathAttribute::AttributeLining, "LINING", "Lining"); + addItem(RimWellPathAttribute::AttributeLiner, "LINER", "Liner"); 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_InitField(&m_depthStart, "DepthStart", 0.0, "Depth Start", "", "", ""); 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(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimWellPathAttribute::diameterInInches() const +{ + return m_diameterInInches; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- 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 RimWellPathAttribute::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +{ + QList 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 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(std::round(fraction / 0.125)); + + if (numerator > 0) + { + return QString("%1 %2/8\"").arg(static_cast(integerPart)).arg(numerator); + } + return QString("%1\"").arg(static_cast(integerPart)); } //-------------------------------------------------------------------------------------------------- @@ -93,9 +166,15 @@ void RimWellPathAttribute::fieldChangedByUi(const caf::PdmFieldHandle* changedFi { 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) { - m_depthEnd.uiCapability()->setUiReadOnly(m_type() == AttributeCasing); + m_depthStart.uiCapability()->setUiReadOnly(m_type() == AttributeCasing); } diff --git a/ApplicationCode/ProjectDataModel/RimWellPathAttribute.h b/ApplicationCode/ProjectDataModel/RimWellPathAttribute.h index ab2893ce44..dd3cec84d3 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathAttribute.h +++ b/ApplicationCode/ProjectDataModel/RimWellPathAttribute.h @@ -29,10 +29,13 @@ class RimWellPathAttribute : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: + static double MAX_DIAMETER_IN_INCHES; + static double MIN_DIAMETER_IN_INCHES; + enum AttributeType { AttributeCasing, - AttributeLining + AttributeLiner }; typedef caf::AppEnum AttributeTypeEnum; @@ -42,15 +45,20 @@ public: AttributeType type() const; double depthStart() const; double depthEnd() const; + double diameterInInches() const; QString label() const; + QString diameterLabel() const; + + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; private: - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + static QString generateInchesLabel(double diameter); + 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 m_type; caf::PdmField m_depthStart; caf::PdmField m_depthEnd; - caf::PdmField m_label; + caf::PdmField m_diameterInInches; };