From fec506121249322e60bafd5e448bd5c45aef052c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 18 Nov 2015 09:35:38 +0100 Subject: [PATCH] Moved context command builder into separate file --- .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../RimContextCommandBuilder.cpp | 277 ++++++++++++++++++ .../RimContextCommandBuilder.h | 32 ++ .../ProjectDataModel/RimProject.cpp | 254 +--------------- 4 files changed, 318 insertions(+), 247 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimContextCommandBuilder.h diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index a8873b1e01..c276e011c4 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -74,6 +74,7 @@ ${CEE_CURRENT_LIST_DIR}RimWellLogFileChannel.h ${CEE_CURRENT_LIST_DIR}RimWellLogFileCurve.h ${CEE_CURRENT_LIST_DIR}RimCrossSection.h ${CEE_CURRENT_LIST_DIR}RimCrossSectionCollection.h +${CEE_CURRENT_LIST_DIR}RimContextCommandBuilder.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -146,6 +147,7 @@ ${CEE_CURRENT_LIST_DIR}RimWellLogFileChannel.cpp ${CEE_CURRENT_LIST_DIR}RimWellLogFileCurve.cpp ${CEE_CURRENT_LIST_DIR}RimCrossSection.cpp ${CEE_CURRENT_LIST_DIR}RimCrossSectionCollection.cpp +${CEE_CURRENT_LIST_DIR}RimContextCommandBuilder.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp new file mode 100644 index 0000000000..68ff16993d --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -0,0 +1,277 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimContextCommandBuilder.h" + +#include "RimCalcScript.h" +#include "RimCaseCollection.h" +#include "RimCellRangeFilter.h" +#include "RimCellRangeFilterCollection.h" +#include "RimEclipseCase.h" +#include "RimEclipseCaseCollection.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseInputProperty.h" +#include "RimEclipseInputPropertyCollection.h" +#include "RimEclipsePropertyFilter.h" +#include "RimEclipsePropertyFilterCollection.h" +#include "RimEclipseStatisticsCase.h" +#include "RimEclipseView.h" +#include "RimGeoMechCase.h" +#include "RimGeoMechPropertyFilter.h" +#include "RimGeoMechPropertyFilterCollection.h" +#include "RimGeoMechView.h" +#include "RimIdenticalGridCaseGroup.h" +#include "RimScriptCollection.h" +#include "RimViewController.h" +#include "RimViewLinker.h" +#include "RimWellLogCurve.h" +#include "RimWellLogFileChannel.h" +#include "RimWellLogPlot.h" +#include "RimWellLogPlotCollection.h" +#include "RimWellLogTrack.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" + +#include "ToggleCommands/RicToggleItemsFeatureImpl.h" + +#include "cafPdmUiItem.h" +#include "cafSelectionManager.h" +#include "cvfAssert.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RimContextCommandBuilder::commandsFromSelection() +{ + QStringList commandIds; + + std::vector uiItems; + caf::SelectionManager::instance()->selectedItems(uiItems); + + if (uiItems.size() == 0) + { + commandIds << "RicNewWellLogPlotFeature"; + } + else if (uiItems.size() > 1) + { + caf::PdmUiItem* uiItem = uiItems[0]; + if (dynamic_cast(uiItem)) + { + commandIds << "RicAddWellLogToPlotFeature"; + } + } + else if (uiItems.size() == 1) + { + caf::PdmUiItem* uiItem = uiItems[0]; + CVF_ASSERT(uiItem); + + if (dynamic_cast(uiItem)) + { + commandIds << "RicImportEclipseCaseFeature"; + commandIds << "RicImportInputEclipseCaseFeature"; + commandIds << "RicCreateGridCaseGroupFeature"; + commandIds << "RicEclipseCaseNewGroupFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicNewViewFeature"; + commandIds << "RicCopyReferencesToClipboardFeature"; + commandIds << "RicPasteGeoMechViewsFeature"; + commandIds << "RicDeleteItemFeature"; + commandIds << "Separator"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicNewViewFeature"; + commandIds << "RicCopyReferencesToClipboardFeature"; + commandIds << "RicPasteEclipseViewsFeature"; + commandIds << "RicDeleteItemFeature"; + commandIds << "Separator"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicPasteEclipseCasesFeature"; + commandIds << "RicNewStatisticsCaseFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicNewViewFeature"; + commandIds << "RicComputeStatisticsFeature"; + commandIds << "RicCloseCaseFeature"; + commandIds << "RicExecuteScriptForCasesFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicCopyReferencesToClipboardFeature"; + + commandIds << "RicPasteEclipseCasesFeature"; + commandIds << "RicPasteEclipseViewsFeature"; + + commandIds << "RicCloseCaseFeature"; + commandIds << "RicNewViewFeature"; + commandIds << "RicEclipseCaseNewGroupFeature"; + commandIds << "RicExecuteScriptForCasesFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicPasteGeoMechViewsFeature"; + commandIds << "RicNewViewFeature"; + commandIds << "Separator"; + + commandIds << "RicCloseCaseFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicEclipseCaseNewGroupFeature"; + commandIds << "RicPasteEclipseCasesFeature"; + commandIds << "RicDeleteItemFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicSaveEclipseResultAsInputPropertyFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicAddEclipseInputPropertyFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicDeleteItemFeature"; + commandIds << "RicSaveEclipseInputPropertyFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicRangeFilterNewFeature"; + commandIds << "RicRangeFilterNewSliceIFeature"; + commandIds << "RicRangeFilterNewSliceJFeature"; + commandIds << "RicRangeFilterNewSliceKFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicRangeFilterInsertFeature"; + commandIds << "RicRangeFilterNewSliceIFeature"; + commandIds << "RicRangeFilterNewSliceJFeature"; + commandIds << "RicRangeFilterNewSliceKFeature"; + commandIds << "Separator"; + commandIds << "RicDeleteItemFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicEclipsePropertyFilterNewFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicEclipsePropertyFilterInsertFeature"; + commandIds << "Separator"; + commandIds << "RicDeleteItemFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicGeoMechPropertyFilterNewFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicGeoMechPropertyFilterInsertFeature"; + commandIds << "Separator"; + commandIds << "RicDeleteItemFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicWellPathsDeleteAllFeature"; + commandIds << "RicWellPathsImportFileFeature"; + commandIds << "RicWellPathsImportSsihubFeature"; + commandIds << "RicWellLogsImportFileFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicNewWellLogFileCurveFeature"; + commandIds << "RicNewWellLogCurveExtractionFeature"; + commandIds << "RicWellPathDeleteFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicEditScriptFeature"; + commandIds << "RicNewScriptFeature"; + commandIds << "Separator"; + commandIds << "RicExecuteScriptFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicAddScriptPathFeature"; + commandIds << "RicDeleteScriptPathFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicShowAllLinkedViewsFeature"; + commandIds << "Separator"; + commandIds << "RicDeleteItemFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicShowAllLinkedViewsFeature"; + commandIds << "Separator"; + commandIds << "RicDeleteAllLinkedViewsFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicNewWellLogPlotFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicNewWellLogPlotTrackFeature"; + commandIds << "RicDeleteItemFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicNewWellLogCurveExtractionFeature"; + commandIds << "RicNewWellLogFileCurveFeature"; + commandIds << "RicDeleteWellLogPlotTrackFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicExportToLasFileFeature"; + commandIds << "RicDeleteItemFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicAddWellLogToPlotFeature"; + } + + if (dynamic_cast(uiItem)) + { + commandIds << "RicLinkVisibleViewsFeature"; + commandIds << "RicLinkViewFeature"; + commandIds << "RicUnLinkViewFeature"; + commandIds << "RicShowLinkOptionsFeature"; + commandIds << "RicSetMasterViewFeature"; + } + } + + if (RicToggleItemsFeatureImpl::isToggleCommandsAvailable()) + { + commandIds << "Separator"; + commandIds << "RicToggleItemsOnFeature"; + commandIds << "RicToggleItemsOffFeature"; + commandIds << "RicToggleItemsFeature"; + } + + return commandIds; +} diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.h b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.h new file mode 100644 index 0000000000..be9a221762 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.h @@ -0,0 +1,32 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 + +//================================================================================================== +/// +/// +//================================================================================================== +class RimContextCommandBuilder +{ +public: + static QStringList commandsFromSelection(); +}; diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 0d63a23332..e4628d2bb1 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -20,47 +20,42 @@ #include "RimProject.h" - #include "RiaApplication.h" #include "RiaVersionInfo.h" #include "RigCaseData.h" -#include "RiaApplication.h" #include "RimCalcScript.h" +#include "RimCase.h" #include "RimCaseCollection.h" #include "RimCommandObject.h" +#include "RimContextCommandBuilder.h" #include "RimEclipseCase.h" #include "RimEclipseCaseCollection.h" -#include "RimEclipseInputProperty.h" -#include "RimEclipseInputPropertyCollection.h" -#include "RimEclipseStatisticsCase.h" -#include "RimEclipseStatisticsCaseCollection.h" -#include "RimEclipseView.h" #include "RimGeoMechCase.h" #include "RimGeoMechModels.h" #include "RimIdenticalGridCaseGroup.h" -#include "RimViewController.h" #include "RimMainPlotCollection.h" #include "RimOilField.h" #include "RimScriptCollection.h" +#include "RimView.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" -#include "RimWellLogPlot.h" #include "RimWellLogPlotCollection.h" -#include "RimWellPath.h" #include "RimWellPathCollection.h" #include "RimWellPathImport.h" #include "RiuMainWindow.h" -#include "ToggleCommands/RicToggleItemsFeatureImpl.h" #include "OctaveScriptCommands/RicExecuteScriptForCasesFeature.h" #include "cafCmdFeature.h" +#include "cafCmdFeatureManager.h" #include "cafPdmUiTreeOrdering.h" #include +#include + CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject"); //-------------------------------------------------------------------------------------------------- @@ -606,247 +601,12 @@ void RimProject::computeUtmAreaOfInterest() } } - - - - - - -#include "cafCmdFeatureManager.h" -#include "cafSelectionManager.h" - -#include "RimCellRangeFilterCollection.h" -#include "RimCellRangeFilter.h" -#include "RimEclipsePropertyFilterCollection.h" -#include "RimEclipsePropertyFilter.h" -#include "RimGeoMechPropertyFilterCollection.h" -#include "RimGeoMechPropertyFilter.h" -#include "RimGeoMechView.h" -#include "RimEclipseCellColors.h" -#include "RimEclipseFaultColors.h" -#include "RimWellLogPlot.h" -#include "RimWellLogTrack.h" -#include "RimWellLogCurve.h" -#include "RimWellLogFileChannel.h" -#include - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimProject::actionsBasedOnSelection(QMenu& contextMenu) { - QStringList commandIds; - - std::vector uiItems; - caf::SelectionManager::instance()->selectedItems(uiItems); - - if (uiItems.size() == 0) - { - commandIds << "RicNewWellLogPlotFeature"; - } - else if (uiItems.size() > 1) - { - caf::PdmUiItem* uiItem = uiItems[0]; - if (dynamic_cast(uiItem)) - { - commandIds << "RicAddWellLogToPlotFeature"; - } - } - else if (uiItems.size() == 1) - { - caf::PdmUiItem* uiItem = uiItems[0]; - CVF_ASSERT(uiItem); - - if (dynamic_cast(uiItem)) - { - commandIds << "RicImportEclipseCaseFeature"; - commandIds << "RicImportInputEclipseCaseFeature"; - commandIds << "RicCreateGridCaseGroupFeature"; - commandIds << "RicEclipseCaseNewGroupFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicNewViewFeature"; - commandIds << "RicCopyReferencesToClipboardFeature"; - commandIds << "RicPasteGeoMechViewsFeature"; - commandIds << "RicDeleteItemFeature"; - commandIds << "Separator"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicNewViewFeature"; - commandIds << "RicCopyReferencesToClipboardFeature"; - commandIds << "RicPasteEclipseViewsFeature"; - commandIds << "RicDeleteItemFeature"; - commandIds << "Separator"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicPasteEclipseCasesFeature"; - commandIds << "RicNewStatisticsCaseFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicNewViewFeature"; - commandIds << "RicComputeStatisticsFeature"; - commandIds << "RicCloseCaseFeature"; - commandIds << "RicExecuteScriptForCasesFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicCopyReferencesToClipboardFeature"; - - commandIds << "RicPasteEclipseCasesFeature"; - commandIds << "RicPasteEclipseViewsFeature"; - - commandIds << "RicCloseCaseFeature"; - commandIds << "RicNewViewFeature"; - commandIds << "RicEclipseCaseNewGroupFeature"; - commandIds << "RicExecuteScriptForCasesFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicPasteGeoMechViewsFeature"; - commandIds << "RicNewViewFeature"; - commandIds << "Separator"; - - commandIds << "RicCloseCaseFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicEclipseCaseNewGroupFeature"; - commandIds << "RicPasteEclipseCasesFeature"; - commandIds << "RicDeleteItemFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicSaveEclipseResultAsInputPropertyFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicAddEclipseInputPropertyFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicDeleteItemFeature"; - commandIds << "RicSaveEclipseInputPropertyFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicRangeFilterNewFeature"; - commandIds << "RicRangeFilterNewSliceIFeature"; - commandIds << "RicRangeFilterNewSliceJFeature"; - commandIds << "RicRangeFilterNewSliceKFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicRangeFilterInsertFeature"; - commandIds << "RicRangeFilterNewSliceIFeature"; - commandIds << "RicRangeFilterNewSliceJFeature"; - commandIds << "RicRangeFilterNewSliceKFeature"; - commandIds << "Separator"; - commandIds << "RicDeleteItemFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicEclipsePropertyFilterNewFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicEclipsePropertyFilterInsertFeature"; - commandIds << "Separator"; - commandIds << "RicDeleteItemFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicGeoMechPropertyFilterNewFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicGeoMechPropertyFilterInsertFeature"; - commandIds << "Separator"; - commandIds << "RicDeleteItemFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicWellPathsDeleteAllFeature"; - commandIds << "RicWellPathsImportFileFeature"; - commandIds << "RicWellPathsImportSsihubFeature"; - commandIds << "RicWellLogsImportFileFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicNewWellLogFileCurveFeature"; - commandIds << "RicNewWellLogCurveExtractionFeature"; - commandIds << "RicWellPathDeleteFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicEditScriptFeature"; - commandIds << "RicNewScriptFeature"; - commandIds << "Separator"; - commandIds << "RicExecuteScriptFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicAddScriptPathFeature"; - commandIds << "RicDeleteScriptPathFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicShowAllLinkedViewsFeature"; - commandIds << "Separator"; - commandIds << "RicDeleteItemFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicShowAllLinkedViewsFeature"; - commandIds << "Separator"; - commandIds << "RicDeleteAllLinkedViewsFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicNewWellLogPlotFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicNewWellLogPlotTrackFeature"; - commandIds << "RicDeleteItemFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicNewWellLogCurveExtractionFeature"; - commandIds << "RicNewWellLogFileCurveFeature"; - commandIds << "RicDeleteWellLogPlotTrackFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicExportToLasFileFeature"; - commandIds << "RicDeleteItemFeature"; - } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicAddWellLogToPlotFeature"; - } - - if (dynamic_cast(uiItem)) - { - commandIds << "RicLinkVisibleViewsFeature"; - commandIds << "RicLinkViewFeature"; - commandIds << "RicUnLinkViewFeature"; - commandIds << "RicShowLinkOptionsFeature"; - commandIds << "RicSetMasterViewFeature"; - } - } - - if (RicToggleItemsFeatureImpl::isToggleCommandsAvailable()) - { - commandIds << "Separator"; - commandIds << "RicToggleItemsOnFeature"; - commandIds << "RicToggleItemsOffFeature"; - commandIds << "RicToggleItemsFeature"; - } + QStringList commandIds = RimContextCommandBuilder::commandsFromSelection(); caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance(); for (int i = 0; i < commandIds.size(); i++)