diff --git a/ApplicationCode/Commands/RicNewWellPathFractureAtPosFeature.cpp b/ApplicationCode/Commands/RicNewWellPathFractureAtPosFeature.cpp index c31c5c1292..87f660dd58 100644 --- a/ApplicationCode/Commands/RicNewWellPathFractureAtPosFeature.cpp +++ b/ApplicationCode/Commands/RicNewWellPathFractureAtPosFeature.cpp @@ -80,8 +80,7 @@ void RicNewWellPathFractureAtPosFeature::onActionTriggered(bool isChecked) RimWellPathFracture* fracture = new RimWellPathFracture(); fractureCollection->fractures.push_back(fracture); - fracture->setAnchorPosition(wellPathItem->m_pipeCenterlineIntersectionInDomainCoords); - fracture->measuredDepth = wellPathItem->m_measuredDepth; + fracture->setMeasuredDepth(wellPathItem->m_measuredDepth); RimOilField* oilfield = nullptr; objHandle->firstAncestorOrThisOfType(oilfield); diff --git a/ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp b/ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp index 38b561f753..5dab5540a1 100644 --- a/ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp +++ b/ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp @@ -63,7 +63,7 @@ void RicNewWellPathFractureFeature::onActionTriggered(bool isChecked) fractureCollection->fractures.push_back(fracture); float md_default = 0.0f; - fracture->measuredDepth = md_default; + fracture->setMeasuredDepth(md_default); RimWellPath* wellPath = nullptr; objHandle->firstAncestorOrThisOfType(wellPath); diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp index 6777903eae..2faaa14402 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp @@ -63,6 +63,10 @@ bool RicWellPathViewerEventHandler::handleEvent(cvf::Object* eventObject) cvf::Vec3d domainCoord = transForm->transformToDomainCoord(uiEvent->globalIntersectionPoint); double measuredDepth = wellPathSourceInfo->measuredDepth(uiEvent->firstPartTriangleIndex, domainCoord); + + // NOTE: This computation was used to find the location for a fracture when clicking on a well path + // It turned out that the computation was a bit inaccurate + // Consider to use code in RigSimulationWellCoordsAndMD instead cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->trueVerticalDepth(uiEvent->firstPartTriangleIndex, domainCoord); QString wellPathText; diff --git a/ApplicationCode/ProjectDataModel/RimWellPathFracture.cpp b/ApplicationCode/ProjectDataModel/RimWellPathFracture.cpp index 38cd1fd5d0..95dd90a0f5 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathFracture.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathFracture.cpp @@ -35,8 +35,8 @@ RimWellPathFracture::RimWellPathFracture(void) { CAF_PDM_InitObject("Fracture", ":/FractureSymbol16x16.png", "", ""); - CAF_PDM_InitField( &measuredDepth, "MeasuredDepth", 0.0f, "Measured Depth Location", "", "", ""); - measuredDepth.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); + CAF_PDM_InitField( &m_measuredDepth, "MeasuredDepth", 0.0f, "Measured Depth Location", "", "", ""); + m_measuredDepth.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); } //-------------------------------------------------------------------------------------------------- @@ -46,6 +46,24 @@ RimWellPathFracture::~RimWellPathFracture() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimWellPathFracture::measuredDepth() const +{ + return m_measuredDepth(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathFracture::setMeasuredDepth(double mdValue) +{ + m_measuredDepth = mdValue; + + updatePositionFromMeasuredDepth(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -53,28 +71,36 @@ void RimWellPathFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedFie { RimFracture::fieldChangedByUi(changedField, oldValue, newValue); - if (changedField == &measuredDepth) + if (changedField == &m_measuredDepth) { - cvf::Vec3d positionAtWellpath = cvf::Vec3d::ZERO; - - caf::PdmObjectHandle* objHandle = dynamic_cast(this); - if (!objHandle) return; + updatePositionFromMeasuredDepth(); - RimWellPath* wellPath = nullptr; - objHandle->firstAncestorOrThisOfType(wellPath); - if (!wellPath) return; - - RigWellPath* wellPathGeometry = wellPath->wellPathGeometry(); - positionAtWellpath = wellPathGeometry->interpolatedPointAlongWellPath(measuredDepth); - - this->setAnchorPosition(positionAtWellpath); - - RimProject* proj; + RimProject* proj = nullptr; this->firstAncestorOrThisOfType(proj); if (proj) proj->createDisplayModelAndRedrawAllViews(); } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathFracture::updatePositionFromMeasuredDepth() +{ + cvf::Vec3d positionAlongWellpath = cvf::Vec3d::ZERO; + + caf::PdmObjectHandle* objHandle = dynamic_cast(this); + if (!objHandle) return; + + RimWellPath* wellPath = nullptr; + objHandle->firstAncestorOrThisOfType(wellPath); + if (!wellPath) return; + + RigWellPath* wellPathGeometry = wellPath->wellPathGeometry(); + positionAlongWellpath = wellPathGeometry->interpolatedPointAlongWellPath(m_measuredDepth()); + + this->setAnchorPosition(positionAlongWellpath); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -82,7 +108,7 @@ void RimWellPathFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder { uiOrdering.add(&name); - uiOrdering.add(&measuredDepth); + uiOrdering.add(&m_measuredDepth); caf::PdmUiGroup* geometryGroup = uiOrdering.addNewGroup("Properties"); geometryGroup->add(&azimuth); @@ -100,7 +126,7 @@ void RimWellPathFracture::defineEditorAttribute(const caf::PdmFieldHandle* field { RimFracture::defineEditorAttribute(field, uiConfigName, attribute); - if (field == &measuredDepth) + if (field == &m_measuredDepth) { caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast(attribute); diff --git a/ApplicationCode/ProjectDataModel/RimWellPathFracture.h b/ApplicationCode/ProjectDataModel/RimWellPathFracture.h index 33e0ffaf6f..c70e2a0426 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathFracture.h +++ b/ApplicationCode/ProjectDataModel/RimWellPathFracture.h @@ -37,12 +37,18 @@ public: RimWellPathFracture(void); virtual ~RimWellPathFracture(void); - caf::PdmField measuredDepth; + double measuredDepth() const; + void setMeasuredDepth(double mdValue); - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; protected: - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; - virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) override; +private: + void updatePositionFromMeasuredDepth(); + +private: + caf::PdmField m_measuredDepth; };