diff --git a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake index 01adb66091..dd55b9252d 100644 --- a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake @@ -26,6 +26,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicMoveWellLogFilesFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogFileCurveFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogRftCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveDeleteFeature.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -55,6 +56,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicMoveWellLogFilesFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogFileCurveFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogRftCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveDeleteFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.cpp b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.cpp new file mode 100644 index 0000000000..866aceb212 --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.cpp @@ -0,0 +1,81 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "Ric3dWellLogCurveDeleteFeature.h" + +#include "RiaApplication.h" + +#include "Rim3dWellLogCurve.h" +#include "Rim3dWellLogCurveCollection.h" +#include "RimProject.h" + +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT(Ric3dWellLogCurveDeleteFeature, "Ric3dWellLogCurveDeleteFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Ric3dWellLogCurveDeleteFeature::isCommandEnabled() +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + if (objects.size() > 0) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Ric3dWellLogCurveDeleteFeature::onActionTriggered(bool isChecked) +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + if (objects.size() == 0) return; + + Rim3dWellLogCurve* firstCurve = objects[0]; + + Rim3dWellLogCurveCollection* curveCollection = nullptr; + firstCurve->firstAncestorOrThisOfType(curveCollection); + if (!curveCollection) return; + + for (Rim3dWellLogCurve* curve : objects) + { + curveCollection->remove3dWellLogCurve(curve); + delete curve; + } + curveCollection->redrawAffectedViewsAndEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Ric3dWellLogCurveDeleteFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Delete 3D Well Log Curve(s)"); + actionToSetup->setIcon(QIcon(":/Erase.png")); +} diff --git a/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.h b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.h new file mode 100644 index 0000000000..6dc5bb9cec --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.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 Ric3dWellLogCurveDeleteFeature : 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/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index 4ad7277a5c..7f1379968e 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -19,6 +19,7 @@ #include "Rim3dWellLogCurveCollection.h" #include "Rim3dWellLogCurve.h" +#include "RimWellPath.h" #include "RimProject.h" CAF_PDM_SOURCE_INIT(Rim3dWellLogCurveCollection, "Rim3dWellLogCurveCollection"); @@ -79,6 +80,14 @@ void Rim3dWellLogCurveCollection::add3dWellLogCurve(Rim3dWellLogCurve* curve) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurveCollection::remove3dWellLogCurve(Rim3dWellLogCurve* curve) +{ + m_3dWellLogCurves.removeChildObject(curve); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -117,6 +126,25 @@ std::vector Rim3dWellLogCurveCollection::vectorOf3dWellLogCu return curves; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurveCollection::redrawAffectedViewsAndEditors() +{ + RimProject* proj = nullptr; + this->firstAncestorOrThisOfType(proj); + if (proj) + { + proj->createDisplayModelAndRedrawAllViews(); + } + RimWellPath* path = nullptr; + this->firstAncestorOrThisOfType(path); + if (path) + { + path->updateConnectedEditors(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h index cc518cbf1f..809ecec4ce 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h @@ -46,6 +46,7 @@ public: bool has3dWellLogCurves() const; void add3dWellLogCurve(Rim3dWellLogCurve* curve); + void remove3dWellLogCurve(Rim3dWellLogCurve* curve); bool isShowingGrid() const; bool isShowingPlot() const; @@ -53,7 +54,7 @@ public: PlanePosition planePosition() const; std::vector vectorOf3dWellLogCurves() const; - + void redrawAffectedViewsAndEditors(); private: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual caf::PdmFieldHandle* objectToggleField() override; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 5ca56e055d..4fb9d19c7c 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -760,18 +760,22 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicDeleteSubItemsFeature"; } + // Special delete commands for specific features + // Placed here to fit context menu location of general delete feature if (caf::CmdFeatureManager::instance()->getCommandFeature("RicWellPathDeleteFeature")->canFeatureBeExecuted()) { - // Special delete command for Well paths - // Placed here to fit context menu location of general delete feature menuBuilder << "Separator"; menuBuilder << "RicWellPathDeleteFeature"; } + if (caf::CmdFeatureManager::instance()->getCommandFeature("Ric3dWellLogCurveDeleteFeature")->canFeatureBeExecuted()) + { + menuBuilder << "Separator"; + menuBuilder << "Ric3dWellLogCurveDeleteFeature"; + } + if (caf::CmdFeatureManager::instance()->getCommandFeature("RicWellLogFileCloseFeature")->canFeatureBeExecuted()) { - // Special delete command for Well paths - // Placed here to fit context menu location of general delete feature menuBuilder << "Separator"; menuBuilder << "RicWellLogFileCloseFeature"; }