diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index 6a0216e485..b605ea648f 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -25,6 +25,7 @@ #include "RimIntersection.h" #include "RivHexGridIntersectionTools.h" +#include "RivIntersectionPartMgr.h" #include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h" @@ -603,6 +604,41 @@ RimIntersection* RivIntersectionGeometryGenerator::crossSection() const return m_crossSection; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Mat4d RivIntersectionGeometryGenerator::unflattenTransformMatrix(const cvf::Vec3d& intersectionPointUtm) +{ + cvf::Vec3d startPt = cvf::Vec3d::ZERO; + + int polyLineIdx = -1; + int segIdx = -1; + for (int i = 0; i < m_flattenedOrOffsettedPolyLines.size(); i++) + { + std::vector pts = m_flattenedOrOffsettedPolyLines[i]; + for(int j = 0; j < pts.size(); j++) + { + // Assumes ascending sorted list + if (j > 0 && intersectionPointUtm.x() < pts[j].x()) + { + polyLineIdx = i; + segIdx = j - 1; + startPt = pts[segIdx]; + break; + } + } + + if (!startPt.isZero()) break; + } + + if (polyLineIdx > -1 && segIdx > -1) + { + cvf::Mat4d t = m_segementTransformPrLinePoint[polyLineIdx][segIdx]; + return t.getInverted(); // Check for invertible? + } + return cvf::Mat4d::ZERO; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h index edf1676894..e92cb0b41d 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h @@ -75,6 +75,8 @@ public: RimIntersection* crossSection() const; + cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointUtm); + private: void calculateArrays(); void calculateSegementTransformPrLinePoint(); diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 1139025620..ca794d6b73 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -967,6 +967,14 @@ const RimIntersection* RivIntersectionPartMgr::intersection() const return m_rimCrossSection.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Mat4d RivIntersectionPartMgr::unflattenTransformMatrix(const cvf::Vec3d& intersectionPointUtm) +{ + return m_crossSectionGenerator->unflattenTransformMatrix(intersectionPointUtm); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h index 6527c970f2..933532b5b3 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h @@ -24,6 +24,8 @@ #include "cvfColor4.h" #include "cvfVector3.h" #include "cvfArray.h" +#include "cvfMatrix4.h" + #include "cafPdmPointer.h" #include @@ -74,6 +76,7 @@ public: const RimIntersection* intersection() const; + cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointUtm); public: static void calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords, diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 13a65aada3..4ed2befb49 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -19,10 +19,10 @@ #pragma once #include "Rim3dView.h" +#include "RivIntersectionPartMgr.h" #include "cafPdmPtrField.h" class RimIntersection; -class RivIntersectionPartMgr; class RimLegendConfig; class RimTernaryLegendConfig; @@ -58,6 +58,8 @@ public: void update3dInfo(); + cvf::ref flatIntersectionPartMgr() const { return m_flatIntersectionPartMgr; } + protected: void updateLegends(); diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp index e9d8584d96..343fd71bc8 100644 --- a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp @@ -29,6 +29,7 @@ #include "RimGeoMechCase.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" +#include "Rim2dIntersectionView.h" #include "RiuGeoMechXfTensorResultAccessor.h" @@ -70,6 +71,14 @@ void RiuFemResultTextBuilder::setIntersectionTriangle(const std::arrayflatIntersectionPartMgr()->unflattenTransformMatrix(m_intersectionPoint); + if (!t.isZero()) + { + cvf::Vec3d intPt = m_intersectionPoint.getTransformedPoint(t); + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", intPt.x(), intPt.y(), -intPt.z()); + text += formattedText; + } + } + else + { + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); + text += formattedText; + } } } } diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h index dd81d9bea0..9754516c9d 100644 --- a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h @@ -30,6 +30,7 @@ class RigGeoMechCaseData; class RimEclipseCellColors; class RimGeoMechResultDefinition; class RimGeoMechView; +class Rim2dIntersectionView; namespace cvf { class Part; @@ -46,6 +47,7 @@ public: void setFace(int face); void setIntersectionPoint(cvf::Vec3d intersectionPoint); void setIntersectionTriangle(const std::array& triangle); + void set2dIntersectionView(Rim2dIntersectionView* intersectionView); QString mainResultText(); @@ -63,6 +65,7 @@ private: private: caf::PdmPointer m_reservoirView; + caf::PdmPointer m_2dIntersectionView; int m_gridIndex; int m_cellIndex; diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp index 9adf6ff8b6..bc7af30898 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp @@ -27,6 +27,8 @@ #include "RigResultAccessorFactory.h" #include "RigSimWellData.h" +#include "Rim2dIntersectionView.h" +#include "RimIntersection.h" #include "RimCellEdgeColors.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" @@ -36,6 +38,8 @@ #include "RimLegendConfig.h" #include "RimReservoirCellResultsStorage.h" +#include "RivIntersectionPartMgr.h" + #include "cafDisplayCoordTransform.h" @@ -73,6 +77,14 @@ void RiuResultTextBuilder::setIntersectionPoint(cvf::Vec3d intersectionPoint) m_intersectionPoint = intersectionPoint; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuResultTextBuilder::set2dIntersectionView(Rim2dIntersectionView* intersectionView) +{ + m_2dIntersectionView = intersectionView; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -177,9 +189,24 @@ QString RiuResultTextBuilder::geometrySelectionText(QString itemSeparator) cvf::Vec3d domainCoord = transForm->translateToDomainCoord(m_intersectionPoint); QString formattedText; - formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); + if (m_2dIntersectionView) + { + formattedText.sprintf("Horizontal length from well start: %.2f", domainCoord.x()); + text += formattedText + itemSeparator; - text += formattedText; + cvf::Mat4d t = m_2dIntersectionView->flatIntersectionPartMgr()->unflattenTransformMatrix(m_intersectionPoint); + if (!t.isZero()) + { + cvf::Vec3d intPt = m_intersectionPoint.getTransformedPoint(t); + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", intPt.x(), intPt.y(), -intPt.z()); + text += formattedText; + } + } + else + { + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); + text += formattedText; + } } } diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.h b/ApplicationCode/UserInterface/RiuResultTextBuilder.h index 7f58c8eaad..b3464529c6 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.h +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.h @@ -26,6 +26,7 @@ class RimEclipseView; class RimEclipseCellColors; +class Rim2dIntersectionView; class QString; class RigEclipseCaseData; @@ -44,6 +45,7 @@ public: void setFace(cvf::StructGridInterface::FaceType face); void setNncIndex(size_t nncIndex); void setIntersectionPoint(cvf::Vec3d intersectionPoint); + void set2dIntersectionView(Rim2dIntersectionView* intersectionView); QString mainResultText(); @@ -69,6 +71,7 @@ private: private: caf::PdmPointer m_reservoirView; + caf::PdmPointer m_2dIntersectionView; size_t m_gridIndex; size_t m_cellIndex; diff --git a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp index 40818f6243..2652a71052 100644 --- a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -310,9 +310,12 @@ void RiuSelectionChangedHandler::updateResultInfo(const RiuSelectionItem* itemAd RiuSelectionItem* selItem = const_cast(itemAdded); if (selItem != NULL) { + Rim2dIntersectionView* intersectionView = nullptr; + if (selItem->type() == RiuSelectionItem::INTERSECTION_SELECTION_OBJECT) { const Riu2dIntersectionSelectionItem* wrapperSelItem = dynamic_cast(selItem); + intersectionView = wrapperSelItem->view(); if (wrapperSelItem && wrapperSelItem->eclipseSelectionItem()) selItem = wrapperSelItem->eclipseSelectionItem(); else if (wrapperSelItem && wrapperSelItem->geoMechSelectionItem()) selItem = wrapperSelItem->geoMechSelectionItem(); } @@ -327,6 +330,7 @@ void RiuSelectionChangedHandler::updateResultInfo(const RiuSelectionItem* itemAd textBuilder.setFace(eclipseSelectionItem->m_face); textBuilder.setNncIndex(eclipseSelectionItem->m_nncIndex); textBuilder.setIntersectionPoint(eclipseSelectionItem->m_localIntersectionPoint); + textBuilder.set2dIntersectionView(intersectionView); resultInfo = textBuilder.mainResultText(); @@ -340,6 +344,7 @@ void RiuSelectionChangedHandler::updateResultInfo(const RiuSelectionItem* itemAd RiuFemResultTextBuilder textBuilder(geomView, (int)geomSelectionItem->m_gridIndex, (int)geomSelectionItem->m_cellIndex, geomView->currentTimeStep()); textBuilder.setIntersectionPoint(geomSelectionItem->m_localIntersectionPoint); textBuilder.setFace(geomSelectionItem->m_elementFace); + textBuilder.set2dIntersectionView(intersectionView); if (geomSelectionItem->m_hasIntersectionTriangle) textBuilder.setIntersectionTriangle(geomSelectionItem->m_intersectionTriangle); resultInfo = textBuilder.mainResultText(); diff --git a/ApplicationCode/UserInterface/RiuSelectionManager.cpp b/ApplicationCode/UserInterface/RiuSelectionManager.cpp index 2406531454..ca10deb431 100644 --- a/ApplicationCode/UserInterface/RiuSelectionManager.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionManager.cpp @@ -218,8 +218,9 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem(RimGeoMechView* view, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Riu2dIntersectionSelectionItem::Riu2dIntersectionSelectionItem(RiuSelectionItem *selItem) +Riu2dIntersectionSelectionItem::Riu2dIntersectionSelectionItem(Rim2dIntersectionView* view, RiuSelectionItem *selItem) { + m_view = view; m_eclipseSelItem = dynamic_cast(selItem); m_geoMechSelItem = dynamic_cast(selItem); } @@ -233,6 +234,14 @@ Riu2dIntersectionSelectionItem::~Riu2dIntersectionSelectionItem() if (m_geoMechSelItem) delete m_geoMechSelItem; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmPointer Riu2dIntersectionSelectionItem::view() const +{ + return m_view; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuSelectionManager.h b/ApplicationCode/UserInterface/RiuSelectionManager.h index 3b731731a5..a736bc5a61 100644 --- a/ApplicationCode/UserInterface/RiuSelectionManager.h +++ b/ApplicationCode/UserInterface/RiuSelectionManager.h @@ -206,7 +206,7 @@ public: class Riu2dIntersectionSelectionItem : public RiuSelectionItem { public: - explicit Riu2dIntersectionSelectionItem(RiuSelectionItem *selItem); + explicit Riu2dIntersectionSelectionItem(Rim2dIntersectionView* view, RiuSelectionItem *selItem); virtual ~Riu2dIntersectionSelectionItem(); @@ -216,10 +216,12 @@ public: } public: + caf::PdmPointer view() const; RiuEclipseSelectionItem* eclipseSelectionItem() const; RiuGeoMechSelectionItem* geoMechSelectionItem() const; private: + caf::PdmPointer m_view; RiuEclipseSelectionItem* m_eclipseSelItem; RiuGeoMechSelectionItem* m_geoMechSelItem; }; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index f70fff7fa4..5af5b8f1c9 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -654,7 +654,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM else selItem = new RiuGeoMechSelectionItem(geomView, gridIndex, cellIndex, curveColor, gmFace, localIntersectionPoint); } - if (intersectionView) selItem = new Riu2dIntersectionSelectionItem(selItem); + if (intersectionView) selItem = new Riu2dIntersectionSelectionItem(intersectionView, selItem); } if (appendToSelection)