diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathPickEventHandler.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathPickEventHandler.cpp index 64929f8126..97deff362d 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathPickEventHandler.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathPickEventHandler.cpp @@ -26,6 +26,8 @@ #include "RimPerforationInterval.h" #include "RimWellMeasurement.h" #include "RimWellMeasurementCollection.h" +#include "RimWellMeasurementInView.h" +#include "RimWellMeasurementInViewCollection.h" #include "RimWellPath.h" #include "RimWellPathAttribute.h" #include "RimWellPathAttributeCollection.h" @@ -159,7 +161,23 @@ bool RicWellPathPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& event } RiuMainWindow::instance()->setResultInfo( measurementText ); - RiuMainWindow::instance()->selectAsCurrentItem( collection ); + + Rim3dView* rimView = RiaApplication::instance()->activeReservoirView(); + if ( rimView ) + { + // Find the RimWellMeasurementInView which matches the selection + std::vector wellMeasurementInViewCollections; + rimView->descendantsIncludingThisOfType( wellMeasurementInViewCollections ); + if ( !wellMeasurementInViewCollections.empty() ) + { + RimWellMeasurementInView* wellMeasurementInView = + wellMeasurementInViewCollections[0]->getWellMeasurementInView( measurement ); + if ( wellMeasurementInView ) + { + RiuMainWindow::instance()->selectAsCurrentItem( wellMeasurementInView ); + } + } + } } } diff --git a/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.cpp index 252e82d0b8..156fcf2901 100644 --- a/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.cpp @@ -142,3 +142,21 @@ void RimWellMeasurementInViewCollection::syncWithChangesInWellMeasurementCollect updateConnectedEditors(); } } + +//-------------------------------------------------------------------------------------------------- +/// Get the "in-view" measurement corresponding to a give measurement. +//-------------------------------------------------------------------------------------------------- +RimWellMeasurementInView* + RimWellMeasurementInViewCollection::getWellMeasurementInView( const RimWellMeasurement* measurement ) const +{ + for ( RimWellMeasurementInView* wellMeasurementInView : measurements() ) + { + if ( wellMeasurementInView->measurementKind() == measurement->kind() ) + { + return wellMeasurementInView; + } + } + + // No match + return nullptr; +} diff --git a/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.h b/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.h index e848f95415..010c84f151 100644 --- a/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.h +++ b/ApplicationCode/ProjectDataModel/RimWellMeasurementInViewCollection.h @@ -24,6 +24,7 @@ #include class RimWellMeasurementInView; +class RimWellMeasurement; class RimWellMeasurementInViewCollection : public RimCheckableNamedObject { @@ -37,6 +38,8 @@ public: void syncWithChangesInWellMeasurementCollection(); + RimWellMeasurementInView* getWellMeasurementInView( const RimWellMeasurement* measurement ) const; + protected: void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField,