From c6ed12be923b2bfbf2b29349f40a1be7cf7c5f9f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 8 Jan 2026 13:58:56 +0100 Subject: [PATCH] Adds MSW name grouping pattern functionality Implements a new command to set the MSW grouping pattern, and ensures that the pattern is only updated if a new value is set. --- .../WellPath/RimWellPathCollection.cpp | 12 ++++++-- .../RimcWellPathCollection.cpp | 28 +++++++++++++++++++ .../RimcWellPathCollection.h | 16 +++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index 6e110ca985..c73c574acf 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -644,8 +644,16 @@ void RimWellPathCollection::deleteWell( RimWellPath* wellPath ) //-------------------------------------------------------------------------------------------------- void RimWellPathCollection::setMswWellPattern( const QString& pattern ) { - m_mswNameGrouping = MswGroupingMode::CUSTOM; - m_mswNameGroupingPattern = pattern; + if ( pattern.isEmpty() ) + { + m_mswNameGrouping = MswGroupingMode::DISABLED; + m_mswNameGroupingPattern = ""; + } + else + { + m_mswNameGrouping = MswGroupingMode::CUSTOM; + m_mswNameGroupingPattern = pattern; + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathCollection.cpp index a5fbb9a8cf..8af3aecb32 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathCollection.cpp @@ -182,3 +182,31 @@ QString RimcWellPathCollection_importWellPathFromPointsInternal::classKeywordRet { return RimPointBasedWellPath::classKeywordStatic(); } + +CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimWellPathCollection, RimcWellPathCollection_setMswNameGrouping, "setMswNameGrouping" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimcWellPathCollection_setMswNameGrouping::RimcWellPathCollection_setMswNameGrouping( caf::PdmObjectHandle* self ) + : caf::PdmVoidObjectMethod( self ) +{ + CAF_PDM_InitObject( "Set MSW Name Grouping" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_mswNameGrouping, "MswNameGrouping", "MSW Name Grouping" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::expected RimcWellPathCollection_setMswNameGrouping::execute() +{ + auto wellPathCollection = self(); + if ( !wellPathCollection ) + { + return std::unexpected( QString( "Well path collection is null. Cannot add well path." ) ); + } + + wellPathCollection->setMswWellPattern( m_mswNameGrouping() ); + + return nullptr; +} diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathCollection.h b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathCollection.h index 2e0a9974b0..e24e08e421 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathCollection.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathCollection.h @@ -63,3 +63,19 @@ private: caf::PdmField m_coordinateYKey; caf::PdmField m_coordinateZKey; }; + +//================================================================================================== +/// +//================================================================================================== +class RimcWellPathCollection_setMswNameGrouping : public caf::PdmVoidObjectMethod +{ + CAF_PDM_HEADER_INIT; + +public: + RimcWellPathCollection_setMswNameGrouping( caf::PdmObjectHandle* self ); + + std::expected execute() override; + +private: + caf::PdmField m_mswNameGrouping; +};