diff --git a/ApplicationCode/Commands/RicViewerEventInterface.h b/ApplicationCode/Commands/RicViewerEventInterface.h index 3e5fba9b07..bb0cefc42a 100644 --- a/ApplicationCode/Commands/RicViewerEventInterface.h +++ b/ApplicationCode/Commands/RicViewerEventInterface.h @@ -30,6 +30,9 @@ namespace cvf { } +//================================================================================================== +/// +//================================================================================================== class RicViewerEventObject { public: @@ -44,6 +47,9 @@ public: }; +//================================================================================================== +/// +//================================================================================================== class RicViewerEventInterface { public: diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp index b6726a94a2..10b96ff7b5 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp @@ -22,6 +22,7 @@ #include "RiaApplication.h" #include "Rim3dView.h" +#include "RimPerforationInterval.h" #include "RimWellPath.h" #include "RiuMainWindow.h" @@ -56,18 +57,41 @@ bool RicWellPathViewerEventHandler::handleEvent(const RicViewerEventObject& even cvf::uint wellPathTriangleIndex = cvf::UNDEFINED_UINT; const RivWellPathSourceInfo* wellPathSourceInfo = nullptr; - if(eventObject.m_partAndTriangleIndexPairs.size() > 0) + if(!eventObject.m_partAndTriangleIndexPairs.empty()) { const auto & partAndTriangleIndexPair = eventObject.m_partAndTriangleIndexPairs.front(); const cvf::Part* part = partAndTriangleIndexPair.first; const RivObjectSourceInfo* sourceInfo = dynamic_cast(part->sourceInfo()); - if (!objectToSelect && sourceInfo) + if (sourceInfo) { - objectToSelect = sourceInfo->object(); + if (dynamic_cast(sourceInfo->object())) + { + objectToSelect = sourceInfo->object(); + + if (eventObject.m_partAndTriangleIndexPairs.size() > 1) + { + const auto& secondPair = eventObject.m_partAndTriangleIndexPairs[1]; + const cvf::Part* secondPickedPart = secondPair.first; + if (secondPickedPart) + { + auto wellPathSourceCandidate = dynamic_cast(secondPickedPart->sourceInfo()); + if (wellPathSourceCandidate) + { + RimWellPath* perforationWellPath = nullptr; + objectToSelect->firstAncestorOrThisOfType(perforationWellPath); + if (perforationWellPath == wellPathSourceCandidate->wellPath()) + { + wellPathSourceInfo = dynamic_cast(secondPickedPart->sourceInfo()); + wellPathTriangleIndex = secondPair.second; + } + } + } + } + } } - if (part && part->sourceInfo() && dynamic_cast(part->sourceInfo())) + if (part && dynamic_cast(part->sourceInfo())) { wellPathSourceInfo = dynamic_cast(part->sourceInfo()); wellPathTriangleIndex = partAndTriangleIndexPair.second; diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.h b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.h index 16dde93d89..a60d598229 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.h +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.h @@ -30,6 +30,6 @@ class RicWellPathViewerEventHandler : public RicViewerEventInterface public: static RicWellPathViewerEventHandler* instance(); - virtual bool handleEvent(const RicViewerEventObject& eventObject); + bool handleEvent(const RicViewerEventObject& eventObject) override; };