Osdu Well Log: show more values in filter.

This commit is contained in:
Kristian Bendiksen 2024-07-10 13:15:49 +02:00
parent 122b724a83
commit 0d845938b6
6 changed files with 136 additions and 42 deletions

View File

@ -629,24 +629,49 @@ void RiaOsduConnector::parseWellLogs( QNetworkReply* reply, const QString& wellb
QString id = resultObj["id"].toString();
QString kind = resultObj["kind"].toString();
QJsonArray curvesArray = resultObj["data"].toObject()["Curves"].toArray();
QStringList curveIds;
QJsonObject dataObj = resultObj["data"].toObject();
QString name = dataObj["Name"].toString();
QString description = dataObj["Description"].toString();
double samplingStart = dataObj["SamplingStart"].toDouble( std::numeric_limits<double>::infinity() );
double samplingStop = dataObj["SamplingStop"].toDouble( std::numeric_limits<double>::infinity() );
QJsonArray curvesArray = dataObj["Curves"].toArray();
QStringList curveMnemonics;
RiaLogging::debug( QString( "Curves for '%1':" ).arg( id ) );
std::vector<OsduWellLogChannel> channels;
for ( const QJsonValue& curve : curvesArray )
{
QString curveId = curve["CurveID"].toString();
QString mnemonic = curve["Mnemonic"].toString();
QString curveDescription = curve["CurveDescription"].toString();
double curveBaseDepth = curve["BaseDepth"].toDouble( 0.0 );
double curveTopDepth = curve["TopDepth"].toDouble( 0.0 );
double curveBaseDepth = curve["BaseDepth"].toDouble( std::numeric_limits<double>::infinity() );
double curveTopDepth = curve["TopDepth"].toDouble( std::numeric_limits<double>::infinity() );
QString interpreterName = curve["InterpreterName"].toString();
QString quality = curve["CurveQuality"].toString();
QString unit = curve["CurveUnit"].toString();
QString depthUnit = curve["DepthUnit"].toString();
curveIds << curveId;
curveMnemonics << mnemonic;
RiaLogging::debug(
QString( "%1: '%2' (%3 - %4)" ).arg( curveId ).arg( curveDescription ).arg( curveTopDepth ).arg( curveBaseDepth ) );
QString( "%1: '%2' (%3 - %4)" ).arg( mnemonic ).arg( curveDescription ).arg( curveTopDepth ).arg( curveBaseDepth ) );
channels.push_back( OsduWellLogChannel{ .mnemonic = mnemonic,
.description = curveDescription,
.topDepth = curveTopDepth,
.baseDepth = curveBaseDepth,
.interpreterName = interpreterName,
.quality = quality,
.unit = unit,
.depthUnit = depthUnit } );
}
QString name = curveIds.join( ", " );
m_wellLogs[wellboreId].push_back( OsduWellLog{ id, kind, wellboreId, name } );
m_wellLogs[wellboreId].push_back( OsduWellLog{ .id = id,
.kind = kind,
.name = name,
.description = description,
.samplingStart = samplingStart,
.samplingStop = samplingStop,
.wellboreId = wellboreId,
.channels = channels } );
}
}

View File

@ -37,12 +37,28 @@ struct OsduWellboreTrajectory
QString wellboreId;
};
struct OsduWellLogChannel
{
QString mnemonic;
QString description;
double topDepth;
double baseDepth;
QString interpreterName;
QString quality;
QString unit;
QString depthUnit;
};
struct OsduWellLog
{
QString id;
QString kind;
QString wellboreId;
QString name;
QString id;
QString kind;
QString name;
QString description;
double samplingStart;
double samplingStop;
QString wellboreId;
std::vector<OsduWellLogChannel> channels;
};
//==================================================================================================

View File

@ -24,6 +24,7 @@
#include <QAbstractTableModel>
#include <QObject>
#include <QString>
#include <QTextEdit>
#include <QtNetwork>
#include <QtWidgets>
@ -43,6 +44,8 @@ RiuWellLogImportWizard::RiuWellLogImportWizard( RiaOsduConnector* osduConnector,
addPage( new WellLogAuthenticationPage( m_osduConnector, this ) );
addPage( new WellLogSelectionPage( m_osduConnector, this ) );
setMinimumSize( 800, 800 );
}
//--------------------------------------------------------------------------------------------------
@ -87,17 +90,17 @@ QString RiuWellLogImportWizard::wellboreId() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RiuWellLogImportWizard::WellLogInfo> RiuWellLogImportWizard::importedWellLogs() const
std::vector<OsduWellLog> RiuWellLogImportWizard::importedWellLogs() const
{
return m_wellLogInfos;
return m_wellLogs;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogImportWizard::addWellLogInfo( RiuWellLogImportWizard::WellLogInfo wellLogInfo )
void RiuWellLogImportWizard::addWellLog( OsduWellLog wellLog )
{
m_wellLogInfos.push_back( wellLogInfo );
m_wellLogs.push_back( wellLog );
}
//--------------------------------------------------------------------------------------------------
@ -198,6 +201,10 @@ WellLogSelectionPage::WellLogSelectionPage( RiaOsduConnector* osduConnector, QWi
m_tableView->setModel( m_proxyModel );
m_tableView->setSortingEnabled( true );
m_detailText = new QTextEdit( this );
m_detailText->setReadOnly( true );
layout->addWidget( m_detailText );
QObject::connect( filterLineEdit, &QLineEdit::textChanged, m_proxyModel, &QSortFilterProxyModel::setFilterWildcard );
m_osduConnector = osduConnector;
@ -271,6 +278,37 @@ void WellLogSelectionPage::selectWellLogs( const QItemSelection& newSelection, c
return {};
};
auto generateWellLogDetailsText = []( const OsduWellLog& wellLog ) -> QString
{
QString text = QString( "Name: %1\n" ).arg( wellLog.name );
if ( !wellLog.description.isEmpty() )
{
text.append( QString( "Description: %2\n" ).arg( wellLog.description ) );
}
for ( auto channel : wellLog.channels )
{
QString channelText = QString( " %1: \"%2\". Depth: %3 - %4." )
.arg( channel.mnemonic )
.arg( channel.description )
.arg( channel.topDepth )
.arg( channel.baseDepth );
if ( !channel.interpreterName.isEmpty() )
{
channelText.append( QString( " Interpreter: %1." ).arg( channel.interpreterName ) );
}
if ( !channel.quality.isEmpty() )
{
channelText.append( QString( " Quality: %1." ).arg( channel.quality ) );
}
text.append( channelText + "\n" );
}
return text;
};
QModelIndexList selection = m_tableView->selectionModel()->selectedRows();
for ( QModelIndex index : selection )
{
@ -282,7 +320,8 @@ void WellLogSelectionPage::selectWellLogs( const QItemSelection& newSelection, c
std::optional<const OsduWellLog> wellLog = findWellLogById( wellLogs, wellLogId );
if ( wellLog.has_value() )
{
wiz->addWellLogInfo( { .name = wellLog->name, .wellLog = wellLogId } );
wiz->addWellLog( wellLog.value() );
m_detailText->setText( generateWellLogDetailsText( wellLog.value() ) );
}
}
}

View File

@ -55,8 +55,7 @@ public:
int columnCount( const QModelIndex& parent = QModelIndex() ) const override
{
Q_UNUSED( parent );
// Assuming you have three fields: id, kind, and name
return 3;
return 7;
}
QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override
@ -65,6 +64,16 @@ public:
if ( index.row() >= static_cast<int>( m_osduWellLogs.size() ) || index.row() < 0 ) return QVariant();
auto createChannelsText = []( const OsduWellLog& wellLog ) -> QString
{
QStringList channels;
for ( auto c : wellLog.channels )
{
channels.push_back( c.mnemonic );
}
return channels.join( ", " );
};
if ( role == Qt::DisplayRole )
{
const OsduWellLog& field = m_osduWellLogs.at( index.row() );
@ -76,6 +85,14 @@ public:
return field.kind;
case 2:
return field.name;
case 3:
return createChannelsText( field );
case 4:
return field.description;
case 5:
return field.samplingStart;
case 6:
return field.samplingStop;
default:
return QVariant();
}
@ -98,6 +115,14 @@ public:
return tr( "Kind" );
case 2:
return tr( "Name" );
case 3:
return tr( "Channels" );
case 4:
return tr( "Description" );
case 5:
return tr( "Sampling Start" );
case 6:
return tr( "Sampling Stop" );
default:
return QVariant();
}
@ -187,6 +212,7 @@ private:
QTableView* m_tableView;
OsduWellLogTableModel* m_osduWellLogsModel;
QSortFilterProxyModel* m_proxyModel;
QTextEdit* m_detailText;
};
//--------------------------------------------------------------------------------------------------
@ -197,20 +223,14 @@ class RiuWellLogImportWizard : public QWizard
Q_OBJECT
public:
struct WellLogInfo
{
QString name;
QString wellLog;
};
RiuWellLogImportWizard( RiaOsduConnector* osduConnector, const QString& wellboreId, QWidget* parent = nullptr );
~RiuWellLogImportWizard() override;
void setSelectedWellLogs( const std::vector<QString>& wellLogIds );
std::vector<QString> selectedWellLogs() const;
void addWellLogInfo( RiuWellLogImportWizard::WellLogInfo wellLogInfo );
std::vector<RiuWellLogImportWizard::WellLogInfo> importedWellLogs() const;
void addWellLog( OsduWellLog wellLogInfo );
std::vector<OsduWellLog> importedWellLogs() const;
QString wellboreId() const;
@ -221,6 +241,6 @@ private:
RiaOsduConnector* m_osduConnector;
std::vector<QString> m_selectedWellLogs;
QString m_wellboreId;
std::vector<RiuWellLogImportWizard::WellLogInfo> m_wellLogInfos;
QString m_wellboreId;
std::vector<OsduWellLog> m_wellLogs;
};

View File

@ -68,16 +68,16 @@ void RicImportWellLogOsduFeature::onActionTriggered( bool isChecked )
if ( QDialog::Accepted == wellLogImportWizard.exec() )
{
std::vector<RiuWellLogImportWizard::WellLogInfo> wellLogs = wellLogImportWizard.importedWellLogs();
std::vector<OsduWellLog> wellLogs = wellLogImportWizard.importedWellLogs();
for ( RiuWellLogImportWizard::WellLogInfo wellLog : wellLogs )
for ( OsduWellLog wellLog : wellLogs )
{
auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector, wellLog.wellLog );
auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector, wellLog.id );
if ( wellLogData.notNull() )
{
RimOsduWellLog* osduWellLog = new RimOsduWellLog;
osduWellLog->setName( wellLog.name );
osduWellLog->setWellLogId( wellLog.wellLog );
osduWellLog->setWellLogId( wellLog.id );
oilField->wellPathCollection->addWellLog( osduWellLog, wellPath );
osduWellLog->setWellLogData( wellLogData.p() );

View File

@ -18,20 +18,14 @@
#include "RimOsduWellLog.h"
#include "RiaDateStringParser.h"
#include "RiaFieldHandleTools.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RiaQDateTimeTools.h"
#include "RimFileWellPath.h"
#include "RimTools.h"
#include "RimWellLogChannel.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RimWellPlotTools.h"
#include "Riu3DMainWindowTools.h"
#include <QString>
CAF_PDM_SOURCE_INIT( RimOsduWellLog, "OsduWellLog" );