From a8fbb4f70e9c9f9ef57f81f9176709ee19e7c36b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 8 Sep 2022 16:14:05 +0200 Subject: [PATCH] Fix missing update of export well name --- .../Application/Tools/RiaWellNameComparer.cpp | 12 ++++++++++++ .../Application/Tools/RiaWellNameComparer.h | 2 ++ .../RicPasteModeledWellPathFeature.cpp | 2 +- .../Completions/RimWellPathCompletionSettings.cpp | 13 ++++++++----- .../ProjectDataModel/WellPath/RimWellPathGroup.cpp | 5 ++--- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/RiaWellNameComparer.cpp b/ApplicationLibCode/Application/Tools/RiaWellNameComparer.cpp index 82270e82c5..b2fcd9849b 100644 --- a/ApplicationLibCode/Application/Tools/RiaWellNameComparer.cpp +++ b/ApplicationLibCode/Application/Tools/RiaWellNameComparer.cpp @@ -102,6 +102,18 @@ void RiaWellNameComparer::clearCache() sm_matchedName.clear(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaWellNameComparer::removeSpacesFromName( const QString& wellName ) +{ + // Eclipse do not support spaces in names in text files. Use this function whenever a string is used in export to + // text files for Eclipse + + QString tmp = wellName; + return tmp.remove( ' ' ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaWellNameComparer.h b/ApplicationLibCode/Application/Tools/RiaWellNameComparer.h index 0a3c2a85d5..141851a6d7 100644 --- a/ApplicationLibCode/Application/Tools/RiaWellNameComparer.h +++ b/ApplicationLibCode/Application/Tools/RiaWellNameComparer.h @@ -38,6 +38,8 @@ public: static void clearCache(); + static QString removeSpacesFromName( const QString& wellName ); + private: static QString tryMatchName( QString searchName, const std::vector& nameList, diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicPasteModeledWellPathFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicPasteModeledWellPathFeature.cpp index 5dd78516c3..f66177898f 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicPasteModeledWellPathFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicPasteModeledWellPathFeature.cpp @@ -152,7 +152,7 @@ RimModeledWellPath* RicPasteModeledWellPathFeature::duplicateAndInitializeWellPa auto* destinationWellPath = dynamic_cast( sourceWellPath->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - QString name = sourceWellPath->name() + " (copy)"; + QString name = sourceWellPath->name() + "(copy)"; destinationWellPath->setName( name ); wpc->addWellPath( destinationWellPath, false ); diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp index ce1fc8fdca..5c9b0148cb 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp @@ -18,9 +18,11 @@ #include "RimWellPathCompletionSettings.h" #include "RiaStdStringTools.h" -#include "RimMswCompletionParameters.h" +#include "RiaWellNameComparer.h" +#include "RimMswCompletionParameters.h" #include "RimWellPath.h" + #include "cafPdmDoubleStringValidator.h" #include "cafPdmUiLineEditor.h" #include "cafPdmUiOrdering.h" @@ -131,8 +133,7 @@ RimWellPathCompletionSettings& RimWellPathCompletionSettings::operator=( const R //-------------------------------------------------------------------------------------------------- void RimWellPathCompletionSettings::setWellNameForExport( const QString& name ) { - auto n = name; - m_wellNameForExport = n.remove( ' ' ); + m_wellNameForExport = RiaWellNameComparer::removeSpacesFromName( name ); } //-------------------------------------------------------------------------------------------------- @@ -141,9 +142,11 @@ void RimWellPathCompletionSettings::setWellNameForExport( const QString& name ) void RimWellPathCompletionSettings::updateWellPathNameHasChanged( const QString& newWellPathName, const QString& previousWellPathName ) { - if ( m_wellNameForExport().isEmpty() || m_wellNameForExport == previousWellPathName ) + auto previousWellNameWithoutSpaces = RiaWellNameComparer::removeSpacesFromName( previousWellPathName ); + + if ( m_wellNameForExport().isEmpty() || m_wellNameForExport == previousWellNameWithoutSpaces ) { - m_wellNameForExport = newWellPathName; + setWellNameForExport( newWellPathName ); } } diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGroup.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGroup.cpp index 3bdc04eab8..3c8e971052 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGroup.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGroup.cpp @@ -18,6 +18,7 @@ #include "RimWellPathGroup.h" #include "RiaTextStringTools.h" +#include "RiaWellNameComparer.h" #include "RigWellPath.h" #include "RimModeledWellPath.h" @@ -326,9 +327,7 @@ QString RimWellPathGroup::createGroupName() const } fullName += trimmedCommonSuffix; - QString nameWithoutSpaces = fullName; - nameWithoutSpaces.remove( ' ' ); - + QString nameWithoutSpaces = RiaWellNameComparer::removeSpacesFromName( fullName ); if ( nameWithoutSpaces.length() > 8 ) fullName = trimmedCommonRoot + trimmedCommonSuffix; if ( fullName.isEmpty() ) fullName = "Well 1";