diff --git a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake index 5bbc65a195..9cd2ca9d6b 100644 --- a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake @@ -24,6 +24,7 @@ ${CEE_CURRENT_LIST_DIR}RicPasteWellLogPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeature.h ${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeatureUi.h ${CEE_CURRENT_LIST_DIR}RicAsciiExportWellLogPlotFeature.h +${CEE_CURRENT_LIST_DIR}RicWellLogFileCloseFeature.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -46,6 +47,7 @@ ${CEE_CURRENT_LIST_DIR}RicPasteWellLogPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeature.cpp ${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeatureUi.cpp ${CEE_CURRENT_LIST_DIR}RicAsciiExportWellLogPlotFeature.cpp +${CEE_CURRENT_LIST_DIR}RicWellLogFileCloseFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/WellLogCommands/RicWellLogFileCloseFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicWellLogFileCloseFeature.cpp new file mode 100644 index 0000000000..e5754e3cf1 --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/RicWellLogFileCloseFeature.cpp @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicWellLogFileCloseFeature.h" + +#include "RimWellPath.h" +#include "RimWellLogFile.h" + +#include "cafSelectionManagerTools.h" + +#include + +CAF_CMD_SOURCE_INIT(RicWellLogFileCloseFeature, "RicWellLogFileCloseFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicWellLogFileCloseFeature::isCommandEnabled() +{ + std::vector objects = caf::selectedObjectsByType(); + return objects.size() > 0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellLogFileCloseFeature::onActionTriggered(bool isChecked) +{ + std::vector objects = caf::selectedObjectsByType(); + + if (objects.size() == 0) return; + + for (const auto& wellLogFile : objects) + { + RimWellPath* parentWellPath; + wellLogFile->firstAncestorOrThisOfType(parentWellPath); + + if (parentWellPath != nullptr) + { + parentWellPath->removeWellLogFile(wellLogFile); + } + parentWellPath->updateConnectedEditors(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellLogFileCloseFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Close Well Log File(s)"); + actionToSetup->setIcon(QIcon(":/Erase.png")); +} diff --git a/ApplicationCode/Commands/WellLogCommands/RicWellLogFileCloseFeature.h b/ApplicationCode/Commands/WellLogCommands/RicWellLogFileCloseFeature.h new file mode 100644 index 0000000000..4445417818 --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/RicWellLogFileCloseFeature.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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" + +//================================================================================================== +/// +//================================================================================================== +class RicWellLogFileCloseFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; +protected: + + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 5782c811b5..25fb70566e 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -574,6 +574,14 @@ QStringList RimContextCommandBuilder::commandsFromSelection() commandIds << "RicWellPathDeleteFeature"; } + if (caf::CmdFeatureManager::instance()->getCommandFeature("RicWellLogFileCloseFeature")->canFeatureBeExecuted()) + { + // Special delete command for Well paths + // Placed here to fit context menu location of general delete feature + commandIds << "Separator"; + commandIds << "RicWellLogFileCloseFeature"; + } + if ( caf::CmdFeatureManager::instance()->getCommandFeature("RicCloseCaseFeature")->canFeatureBeExecuted() ) { commandIds << "Separator"; diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index de14df7cbc..7b73fc7f38 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -650,6 +650,21 @@ void RimWellPath::addWellLogFile(RimWellLogFile* logFileInfo) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPath::removeWellLogFile(const RimWellLogFile* logFileInfo) +{ + for (int i = 0; i < m_wellLogFiles.size(); i++) + { + if (m_wellLogFiles[i] == logFileInfo) + { + m_wellLogFiles.erase(i); + break; + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index 71efb8d2b5..5d54feb73c 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -65,6 +65,7 @@ public: virtual ~RimWellPath(); void addWellLogFile(RimWellLogFile* logFileInfo); + void removeWellLogFile(const RimWellLogFile* logFileInfo); virtual caf::PdmFieldHandle* userDescriptionField(); virtual caf::PdmFieldHandle* objectToggleField();