From ab35d30ff5371b1f572ebc69012238b809ad33ec Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 8 Jan 2018 14:48:00 +0100 Subject: [PATCH] #2348 Elm Props: "Import Element Property Table" command --- .../Commands/CMakeLists_files.cmake | 2 + .../RicImportElementPropertyFeature.cpp | 68 +++++++++++++++++++ .../RicImportElementPropertyFeature.h | 34 ++++++++++ .../UserInterface/RiuMainPlotWindow.cpp | 1 + .../UserInterface/RiuMainWindow.cpp | 1 + 5 files changed, 106 insertions(+) create mode 100644 ApplicationCode/Commands/RicImportElementPropertyFeature.cpp create mode 100644 ApplicationCode/Commands/RicImportElementPropertyFeature.h diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 9673c13eaa..cfda894e19 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -34,6 +34,7 @@ ${CEE_CURRENT_LIST_DIR}RicReloadWellPathFormationNamesFeature.h ${CEE_CURRENT_LIST_DIR}RicNewSliceRangeFilterFeature.h ${CEE_CURRENT_LIST_DIR}RicHideIntersectionFeature.h ${CEE_CURRENT_LIST_DIR}RicHideIntersectionBoxFeature.h +${CEE_CURRENT_LIST_DIR}RicImportElementPropertyFeature.h ${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h @@ -112,6 +113,7 @@ ${CEE_CURRENT_LIST_DIR}RicReloadWellPathFormationNamesFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewSliceRangeFilterFeature.cpp ${CEE_CURRENT_LIST_DIR}RicHideIntersectionFeature.cpp ${CEE_CURRENT_LIST_DIR}RicHideIntersectionBoxFeature.cpp +${CEE_CURRENT_LIST_DIR}RicImportElementPropertyFeature.cpp ${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.cpp ${CEE_CURRENT_LIST_DIR}RicImportGeoMechCaseFeature.cpp diff --git a/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp b/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp new file mode 100644 index 0000000000..9064e42abf --- /dev/null +++ b/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp @@ -0,0 +1,68 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicImportElementPropertyFeature.h" + +#include "RiaApplication.h" + +#include +#include + +CAF_CMD_SOURCE_INIT(RicImportElementPropertyFeature, "RicImportElementPropertyFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportElementPropertyFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportElementPropertyFeature::onActionTriggered(bool isChecked) +{ + RiaApplication* app = RiaApplication::instance(); + + QString defaultDir = app->lastUsedDialogDirectory("ELM_PROPS"); + QStringList fileNames = QFileDialog::getOpenFileNames(NULL, "Import Element Property Table", defaultDir, "Property Table (*.inp)"); + + if (fileNames.size()) + { + defaultDir = QFileInfo(fileNames.last()).absolutePath(); + } + + app->setLastUsedDialogDirectory("ELM_PROPS", defaultDir); + + for (int i = 0; i < fileNames.size(); i++) + { + QString fileName = fileNames[i]; + + //TODO + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportElementPropertyFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/GeoMechCase48x48.png")); + actionToSetup->setText("Import &Element Property Table"); +} diff --git a/ApplicationCode/Commands/RicImportElementPropertyFeature.h b/ApplicationCode/Commands/RicImportElementPropertyFeature.h new file mode 100644 index 0000000000..781af3fc47 --- /dev/null +++ b/ApplicationCode/Commands/RicImportElementPropertyFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicImportElementPropertyFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index 747c1ad3b5..df865f785c 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -192,6 +192,7 @@ void RiuMainPlotWindow::createMenus() importMenu->addSeparator(); #ifdef USE_ODB_API importMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature")); importMenu->addSeparator(); #endif importMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index f8969ee52a..cb5d67a2ca 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -358,6 +358,7 @@ void RiuMainWindow::createMenus() importMenu->addSeparator(); #ifdef USE_ODB_API importMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature")); importMenu->addSeparator(); #endif importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature"));