diff --git a/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake index b249623bc5..063a266700 100644 --- a/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake @@ -6,6 +6,7 @@ endif() set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.h +${CEE_CURRENT_LIST_DIR}RicWellPathImportCompletionsFileFeature.h ${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.h ${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.h ${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.h @@ -13,6 +14,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.h set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.cpp +${CEE_CURRENT_LIST_DIR}RicWellPathImportCompletionsFileFeature.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.cpp diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathImportCompletionsFileFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathImportCompletionsFileFeature.cpp new file mode 100644 index 0000000000..d1e319471f --- /dev/null +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathImportCompletionsFileFeature.cpp @@ -0,0 +1,92 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicWellPathImportCompletionsFileFeature.h" + +#include "RiaApplication.h" + +#include "RimProject.h" +#include "RimWellPath.h" +#include "RimWellPathCompletionCollection.h" + +#include "RiuMainWindow.h" + +#include "cafSelectionManager.h" + +#include +#include + +namespace caf +{ + CAF_CMD_SOURCE_INIT(RicWellPathImportCompletionsFileFeature, "RicWellPathImportCompletionsFileFeature"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicWellPathImportCompletionsFileFeature::isCommandEnabled() +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + if (objects.size() == 1) { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathImportCompletionsFileFeature::onActionTriggered(bool isChecked) +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + CVF_ASSERT(objects.size() == 1); + + // Open dialog box to select well path files + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->lastUsedDialogDirectory("WELLPATH_DIR"); + QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Well Path Completions", defaultDir, "Well Path Completions (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)"); + + if (wellPathFilePaths.size() < 1) return; + + // Remember the path to next time + app->setLastUsedDialogDirectory("WELLPATH_DIR", QFileInfo(wellPathFilePaths.last()).absolutePath()); + + objects[0]->m_completionCollection()->importCompletionsFromFile(wellPathFilePaths); + + if (app->project()) + { + app->project()->createDisplayModelAndRedrawAllViews(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathImportCompletionsFileFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Import Completions from File"); + actionToSetup->setIcon(QIcon(":/Well.png")); +} + +} // end namespace caf diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathImportCompletionsFileFeature.h b/ApplicationCode/Commands/WellPathCommands/RicWellPathImportCompletionsFileFeature.h new file mode 100644 index 0000000000..1967c04d89 --- /dev/null +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathImportCompletionsFileFeature.h @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +namespace caf +{ + +//================================================================================================== +/// +//================================================================================================== +class RicWellPathImportCompletionsFileFeature : public CmdFeature +{ + CAF_CMD_HEADER_INIT; +protected: + + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); +}; + + + +} // end namespace caf diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 29e3f8564e..045956893a 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -397,6 +397,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection() commandIds << "RicNewFishbonesSubsFeature"; commandIds << "RicExportFishbonesLateralsFeature"; + commandIds << "RicWellPathImportCompletionsFileFeature"; // Work in progress -- End diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index 73820fa281..d29ac75678 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -30,6 +30,7 @@ #include "RimWellLogFile.h" #include "RimWellLogPlotCollection.h" #include "RimWellPathCollection.h" +#include "RimWellPathCompletionCollection.h" #include "RimFishbonesMultipleSubs.h" @@ -37,6 +38,8 @@ #include "RivWellPathPartMgr.h" +#include "cafPdmUiTreeOrdering.h" + #include #include #include @@ -98,6 +101,10 @@ RimWellPath::RimWellPath() CAF_PDM_InitField(&wellPathRadiusScaleFactor, "WellPathRadiusScale", 1.0, "Well path radius scale", "", "", ""); CAF_PDM_InitField(&wellPathColor, "WellPathColor", cvf::Color3f(0.999f, 0.333f, 0.999f), "Well path color", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_completionCollection, "Completions", "Completions", "", "", ""); + m_completionCollection = new RimWellPathCompletionCollection; + m_completionCollection.uiCapability()->setUiHidden(true); CAF_PDM_InitFieldNoDefault(&m_wellLogFile, "WellLogFile", "Well Log File", "", "", ""); m_wellLogFile.uiCapability()->setUiHidden(true); @@ -270,6 +277,20 @@ void RimWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPath::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) +{ + uiTreeOrdering.skipRemainingChildren(true); + uiTreeOrdering.add(&m_wellLogFile); + if (!m_completionCollection->m_completions.empty()) + { + uiTreeOrdering.add(&m_completionCollection); + } + uiTreeOrdering.add(&fishbonesSubs); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index 6becb12a4b..4c33bb802a 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -36,6 +36,7 @@ class RifWellPathImporter; class RigWellPath; class RimProject; class RimWellLogFile; +class RimWellPathCompletionCollection; class RivWellPathPartMgr; class RimFishbonesMultipleSubs; @@ -71,6 +72,7 @@ public: caf::PdmField wellPathRadiusScaleFactor; caf::PdmChildField m_wellLogFile; + caf::PdmChildField m_completionCollection; RigWellPath* wellPathGeometry(); caf::PdmChildArrayField fishbonesSubs; @@ -89,6 +91,7 @@ private: void setSurveyType(QString surveyType); virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); + virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) override; bool isStoredInCache(); QString getCacheFileName();