From 3490d07dd12a18f441ace5d7be9c7826276778a4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 14 Feb 2013 14:30:01 +0100 Subject: [PATCH] Added IdenticalGridCaseGroup, now displayed in tree view p4#: 20518 --- ApplicationCode/CMakeLists.txt | 1 + .../RimIdenticalGridCaseGroup.cpp | 83 +++++++++++++++++++ .../RimIdenticalGridCaseGroup.h | 51 ++++++++++++ .../ProjectDataModel/RimProject.cpp | 44 ++++++++-- ApplicationCode/ProjectDataModel/RimProject.h | 9 +- .../ProjectDataModel/RimReservoir.cpp | 3 +- 6 files changed, 178 insertions(+), 13 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index d124b84e2d..8b12d131ed 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -74,6 +74,7 @@ list( APPEND CPP_SOURCES ProjectDataModel/RimLegendConfig.cpp ProjectDataModel/RimProject.cpp ProjectDataModel/RimReservoir.cpp + ProjectDataModel/RimIdenticalGridCaseGroup.cpp ProjectDataModel/RimInputProperty.cpp ProjectDataModel/RimInputPropertyCollection.cpp ProjectDataModel/RimInputReservoir.cpp diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp new file mode 100644 index 0000000000..002ab57a39 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -0,0 +1,83 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RIStdInclude.h" + +#include "RimIdenticalGridCaseGroup.h" +#include "RimReservoir.h" +#include "RimReservoirView.h" +#include "RigEclipseCase.h" + + +CAF_PDM_SOURCE_INIT(RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() +{ + CAF_PDM_InitObject("Identical Grids", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIdenticalGridCaseGroup::~RimIdenticalGridCaseGroup() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIdenticalGridCaseGroup::addCase(RimReservoir* reservoir) +{ + CVF_ASSERT(reservoir); + + if (!reservoir) return; + + RigMainGrid* incomingMainGrid = reservoir->reservoirData()->mainGrid(); + + if (m_mainGrid.isNull()) + { + m_mainGrid = incomingMainGrid; + } + else + { + if (m_mainGrid.p() != incomingMainGrid) + { + CVF_ASSERT(false); + return; + } + } + + reservoirs.push_back(reservoir); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigMainGrid* RimIdenticalGridCaseGroup::mainGrid() +{ + if (m_mainGrid.notNull()) return m_mainGrid.p(); + + return NULL; +} + diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h new file mode 100644 index 0000000000..45ec34cacd --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -0,0 +1,51 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "cvfBase.h" +#include "cvfObject.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +class RimReservoir; +class RigMainGrid; + +//================================================================================================== +// +// +// +//================================================================================================== +class RimIdenticalGridCaseGroup : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimIdenticalGridCaseGroup(); + virtual ~RimIdenticalGridCaseGroup(); + + void addCase(RimReservoir* reservoir); + + caf::PdmPointersField reservoirs; + + RigMainGrid* mainGrid(); + +private: + cvf::ref m_mainGrid; + +}; diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index a8672481c6..81d5bff863 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -21,7 +21,7 @@ #include "RimProject.h" #include "RIApplication.h" #include "RIVersionInfo.h" -#include "RimScriptCollection.h" + #include "RigGridCollection.h" #include "RigEclipseCase.h" @@ -36,6 +36,8 @@ RimProject::RimProject(void) m_projectFileVersionString.setUiHidden(true); CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&caseGroups, "CaseGroups", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&scriptCollection, "ScriptCollection", "Scripts", ":/Default.png", "", ""); scriptCollection = new RimScriptCollection(); @@ -69,6 +71,7 @@ void RimProject::close() } reservoirs.deleteAllChildObjects(); + caseGroups.deleteAllChildObjects(); fileName = ""; } @@ -129,24 +132,26 @@ QString RimProject::projectFileVersionString() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::registerEclipseCase(RigEclipseCase* eclipseCase) +void RimProject::registerEclipseCase(RimReservoir* rimReservoir) { - CVF_ASSERT(eclipseCase); + CVF_ASSERT(rimReservoir); - RigMainGrid* equalGrid = m_gridCollection->findEqualGrid(eclipseCase->mainGrid()); + RigEclipseCase* rigEclipseCase = rimReservoir->reservoirData(); + + RigMainGrid* equalGrid = m_gridCollection->findEqualGrid(rigEclipseCase->mainGrid()); if (equalGrid) { // Replace the grid with an already registered grid - eclipseCase->setMainGrid(equalGrid); + rigEclipseCase->setMainGrid(equalGrid); } else { // This is the first insertion of this grid, compute cached data - eclipseCase->mainGrid()->computeCachedData(); + rigEclipseCase->mainGrid()->computeCachedData(); std::vector grids; - eclipseCase->allGrids(&grids); + rigEclipseCase->allGrids(&grids); size_t i; for (i = 0; i < grids.size(); i++) @@ -155,5 +160,28 @@ void RimProject::registerEclipseCase(RigEclipseCase* eclipseCase) } } - m_gridCollection->addCase(eclipseCase); + m_gridCollection->addCase(rigEclipseCase); + + + // Insert in identical grid group + bool foundGroup = false; + + for (size_t i = 0; i < caseGroups.size(); i++) + { + RimIdenticalGridCaseGroup* cg = caseGroups()[i]; + + if (cg->mainGrid() == equalGrid) + { + cg->addCase(rimReservoir); + foundGroup = true; + } + } + + if (!foundGroup) + { + RimIdenticalGridCaseGroup* group = new RimIdenticalGridCaseGroup; + group->addCase(rimReservoir); + + caseGroups().push_back(group); + } } diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 1212a20aad..cf42fdf146 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -20,10 +20,10 @@ #include "cafPdmDocument.h" #include "RimScriptCollection.h" +#include "RimIdenticalGridCaseGroup.h" class RimReservoir; class RigGridCollection; -class RigEclipseCase; //================================================================================================== /// @@ -34,8 +34,9 @@ class RimProject : public caf::PdmDocument CAF_PDM_HEADER_INIT; public: - caf::PdmPointersField reservoirs; - caf::PdmField scriptCollection; + caf::PdmPointersField reservoirs; + caf::PdmPointersField caseGroups; + caf::PdmField scriptCollection; void setUserScriptPath(const QString& path); //void updateProjectScriptPath(); @@ -47,7 +48,7 @@ public: void close(); - void registerEclipseCase(RigEclipseCase* eclipseCase); + void registerEclipseCase(RimReservoir* rimReservoir); protected: // Overridden methods diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index 318760e08f..28f0154b11 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -247,7 +247,8 @@ void RimReservoir::registerEclipseCase() CVF_ASSERT(proj); if (proj) { - proj->registerEclipseCase(m_rigEclipseCase.p()); + + proj->registerEclipseCase(this); } }