mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Refactor: use new base class WellLog where possible.
This commit is contained in:
@@ -74,7 +74,7 @@ void RicImportWellLogCsvFileFeature::onActionTriggered( bool isChecked )
|
||||
QString errorMessage;
|
||||
if ( !wellLogCsvFile->readFile( &errorMessage ) )
|
||||
{
|
||||
wellPath->deleteWellLogFile( wellLogCsvFile );
|
||||
wellPath->deleteWellLog( wellLogCsvFile );
|
||||
QString displayMessage = "Errors opening the CSV file: \n" + errorMessage;
|
||||
RiaLogging::errorInMessageBox( Riu3DMainWindowTools::mainWindowWidget(), "File open error", displayMessage );
|
||||
return;
|
||||
|
||||
@@ -160,14 +160,14 @@ void RicWellLogTools::addWellLogChannelsToPlotTrack( RimWellLogTrack* plotTrack,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellPath* RicWellLogTools::selectedWellPathWithLogFile()
|
||||
RimWellPath* RicWellLogTools::selectedWellPathWithLog()
|
||||
{
|
||||
std::vector<RimWellPath*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType( &selection );
|
||||
if ( !selection.empty() )
|
||||
{
|
||||
RimWellPath* wellPath = selection[0];
|
||||
if ( !wellPath->wellLogFiles().empty() )
|
||||
if ( !wellPath->wellLogs().empty() )
|
||||
{
|
||||
return wellPath;
|
||||
}
|
||||
@@ -179,10 +179,10 @@ RimWellPath* RicWellLogTools::selectedWellPathWithLogFile()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellPath* RicWellLogTools::findWellPathWithLogFileFromSelection()
|
||||
RimWellPath* RicWellLogTools::findWellPathWithLogFromSelection()
|
||||
{
|
||||
RimWellPath* wellPath = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPath>();
|
||||
if ( wellPath && !wellPath->wellLogFiles().empty() )
|
||||
if ( wellPath && !wellPath->wellLogs().empty() )
|
||||
{
|
||||
return wellPath;
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ public:
|
||||
static bool hasRftDataForWell( const QString& wellName );
|
||||
static bool isWellPathOrSimWellSelectedInView();
|
||||
static void addWellLogChannelsToPlotTrack( RimWellLogTrack* plotTrack, const std::vector<RimWellLogChannel*>& wellLogFileChannels );
|
||||
static RimWellPath* selectedWellPathWithLogFile();
|
||||
static RimWellPath* findWellPathWithLogFileFromSelection();
|
||||
static RimWellPath* selectedWellPathWithLog();
|
||||
static RimWellPath* findWellPathWithLogFromSelection();
|
||||
static RimWellLogRftCurve* addRftCurve( RimWellLogTrack* plotTrack, const RimSimWellInView* simWell, bool showPlotWindow = true );
|
||||
static RimWellLogLasFileCurve* addFileCurve( RimWellLogTrack* plotTrack, bool showPlotWindow = true );
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ bool RicAdd3dWellLogFileCurveFeature::isCommandEnabled() const
|
||||
std::vector<RimCase*> cases = RimProject::current()->allGridCases();
|
||||
if ( cases.empty() ) return false;
|
||||
|
||||
return ( RicWellLogTools::findWellPathWithLogFileFromSelection() != nullptr );
|
||||
return ( RicWellLogTools::findWellPathWithLogFromSelection() != nullptr );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -46,7 +46,7 @@ bool RicAdd3dWellLogFileCurveFeature::isCommandEnabled() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAdd3dWellLogFileCurveFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimWellPath* selectedWellPath = RicWellLogTools::findWellPathWithLogFileFromSelection();
|
||||
RimWellPath* selectedWellPath = RicWellLogTools::findWellPathWithLogFromSelection();
|
||||
if ( !selectedWellPath ) return;
|
||||
|
||||
Rim3dWellLogFileCurve* rim3dWellLogFileCurve = new Rim3dWellLogFileCurve();
|
||||
|
||||
@@ -61,8 +61,8 @@ void RicMoveWellLogFilesFeature::onActionTriggered( bool isChecked )
|
||||
|
||||
if ( !destWellPath || !wellLogFile || !sourceWellPath ) return;
|
||||
|
||||
sourceWellPath->detachWellLogFile( wellLogFile );
|
||||
destWellPath->addWellLogFile( wellLogFile );
|
||||
sourceWellPath->detachWellLog( wellLogFile );
|
||||
destWellPath->addWellLog( wellLogFile );
|
||||
|
||||
sourceWellPath->updateConnectedEditors();
|
||||
destWellPath->updateConnectedEditors();
|
||||
|
||||
@@ -48,7 +48,7 @@ bool RicNewWellLogFileCurveFeature::isCommandEnabled() const
|
||||
{
|
||||
if ( RicWellLogPlotCurveFeatureImpl::parentWellRftPlot() ) return false;
|
||||
return ( caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellLogTrack>() != nullptr && wellLogFilesAvailable() ) ||
|
||||
RicWellLogTools::selectedWellPathWithLogFile() != nullptr;
|
||||
RicWellLogTools::selectedWellPathWithLog() != nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -63,7 +63,7 @@ void RicNewWellLogFileCurveFeature::onActionTriggered( bool isChecked )
|
||||
}
|
||||
else
|
||||
{
|
||||
RimWellPath* wellPath = RicWellLogTools::selectedWellPathWithLogFile();
|
||||
RimWellPath* wellPath = RicWellLogTools::selectedWellPathWithLog();
|
||||
if ( wellPath )
|
||||
{
|
||||
RimWellLogTrack* newWellLogPlotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
|
||||
|
||||
@@ -59,7 +59,7 @@ void RicWellLogFileCloseFeature::onActionTriggered( bool isChecked )
|
||||
if ( parentWellPath )
|
||||
{
|
||||
std::set<RimViewWindow*> referringPlots = referringWellLogPlots( wellLogFile );
|
||||
parentWellPath->deleteWellLogFile( wellLogFile );
|
||||
parentWellPath->deleteWellLog( wellLogFile );
|
||||
|
||||
for ( RimViewWindow* plot : referringPlots )
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user