Refactor: use new base class WellLog where possible.

This commit is contained in:
Kristian Bendiksen
2024-05-29 10:57:59 +02:00
parent a0ebb6e496
commit 0477371e0d
10 changed files with 81 additions and 51 deletions

View File

@@ -131,7 +131,7 @@ RimWellPath::RimWellPath()
CAF_PDM_InitScriptableFieldNoDefault( &m_completionSettings, "CompletionSettings", "Completion Settings" );
m_completionSettings = new RimWellPathCompletionSettings;
CAF_PDM_InitFieldNoDefault( &m_wellLogFiles, "WellLogFiles", "Well Log Files" );
CAF_PDM_InitFieldNoDefault( &m_wellLogs, "WellLogFiles", "Well Logs" );
CAF_PDM_InitFieldNoDefault( &m_3dWellLogCurves, "CollectionOf3dWellLogCurves", "3D Track" );
m_3dWellLogCurves = new Rim3dWellLogCurveCollection;
@@ -161,9 +161,9 @@ RimWellPath::RimWellPath()
//--------------------------------------------------------------------------------------------------
RimWellPath::~RimWellPath()
{
for ( const auto& file : m_wellLogFiles() )
for ( const auto& wellLog : m_wellLogs() )
{
delete file;
delete wellLog;
}
RimWellLogPlotCollection* plotCollection = RimMainPlotCollection::current()->wellLogPlotCollection();
@@ -577,7 +577,24 @@ void RimWellPath::setNameNoUpdateOfExportName( const QString& name )
//--------------------------------------------------------------------------------------------------
std::vector<RimWellLogFile*> RimWellPath::wellLogFiles() const
{
return std::vector<RimWellLogFile*>( m_wellLogFiles.begin(), m_wellLogFiles.end() );
std::vector<RimWellLogFile*> wellLogFiles;
for ( RimWellLog* wellLog : m_wellLogs )
{
if ( auto wellLogFile = dynamic_cast<RimWellLogFile*>( wellLog ) )
{
wellLogFiles.push_back( wellLogFile );
}
}
return wellLogFiles;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimWellLog*> RimWellPath::wellLogs() const
{
return m_wellLogs.childrenByType();
}
//--------------------------------------------------------------------------------------------------
@@ -585,11 +602,9 @@ std::vector<RimWellLogFile*> RimWellPath::wellLogFiles() const
//--------------------------------------------------------------------------------------------------
RimWellLogFile* RimWellPath::firstWellLogFileMatchingChannelName( const QString& channelName ) const
{
std::vector<RimWellLogFile*> allWellLogFiles = wellLogFiles();
for ( RimWellLogFile* logFile : allWellLogFiles )
for ( RimWellLogFile* logFile : wellLogFiles() )
{
std::vector<RimWellLogChannel*> channels = logFile->wellLogChannels();
for ( RimWellLogChannel* channel : channels )
for ( RimWellLogChannel* channel : logFile->wellLogChannels() )
{
if ( channel->name() == channelName )
{
@@ -597,6 +612,7 @@ RimWellLogFile* RimWellPath::firstWellLogFileMatchingChannelName( const QString&
}
}
}
return nullptr;
}
@@ -745,7 +761,7 @@ void RimWellPath::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& ui
//--------------------------------------------------------------------------------------------------
void RimWellPath::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName )
{
uiTreeOrdering.add( &m_wellLogFiles );
uiTreeOrdering.add( &m_wellLogs );
if ( m_wellIASettingsCollection()->isEnabled() && m_wellIASettingsCollection()->hasSettings() )
{
@@ -892,47 +908,58 @@ double RimWellPath::datumElevation() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPath::addWellLogFile( RimWellLogFile* logFileInfo )
void RimWellPath::addWellLog( RimWellLog* wellLog )
{
// Prevent the same file from being loaded more than once
auto itr = std::find_if( m_wellLogFiles.begin(),
m_wellLogFiles.end(),
[&]( const RimWellLogFile* file )
{ return QString::compare( file->fileName(), logFileInfo->fileName(), Qt::CaseInsensitive ) == 0; } );
// Todo: Verify well name to ensure all well log files having the same well name
if ( itr == m_wellLogFiles.end() )
if ( RimWellLogFile* wellLogFile = dynamic_cast<RimWellLogFile*>( wellLog ) )
{
m_wellLogFiles.push_back( logFileInfo );
// Prevent the same file from being loaded more than once
auto itr =
std::find_if( m_wellLogs.begin(),
m_wellLogs.end(),
[&]( const RimWellLog* existingWellLog )
{
auto existingWellLogFile = dynamic_cast<const RimWellLogFile*>( existingWellLog );
return existingWellLogFile &&
QString::compare( existingWellLogFile->fileName(), wellLogFile->fileName(), Qt::CaseInsensitive ) == 0;
} );
if ( m_wellLogFiles.size() == 1 && name().isEmpty() )
// Todo: Verify well name to ensure all well log files having the same well name
if ( itr == m_wellLogs.end() )
{
setName( m_wellLogFiles[0]->wellName() );
m_wellLogs.push_back( wellLog );
if ( m_wellLogs.size() == 1 && name().isEmpty() )
{
setName( m_wellLogs[0]->wellName() );
}
}
}
else
{
m_wellLogs.push_back( osduWellLog );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPath::deleteWellLogFile( RimWellLogFile* logFileInfo )
void RimWellPath::deleteWellLog( RimWellLog* wellLog )
{
detachWellLogFile( logFileInfo );
delete logFileInfo;
detachWellLog( wellLog );
delete wellLog;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPath::detachWellLogFile( RimWellLogFile* logFileInfo )
void RimWellPath::detachWellLog( RimWellLog* wellLog )
{
auto pdmObject = dynamic_cast<caf::PdmObjectHandle*>( logFileInfo );
for ( size_t i = 0; i < m_wellLogFiles.size(); i++ )
auto pdmObject = dynamic_cast<caf::PdmObjectHandle*>( wellLog );
for ( size_t i = 0; i < m_wellLogs.size(); i++ )
{
if ( m_wellLogFiles[i] == pdmObject )
if ( m_wellLogs[i] == pdmObject )
{
m_wellLogFiles.removeChild( pdmObject );
m_wellLogs.removeChild( pdmObject );
break;
}
}

View File

@@ -62,6 +62,7 @@ class RimWellPathTieIn;
class RimMswCompletionParameters;
class RimWellIASettingsCollection;
class RimWellLogFile;
class RimWellLog;
//==================================================================================================
///
@@ -105,11 +106,13 @@ public:
double uniqueStartMD() const;
double uniqueEndMD() const;
void addWellLogFile( RimWellLogFile* logFileInfo );
void deleteWellLogFile( RimWellLogFile* logFileInfo );
void detachWellLogFile( RimWellLogFile* logFileInfo );
void addWellLog( RimWellLog* wellLog );
void deleteWellLog( RimWellLog* wellLog );
void detachWellLog( RimWellLog* wellLog );
std::vector<RimWellLogFile*> wellLogFiles() const;
RimWellLogFile* firstWellLogFileMatchingChannelName( const QString& channelName ) const;
std::vector<RimWellLog*> wellLogs() const;
RimWellLogFile* firstWellLogFileMatchingChannelName( const QString& channelName ) const;
void setFormationsGeometry( cvf::ref<RigWellPathFormations> wellPathFormations );
bool readWellPathFormationsFile( QString* errorMessage, RifWellPathFormationsImporter* wellPathFormationsImporter );
@@ -210,7 +213,7 @@ private:
caf::PdmField<double> m_wellPathRadiusScaleFactor;
caf::PdmField<cvf::Color3f> m_wellPathColor;
caf::PdmChildArrayField<RimWellLogFile*> m_wellLogFiles;
caf::PdmChildArrayField<RimWellLog*> m_wellLogs;
caf::PdmChildField<Rim3dWellLogCurveCollection*> m_3dWellLogCurves;
caf::PdmChildField<RimWellPathCompletionSettings*> m_completionSettings;
caf::PdmChildField<RimWellPathCompletions*> m_completions;

View File

@@ -405,7 +405,7 @@ std::vector<RimWellLogLasFile*> RimWellPathCollection::addWellLogs( const QStrin
addWellPath( wellPath );
}
wellPath->addWellLogFile( logFileInfo );
wellPath->addWellLog( logFileInfo );
logFileInfos.push_back( logFileInfo );
}
}
@@ -421,7 +421,7 @@ std::vector<RimWellLogLasFile*> RimWellPathCollection::addWellLogs( const QStrin
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::addWellLog( RimWellLogFile* wellLogFile, RimWellPath* wellPath )
{
wellPath->addWellLogFile( wellLogFile );
wellPath->addWellLog( wellLogFile );
sortWellsByName();
updateAllRequiredEditors();
}