mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added command feature for SSIHUB import
This commit is contained in:
@@ -39,6 +39,7 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJ.h
|
|||||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceK.h
|
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceK.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputProperty.h
|
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputProperty.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
|
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicImportWellPathsSsihubFeature.h
|
||||||
|
|
||||||
# General delete of any object in a child array field
|
# General delete of any object in a child array field
|
||||||
${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h
|
${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h
|
||||||
@@ -80,6 +81,7 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJ.cpp
|
|||||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceK.cpp
|
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceK.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputProperty.cpp
|
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputProperty.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
|
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicImportWellPathsSsihubFeature.cpp
|
||||||
|
|
||||||
# General delete of any object in a child array field
|
# General delete of any object in a child array field
|
||||||
${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.cpp
|
${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.cpp
|
||||||
|
|||||||
146
ApplicationCode/Commands/RicImportWellPathsSsihubFeature.cpp
Normal file
146
ApplicationCode/Commands/RicImportWellPathsSsihubFeature.cpp
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
//##################################################################################################
|
||||||
|
//
|
||||||
|
// Custom Visualization Core library
|
||||||
|
// Copyright (C) 2011-2013 Ceetron AS
|
||||||
|
//
|
||||||
|
// This library may be used under the terms of either the GNU General Public License or
|
||||||
|
// the GNU Lesser General Public License as follows:
|
||||||
|
//
|
||||||
|
// GNU General Public License Usage
|
||||||
|
// This library 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.
|
||||||
|
//
|
||||||
|
// This library 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.
|
||||||
|
//
|
||||||
|
// GNU Lesser General Public License Usage
|
||||||
|
// This library is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
//##################################################################################################
|
||||||
|
|
||||||
|
#include "RicImportWellPathsSsihubFeature.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(RicImportWellPathsSsihubFeature, "RicImportWellPathsSsihubFeature");
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicImportWellPathsSsihubFeature::isCommandEnabled()
|
||||||
|
{
|
||||||
|
RiaApplication* app = RiaApplication::instance();
|
||||||
|
if (!app->project())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!QFile::exists(app->project()->fileName()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicImportWellPathsSsihubFeature::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 RicImportWellPathsSsihubFeature::setupActionLook(QAction* actionToSetup)
|
||||||
|
{
|
||||||
|
actionToSetup->setText("Import Well Paths from &SSI-hub");
|
||||||
|
actionToSetup->setIcon(QIcon(":/WellCollection.png"));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end namespace caf
|
||||||
61
ApplicationCode/Commands/RicImportWellPathsSsihubFeature.h
Normal file
61
ApplicationCode/Commands/RicImportWellPathsSsihubFeature.h
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
//##################################################################################################
|
||||||
|
//
|
||||||
|
// Custom Visualization Core library
|
||||||
|
// Copyright (C) 2011-2013 Ceetron AS
|
||||||
|
//
|
||||||
|
// This library may be used under the terms of either the GNU General Public License or
|
||||||
|
// the GNU Lesser General Public License as follows:
|
||||||
|
//
|
||||||
|
// GNU General Public License Usage
|
||||||
|
// This library 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.
|
||||||
|
//
|
||||||
|
// This library 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.
|
||||||
|
//
|
||||||
|
// GNU Lesser General Public License Usage
|
||||||
|
// This library is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
//##################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "cafCmdFeature.h"
|
||||||
|
|
||||||
|
namespace caf
|
||||||
|
{
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RicImportWellPathsSsihubFeature : public CmdFeature
|
||||||
|
{
|
||||||
|
CAF_CMD_HEADER_INIT;
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Overrides
|
||||||
|
virtual bool isCommandEnabled();
|
||||||
|
virtual void onActionTriggered( bool isChecked );
|
||||||
|
virtual void setupActionLook( QAction* actionToSetup );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // end namespace caf
|
||||||
@@ -599,6 +599,10 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
|
|||||||
|
|
||||||
actions.push_back(commandManager->action("RicDeleteItemFeature"));
|
actions.push_back(commandManager->action("RicDeleteItemFeature"));
|
||||||
}
|
}
|
||||||
|
else if (dynamic_cast<RimWellPathCollection*>(uiItem))
|
||||||
|
{
|
||||||
|
actions.push_back(commandManager->action("RicImportWellPathsSsihubFeature"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,8 @@
|
|||||||
#include "cafAboutDialog.h"
|
#include "cafAboutDialog.h"
|
||||||
#include "cafAnimationToolBar.h"
|
#include "cafAnimationToolBar.h"
|
||||||
#include "cafCmdExecCommandManager.h"
|
#include "cafCmdExecCommandManager.h"
|
||||||
|
#include "cafCmdFeatureManager.h"
|
||||||
|
#include "cafPdmDefaultObjectFactory.h"
|
||||||
#include "cafPdmFieldCvfMat4d.h"
|
#include "cafPdmFieldCvfMat4d.h"
|
||||||
#include "cafPdmObjectGroup.h"
|
#include "cafPdmObjectGroup.h"
|
||||||
#include "cafPdmSettings.h"
|
#include "cafPdmSettings.h"
|
||||||
@@ -72,7 +74,6 @@
|
|||||||
#include "cafSelectionManager.h"
|
#include "cafSelectionManager.h"
|
||||||
|
|
||||||
#include "cvfTimer.h"
|
#include "cvfTimer.h"
|
||||||
#include "cafPdmDefaultObjectFactory.h"
|
|
||||||
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
@@ -1964,61 +1965,9 @@ void RiuMainWindow::selectedCases(std::vector<RimCase*>& cases)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuMainWindow::slotImportWellPathsFromSSIHub()
|
void RiuMainWindow::slotImportWellPathsFromSSIHub()
|
||||||
{
|
{
|
||||||
RiaApplication* app = RiaApplication::instance();
|
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
|
||||||
if (!app->project())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!QFile::exists(app->project()->fileName()))
|
commandManager->action("RicImportWellPathsSsihubFeature")->trigger();
|
||||||
{
|
|
||||||
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(), this);
|
|
||||||
|
|
||||||
// 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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user