Add well log loaders.

This commit is contained in:
Kristian Bendiksen committed 2024-08-14 11:32:07 +02:00
1 parent 694d2eda66
commit 2651ca91b6
11 files changed
+311 -47

No files matched your search

@@ -31,6 +31,8 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimRftTopologyCurve.h
${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveInfoTextProvider.h
${CMAKE_CURRENT_LIST_DIR}/RimWellLogCalculatedCurve.h
${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileDataLoader.h
${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLogDataLoader.h
)
set(SOURCE_GROUP_SOURCE_FILES
@@ -68,12 +70,16 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimRftTopologyCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveInfoTextProvider.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogCalculatedCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileDataLoader.cpp
${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLogDataLoader.cpp
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})
list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLogDataLoader.h)
source_group(
"ProjectDataModel\\WellLog"
FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES}
@@ -0,0 +1,111 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimOsduWellLogDataLoader.h"
#include "Cloud/RiaOsduConnector.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RimOsduWellLog.h"
#include "RifOsduWellLogReader.h"
#include "RigWellLogData.h"
#include "cafProgressInfo.h"
#include <QApplication>
#include <QObject>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimOsduWellLogDataLoader::RimOsduWellLogDataLoader()
: caf::DataLoader()
{
RiaApplication* app = RiaApplication::instance();
RiaOsduConnector* osduConnector = app->makeOsduConnector();
connect( osduConnector,
SIGNAL( parquetDownloadFinished( const QByteArray&, const QString&, const QString& ) ),
this,
SLOT( parquetDownloadComplete( const QByteArray&, const QString&, const QString& ) ),
Qt::QueuedConnection );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimOsduWellLogDataLoader::loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo )
{
RiaApplication* app = RiaApplication::instance();
RiaOsduConnector* osduConnector = app->makeOsduConnector();
// TODO: this is weird?
m_dataType = dataType;
if ( RimOsduWellLog* osduWellLog = dynamic_cast<RimOsduWellLog*>( &pdmObject ) )
{
QString wellLogId = osduWellLog->wellLogId();
osduConnector->requestWellLogParquetDataById( wellLogId );
m_wellLogs[wellLogId] = osduWellLog;
m_taskIds[wellLogId] = taskId;
}
QApplication::processEvents();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimOsduWellLogDataLoader::isRunnable() const
{
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimOsduWellLogDataLoader::parquetDownloadComplete( const QByteArray& contents, const QString& url, const QString& id )
{
QMutexLocker lock( &m_mutex );
if ( m_wellLogs.find( id ) != m_wellLogs.end() )
{
int taskId = m_taskIds[id];
RiaLogging::info( QString( "Parquet download complete. Id: %1 Size: %2" ).arg( id ).arg( contents.size() ) );
if ( !contents.isEmpty() )
{
auto osduWellLog = m_wellLogs[id];
auto [wellLogData, errorMessage] = RifOsduWellLogReader::readWellLogData( contents );
if ( wellLogData.notNull() )
{
osduWellLog->setWellLogData( wellLogData.p() );
}
else
{
RiaLogging::warning( errorMessage );
}
}
taskDone.send( m_dataType, taskId );
}
}
@@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafDataLoader.h"
#include "cafProgressInfo.h"
#include <QMutex>
#include <QObject>
#include <QString>
class RimOsduWellLog;
//==================================================================================================
///
///
//==================================================================================================
class RimOsduWellLogDataLoader : public QObject, public caf::DataLoader
{
Q_OBJECT
public:
RimOsduWellLogDataLoader();
void loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) override;
bool isRunnable() const override;
private slots:
void parquetDownloadComplete( const QByteArray& contents, const QString& url, const QString& id );
private:
std::map<QString, RimOsduWellLog*> m_wellLogs;
std::map<QString, int> m_taskIds;
QString m_dataType;
QMutex m_mutex;
};
@@ -0,0 +1,62 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimWellLogFileDataLoader.h"
#include "RiaLogging.h"
#include "RimWellLogFile.h"
#include "RigWellPath.h"
#include "cafProgressInfo.h"
#include <QApplication>
#include <QObject>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogFileDataLoader::RimWellLogFileDataLoader()
: caf::DataLoader()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogFileDataLoader::loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo )
{
if ( RimWellLogFile* wellLogFile = dynamic_cast<RimWellLogFile*>( &pdmObject ) )
{
QString errorMessage;
if ( !wellLogFile->readFile( &errorMessage ) )
{
RiaLogging::warning( errorMessage );
}
}
taskDone.send( dataType, taskId );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellLogFileDataLoader::isRunnable() const
{
return true;
}
@@ -0,0 +1,40 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimFileWellPath.h"
#include "cafDataLoader.h"
#include "cafProgressInfo.h"
#include <QString>
#include <memory>
//==================================================================================================
///
///
//==================================================================================================
class RimWellLogFileDataLoader : public caf::DataLoader
{
public:
RimWellLogFileDataLoader();
void loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) override;
bool isRunnable() const override;
};