From 461e3b87b83e718c43152255684459df33d79855 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 5 Oct 2018 10:26:26 +0200 Subject: [PATCH] #3459 Set initial start and end depth from well path --- .../RicNewWellPathAttributeFeature.cpp | 14 +++++++++++-- .../ProjectDataModel/RimWellPathAttribute.cpp | 20 +++++++++++++++---- .../ProjectDataModel/RimWellPathAttribute.h | 5 ++++- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.cpp index a996a64f45..b57bfb0009 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.cpp @@ -62,7 +62,14 @@ void RicNewWellPathAttributeFeature::onActionTriggered(bool isChecked) { RimWellPathAttributeCollection* attributeCollection = nullptr; attributes[0]->firstAncestorOrThisOfTypeAsserted(attributeCollection); - attributeCollection->insertAttribute(attributes[0], new RimWellPathAttribute); + + RimWellPathAttribute* attribute = new RimWellPathAttribute; + RimWellPath* wellPath = nullptr; + attributeCollection->firstAncestorOrThisOfTypeAsserted(wellPath); + + attribute->setDepthsFromWellPath(wellPath); + attributeCollection->insertAttribute(attributes[0], attribute); + attributeCollection->updateAllRequiredEditors(); return; } @@ -74,7 +81,10 @@ void RicNewWellPathAttributeFeature::onActionTriggered(bool isChecked) wellPath->descendantsIncludingThisOfType(attributeCollections); if (!attributeCollections.empty()) { - attributeCollections[0]->insertAttribute(nullptr, new RimWellPathAttribute); + RimWellPathAttribute* attribute = new RimWellPathAttribute; + attribute->setDepthsFromWellPath(wellPath); + + attributeCollections[0]->insertAttribute(nullptr, attribute); attributeCollections[0]->updateAllRequiredEditors(); } } diff --git a/ApplicationCode/ProjectDataModel/RimWellPathAttribute.cpp b/ApplicationCode/ProjectDataModel/RimWellPathAttribute.cpp index a9b8f5d471..1bb4bc2dd7 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathAttribute.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathAttribute.cpp @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimWellPathAttribute.h" +#include "RigWellPath.h" #include "RimWellPathAttributeCollection.h" #include "RimWellPath.h" @@ -48,8 +49,8 @@ RimWellPathAttribute::RimWellPathAttribute() { CAF_PDM_InitObject("RimWellPathAttribute", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_type, "AttributeType", "Type ", "", "", ""); - CAF_PDM_InitField(&m_depthStart, "DepthStart", 0.0, "Start MD", "", "", ""); - CAF_PDM_InitField(&m_depthEnd, "DepthEnd", 0.0, "End MD", "", "", ""); + CAF_PDM_InitField(&m_depthStart, "DepthStart", -1.0, "Start MD", "", "", ""); + CAF_PDM_InitField(&m_depthEnd, "DepthEnd", -1.0, "End MD", "", "", ""); CAF_PDM_InitField(&m_diameterInInches, "DiameterInInches", MAX_DIAMETER_IN_INCHES, "Diameter", "", "", ""); m_diameterInInches.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName()); } @@ -133,6 +134,15 @@ bool RimWellPathAttribute::operator<(const RimWellPathAttribute& rhs) const return depthEnd() > rhs.depthEnd(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathAttribute::setDepthsFromWellPath(const RimWellPath* wellPath) +{ + m_depthStart = wellPath->wellPathGeometry()->measureDepths().front(); + m_depthEnd = wellPath->wellPathGeometry()->measureDepths().back(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -186,7 +196,9 @@ void RimWellPathAttribute::fieldChangedByUi(const caf::PdmFieldHandle* changedFi { if (m_type() == AttributeCasing) { - m_depthStart = 0; + RimWellPath* wellPath = nullptr; + this->firstAncestorOrThisOfTypeAsserted(wellPath); + m_depthStart = wellPath->wellPathGeometry()->measureDepths().front(); } } @@ -201,7 +213,7 @@ void RimWellPathAttribute::fieldChangedByUi(const caf::PdmFieldHandle* changedFi /// //-------------------------------------------------------------------------------------------------- void RimWellPathAttribute::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) -{ +{ bool startDepthAvailable = m_type() != AttributeCasing; bool endDepthAvailable = true; bool diameterAvailable = m_type() == AttributeCasing || m_type() == AttributeLiner; diff --git a/ApplicationCode/ProjectDataModel/RimWellPathAttribute.h b/ApplicationCode/ProjectDataModel/RimWellPathAttribute.h index 2567605785..f0072b09bc 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathAttribute.h +++ b/ApplicationCode/ProjectDataModel/RimWellPathAttribute.h @@ -25,6 +25,8 @@ #include +class RimWellPath; + class RimWellPathAttribute : public caf::PdmObject { CAF_PDM_HEADER_INIT; @@ -45,7 +47,7 @@ public: AttributeFishbonesInterval, AttributeAICD, AttributeICD, - AttributeICV, + AttributeICV }; typedef caf::AppEnum AttributeTypeEnum; @@ -59,6 +61,7 @@ public: QString label() const; QString diameterLabel() const; bool operator<(const RimWellPathAttribute& rhs) const; + void setDepthsFromWellPath(const RimWellPath* wellPath); private: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;