2015-08-14 02:45:57 -05:00
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-06-14 03:45:47 -05:00
|
|
|
|
//
|
2015-08-14 02:45:57 -05: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-06-14 03:45:47 -05:00
|
|
|
|
//
|
2015-08-14 02:45:57 -05: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-06-14 03:45:47 -05:00
|
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2015-08-14 02:45:57 -05:00
|
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
2015-08-12 13:12:50 -05:00
|
|
|
|
|
2015-08-12 14:09:03 -05:00
|
|
|
|
#include "RicWellPathsImportSsihubFeature.h"
|
2015-08-12 13:12:50 -05:00
|
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
2021-04-28 03:29:53 -05:00
|
|
|
|
#include "RiaGuiApplication.h"
|
2015-08-12 13:12:50 -05:00
|
|
|
|
#include "RiaPreferences.h"
|
2019-12-11 04:39:02 -06:00
|
|
|
|
|
|
|
|
|
#include "RimFileWellPath.h"
|
2015-08-12 13:12:50 -05:00
|
|
|
|
#include "RimProject.h"
|
|
|
|
|
#include "RimTools.h"
|
|
|
|
|
#include "RimWellPathImport.h"
|
2019-12-11 04:39:02 -06:00
|
|
|
|
|
2015-08-12 13:12:50 -05:00
|
|
|
|
#include "RiuMainWindow.h"
|
|
|
|
|
#include "RiuWellImportWizard.h"
|
|
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFile>
|
2019-06-14 03:45:24 -05:00
|
|
|
|
#include <QMessageBox>
|
2015-08-12 13:12:50 -05:00
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
|
CAF_CMD_SOURCE_INIT( RicWellPathsImportSsihubFeature, "RicWellPathsImportSsihubFeature" );
|
2015-08-12 13:12:50 -05:00
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-06-14 03:45:47 -05:00
|
|
|
|
///
|
2015-08-12 13:12:50 -05:00
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-08-12 14:09:03 -05:00
|
|
|
|
bool RicWellPathsImportSsihubFeature::isCommandEnabled()
|
2015-08-12 13:12:50 -05:00
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-06-14 03:45:47 -05:00
|
|
|
|
///
|
2015-08-12 13:12:50 -05:00
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
|
void RicWellPathsImportSsihubFeature::onActionTriggered( bool isChecked )
|
2015-08-12 13:12:50 -05:00
|
|
|
|
{
|
|
|
|
|
RiaApplication* app = RiaApplication::instance();
|
2019-09-06 03:40:57 -05:00
|
|
|
|
if ( !app->project() ) return;
|
2017-10-17 05:48:36 -05:00
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
|
if ( !app->isProjectSavedToDisc() )
|
2019-06-14 03:45:24 -05:00
|
|
|
|
{
|
|
|
|
|
RiaGuiApplication* guiApp = RiaGuiApplication::instance();
|
2019-09-06 03:40:57 -05:00
|
|
|
|
if ( guiApp )
|
2019-06-14 03:45:24 -05:00
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
|
QMessageBox msgBox( guiApp->mainWindow() );
|
|
|
|
|
msgBox.setIcon( QMessageBox::Question );
|
2019-06-14 03:45:24 -05:00
|
|
|
|
|
2023-02-26 03:48:40 -06:00
|
|
|
|
QString questionText = QString( "Import of well paths will be stored as a part of a ResInsight project file. Please "
|
|
|
|
|
"save the project to file before importing well paths." );
|
2015-08-12 13:12:50 -05:00
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
|
msgBox.setText( questionText );
|
|
|
|
|
msgBox.setInformativeText( "Do you want to save the project?" );
|
|
|
|
|
msgBox.setStandardButtons( QMessageBox::Yes | QMessageBox::No );
|
2019-06-14 03:45:24 -05:00
|
|
|
|
|
|
|
|
|
int ret = msgBox.exec();
|
2019-09-06 03:40:57 -05:00
|
|
|
|
if ( ret == QMessageBox::Yes )
|
2019-06-14 03:45:24 -05:00
|
|
|
|
{
|
|
|
|
|
guiApp->saveProject();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
|
if ( !app->isProjectSavedToDisc() )
|
2019-06-14 03:45:24 -05:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-12 13:12:50 -05:00
|
|
|
|
|
|
|
|
|
// Update the UTM bounding box from the reservoir
|
|
|
|
|
app->project()->computeUtmAreaOfInterest();
|
|
|
|
|
|
2019-12-11 04:39:02 -06:00
|
|
|
|
QString wellPathsFolderPath = RimFileWellPath::getCacheDirectoryPath();
|
2019-09-06 03:40:57 -05:00
|
|
|
|
QDir::root().mkpath( wellPathsFolderPath );
|
2015-08-12 13:12:50 -05:00
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
|
if ( !app->project()->wellPathImport() ) return;
|
2015-08-12 13:12:50 -05:00
|
|
|
|
|
|
|
|
|
// Keep a copy of the import settings, and restore if cancel is pressed in the import wizard
|
2016-12-12 00:29:44 -06:00
|
|
|
|
QString copyOfOriginalObject = app->project()->wellPathImport()->writeObjectToXmlString();
|
2015-08-12 13:12:50 -05:00
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
|
if ( !app->preferences() ) return;
|
|
|
|
|
RiuWellImportWizard wellImportwizard( app->preferences()->ssihubAddress,
|
|
|
|
|
wellPathsFolderPath,
|
|
|
|
|
app->project()->wellPathImport(),
|
|
|
|
|
RiuMainWindow::instance() );
|
2015-08-12 13:12:50 -05:00
|
|
|
|
|
|
|
|
|
// Get password/username from application cache
|
|
|
|
|
{
|
|
|
|
|
#ifdef _DEBUG
|
2019-06-14 03:45:47 -05:00
|
|
|
|
// Valid credentials for ssihubfake received in mail from H<>kon
|
2015-12-07 05:53:36 -06:00
|
|
|
|
QString ssihubUsername = "admin";
|
|
|
|
|
QString ssihubPassword = "resinsight";
|
|
|
|
|
#else
|
2019-09-06 03:40:57 -05:00
|
|
|
|
QString ssihubUsername = app->cacheDataObject( "ssihub_username" ).toString();
|
2019-05-09 06:43:18 -05:00
|
|
|
|
QString ssihubPassword;
|
2015-08-12 13:12:50 -05:00
|
|
|
|
#endif
|
2019-09-06 03:40:57 -05:00
|
|
|
|
wellImportwizard.setCredentials( ssihubUsername, ssihubPassword );
|
2015-08-12 13:12:50 -05:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
|
if ( QDialog::Accepted == wellImportwizard.exec() )
|
2015-08-12 13:12:50 -05:00
|
|
|
|
{
|
|
|
|
|
QStringList wellPaths = wellImportwizard.absoluteFilePathsToWellPaths();
|
2019-09-06 03:40:57 -05:00
|
|
|
|
if ( wellPaths.size() > 0 )
|
2015-08-12 13:12:50 -05:00
|
|
|
|
{
|
2019-10-09 02:21:28 -05:00
|
|
|
|
QStringList errorMessages;
|
2023-03-07 05:51:14 -06:00
|
|
|
|
app->addWellPathsToModel( wellPaths, &errorMessages );
|
2018-09-11 05:41:45 -05:00
|
|
|
|
app->project()->scheduleCreateDisplayModelAndRedrawAllViews();
|
2015-08-12 13:12:50 -05:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
|
app->setCacheDataObject( "ssihub_username", wellImportwizard.field( "username" ) );
|
2015-08-12 13:12:50 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-02-26 03:48:40 -06:00
|
|
|
|
app->project()->wellPathImport()->readObjectFromXmlString( copyOfOriginalObject, caf::PdmDefaultObjectFactory::instance() );
|
2015-08-12 13:12:50 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-06-14 03:45:47 -05:00
|
|
|
|
///
|
2015-08-12 13:12:50 -05:00
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
|
void RicWellPathsImportSsihubFeature::setupActionLook( QAction* actionToSetup )
|
2015-08-12 13:12:50 -05:00
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
|
actionToSetup->setText( "Import Well Paths from &SSI-hub" );
|
|
|
|
|
actionToSetup->setIcon( QIcon( ":/WellCollection.png" ) );
|
2015-08-12 13:12:50 -05:00
|
|
|
|
}
|