From 6ca980385c06b6cd83506da060502128e76de3b0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 18 Nov 2015 15:09:50 +0100 Subject: [PATCH] (#657) Created command feature for adding cross section from simulation well --- .../CMakeLists_files.cmake | 4 + .../RicNewSimWellCrossSectionFeature.cpp | 123 +++++++++++++++++ .../RicNewSimWellCrossSectionFeature.h | 64 +++++++++ .../RicNewWellPathCrossSectionFeature.cpp | 124 ++++++++++++++++++ .../RicNewWellPathCrossSectionFeature.h | 64 +++++++++ .../RimContextCommandBuilder.cpp | 5 + .../ProjectDataModel/RimEclipseView.cpp | 2 +- .../ProjectDataModel/RimGeoMechView.cpp | 2 +- ApplicationCode/ProjectDataModel/RimView.cpp | 6 +- ApplicationCode/ProjectDataModel/RimView.h | 3 +- 10 files changed, 390 insertions(+), 7 deletions(-) create mode 100644 ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellCrossSectionFeature.cpp create mode 100644 ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellCrossSectionFeature.h create mode 100644 ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathCrossSectionFeature.cpp create mode 100644 ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathCrossSectionFeature.h diff --git a/ApplicationCode/Commands/CrossSectionCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CrossSectionCommands/CMakeLists_files.cmake index cacef2158e..8bf1591780 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CrossSectionCommands/CMakeLists_files.cmake @@ -6,10 +6,14 @@ endif() set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicAppendCrossSectionFeature.h +${CEE_CURRENT_LIST_DIR}RicNewSimWellCrossSectionFeature.h +${CEE_CURRENT_LIST_DIR}RicNewWellPathCrossSectionFeature.h ) set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicAppendCrossSectionFeature.cpp +${CEE_CURRENT_LIST_DIR}RicNewSimWellCrossSectionFeature.cpp +${CEE_CURRENT_LIST_DIR}RicNewWellPathCrossSectionFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellCrossSectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellCrossSectionFeature.cpp new file mode 100644 index 0000000000..8d592eaca5 --- /dev/null +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellCrossSectionFeature.cpp @@ -0,0 +1,123 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicNewSimWellCrossSectionFeature.h" + +#include "RimCrossSection.h" +#include "RimCrossSectionCollection.h" + +#include "RiuMainWindow.h" + +#include "cafCmdExecCommandManager.h" +#include "cafSelectionManager.h" + +#include "cvfAssert.h" + +#include +#include "RimEclipseView.h" +#include "RimEclipseWell.h" + +CAF_CMD_SOURCE_INIT(RicNewSimWellCrossSectionFeature, "RicNewSimWellCrossSectionFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewSimWellCrossSectionFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewSimWellCrossSectionFeature::onActionTriggered(bool isChecked) +{ + std::vector collection; + caf::SelectionManager::instance()->objectsByType(&collection); + CVF_ASSERT(collection.size() == 1); + + RimEclipseWell* eclWell = collection[0]; + + RimEclipseView* eclView = NULL; + eclWell->firstAnchestorOrThisOfType(eclView); + CVF_ASSERT(eclView); + + RicNewWellPathCrossSectionFeatureCmd* cmd = new RicNewWellPathCrossSectionFeatureCmd(eclView->crossSectionCollection, eclWell); + caf::CmdExecCommandManager::instance()->processExecuteCommand(cmd); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewSimWellCrossSectionFeature::setupActionLook(QAction* actionToSetup) +{ +// actionToSetup->setIcon(QIcon(":/CellFilter_Values.png")); + actionToSetup->setText("New Cross Section"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicNewWellPathCrossSectionFeatureCmd::RicNewWellPathCrossSectionFeatureCmd(RimCrossSectionCollection* crossSectionCollection, RimEclipseWell* simWell) + : CmdExecuteCommand(NULL), + m_crossSectionCollection(crossSectionCollection), + m_wellPath(simWell) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicNewWellPathCrossSectionFeatureCmd::~RicNewWellPathCrossSectionFeatureCmd() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicNewWellPathCrossSectionFeatureCmd::name() +{ + return "Create Cross Section From Well"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewWellPathCrossSectionFeatureCmd::redo() +{ + CVF_ASSERT(m_crossSectionCollection); + CVF_ASSERT(m_wellPath); + + RimCrossSection* crossSection = new RimCrossSection(); + crossSection->name = m_wellPath->name; + crossSection->crossSectionType = RimCrossSection::CS_SIMULATION_WELL; + crossSection->simulationWell = m_wellPath; + + m_crossSectionCollection->crossSections.push_back(crossSection); + + m_crossSectionCollection->updateConnectedEditors(); + RiuMainWindow::instance()->setCurrentObjectInTreeView(crossSection); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewWellPathCrossSectionFeatureCmd::undo() +{ +} diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellCrossSectionFeature.h b/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellCrossSectionFeature.h new file mode 100644 index 0000000000..10d438053e --- /dev/null +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellCrossSectionFeature.h @@ -0,0 +1,64 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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" +#include "cafCmdExecuteCommand.h" +#include "cafPdmPointer.h" + +class RimCrossSectionCollection; +class RimEclipseWell; + + +//================================================================================================== +/// +//================================================================================================== +class RicNewWellPathCrossSectionFeatureCmd : public caf::CmdExecuteCommand +{ +public: + RicNewWellPathCrossSectionFeatureCmd(RimCrossSectionCollection* crossSectionCollection, RimEclipseWell* simWell); + virtual ~RicNewWellPathCrossSectionFeatureCmd(); + + virtual QString name(); + virtual void redo(); + virtual void undo(); + +private: + caf::PdmPointer m_crossSectionCollection; + caf::PdmPointer m_wellPath; +}; + + + +//================================================================================================== +/// +//================================================================================================== +class RicNewSimWellCrossSectionFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); +}; + + diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathCrossSectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathCrossSectionFeature.cpp new file mode 100644 index 0000000000..c09a678827 --- /dev/null +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathCrossSectionFeature.cpp @@ -0,0 +1,124 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicNewWellPathCrossSectionFeature.h" + +#include "RimCrossSection.h" +#include "RimCrossSectionCollection.h" +#include "RimWellPath.h" + +#include "RiuMainWindow.h" + +#include "cafCmdExecCommandManager.h" +#include "cafSelectionManager.h" + +#include "cvfAssert.h" + +#include + +CAF_CMD_SOURCE_INIT(RicNewWellPathCrossSectionFeature, "RicNewWellPathCrossSectionFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewWellPathCrossSectionFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewWellPathCrossSectionFeature::onActionTriggered(bool isChecked) +{ +/* + std::vector collection; + caf::SelectionManager::instance()->objectsByType(&collection); + CVF_ASSERT(collection.size() == 1); + + RimEclipseWell* eclWell = collection[0]; + + RimEclipseView* eclView = NULL; + eclWell->firstAnchestorOrThisOfType(eclView); + CVF_ASSERT(eclView); + + RicNewWellPathCrossSectionFeatureCmd* cmd = new RicNewWellPathCrossSectionFeatureCmd(eclView->crossSectionCollection, eclWell); + caf::CmdExecCommandManager::instance()->processExecuteCommand(cmd); +*/ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewWellPathCrossSectionFeature::setupActionLook(QAction* actionToSetup) +{ +// actionToSetup->setIcon(QIcon(":/CellFilter_Values.png")); + actionToSetup->setText("New Cross Section"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicNewWellPathCrossSectionFeatureCmd::RicNewWellPathCrossSectionFeatureCmd(RimCrossSectionCollection* crossSectionCollection, RimWellPath* wellPath) + : CmdExecuteCommand(NULL), + m_crossSectionCollection(crossSectionCollection), + m_wellPath(wellPath) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicNewWellPathCrossSectionFeatureCmd::~RicNewWellPathCrossSectionFeatureCmd() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicNewWellPathCrossSectionFeatureCmd::name() +{ + return "Create Cross Section From Well Path"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewWellPathCrossSectionFeatureCmd::redo() +{ + CVF_ASSERT(m_crossSectionCollection); + CVF_ASSERT(m_wellPath); + + RimCrossSection* crossSection = new RimCrossSection(); + crossSection->name = m_wellPath->name; + crossSection->crossSectionType = RimCrossSection::CS_WELL_PATH; + crossSection->wellPath = m_wellPath; + + m_crossSectionCollection->crossSections.push_back(crossSection); + + m_crossSectionCollection->updateConnectedEditors(); + RiuMainWindow::instance()->setCurrentObjectInTreeView(crossSection); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewWellPathCrossSectionFeatureCmd::undo() +{ +} diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathCrossSectionFeature.h b/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathCrossSectionFeature.h new file mode 100644 index 0000000000..905bd07d9f --- /dev/null +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathCrossSectionFeature.h @@ -0,0 +1,64 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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" +#include "cafCmdExecuteCommand.h" +#include "cafPdmPointer.h" + +class RimCrossSectionCollection; +class RimWellPath; + + +//================================================================================================== +/// +//================================================================================================== +class RicNewWellPathCrossSectionFeatureCmd : public caf::CmdExecuteCommand +{ +public: + RicNewWellPathCrossSectionFeatureCmd(RimCrossSectionCollection* crossSectionCollection, RimWellPath* wellPath); + virtual ~RicNewWellPathCrossSectionFeatureCmd(); + + virtual QString name(); + virtual void redo(); + virtual void undo(); + +private: + caf::PdmPointer m_crossSectionCollection; + caf::PdmPointer m_wellPath; +}; + + + +//================================================================================================== +/// +//================================================================================================== +class RicNewWellPathCrossSectionFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); +}; + + diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 4ac94d6ceb..60f6f5c3b2 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -34,6 +34,7 @@ #include "RimEclipsePropertyFilterCollection.h" #include "RimEclipseStatisticsCase.h" #include "RimEclipseView.h" +#include "RimEclipseWell.h" #include "RimGeoMechCase.h" #include "RimGeoMechPropertyFilter.h" #include "RimGeoMechPropertyFilterCollection.h" @@ -265,6 +266,10 @@ QStringList RimContextCommandBuilder::commandsFromSelection() commandIds << "RicAppendCrossSectionFeature"; commandIds << "RicDeleteItemFeature"; } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicNewSimWellCrossSectionFeature"; + } if (dynamic_cast(uiItem)) { diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index df0ddc365a..355970f3f3 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1350,7 +1350,7 @@ void RimEclipseView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering uiTreeOrdering.add(m_rangeFilterCollection()); uiTreeOrdering.add(m_propertyFilterCollection()); - uiTreeOrdering.add(m_crossSectionCollection()); + uiTreeOrdering.add(crossSectionCollection()); uiTreeOrdering.setForgetRemainingFields(true); } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 716031add0..4fd8e0c4e7 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -637,7 +637,7 @@ void RimGeoMechView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering uiTreeOrdering.add(m_rangeFilterCollection()); uiTreeOrdering.add(m_propertyFilterCollection()); - uiTreeOrdering.add(m_crossSectionCollection()); + uiTreeOrdering.add(crossSectionCollection()); uiTreeOrdering.setForgetRemainingFields(true); } diff --git a/ApplicationCode/ProjectDataModel/RimView.cpp b/ApplicationCode/ProjectDataModel/RimView.cpp index 4fca175e19..608515a850 100644 --- a/ApplicationCode/ProjectDataModel/RimView.cpp +++ b/ApplicationCode/ProjectDataModel/RimView.cpp @@ -117,9 +117,9 @@ RimView::RimView(void) m_overrideRangeFilterCollection.xmlCapability()->setIOWritable(false); m_overrideRangeFilterCollection.xmlCapability()->setIOReadable(false); - CAF_PDM_InitFieldNoDefault(&m_crossSectionCollection, "CrossSections", "Cross Sections", "", "", ""); - m_crossSectionCollection.uiCapability()->setUiHidden(true); - m_crossSectionCollection = new RimCrossSectionCollection(); + CAF_PDM_InitFieldNoDefault(&crossSectionCollection, "CrossSections", "Cross Sections", "", "", ""); + crossSectionCollection.uiCapability()->setUiHidden(true); + crossSectionCollection = new RimCrossSectionCollection(); m_previousGridModeMeshLinesWasFaults = false; } diff --git a/ApplicationCode/ProjectDataModel/RimView.h b/ApplicationCode/ProjectDataModel/RimView.h index cc4d2bb8ed..03d2e2aa1b 100644 --- a/ApplicationCode/ProjectDataModel/RimView.h +++ b/ApplicationCode/ProjectDataModel/RimView.h @@ -90,6 +90,7 @@ public: caf::PdmField< std::vector > windowGeometry; + caf::PdmChildField crossSectionCollection; // Draw style @@ -192,8 +193,6 @@ protected: caf::PdmChildField m_rangeFilterCollection; caf::PdmChildField m_overrideRangeFilterCollection; - caf::PdmChildField m_crossSectionCollection; - // Overridden PDM methods: virtual void setupBeforeSave();