From dc95b217c54aacd1fc0dedbe9d94cc00ee6ba452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 2 Jul 2018 14:51:17 +0200 Subject: [PATCH] #2609 Update the visualization when the well path geometry definition changes --- .../RicDeleteWellPathTargetFeature.cpp | 1 + .../RicNewWellPathListTargetFeature.cpp | 2 + .../ProjectDataModel/RimModeledWellPath.cpp | 89 +++++++++++++++++-- .../ProjectDataModel/RimModeledWellPath.h | 12 ++- .../ProjectDataModel/RimWellPathTarget.cpp | 19 +++- .../ProjectDataModel/RimWellPathTarget.h | 6 +- .../ReservoirDataModel/RigWellPath.h | 6 +- 7 files changed, 120 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/Commands/WellPathCommands/RicDeleteWellPathTargetFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicDeleteWellPathTargetFeature.cpp index f12f554ca4..b5e1e77d1f 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicDeleteWellPathTargetFeature.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicDeleteWellPathTargetFeature.cpp @@ -60,6 +60,7 @@ void RicDeleteWellPathTargetFeature::onActionTriggered(bool isChecked) } wellGeomDef->updateConnectedEditors(); + wellGeomDef->updateWellPathVisualization(); } } diff --git a/ApplicationCode/Commands/WellPathCommands/RicNewWellPathListTargetFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicNewWellPathListTargetFeature.cpp index 100b761c0f..966cdd3d6c 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicNewWellPathListTargetFeature.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicNewWellPathListTargetFeature.cpp @@ -65,6 +65,7 @@ void RicNewWellPathListTargetFeature::onActionTriggered(bool isChecked) wellGeomDef->insertTarget(targets[0], new RimWellPathTarget); wellGeomDef->updateConnectedEditors(); + wellGeomDef->updateWellPathVisualization(); return; } @@ -76,6 +77,7 @@ void RicNewWellPathListTargetFeature::onActionTriggered(bool isChecked) wellGeomDef->insertTarget(nullptr, new RimWellPathTarget); wellGeomDef->updateConnectedEditors(); + wellGeomDef->updateWellPathVisualization(); } } diff --git a/ApplicationCode/ProjectDataModel/RimModeledWellPath.cpp b/ApplicationCode/ProjectDataModel/RimModeledWellPath.cpp index 0e75e386f7..8e065b442e 100644 --- a/ApplicationCode/ProjectDataModel/RimModeledWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimModeledWellPath.cpp @@ -3,6 +3,12 @@ #include "RimWellPathTarget.h" #include "cafPdmUiTreeOrdering.h" #include "cafCmdFeatureMenuBuilder.h" +#include "RigWellPath.h" +#include "RimProject.h" +#include "cvfGeometryTools.h" +#include "cvfMatrix4.h" + +#include "RiaPolyArcLineSampler.h" CAF_PDM_SOURCE_INIT(RimModeledWellPath, "ModeledWellPath"); @@ -27,6 +33,17 @@ RimModeledWellPath::~RimModeledWellPath() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimModeledWellPath::updateWellPathVisualization() +{ + this->setWellPathGeometry(m_geometryDefinition->createWellPathGeometry().p()); + RimProject* proj; + this->firstAncestorOrThisOfTypeAsserted(proj); + proj->createDisplayModelAndRedrawAllViews(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -60,7 +77,7 @@ RimWellPathGeometryDef::RimWellPathGeometryDef() CAF_PDM_InitObject("Trajectory", ":/Well.png", "", ""); CAF_PDM_InitFieldNoDefault(&m_wellStartType, "WellStartType", "Start Type", "", "", ""); - CAF_PDM_InitField(&m_startPos, "StartPos", cvf::Vec3d(0,0,0), "UTM Start Pos", "", "", ""); + CAF_PDM_InitField(&m_referencePoint, "ReferencePos", cvf::Vec3d(0,0,0), "UTM Reference Point", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_parentWell, "ParentWell", "Parent Well", "", "", ""); CAF_PDM_InitField(&m_kickoffDepthOrMD, "KickoffDepthOrMD", 100.0, "Kickoff Depth", "", "", ""); @@ -84,6 +101,50 @@ RimWellPathGeometryDef::~RimWellPathGeometryDef() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RimWellPathGeometryDef::createWellPathGeometry() +{ + cvf::ref wellPathGeometry = new RigWellPath; + + if (m_wellTargets.size() < 2) return wellPathGeometry; + + RiaPolyArcLineSampler arcLineSampler(lineArcEndpoints()); + + arcLineSampler.sampledPointsAndMDs(30, + false, + &(wellPathGeometry->m_wellPathPoints), + &(wellPathGeometry->m_measuredDepths)); + #if 0 + + double md = 0.0; + wellPathGeometry->m_wellPathPoints.push_back(m_referencePoint() + m_wellTargets[0]->targetPointXYZ()); + wellPathGeometry->m_measuredDepths.push_back(md); + + for (size_t tIdx = 1; tIdx < m_wellTargets.size(); ++tIdx) + { + cvf::Vec3d p1 = wellPathGeometry->m_wellPathPoints.back(); + RimWellPathTarget* target = m_wellTargets[tIdx]; + wellPathGeometry->m_wellPathPoints.push_back(m_referencePoint() + target->targetPointXYZ()); + cvf::Vec3d p2 = wellPathGeometry->m_wellPathPoints.back(); + md += (p2 - p1).length(); + wellPathGeometry->m_measuredDepths.push_back( md ); + } + #endif + return wellPathGeometry; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathGeometryDef::updateWellPathVisualization() +{ + RimModeledWellPath* modWellPath; + this->firstAncestorOrThisOfTypeAsserted(modWellPath); + modWellPath->updateWellPathVisualization(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -106,12 +167,16 @@ void RimWellPathGeometryDef::deleteTarget(RimWellPathTarget* targetTodelete) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellPathGeometryDef::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimWellPathGeometryDef::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) { - if (&m_startPos == changedField) + if (&m_referencePoint == changedField) { std::cout << "fieldChanged" << std::endl; } + + updateWellPathVisualization(); } //-------------------------------------------------------------------------------------------------- @@ -129,11 +194,11 @@ void RimWellPathGeometryDef::defineUiOrdering(QString uiConfigName, caf::PdmUiOr if (m_wellStartType == START_AT_SURFACE) { - uiOrdering.add(&m_startPos); - m_kickoffDepthOrMD.uiCapability()->setUiName("Kick Off Depth"); + m_kickoffDepthOrMD.uiCapability()->setUiName("Kick-Off Depth"); uiOrdering.add(&m_kickoffDepthOrMD); } + uiOrdering.add(&m_referencePoint); uiOrdering.add(&m_wellTargets); uiOrdering.skipRemainingFields(true); } @@ -146,6 +211,20 @@ void RimWellPathGeometryDef::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTree uiTreeOrdering.skipRemainingChildren(true); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimWellPathGeometryDef::lineArcEndpoints() +{ + std::vector endPoints; + for (RimWellPathTarget* target: m_wellTargets) + { + endPoints.push_back( target->targetPointXYZ() + m_referencePoint() ); + } + + return endPoints; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimModeledWellPath.h b/ApplicationCode/ProjectDataModel/RimModeledWellPath.h index bfd4dd10ad..fbc181cb99 100644 --- a/ApplicationCode/ProjectDataModel/RimModeledWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimModeledWellPath.h @@ -37,6 +37,8 @@ public: RimModeledWellPath(); ~RimModeledWellPath(); + void updateWellPathVisualization(); + private: @@ -57,17 +59,22 @@ public: enum WellStartType { START_AT_FIRST_TARGET, START_AT_SURFACE, START_FROM_OTHER_WELL, START_AT_AUTO_SURFACE }; + cvf::ref createWellPathGeometry(); + + void updateWellPathVisualization(); + void insertTarget(RimWellPathTarget* targetToInsertBefore, RimWellPathTarget* targetToInsert); void deleteTarget(RimWellPathTarget* targetTodelete); - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) 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; virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) override; + std::vector lineArcEndpoints(); caf::PdmField > m_wellStartType; - caf::PdmField m_startPos; + caf::PdmField m_referencePoint; caf::PdmField m_kickoffDepthOrMD; caf::PdmPtrField m_parentWell; @@ -80,3 +87,4 @@ protected: QWidget* fieldEditorWidget) override; }; + diff --git a/ApplicationCode/ProjectDataModel/RimWellPathTarget.cpp b/ApplicationCode/ProjectDataModel/RimWellPathTarget.cpp index a47d847409..d7b118452b 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathTarget.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathTarget.cpp @@ -1,4 +1,5 @@ #include "RimWellPathTarget.h" +#include "RimModeledWellPath.h" CAF_PDM_SOURCE_INIT(RimWellPathTarget, "WellPathTarget"); @@ -41,7 +42,7 @@ RimWellPathTarget::~RimWellPathTarget() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellPathTarget::setAsPointTarget(const cvf::Vec3d& point) +void RimWellPathTarget::setAsPointTargetXYD(const cvf::Vec3d& point) { m_targetType = POINT; m_targetPoint = point; @@ -73,9 +74,11 @@ RimWellPathTarget::TargetTypeEnum RimWellPathTarget::targetType() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Vec3d RimWellPathTarget::targetPoint() +cvf::Vec3d RimWellPathTarget::targetPointXYZ() { - return m_targetPoint(); + cvf::Vec3d xyzPoint(m_targetPoint()); + xyzPoint.z() = -xyzPoint.z(); + return xyzPoint; } //-------------------------------------------------------------------------------------------------- @@ -107,3 +110,13 @@ double RimWellPathTarget::inclination() return std::numeric_limits::infinity(); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathTarget::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + RimModeledWellPath* wellPath; + firstAncestorOrThisOfTypeAsserted(wellPath); + wellPath->updateWellPathVisualization(); +} diff --git a/ApplicationCode/ProjectDataModel/RimWellPathTarget.h b/ApplicationCode/ProjectDataModel/RimWellPathTarget.h index 49157374a2..78d3e1caa2 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathTarget.h +++ b/ApplicationCode/ProjectDataModel/RimWellPathTarget.h @@ -32,16 +32,18 @@ public: RimWellPathTarget(); ~RimWellPathTarget(); - void setAsPointTarget(const cvf::Vec3d& point); + void setAsPointTargetXYD(const cvf::Vec3d& point); void setAsPointAndTangentTarget(const cvf::Vec3d& point, double azimuth, double inclination); enum TargetTypeEnum { POINT_AND_TANGENT, POINT }; TargetTypeEnum targetType(); - cvf::Vec3d targetPoint(); + cvf::Vec3d targetPointXYZ(); double azimuth(); double inclination(); private: + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + caf::PdmField m_isEnabled; caf::PdmField > m_targetType; caf::PdmField m_targetPoint; diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.h b/ApplicationCode/ReservoirDataModel/RigWellPath.h index aa5a3caba8..e2186d4978 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.h @@ -40,6 +40,9 @@ public: std::vector m_wellPathPoints; std::vector m_measuredDepths; + const std::vector& wellPathPoints() const; + const std::vector& measureDepths() const; + RigWellPath(); void setDatumElevation(double value); bool hasDatumElevation() const; @@ -67,9 +70,6 @@ public: double maxZ, double * horizontalLengthAlongWellToClipPoint, size_t * indexToFirstVisibleSegment); - const std::vector& wellPathPoints() const; - const std::vector& measureDepths() const; - private: bool m_hasDatumElevation; double m_datumElevation;