mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Moved well path commands into separate folder
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicWellPathsImportSsihubFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimTools.h"
|
||||
#include "RimWellPathImport.h"
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuWellImportWizard.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
CAF_CMD_SOURCE_INIT(RicWellPathsImportSsihubFeature, "RicWellPathsImportSsihubFeature");
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicWellPathsImportSsihubFeature::isCommandEnabled()
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
if (!app->project())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!QFile::exists(app->project()->fileName()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellPathsImportSsihubFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
if (!app->project())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!QFile::exists(app->project()->fileName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the UTM bounding box from the reservoir
|
||||
app->project()->computeUtmAreaOfInterest();
|
||||
|
||||
QString wellPathsFolderPath = RimTools::getCacheRootDirectoryPathFromProject();
|
||||
wellPathsFolderPath += "_wellpaths";
|
||||
QDir::root().mkpath(wellPathsFolderPath);
|
||||
|
||||
|
||||
// Keep a copy of the import settings, and restore if cancel is pressed in the import wizard
|
||||
QString copyOfOriginalObject = xmlObj(app->project()->wellPathImport())->writeObjectToXmlString();
|
||||
|
||||
RiuWellImportWizard wellImportwizard(app->preferences()->ssihubAddress, wellPathsFolderPath, app->project()->wellPathImport(), RiuMainWindow::instance());
|
||||
|
||||
// Get password/username from application cache
|
||||
{
|
||||
QString ssihubUsername = app->cacheDataObject("ssihub_username").toString();
|
||||
QString ssihubPassword = app->cacheDataObject("ssihub_password").toString();
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
// Valid credentials for ssihubfake received in mail from H<>kon
|
||||
ssihubUsername = "admin";
|
||||
ssihubPassword = "resinsight";
|
||||
#endif
|
||||
|
||||
wellImportwizard.setCredentials(ssihubUsername, ssihubPassword);
|
||||
}
|
||||
|
||||
if (QDialog::Accepted == wellImportwizard.exec())
|
||||
{
|
||||
QStringList wellPaths = wellImportwizard.absoluteFilePathsToWellPaths();
|
||||
if (wellPaths.size() > 0)
|
||||
{
|
||||
app->addWellPathsToModel(wellPaths);
|
||||
app->project()->createDisplayModelAndRedrawAllViews();
|
||||
}
|
||||
|
||||
app->setCacheDataObject("ssihub_username", wellImportwizard.field("username"));
|
||||
app->setCacheDataObject("ssihub_password", wellImportwizard.field("password"));
|
||||
}
|
||||
else
|
||||
{
|
||||
xmlObj(app->project()->wellPathImport())->readObjectFromXmlString(copyOfOriginalObject, caf::PdmDefaultObjectFactory::instance());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellPathsImportSsihubFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Import Well Paths from &SSI-hub");
|
||||
actionToSetup->setIcon(QIcon(":/WellCollection.png"));
|
||||
}
|
||||
|
||||
} // end namespace caf
|
||||
Reference in New Issue
Block a user