2015-08-14 02:45:57 -05:00
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
|
|
|
|
//
|
|
|
|
|
// 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.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
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"
|
|
|
|
|
#include "RiaPreferences.h"
|
|
|
|
|
#include "RimProject.h"
|
|
|
|
|
#include "RimTools.h"
|
|
|
|
|
#include "RimWellPathImport.h"
|
|
|
|
|
#include "RiuMainWindow.h"
|
|
|
|
|
#include "RiuWellImportWizard.h"
|
|
|
|
|
|
2017-05-11 02:23:13 -05:00
|
|
|
|
#include "cafUtils.h"
|
|
|
|
|
|
2015-08-12 13:12:50 -05:00
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFile>
|
|
|
|
|
|
2017-05-19 06:40:38 -05:00
|
|
|
|
CAF_CMD_SOURCE_INIT(RicWellPathsImportSsihubFeature, "RicWellPathsImportSsihubFeature");
|
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
|
|
|
|
{
|
|
|
|
|
RiaApplication* app = RiaApplication::instance();
|
|
|
|
|
if (!app->project())
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-11 02:23:13 -05:00
|
|
|
|
if (!caf::Utils::fileExists(app->project()->fileName()))
|
2015-08-12 13:12:50 -05:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-08-12 14:09:03 -05:00
|
|
|
|
void RicWellPathsImportSsihubFeature::onActionTriggered(bool isChecked)
|
2015-08-12 13:12:50 -05:00
|
|
|
|
{
|
|
|
|
|
RiaApplication* app = RiaApplication::instance();
|
2017-10-17 05:48:36 -05:00
|
|
|
|
if (!app->project()) return;
|
|
|
|
|
|
|
|
|
|
if (!caf::Utils::fileExists(app->project()->fileName())) return;
|
2015-08-12 13:12:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update the UTM bounding box from the reservoir
|
|
|
|
|
app->project()->computeUtmAreaOfInterest();
|
|
|
|
|
|
|
|
|
|
QString wellPathsFolderPath = RimTools::getCacheRootDirectoryPathFromProject();
|
|
|
|
|
wellPathsFolderPath += "_wellpaths";
|
|
|
|
|
QDir::root().mkpath(wellPathsFolderPath);
|
|
|
|
|
|
2017-10-17 05:48:36 -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
|
|
|
|
|
2017-10-17 05:48:36 -05:00
|
|
|
|
if (!app->preferences()) return;
|
2015-08-12 13:12:50 -05:00
|
|
|
|
RiuWellImportWizard wellImportwizard(app->preferences()->ssihubAddress, wellPathsFolderPath, app->project()->wellPathImport(), RiuMainWindow::instance());
|
|
|
|
|
|
|
|
|
|
// Get password/username from application cache
|
|
|
|
|
{
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
// 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
|
|
|
|
|
QString ssihubUsername = app->cacheDataObject("ssihub_username").toString();
|
|
|
|
|
QString ssihubPassword = app->cacheDataObject("ssihub_password").toString();
|
2015-08-12 13:12:50 -05:00
|
|
|
|
#endif
|
|
|
|
|
wellImportwizard.setCredentials(ssihubUsername, ssihubPassword);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (QDialog::Accepted == wellImportwizard.exec())
|
|
|
|
|
{
|
|
|
|
|
QStringList wellPaths = wellImportwizard.absoluteFilePathsToWellPaths();
|
|
|
|
|
if (wellPaths.size() > 0)
|
|
|
|
|
{
|
|
|
|
|
app->addWellPathsToModel(wellPaths);
|
2018-09-11 05:41:45 -05:00
|
|
|
|
app->project()->scheduleCreateDisplayModelAndRedrawAllViews();
|
2015-08-12 13:12:50 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app->setCacheDataObject("ssihub_username", wellImportwizard.field("username"));
|
|
|
|
|
app->setCacheDataObject("ssihub_password", wellImportwizard.field("password"));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-12-12 00:29:44 -06:00
|
|
|
|
app->project()->wellPathImport()->readObjectFromXmlString(copyOfOriginalObject, caf::PdmDefaultObjectFactory::instance());
|
2015-08-12 13:12:50 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-08-12 14:09:03 -05:00
|
|
|
|
void RicWellPathsImportSsihubFeature::setupActionLook(QAction* actionToSetup)
|
2015-08-12 13:12:50 -05:00
|
|
|
|
{
|
|
|
|
|
actionToSetup->setText("Import Well Paths from &SSI-hub");
|
|
|
|
|
actionToSetup->setIcon(QIcon(":/WellCollection.png"));
|
|
|
|
|
}
|