diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index de25a61c04..c9cf21a3b8 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -124,6 +124,7 @@ list( APPEND REFERENCED_CMAKE_FILES Commands/EclipseCommands/CMakeLists_files.cmake Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake Commands/FishbonesCommands/CMakeLists_files.cmake + Commands/PerforationCommands/CMakeLists_files.cmake Commands/FlowCommands/CMakeLists_files.cmake Commands/IntersectionBoxCommands/CMakeLists_files.cmake Commands/OctaveScriptCommands/CMakeLists_files.cmake diff --git a/ApplicationCode/Commands/PerforationCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/PerforationCommands/CMakeLists_files.cmake new file mode 100644 index 0000000000..a68b40ff71 --- /dev/null +++ b/ApplicationCode/Commands/PerforationCommands/CMakeLists_files.cmake @@ -0,0 +1,23 @@ + +# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly +if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") + set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) +endif() + +set (SOURCE_GROUP_HEADER_FILES +${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalFeature.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalFeature.cpp +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "CommandFeature\\Perforations" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/PerforationCommands/RicNewPerforationIntervalFeature.cpp b/ApplicationCode/Commands/PerforationCommands/RicNewPerforationIntervalFeature.cpp new file mode 100644 index 0000000000..cb0b5e780c --- /dev/null +++ b/ApplicationCode/Commands/PerforationCommands/RicNewPerforationIntervalFeature.cpp @@ -0,0 +1,96 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicNewPerforationIntervalFeature.h" + +#include "RiuMainWindow.h" + +#include "RimPerforationInterval.h" +#include "RimPerforationCollection.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" + +#include "cafSelectionManager.h" + +#include + +namespace caf +{ + + +CAF_CMD_SOURCE_INIT(RicNewPerforationIntervalFeature, "RicNewPerforationIntervalFeature"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewPerforationIntervalFeature::isCommandEnabled() +{ + return selectedWellPath() != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewPerforationIntervalFeature::onActionTriggered(bool isChecked) +{ + RimWellPath* wellPath = selectedWellPath(); + if (wellPath == nullptr) return; + + RimPerforationInterval* perforationInterval = new RimPerforationInterval; + + wellPath->m_perforationCollection()->appendPerforation(perforationInterval); + + RimWellPathCollection* wellPathCollection = nullptr; + wellPath->firstAncestorOrThisOfType(wellPathCollection); + if (!wellPathCollection) return; + + wellPathCollection->uiCapability()->updateConnectedEditors(); + wellPathCollection->scheduleGeometryRegenAndRedrawViews(); + + RiuMainWindow::instance()->selectAsCurrentItem(perforationInterval); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewPerforationIntervalFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("New Perforation Interval"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPath * RicNewPerforationIntervalFeature::selectedWellPath() +{ + RimWellPath* wellPath = nullptr; + + caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); + + caf::PdmObjectHandle* objHandle = dynamic_cast(pdmUiItem); + if (objHandle) + { + objHandle->firstAncestorOrThisOfType(wellPath); + } + + return wellPath; +} + +} // end namespace caf diff --git a/ApplicationCode/Commands/PerforationCommands/RicNewPerforationIntervalFeature.h b/ApplicationCode/Commands/PerforationCommands/RicNewPerforationIntervalFeature.h new file mode 100644 index 0000000000..573349e0f7 --- /dev/null +++ b/ApplicationCode/Commands/PerforationCommands/RicNewPerforationIntervalFeature.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 RimWellPath; + +namespace caf +{ + +//================================================================================================== +/// +//================================================================================================== +class RicNewPerforationIntervalFeature : public CmdFeature +{ + CAF_CMD_HEADER_INIT; +protected: + + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); + +private: + RimWellPath* selectedWellPath(); +}; + + + +} // end namespace caf diff --git a/ApplicationCode/Commands/RicDeleteItemFeature.cpp b/ApplicationCode/Commands/RicDeleteItemFeature.cpp index 5f6ab643ae..6cf56c7118 100644 --- a/ApplicationCode/Commands/RicDeleteItemFeature.cpp +++ b/ApplicationCode/Commands/RicDeleteItemFeature.cpp @@ -44,6 +44,7 @@ #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" #include "RimWellPathCompletion.h" +#include "RimPerforationInterval.h" #include "cafCmdExecCommandManager.h" #include "cafCmdSelectionHelper.h" @@ -96,6 +97,7 @@ bool isDeletable(PdmUiItem * uiItem) if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; + if (dynamic_cast(uiItem)) return true; return false; } diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 045956893a..649928022b 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -396,6 +396,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection() commandIds << "RicSummaryCurveSwitchAxisFeature"; commandIds << "RicNewFishbonesSubsFeature"; + commandIds << "RicNewPerforationIntervalFeature"; commandIds << "RicExportFishbonesLateralsFeature"; commandIds << "RicWellPathImportCompletionsFileFeature";