mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2383 Eclipse cases import. New command feature using file hierarchy dialog
This commit is contained in:
@@ -17,6 +17,7 @@ ${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewExec.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicImportEclipseCasesFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.h
|
||||
@@ -38,6 +39,7 @@ ${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewExec.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicImportEclipseCasesFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.cpp
|
||||
|
||||
@@ -59,7 +59,7 @@ void RicImportEclipseCaseFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
QString fileName = fileNames[i];
|
||||
|
||||
if (!fileNames.isEmpty())
|
||||
if (!fileName.isEmpty())
|
||||
{
|
||||
if (RiaImportEclipseCaseTools::openEclipseCaseFromFile(fileName))
|
||||
{
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicImportEclipseCasesFeature.h"
|
||||
|
||||
#include "RiaImportEclipseCaseTools.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RicFileHierarchyDialog.h"
|
||||
|
||||
#include "RimEclipseCaseCollection.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicImportEclipseCasesFeature, "RicImportEclipseCasesFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicImportEclipseCasesFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportEclipseCasesFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID");
|
||||
|
||||
RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(NULL,
|
||||
"Import Eclipse Cases",
|
||||
defaultDir,
|
||||
m_pathFilter,
|
||||
m_fileNameFilter,
|
||||
QStringList() << ".EGRID" << ".GRID");
|
||||
|
||||
// Remember filters
|
||||
m_pathFilter = result.pathFilter;
|
||||
m_fileNameFilter = result.fileNameFilter;
|
||||
|
||||
if (!result.ok) return;
|
||||
|
||||
// Remember the path to next time
|
||||
app->setLastUsedDialogDirectory("BINARY_GRID", QFileInfo(result.rootDir).absoluteFilePath());
|
||||
|
||||
int i;
|
||||
for (i = 0; i < result.files.size(); i++)
|
||||
{
|
||||
QString fileName = result.files[i];
|
||||
|
||||
if (!fileName.isEmpty())
|
||||
{
|
||||
if (RiaImportEclipseCaseTools::openEclipseCaseFromFile(fileName))
|
||||
{
|
||||
app->addToRecentFiles(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportEclipseCasesFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setIcon(QIcon(":/Case48x48.png"));
|
||||
actionToSetup->setText("Import Eclipse Cases Recursively");
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicImportEclipseCasesFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicImportEclipseCasesFeature() : m_pathFilter("*"), m_fileNameFilter("*") {}
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
|
||||
private:
|
||||
QString m_pathFilter;
|
||||
QString m_fileNameFilter;
|
||||
};
|
||||
|
||||
|
||||
@@ -123,6 +123,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
if (dynamic_cast<RimEclipseCaseCollection*>(uiItem))
|
||||
{
|
||||
menuBuilder << "RicImportEclipseCaseFeature";
|
||||
menuBuilder << "RicImportEclipseCasesFeature";
|
||||
menuBuilder << "RicImportInputEclipseCaseFeature";
|
||||
menuBuilder << "RicCreateGridCaseGroupFeature";
|
||||
menuBuilder << "RicCreateGridCaseGroupFromFilesFeature";
|
||||
|
||||
@@ -185,6 +185,7 @@ void RiuMainPlotWindow::createMenus()
|
||||
|
||||
QMenu* importMenu = fileMenu->addMenu("&Import");
|
||||
importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature"));
|
||||
importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCasesFeature"));
|
||||
importMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature"));
|
||||
importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature"));
|
||||
importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature"));
|
||||
@@ -257,6 +258,7 @@ QStringList RiuMainPlotWindow::toolbarCommandIds(const QString& toolbarName)
|
||||
if (toolbarName.isEmpty() || toolbarName == "Standard")
|
||||
{
|
||||
commandIds << "RicImportEclipseCaseFeature";
|
||||
commandIds << "RicImportEclipseCasesFeature";
|
||||
commandIds << "RicImportInputEclipseCaseFeature";
|
||||
commandIds << "RicImportSummaryCaseFeature";
|
||||
commandIds << "RicOpenProjectFeature";
|
||||
|
||||
@@ -352,6 +352,7 @@ void RiuMainWindow::createMenus()
|
||||
|
||||
QMenu* importMenu = fileMenu->addMenu("&Import");
|
||||
importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature"));
|
||||
importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCasesFeature"));
|
||||
importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseTimeStepFilterFeature"));
|
||||
importMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature"));
|
||||
importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature"));
|
||||
|
||||
Reference in New Issue
Block a user