mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
(#339) Added RicImportEclipseCaseFeature
This commit is contained in:
parent
4d1f98c138
commit
cd1e04d6e8
@ -41,6 +41,7 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceKFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
|
||||
${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseFeature.h
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.h
|
||||
@ -88,6 +89,7 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceKFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseFeature.cpp
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.cpp
|
||||
|
78
ApplicationCode/Commands/RicImportEclipseCaseFeature.cpp
Normal file
78
ApplicationCode/Commands/RicImportEclipseCaseFeature.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicImportEclipseCaseFeature.h"
|
||||
|
||||
#include "RimEclipseCaseCollection.h"
|
||||
#include "RiaApplication.h"
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicImportEclipseCaseFeature, "RicImportEclipseCaseFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicImportEclipseCaseFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimEclipseCaseCollection*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
return selection.size() > 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportEclipseCaseFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
|
||||
QString defaultDir = app->defaultFileDialogDirectory("BINARY_GRID");
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Eclipse File", defaultDir, "Eclipse Grid Files (*.GRID *.EGRID)");
|
||||
if (fileNames.size()) defaultDir = QFileInfo(fileNames.last()).absolutePath();
|
||||
app->setDefaultFileDialogDirectory("BINARY_GRID", defaultDir);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < fileNames.size(); i++)
|
||||
{
|
||||
QString fileName = fileNames[i];
|
||||
|
||||
if (!fileNames.isEmpty())
|
||||
{
|
||||
if (app->openEclipseCaseFromFile(fileName))
|
||||
{
|
||||
RiuMainWindow::instance()->addRecentFiles(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportEclipseCaseFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setIcon(QIcon(":/Case48x48.png"));
|
||||
actionToSetup->setText("Import Eclipse Case");
|
||||
}
|
40
ApplicationCode/Commands/RicImportEclipseCaseFeature.h
Normal file
40
ApplicationCode/Commands/RicImportEclipseCaseFeature.h
Normal file
@ -0,0 +1,40 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 RicImportEclipseCaseFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
};
|
||||
|
||||
|
@ -558,7 +558,11 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
||||
caf::PdmUiItem* uiItem = uiItems[0];
|
||||
CVF_ASSERT(uiItem);
|
||||
|
||||
if (dynamic_cast<RimGeoMechView*>(uiItem))
|
||||
if (dynamic_cast<RimEclipseCaseCollection*>(uiItem))
|
||||
{
|
||||
commandIds << "RicImportEclipseCaseFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimGeoMechView*>(uiItem))
|
||||
{
|
||||
commandIds << "RicNewViewFeature";
|
||||
commandIds << "RicCopyReferencesToClipboardFeature";
|
||||
|
@ -899,26 +899,10 @@ void RiuMainWindow::slotImportEclipseCase()
|
||||
{
|
||||
if (checkForDocumentModifications())
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QAction* action = caf::CmdFeatureManager::instance()->action("RicImportEclipseCaseFeature");
|
||||
CVF_ASSERT(action);
|
||||
|
||||
QString defaultDir = app->defaultFileDialogDirectory("BINARY_GRID");
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Import Eclipse File", defaultDir, "Eclipse Grid Files (*.GRID *.EGRID)");
|
||||
if (fileNames.size()) defaultDir = QFileInfo(fileNames.last()).absolutePath();
|
||||
app->setDefaultFileDialogDirectory("BINARY_GRID", defaultDir);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < fileNames.size(); i++)
|
||||
{
|
||||
QString fileName = fileNames[i];
|
||||
|
||||
if (!fileNames.isEmpty())
|
||||
{
|
||||
if (app->openEclipseCaseFromFile(fileName))
|
||||
{
|
||||
addRecentFiles(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
action->trigger();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,6 +108,9 @@ public:
|
||||
|
||||
void setExpanded(const caf::PdmUiItem* uiItem, bool expanded);
|
||||
|
||||
void addRecentFiles(const QString& file);
|
||||
void removeRecentFiles(const QString& file);
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent* event);
|
||||
|
||||
@ -121,9 +124,7 @@ private:
|
||||
bool checkForDocumentModifications();
|
||||
|
||||
void updateRecentFileActions();
|
||||
void addRecentFiles(const QString& file);
|
||||
void removeRecentFiles(const QString& file);
|
||||
|
||||
|
||||
QMdiSubWindow* findMdiSubWindow(RiuViewer* viewer);
|
||||
|
||||
void storeTreeViewState();
|
||||
|
Loading…
Reference in New Issue
Block a user