2013-09-02 08:39:29 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2013-09-02 08:39:29 +02:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2013-09-02 08:39:29 +02:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2013-09-02 08:39:29 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "RiuWellImportWizard.h"
|
|
|
|
|
|
2025-12-10 09:49:06 +01:00
|
|
|
#include "RiaStringListSerializer.h"
|
|
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
#include <QAbstractTableModel>
|
2015-08-01 23:04:04 +02:00
|
|
|
#include <QObject>
|
2024-02-28 08:10:52 +01:00
|
|
|
#include <QString>
|
2019-06-17 09:11:38 +02:00
|
|
|
|
2025-12-10 09:49:06 +01:00
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QRadioButton>
|
|
|
|
|
#include <QSettings>
|
2015-08-01 23:04:04 +02:00
|
|
|
#include <QtNetwork>
|
2020-05-12 09:00:20 +02:00
|
|
|
#include <QtWidgets>
|
2013-09-05 07:34:04 +02:00
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
#include <optional>
|
|
|
|
|
#include <vector>
|
2019-06-17 09:11:38 +02:00
|
|
|
|
2025-12-10 09:49:06 +01:00
|
|
|
// Static member definitions
|
|
|
|
|
const QString FieldSelectionPage::FIELD_SEARCH_HISTORY_KEY = "OsduWellImport/FieldSearchHistory";
|
|
|
|
|
const QString WellSelectionPage::WELL_FILTER_HISTORY_KEY = "OsduWellImport/WellFilterHistory";
|
|
|
|
|
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-07-29 11:30:28 +02:00
|
|
|
RiuWellImportWizard::RiuWellImportWizard( RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ )
|
2019-09-06 10:40:57 +02:00
|
|
|
: QWizard( parent )
|
2013-09-02 08:39:29 +02:00
|
|
|
{
|
2024-07-29 11:30:28 +02:00
|
|
|
m_osduConnector = osduConnector;
|
2013-09-02 08:39:29 +02:00
|
|
|
|
2013-09-06 15:59:25 +02:00
|
|
|
m_firstTimeRequestingAuthentication = true;
|
|
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
addPage( new AuthenticationPage( m_osduConnector, this ) );
|
2024-07-29 11:30:28 +02:00
|
|
|
addPage( new FieldSelectionPage( m_osduConnector, this ) );
|
|
|
|
|
addPage( new WellSelectionPage( m_osduConnector, this ) );
|
|
|
|
|
addPage( new WellSummaryPage( m_osduConnector, this ) );
|
2013-09-02 08:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-12 18:44:03 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2015-08-12 18:44:03 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 11:13:38 +01:00
|
|
|
RiuWellImportWizard::~RiuWellImportWizard()
|
|
|
|
|
{
|
|
|
|
|
}
|
2015-08-12 18:44:03 +02:00
|
|
|
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-06-12 10:32:04 +02:00
|
|
|
void RiuWellImportWizard::downloadFields( const QString& fieldName )
|
2013-09-02 08:39:29 +02:00
|
|
|
{
|
2024-06-12 10:32:04 +02:00
|
|
|
m_osduConnector->requestFieldsByName( fieldName );
|
2013-09-05 08:45:24 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-09-05 08:45:24 +02:00
|
|
|
/// This slot will be called for the first network reply that will need authentication.
|
|
|
|
|
/// If the authentication is successful, the username/password is cached in the QNetworkAccessManager
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RiuWellImportWizard::slotAuthenticationRequired( QNetworkReply* networkReply, QAuthenticator* authenticator )
|
2013-09-02 08:39:29 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( m_firstTimeRequestingAuthentication )
|
2013-09-05 08:45:24 +02:00
|
|
|
{
|
|
|
|
|
m_firstTimeRequestingAuthentication = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
QMessageBox::information( this,
|
|
|
|
|
"Authentication failed",
|
2024-02-28 08:10:52 +01:00
|
|
|
"Failed to authenticate. You will now be directed back to the first wizard page." );
|
2013-09-05 08:45:24 +02:00
|
|
|
m_firstTimeRequestingAuthentication = true;
|
2013-09-02 08:39:29 +02:00
|
|
|
|
2013-09-05 08:45:24 +02:00
|
|
|
restart();
|
|
|
|
|
}
|
2013-09-02 08:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-02-28 08:10:52 +01:00
|
|
|
void RiuWellImportWizard::downloadWells( const QString& fieldId )
|
2013-09-02 08:39:29 +02:00
|
|
|
{
|
2024-06-17 22:21:32 +02:00
|
|
|
m_osduConnector->clearCachedData();
|
2025-11-21 11:00:31 +01:00
|
|
|
m_osduConnector->requestWellboresByFieldId( fieldId );
|
2013-09-02 08:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-02-28 08:10:52 +01:00
|
|
|
void RiuWellImportWizard::downloadWellPaths( const QString& wellboreId )
|
2013-09-02 08:39:29 +02:00
|
|
|
{
|
2024-02-28 08:10:52 +01:00
|
|
|
m_osduConnector->requestWellboreTrajectoryByWellboreId( wellboreId );
|
2013-09-02 08:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
2019-05-09 13:39:00 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-02-28 08:10:52 +01:00
|
|
|
void RiuWellImportWizard::resetAuthenticationCount()
|
2019-05-09 13:39:00 +02:00
|
|
|
{
|
2024-02-28 08:10:52 +01:00
|
|
|
m_firstTimeRequestingAuthentication = true;
|
2025-02-03 11:42:17 +01:00
|
|
|
|
|
|
|
|
if ( !m_osduConnector->isGranted() )
|
|
|
|
|
{
|
|
|
|
|
m_osduConnector->requestTokenWithCancelButton();
|
|
|
|
|
}
|
2019-05-09 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-02-28 08:10:52 +01:00
|
|
|
void RiuWellImportWizard::setSelectedFieldId( const QString& fieldId )
|
2019-05-09 13:39:00 +02:00
|
|
|
{
|
2024-02-28 08:10:52 +01:00
|
|
|
m_selectedFieldId = fieldId;
|
2019-05-09 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-02-28 08:10:52 +01:00
|
|
|
QString RiuWellImportWizard::selectedFieldId() const
|
2013-09-02 08:39:29 +02:00
|
|
|
{
|
2024-02-28 08:10:52 +01:00
|
|
|
return m_selectedFieldId;
|
2013-09-02 08:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-04 08:03:11 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-04 08:03:11 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-06-17 22:21:32 +02:00
|
|
|
void RiuWellImportWizard::setSelectedWellboreIds( const std::vector<QString>& wellboreIds )
|
2013-09-04 08:03:11 +02:00
|
|
|
{
|
2024-06-17 22:21:32 +02:00
|
|
|
m_selectedWellboreIds = wellboreIds;
|
2013-09-04 08:03:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-04 08:03:11 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-06-17 22:21:32 +02:00
|
|
|
std::vector<QString> RiuWellImportWizard::selectedWellboreIds() const
|
2013-09-04 08:03:11 +02:00
|
|
|
{
|
2024-06-17 22:21:32 +02:00
|
|
|
return m_selectedWellboreIds;
|
2013-09-04 08:03:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-04 08:03:11 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-02-28 08:10:52 +01:00
|
|
|
std::vector<RiuWellImportWizard::WellInfo> RiuWellImportWizard::importedWells() const
|
2013-09-04 08:03:11 +02:00
|
|
|
{
|
2024-02-28 08:10:52 +01:00
|
|
|
return m_wellInfos;
|
2013-09-04 08:03:11 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-05 08:45:24 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-05 08:45:24 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-02-28 08:10:52 +01:00
|
|
|
void RiuWellImportWizard::addWellInfo( RiuWellImportWizard::WellInfo wellInfo )
|
2013-09-05 08:45:24 +02:00
|
|
|
{
|
2024-02-28 08:10:52 +01:00
|
|
|
m_wellInfos.push_back( wellInfo );
|
2013-09-05 08:45:24 +02:00
|
|
|
}
|
|
|
|
|
|
2025-12-10 09:49:06 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RiuWellImportWizard::clearWellInfos()
|
|
|
|
|
{
|
|
|
|
|
m_wellInfos.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 13:06:39 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-06 13:06:39 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-02-28 08:10:52 +01:00
|
|
|
AuthenticationPage::AuthenticationPage( RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ )
|
|
|
|
|
: QWizardPage( parent )
|
|
|
|
|
, m_accessOk( false )
|
2013-09-06 13:06:39 +02:00
|
|
|
{
|
2024-02-28 08:10:52 +01:00
|
|
|
setTitle( "OSDU - Login" );
|
2013-09-06 13:06:39 +02:00
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
QVBoxLayout* layout = new QVBoxLayout;
|
2015-08-12 18:44:03 +02:00
|
|
|
|
2024-06-14 12:16:05 +02:00
|
|
|
m_connectionLabel = new QLabel( "Checking OSDU connection. You might need to login." );
|
|
|
|
|
layout->addWidget( m_connectionLabel );
|
2013-09-06 13:06:39 +02:00
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
QFormLayout* formLayout = new QFormLayout;
|
|
|
|
|
layout->addLayout( formLayout );
|
2013-09-06 13:06:39 +02:00
|
|
|
|
2024-06-12 11:33:58 +02:00
|
|
|
QLineEdit* serverLineEdit = new QLineEdit( osduConnector->server(), this );
|
|
|
|
|
serverLineEdit->setReadOnly( true );
|
2024-02-28 08:10:52 +01:00
|
|
|
QLineEdit* partitionLineEdit = new QLineEdit( osduConnector->dataPartition(), this );
|
2024-06-12 11:33:58 +02:00
|
|
|
partitionLineEdit->setReadOnly( true );
|
2013-09-08 09:05:26 +02:00
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
formLayout->addRow( "Server:", serverLineEdit );
|
|
|
|
|
formLayout->addRow( "Data Partition:", partitionLineEdit );
|
2013-09-08 09:05:26 +02:00
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
setLayout( layout );
|
|
|
|
|
|
|
|
|
|
connect( osduConnector, SIGNAL( tokenReady( const QString& ) ), this, SLOT( accessOk() ) );
|
2025-02-03 11:42:17 +01:00
|
|
|
|
|
|
|
|
if ( osduConnector->isGranted() ) accessOk();
|
2013-09-08 09:05:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-08 09:05:26 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-02-28 08:10:52 +01:00
|
|
|
void AuthenticationPage::initializePage()
|
2013-09-08 09:05:26 +02:00
|
|
|
{
|
2024-02-28 08:10:52 +01:00
|
|
|
RiuWellImportWizard* wiz = dynamic_cast<RiuWellImportWizard*>( wizard() );
|
|
|
|
|
wiz->resetAuthenticationCount();
|
2013-09-08 09:05:26 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-08 10:53:25 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-08 10:53:25 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-02-28 08:10:52 +01:00
|
|
|
bool AuthenticationPage::isComplete() const
|
2013-09-08 10:53:25 +02:00
|
|
|
{
|
2024-02-28 08:10:52 +01:00
|
|
|
return m_accessOk;
|
2013-09-08 10:53:25 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-12 18:44:03 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2015-08-12 18:44:03 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-02-28 08:10:52 +01:00
|
|
|
void AuthenticationPage::accessOk()
|
2015-08-12 18:44:03 +02:00
|
|
|
{
|
2024-06-14 12:16:05 +02:00
|
|
|
m_connectionLabel->setText( "Connection to OSDU: OK." );
|
2024-02-28 08:10:52 +01:00
|
|
|
m_accessOk = true;
|
|
|
|
|
emit( completeChanged() );
|
2015-08-12 18:44:03 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-07-29 11:30:28 +02:00
|
|
|
FieldSelectionPage::FieldSelectionPage( RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ )
|
2013-09-02 08:39:29 +02:00
|
|
|
{
|
2024-02-28 08:10:52 +01:00
|
|
|
setTitle( "Field Selection" );
|
2013-09-02 08:39:29 +02:00
|
|
|
|
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout;
|
2024-02-28 08:10:52 +01:00
|
|
|
setLayout( layout );
|
2013-09-02 08:39:29 +02:00
|
|
|
|
2024-06-12 10:32:04 +02:00
|
|
|
QHBoxLayout* searchLayout = new QHBoxLayout;
|
2025-12-10 09:49:06 +01:00
|
|
|
m_searchComboBox = new QComboBox( this );
|
|
|
|
|
m_searchComboBox->setEditable( true );
|
|
|
|
|
m_searchComboBox->setInsertPolicy( QComboBox::NoInsert );
|
|
|
|
|
m_searchComboBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
|
|
|
|
|
searchLayout->addWidget( m_searchComboBox );
|
2024-06-12 10:32:04 +02:00
|
|
|
|
|
|
|
|
m_searchButton = new QPushButton( "Search", this );
|
|
|
|
|
m_searchButton->setEnabled( false );
|
|
|
|
|
searchLayout->addWidget( m_searchButton );
|
|
|
|
|
|
|
|
|
|
layout->addLayout( searchLayout );
|
|
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
QLabel* label = new QLabel( "Select fields" );
|
2019-09-06 10:40:57 +02:00
|
|
|
layout->addWidget( label );
|
2013-09-02 08:39:29 +02:00
|
|
|
|
2024-09-09 14:11:15 +02:00
|
|
|
int nameColumn = OsduFieldTableModel::Column::Name;
|
|
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
m_tableView = new QTableView( this );
|
|
|
|
|
m_tableView->setSelectionBehavior( QAbstractItemView::SelectRows );
|
2024-06-14 12:12:33 +02:00
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
m_osduFieldsModel = new OsduFieldTableModel;
|
|
|
|
|
m_tableView->setModel( m_osduFieldsModel );
|
2024-06-18 09:27:34 +02:00
|
|
|
m_tableView->setSortingEnabled( true );
|
|
|
|
|
m_tableView->sortByColumn( nameColumn, Qt::AscendingOrder );
|
|
|
|
|
|
2024-09-09 14:11:15 +02:00
|
|
|
QHeaderView* header = m_tableView->horizontalHeader();
|
|
|
|
|
header->setSectionResizeMode( QHeaderView::Interactive );
|
|
|
|
|
header->setSectionResizeMode( nameColumn, QHeaderView::ResizeToContents );
|
|
|
|
|
header->setStretchLastSection( true );
|
|
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
layout->addWidget( m_tableView );
|
|
|
|
|
layout->setStretchFactor( m_tableView, 10 );
|
|
|
|
|
|
|
|
|
|
setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
|
2013-09-02 08:39:29 +02:00
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
m_osduConnector = osduConnector;
|
|
|
|
|
connect( m_osduConnector, SIGNAL( fieldsFinished() ), SLOT( fieldsFinished() ) );
|
2013-09-02 08:39:29 +02:00
|
|
|
|
2025-12-10 09:49:06 +01:00
|
|
|
connect( m_searchComboBox->lineEdit(), SIGNAL( textChanged( const QString& ) ), this, SLOT( onSearchTextChanged( const QString& ) ) );
|
|
|
|
|
connect( m_searchComboBox->lineEdit(), SIGNAL( returnPressed() ), this, SLOT( searchForFields() ) );
|
|
|
|
|
connect( m_searchComboBox, SIGNAL( currentTextChanged( const QString& ) ), this, SLOT( onSearchTextChanged( const QString& ) ) );
|
2024-06-12 10:32:04 +02:00
|
|
|
|
|
|
|
|
connect( m_searchButton, SIGNAL( clicked() ), this, SLOT( searchForFields() ) );
|
|
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
connect( m_tableView->selectionModel(),
|
|
|
|
|
SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ),
|
|
|
|
|
SLOT( selectField( const QItemSelection&, const QItemSelection& ) ) );
|
2013-09-02 08:39:29 +02:00
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
connect( m_tableView->selectionModel(),
|
|
|
|
|
SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ),
|
|
|
|
|
SIGNAL( completeChanged() ) );
|
2025-12-10 09:49:06 +01:00
|
|
|
|
|
|
|
|
// Load search history after all UI elements are created
|
|
|
|
|
{
|
|
|
|
|
RiaStringListSerializer serializer( FIELD_SEARCH_HISTORY_KEY );
|
|
|
|
|
QStringList history = serializer.textStrings();
|
|
|
|
|
|
|
|
|
|
m_searchComboBox->clear();
|
|
|
|
|
m_searchComboBox->addItems( history );
|
|
|
|
|
|
|
|
|
|
// Set the last used search term as default (first item in history)
|
|
|
|
|
if ( !history.isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
m_searchComboBox->setCurrentText( history.first() );
|
|
|
|
|
// Enable search button if text meets minimum requirements
|
|
|
|
|
m_searchButton->setEnabled( history.first().length() >= MINIMUM_CHARACTERS_FOR_SEARCH );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_searchComboBox->setCurrentText( "" ); // Start with empty text if no history
|
|
|
|
|
m_searchButton->setEnabled( false );
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-09-02 08:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-06-12 10:32:04 +02:00
|
|
|
void FieldSelectionPage::onSearchTextChanged( const QString& text )
|
|
|
|
|
{
|
|
|
|
|
m_searchButton->setEnabled( text.length() >= MINIMUM_CHARACTERS_FOR_SEARCH );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void FieldSelectionPage::searchForFields()
|
2013-09-05 08:45:24 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
RiuWellImportWizard* wiz = dynamic_cast<RiuWellImportWizard*>( wizard() );
|
2024-06-12 10:32:04 +02:00
|
|
|
|
2025-12-10 09:49:06 +01:00
|
|
|
QString text = m_searchComboBox->currentText();
|
|
|
|
|
if ( text.length() >= MINIMUM_CHARACTERS_FOR_SEARCH )
|
|
|
|
|
{
|
|
|
|
|
RiaStringListSerializer serializer( FIELD_SEARCH_HISTORY_KEY );
|
|
|
|
|
serializer.addString( text, 10 );
|
|
|
|
|
wiz->downloadFields( text );
|
|
|
|
|
}
|
2013-09-05 08:45:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-05 08:45:24 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-02-28 08:10:52 +01:00
|
|
|
void FieldSelectionPage::fieldsFinished()
|
2013-09-02 08:39:29 +02:00
|
|
|
{
|
2024-02-28 08:10:52 +01:00
|
|
|
std::vector<OsduField> fields = m_osduConnector->fields();
|
|
|
|
|
m_osduFieldsModel->setOsduFields( fields );
|
|
|
|
|
}
|
2013-09-05 07:34:04 +02:00
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void FieldSelectionPage::selectField( const QItemSelection& newSelection, const QItemSelection& oldSelection )
|
|
|
|
|
{
|
|
|
|
|
if ( !newSelection.indexes().empty() )
|
|
|
|
|
{
|
|
|
|
|
QModelIndex index = newSelection.indexes()[0];
|
2024-09-09 13:09:57 +02:00
|
|
|
int column = OsduFieldTableModel::Column::Id;
|
2024-02-28 08:10:52 +01:00
|
|
|
QString fieldId = m_osduFieldsModel->data( index.siblingAtColumn( column ) ).toString();
|
|
|
|
|
RiuWellImportWizard* wiz = dynamic_cast<RiuWellImportWizard*>( wizard() );
|
|
|
|
|
wiz->setSelectedFieldId( fieldId );
|
|
|
|
|
}
|
2013-09-02 08:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-02-28 08:10:52 +01:00
|
|
|
bool FieldSelectionPage::isComplete() const
|
2013-09-02 08:39:29 +02:00
|
|
|
{
|
2024-02-28 08:10:52 +01:00
|
|
|
QItemSelectionModel* select = m_tableView->selectionModel();
|
|
|
|
|
return select->selectedRows().size() == 1;
|
2013-09-02 08:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-12 18:44:03 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2015-08-12 18:44:03 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
FieldSelectionPage::~FieldSelectionPage()
|
|
|
|
|
{
|
|
|
|
|
}
|
2013-09-02 08:39:29 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-07-29 11:30:28 +02:00
|
|
|
WellSelectionPage::WellSelectionPage( RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ )
|
2013-09-02 08:39:29 +02:00
|
|
|
{
|
2013-09-05 07:34:04 +02:00
|
|
|
QVBoxLayout* layout = new QVBoxLayout;
|
2019-09-06 10:40:57 +02:00
|
|
|
setLayout( layout );
|
2013-09-05 07:34:04 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
QLabel* label = new QLabel( "Select wells" );
|
|
|
|
|
layout->addWidget( label );
|
2019-06-17 09:11:38 +02:00
|
|
|
|
2024-06-18 09:27:34 +02:00
|
|
|
QHBoxLayout* filterLayout = new QHBoxLayout;
|
|
|
|
|
filterLayout->addWidget( new QLabel( "Filter:", this ) );
|
2025-12-10 09:49:06 +01:00
|
|
|
m_filterComboBox = new QComboBox( this );
|
|
|
|
|
m_filterComboBox->setEditable( true );
|
|
|
|
|
m_filterComboBox->setInsertPolicy( QComboBox::NoInsert );
|
|
|
|
|
m_filterComboBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
|
|
|
|
|
filterLayout->addWidget( m_filterComboBox );
|
2024-06-18 09:27:34 +02:00
|
|
|
|
|
|
|
|
layout->addLayout( filterLayout );
|
|
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
m_tableView = new QTableView( this );
|
|
|
|
|
m_tableView->setSelectionBehavior( QAbstractItemView::SelectRows );
|
2024-09-09 11:20:22 +02:00
|
|
|
m_tableView->setSelectionMode( QAbstractItemView::ExtendedSelection );
|
2024-06-18 09:27:34 +02:00
|
|
|
m_tableView->setSortingEnabled( true );
|
2024-09-09 13:09:57 +02:00
|
|
|
int nameColumn = OsduWellboreTableModel::Column::Name;
|
2024-06-18 09:27:34 +02:00
|
|
|
m_tableView->sortByColumn( nameColumn, Qt::AscendingOrder );
|
|
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
m_osduWellboresModel = new OsduWellboreTableModel;
|
|
|
|
|
layout->addWidget( m_tableView );
|
|
|
|
|
layout->setStretchFactor( m_tableView, 10 );
|
2019-06-17 09:11:38 +02:00
|
|
|
|
2024-06-18 09:27:34 +02:00
|
|
|
m_proxyModel = new QSortFilterProxyModel( this );
|
|
|
|
|
m_proxyModel->setSourceModel( m_osduWellboresModel );
|
|
|
|
|
m_proxyModel->setFilterKeyColumn( nameColumn );
|
|
|
|
|
m_proxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive );
|
|
|
|
|
|
|
|
|
|
m_tableView->setModel( m_proxyModel );
|
|
|
|
|
m_tableView->setSortingEnabled( true );
|
|
|
|
|
|
2024-09-09 14:11:15 +02:00
|
|
|
QHeaderView* header = m_tableView->horizontalHeader();
|
|
|
|
|
header->setSectionResizeMode( QHeaderView::Interactive );
|
|
|
|
|
header->setSectionResizeMode( nameColumn, QHeaderView::ResizeToContents );
|
|
|
|
|
header->setStretchLastSection( true );
|
|
|
|
|
|
2025-12-10 09:49:06 +01:00
|
|
|
QObject::connect( m_filterComboBox->lineEdit(), &QLineEdit::textChanged, m_proxyModel, &QSortFilterProxyModel::setFilterWildcard );
|
|
|
|
|
|
|
|
|
|
// Add to history when text is entered and filter is applied
|
|
|
|
|
QObject::connect( m_filterComboBox->lineEdit(),
|
|
|
|
|
&QLineEdit::editingFinished,
|
|
|
|
|
[this]()
|
|
|
|
|
{
|
|
|
|
|
QString filterText = m_filterComboBox->currentText();
|
|
|
|
|
if ( !filterText.isEmpty() && filterText.length() >= 2 ) // Minimum 2 characters for history
|
|
|
|
|
{
|
|
|
|
|
RiaStringListSerializer serializer( WELL_FILTER_HISTORY_KEY );
|
|
|
|
|
serializer.addString( filterText, 10 );
|
|
|
|
|
}
|
|
|
|
|
} );
|
2024-06-18 09:27:34 +02:00
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
m_osduConnector = osduConnector;
|
2025-11-21 11:00:31 +01:00
|
|
|
connect( m_osduConnector, SIGNAL( wellboresByFieldIdFinished( const QString& ) ), SLOT( wellboresByFieldIdFinished( const QString& ) ) );
|
2013-09-07 20:43:29 +02:00
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
connect( m_tableView->selectionModel(),
|
|
|
|
|
SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ),
|
|
|
|
|
SLOT( selectWellbore( const QItemSelection&, const QItemSelection& ) ) );
|
2013-09-08 09:52:25 +02:00
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
connect( m_tableView->selectionModel(),
|
|
|
|
|
SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ),
|
|
|
|
|
SIGNAL( completeChanged() ) );
|
2025-12-10 09:49:06 +01:00
|
|
|
|
|
|
|
|
// Load well filter history after all UI elements and proxy model are created
|
|
|
|
|
{
|
|
|
|
|
RiaStringListSerializer serializer( WELL_FILTER_HISTORY_KEY );
|
|
|
|
|
QStringList history = serializer.textStrings();
|
|
|
|
|
|
|
|
|
|
m_filterComboBox->clear();
|
|
|
|
|
m_filterComboBox->addItems( history );
|
|
|
|
|
|
|
|
|
|
// Set the last used filter as default (first item in history)
|
|
|
|
|
if ( !history.isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
m_filterComboBox->setCurrentText( history.first() );
|
|
|
|
|
// Apply the filter to the proxy model
|
|
|
|
|
if ( m_proxyModel )
|
|
|
|
|
{
|
|
|
|
|
m_proxyModel->setFilterWildcard( history.first() );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_filterComboBox->setCurrentText( "" ); // Start with empty text if no history
|
|
|
|
|
if ( m_proxyModel )
|
|
|
|
|
{
|
|
|
|
|
m_proxyModel->setFilterWildcard( "" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-09-04 08:03:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-04 08:03:11 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void WellSelectionPage::initializePage()
|
|
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
RiuWellImportWizard* wiz = dynamic_cast<RiuWellImportWizard*>( wizard() );
|
|
|
|
|
if ( !wiz ) return;
|
2013-09-02 08:39:29 +02:00
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
QString fieldId = wiz->selectedFieldId();
|
|
|
|
|
wiz->downloadWells( fieldId );
|
2013-09-26 10:57:35 +02:00
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
setButtonText( QWizard::NextButton, "Next" );
|
2013-09-08 09:05:26 +02:00
|
|
|
}
|
2013-09-02 08:39:29 +02:00
|
|
|
|
2013-09-08 09:05:26 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-08 09:05:26 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-02-28 08:10:52 +01:00
|
|
|
WellSelectionPage::~WellSelectionPage()
|
2013-09-08 09:05:26 +02:00
|
|
|
{
|
2013-09-08 09:52:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-08 09:52:25 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-11-21 11:00:31 +01:00
|
|
|
void WellSelectionPage::wellboresByFieldIdFinished( const QString& fieldId )
|
2013-09-08 09:52:25 +02:00
|
|
|
{
|
2025-11-21 11:00:31 +01:00
|
|
|
RiuWellImportWizard* wiz = dynamic_cast<RiuWellImportWizard*>( wizard() );
|
|
|
|
|
QString selectedFieldId = wiz->selectedFieldId();
|
|
|
|
|
|
|
|
|
|
std::vector<OsduWellbore> wellbores = m_osduConnector->wellboresByFieldId( selectedFieldId );
|
|
|
|
|
|
|
|
|
|
// Extract unique well IDs from wellbores
|
|
|
|
|
std::set<QString> uniqueWellIds;
|
|
|
|
|
for ( const auto& wellbore : wellbores )
|
2015-08-12 18:44:03 +02:00
|
|
|
{
|
2025-11-21 11:00:31 +01:00
|
|
|
if ( !wellbore.wellId.isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
uniqueWellIds.insert( wellbore.wellId );
|
|
|
|
|
}
|
2015-08-12 18:44:03 +02:00
|
|
|
}
|
2013-09-02 08:39:29 +02:00
|
|
|
|
2025-11-21 11:00:31 +01:00
|
|
|
// Request wells for each unique well ID
|
|
|
|
|
for ( const QString& wellId : uniqueWellIds )
|
|
|
|
|
{
|
|
|
|
|
// For now, we just populate the wellbores directly since we already have them
|
|
|
|
|
// The wellId is already in the wellbore structure
|
|
|
|
|
std::vector<OsduWellbore> wellboresForWell;
|
|
|
|
|
for ( const auto& wellbore : wellbores )
|
|
|
|
|
{
|
|
|
|
|
if ( wellbore.wellId == wellId )
|
|
|
|
|
{
|
|
|
|
|
wellboresForWell.push_back( wellbore );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_osduWellboresModel->setOsduWellbores( wellId, wellboresForWell );
|
|
|
|
|
}
|
2015-08-12 18:44:03 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-17 09:11:38 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-02-28 08:10:52 +01:00
|
|
|
bool WellSelectionPage::isComplete() const
|
2019-06-17 09:11:38 +02:00
|
|
|
{
|
2024-02-28 08:10:52 +01:00
|
|
|
QItemSelectionModel* select = m_tableView->selectionModel();
|
2024-06-17 22:21:32 +02:00
|
|
|
return !select->selectedRows().empty();
|
2019-06-17 09:11:38 +02:00
|
|
|
}
|
|
|
|
|
|
2015-12-01 13:28:44 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2015-12-01 13:28:44 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-02-28 08:10:52 +01:00
|
|
|
void WellSelectionPage::selectWellbore( const QItemSelection& newSelection, const QItemSelection& oldSelection )
|
2015-12-01 13:28:44 +01:00
|
|
|
{
|
2024-02-28 08:10:52 +01:00
|
|
|
if ( !newSelection.indexes().empty() )
|
2015-12-01 13:28:44 +01:00
|
|
|
{
|
2024-06-17 22:21:32 +02:00
|
|
|
std::vector<QString> wellboreIds;
|
|
|
|
|
QModelIndexList selection = m_tableView->selectionModel()->selectedRows();
|
|
|
|
|
for ( QModelIndex index : selection )
|
|
|
|
|
{
|
2024-09-09 14:11:15 +02:00
|
|
|
int idColumn = OsduWellboreTableModel::Column::Id;
|
|
|
|
|
QString wellboreId = m_proxyModel->data( index.siblingAtColumn( idColumn ) ).toString();
|
|
|
|
|
wellboreIds.push_back( wellboreId );
|
2024-06-17 22:21:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RiuWellImportWizard* wiz = dynamic_cast<RiuWellImportWizard*>( wizard() );
|
|
|
|
|
wiz->setSelectedWellboreIds( wellboreIds );
|
2015-12-01 13:28:44 +01:00
|
|
|
}
|
|
|
|
|
}
|
2013-09-02 08:39:29 +02:00
|
|
|
|
2015-12-01 13:28:44 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2015-12-01 13:28:44 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-07-29 11:30:28 +02:00
|
|
|
WellSummaryPage::WellSummaryPage( RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ )
|
2013-09-02 08:39:29 +02:00
|
|
|
{
|
2024-02-28 08:10:52 +01:00
|
|
|
m_osduConnector = osduConnector;
|
|
|
|
|
|
2013-09-02 08:39:29 +02:00
|
|
|
QVBoxLayout* layout = new QVBoxLayout;
|
2019-09-06 10:40:57 +02:00
|
|
|
setLayout( layout );
|
2013-09-02 08:39:29 +02:00
|
|
|
|
2025-12-10 09:49:06 +01:00
|
|
|
// Existence Kind filter
|
|
|
|
|
QHBoxLayout* existenceFilterLayout = new QHBoxLayout;
|
|
|
|
|
existenceFilterLayout->addWidget( new QLabel( "Import:", this ) );
|
|
|
|
|
|
|
|
|
|
m_showAllRadioButton = new QRadioButton( "All", this );
|
|
|
|
|
m_showActualRadioButton = new QRadioButton( "Actual only", this );
|
|
|
|
|
m_showActualRadioButton->setChecked( true ); // Default to Actual only
|
|
|
|
|
|
|
|
|
|
existenceFilterLayout->addWidget( m_showAllRadioButton );
|
|
|
|
|
existenceFilterLayout->addWidget( m_showActualRadioButton );
|
|
|
|
|
existenceFilterLayout->addStretch();
|
|
|
|
|
|
|
|
|
|
layout->addLayout( existenceFilterLayout );
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
m_textEdit = new QTextEdit( this );
|
|
|
|
|
m_textEdit->setReadOnly( true );
|
|
|
|
|
layout->addWidget( m_textEdit );
|
2013-09-05 07:34:04 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
setButtonText( QWizard::FinishButton, "Import" );
|
2024-02-28 08:10:52 +01:00
|
|
|
|
2024-06-17 22:21:32 +02:00
|
|
|
connect( m_osduConnector,
|
|
|
|
|
SIGNAL( wellboreTrajectoryFinished( const QString&, int, const QString& ) ),
|
|
|
|
|
SLOT( wellboreTrajectoryFinished( const QString&, int, const QString& ) ) );
|
2025-12-10 09:49:06 +01:00
|
|
|
|
|
|
|
|
connect( m_showAllRadioButton, SIGNAL( toggled( bool ) ), this, SLOT( onFilterChanged() ) );
|
|
|
|
|
connect( m_showActualRadioButton, SIGNAL( toggled( bool ) ), this, SLOT( onFilterChanged() ) );
|
2013-09-02 08:39:29 +02:00
|
|
|
}
|
2013-09-04 08:03:11 +02:00
|
|
|
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-02 08:39:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-09-04 08:03:11 +02:00
|
|
|
void WellSummaryPage::initializePage()
|
2013-09-02 08:39:29 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
RiuWellImportWizard* wiz = dynamic_cast<RiuWellImportWizard*>( wizard() );
|
2024-02-28 08:10:52 +01:00
|
|
|
|
2025-12-10 08:41:36 +01:00
|
|
|
m_textEdit->clear();
|
|
|
|
|
|
2024-06-17 22:21:32 +02:00
|
|
|
QMutexLocker lock( &m_mutex );
|
|
|
|
|
m_pendingWellboreIds.clear();
|
2025-12-10 09:49:06 +01:00
|
|
|
m_wellboreTrajectories.clear();
|
2024-06-17 22:21:32 +02:00
|
|
|
for ( const QString& wellboreId : wiz->selectedWellboreIds() )
|
|
|
|
|
{
|
|
|
|
|
m_pendingWellboreIds.insert( wellboreId );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ( const QString& wellboreId : wiz->selectedWellboreIds() )
|
|
|
|
|
{
|
|
|
|
|
wiz->downloadWellPaths( wellboreId );
|
|
|
|
|
}
|
2013-09-02 08:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-08 10:05:24 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2013-09-08 10:05:24 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-06-17 22:21:32 +02:00
|
|
|
void WellSummaryPage::wellboreTrajectoryFinished( const QString& wellboreId, int numTrajectories, const QString& errorMessage )
|
2013-09-08 10:05:24 +02:00
|
|
|
{
|
2024-02-28 08:10:52 +01:00
|
|
|
std::vector<OsduWellboreTrajectory> wellboreTrajectories = m_osduConnector->wellboreTrajectories( wellboreId );
|
2015-08-12 18:44:03 +02:00
|
|
|
|
2024-02-28 08:10:52 +01:00
|
|
|
{
|
2024-06-17 22:21:32 +02:00
|
|
|
QMutexLocker lock( &m_mutex );
|
|
|
|
|
|
2025-12-10 09:49:06 +01:00
|
|
|
// Store trajectory data for filtering
|
|
|
|
|
m_wellboreTrajectories[wellboreId] = wellboreTrajectories;
|
|
|
|
|
|
2025-11-21 11:00:31 +01:00
|
|
|
std::optional<OsduWellbore> wellbore = m_osduConnector->wellboreById( wellboreId );
|
|
|
|
|
if ( wellbore.has_value() )
|
2024-02-28 08:10:52 +01:00
|
|
|
{
|
2024-06-17 22:21:32 +02:00
|
|
|
if ( !errorMessage.isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
m_textEdit->append( QString( "Wellbore '%1' download failed: %2." ).arg( wellbore.value().name ).arg( errorMessage ) );
|
|
|
|
|
}
|
|
|
|
|
else if ( numTrajectories == 0 )
|
|
|
|
|
{
|
|
|
|
|
m_textEdit->append( QString( "Wellbore '%1': No trajectory found." ).arg( wellbore.value().name ) );
|
|
|
|
|
}
|
2025-12-10 08:41:36 +01:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_textEdit->append( QString( "Wellbore '%1': Found %2 trajectory(ies)." ).arg( wellbore.value().name ).arg( numTrajectories ) );
|
|
|
|
|
}
|
2025-12-10 09:49:06 +01:00
|
|
|
}
|
2024-06-17 22:21:32 +02:00
|
|
|
|
2025-12-10 09:49:06 +01:00
|
|
|
m_pendingWellboreIds.erase( wellboreId );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update the display after data is loaded
|
|
|
|
|
if ( m_pendingWellboreIds.empty() )
|
|
|
|
|
{
|
|
|
|
|
updateSummaryDisplay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emit( completeChanged() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void WellSummaryPage::onFilterChanged()
|
|
|
|
|
{
|
|
|
|
|
if ( m_pendingWellboreIds.empty() )
|
|
|
|
|
{
|
|
|
|
|
updateSummaryDisplay();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void WellSummaryPage::updateSummaryDisplay()
|
|
|
|
|
{
|
|
|
|
|
RiuWellImportWizard* wiz = dynamic_cast<RiuWellImportWizard*>( wizard() );
|
|
|
|
|
if ( !wiz ) return;
|
|
|
|
|
|
|
|
|
|
// Clear the text display
|
|
|
|
|
m_textEdit->clear();
|
|
|
|
|
|
|
|
|
|
// Clear existing well infos and rebuild based on current filter
|
|
|
|
|
wiz->clearWellInfos();
|
|
|
|
|
|
|
|
|
|
QMutexLocker lock( &m_mutex );
|
|
|
|
|
|
|
|
|
|
for ( const auto& [wellboreId, trajectories] : m_wellboreTrajectories )
|
|
|
|
|
{
|
|
|
|
|
std::optional<OsduWellbore> wellbore = m_osduConnector->wellboreById( wellboreId );
|
|
|
|
|
if ( wellbore.has_value() )
|
|
|
|
|
{
|
|
|
|
|
int includedCount = 0;
|
|
|
|
|
for ( const auto& w : trajectories )
|
|
|
|
|
{
|
|
|
|
|
if ( shouldIncludeTrajectory( w.existenceKind ) )
|
|
|
|
|
{
|
|
|
|
|
QString wellboreTrajectoryId = w.id;
|
|
|
|
|
wiz->addWellInfo( { .name = wellbore.value().name,
|
|
|
|
|
.wellId = wellbore.value().wellId,
|
|
|
|
|
.wellboreId = w.wellboreId,
|
|
|
|
|
.wellboreTrajectoryId = wellboreTrajectoryId,
|
|
|
|
|
.existenceKind = w.existenceKind,
|
|
|
|
|
.datumElevation = wellbore.value().datumElevation } );
|
|
|
|
|
includedCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Show trajectory count and filtering info
|
|
|
|
|
if ( m_showActualRadioButton->isChecked() )
|
|
|
|
|
{
|
|
|
|
|
if ( includedCount != static_cast<int>( trajectories.size() ) )
|
|
|
|
|
{
|
|
|
|
|
m_textEdit->append( QString( "Wellbore '%1': Found %2 trajectory(ies), %3 included after filtering." )
|
|
|
|
|
.arg( wellbore.value().name )
|
|
|
|
|
.arg( trajectories.size() )
|
|
|
|
|
.arg( includedCount ) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_textEdit->append( QString( "Wellbore '%1': Found %2 trajectory(ies) (all match filter)." )
|
|
|
|
|
.arg( wellbore.value().name )
|
|
|
|
|
.arg( trajectories.size() ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2024-06-17 22:21:32 +02:00
|
|
|
{
|
2025-12-10 09:49:06 +01:00
|
|
|
m_textEdit->append(
|
|
|
|
|
QString( "Wellbore '%1': Found %2 trajectory(ies)." ).arg( wellbore.value().name ).arg( trajectories.size() ) );
|
2024-06-17 22:21:32 +02:00
|
|
|
}
|
2024-02-28 08:10:52 +01:00
|
|
|
}
|
2025-12-10 09:49:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
2024-06-17 22:21:32 +02:00
|
|
|
|
2025-12-10 09:49:06 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool WellSummaryPage::shouldIncludeTrajectory( const QString& existenceKind ) const
|
|
|
|
|
{
|
|
|
|
|
if ( m_showActualRadioButton->isChecked() )
|
|
|
|
|
{
|
|
|
|
|
// Match the OSDU format: "data:reference-data--ExistenceKind:Actual:"
|
|
|
|
|
return existenceKind.contains( ":Actual:", Qt::CaseInsensitive );
|
2024-02-28 08:10:52 +01:00
|
|
|
}
|
2024-06-17 22:21:32 +02:00
|
|
|
|
2025-12-10 09:49:06 +01:00
|
|
|
return true;
|
2024-06-17 22:21:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool WellSummaryPage::isComplete() const
|
|
|
|
|
{
|
|
|
|
|
QMutexLocker lock( &m_mutex );
|
|
|
|
|
return m_pendingWellboreIds.empty();
|
2015-08-12 18:44:03 +02:00
|
|
|
}
|