From 399d0fdcca062e10a74e98aa990d8aa0610ee7a2 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 22 Mar 2024 18:14:25 +0100 Subject: [PATCH] WIP: move contour map collection from eclipse case child to standalone collection. --- .../Commands/RicNewContourMapViewFeature.cpp | 16 +++++- .../ProjectDataModel/RimEclipseCase.cpp | 56 +++++++++++++------ .../ProjectDataModel/RimEclipseCase.h | 26 +++++---- .../RimEclipseContourMapProjection.cpp | 4 +- .../ProjectDataModel/RimOilField.cpp | 4 ++ .../ProjectDataModel/RimOilField.h | 32 ++++++----- .../ProjectDataModel/RimProject.cpp | 2 + 7 files changed, 93 insertions(+), 47 deletions(-) diff --git a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp index 5793c615c0b..14454c995bd 100644 --- a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp @@ -86,7 +86,7 @@ void RicNewContourMapViewFeature::onActionTriggered( bool isChecked ) { RimEclipseView* reservoirView = caf::SelectionManager::instance()->selectedItemOfType(); RimEclipseContourMapView* existingEclipseContourMap = caf::SelectionManager::instance()->selectedItemOfType(); - RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemAncestorOfType(); + RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemOfType(); RimEclipseContourMapView* eclipseContourMap = nullptr; RimGeoMechView* geoMechView = caf::SelectionManager::instance()->selectedItemOfType(); @@ -97,11 +97,19 @@ void RicNewContourMapViewFeature::onActionTriggered( bool isChecked ) // Find case to insert into if ( existingEclipseContourMap ) { - eclipseContourMap = createEclipseContourMapFromExistingContourMap( eclipseCase, existingEclipseContourMap ); + eclipseCase = existingEclipseContourMap->eclipseCase(); + if ( eclipseCase ) + { + eclipseContourMap = createEclipseContourMapFromExistingContourMap( eclipseCase, existingEclipseContourMap ); + } } else if ( reservoirView ) { - eclipseContourMap = createEclipseContourMapFrom3dView( eclipseCase, reservoirView ); + eclipseCase = reservoirView->eclipseCase(); + if ( eclipseCase ) + { + eclipseContourMap = createEclipseContourMapFrom3dView( eclipseCase, reservoirView ); + } } else if ( eclipseCase ) { @@ -268,6 +276,8 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMapFr contourMap->initAfterReadRecursively(); + eclipseCase->contourMapCollection()->updateConnectedEditors(); + return contourMap; } diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp index 31ea704f96a..a2c583108ff 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp @@ -106,8 +106,8 @@ RimEclipseCase::RimEclipseCase() // https://github.com/OPM/ResInsight/issues/7308 m_filesContainingFaults.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_contourMapCollection, "ContourMaps", "2d Contour Maps" ); - m_contourMapCollection = new RimEclipseContourMapViewCollection; + CAF_PDM_InitFieldNoDefault( &m_contourMapCollection_OBSOLETE, "ContourMaps", "2d Contour Maps" ); + m_contourMapCollection_OBSOLETE = new RimEclipseContourMapViewCollection; CAF_PDM_InitFieldNoDefault( &m_inputPropertyCollection, "InputPropertyCollection", "" ); m_inputPropertyCollection = new RimEclipseInputPropertyCollection; @@ -290,11 +290,14 @@ void RimEclipseCase::initAfterRead() } m_reservoirViews_OBSOLETE.clearWithoutDelete(); - } - for ( RimEclipseContourMapView* contourMap : m_contourMapCollection->views() ) - { - contourMap->setEclipseCase( this ); + // Move contour maps + for ( RimEclipseContourMapView* contourMap : m_contourMapCollection_OBSOLETE->views() ) + { + contourMap->setEclipseCase( this ); + + // TODO: move to root collection + } } } @@ -547,11 +550,6 @@ void RimEclipseCase::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin { uiTreeOrdering.add( &m_2dIntersectionViewCollection ); } - - if ( !m_contourMapCollection->views().empty() ) - { - uiTreeOrdering.add( &m_contourMapCollection ); - } } else if ( uiConfigName == "MainWindow.DataSources" ) { @@ -652,9 +650,15 @@ RimCaseCollection* RimEclipseCase::parentCaseCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEclipseContourMapViewCollection* RimEclipseCase::contourMapCollection() +RimEclipseContourMapViewCollection* RimEclipseCase::contourMapCollection() const { - return m_contourMapCollection; + RimProject* project = RimProject::current(); + if ( !project ) return nullptr; + + RimOilField* oilField = project->activeOilField(); + if ( !oilField ) return nullptr; + + return oilField->eclipseContourMapCollection(); } //-------------------------------------------------------------------------------------------------- @@ -1069,7 +1073,7 @@ std::vector RimEclipseCase::allSpecialViews() const views.push_back( view ); } - for ( RimEclipseContourMapView* view : m_contourMapCollection->views() ) + for ( RimEclipseContourMapView* view : contourMapViews() ) { views.push_back( view ); } @@ -1194,8 +1198,7 @@ RimEclipseViewCollection* RimEclipseCase::viewCollection() const RimOilField* oilField = project->activeOilField(); if ( !oilField ) return nullptr; - RimEclipseViewCollection* viewCollection = oilField->eclipseViewCollection(); - return viewCollection; + return oilField->eclipseViewCollection(); } //-------------------------------------------------------------------------------------------------- @@ -1218,3 +1221,24 @@ std::vector RimEclipseCase::reservoirViews() const return views; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEclipseCase::contourMapViews() const +{ + std::vector views; + RimEclipseContourMapViewCollection* viewColl = contourMapCollection(); + if ( viewColl ) + { + for ( auto view : viewColl->views() ) + { + if ( view->eclipseCase() && view->eclipseCase() == this ) + { + views.push_back( view ); + } + } + } + + return views; +} diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h index 6ce80ad61c1..bcd29f88df8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h @@ -99,7 +99,7 @@ class RimEclipseCase : public RimCase virtual QString locationOnDisc() const { return QString(); } RimCaseCollection* parentCaseCollection(); - RimEclipseContourMapViewCollection* contourMapCollection(); + RimEclipseContourMapViewCollection* contourMapCollection() const; RimEclipseInputPropertyCollection* inputPropertyCollection() const; QStringList timeStepStrings() const override; @@ -137,15 +137,18 @@ class RimEclipseCase : public RimCase // Internal methods protected: - void computeCachedData(); - void setReservoirData( RigEclipseCaseData* eclipseCase ); - std::vector additionalFiles() const; - RimEclipseViewCollection* viewCollection() const; + void computeCachedData(); + void setReservoirData( RigEclipseCaseData* eclipseCase ); + std::vector additionalFiles() const; + RimEclipseViewCollection* viewCollection() const; + RimEclipseContourMapViewCollection* contourMapViewCollection() const; private: - void createTimeStepFormatString(); - std::vector allSpecialViews() const override; - void buildResultChildNodes(); + void createTimeStepFormatString(); + std::vector allSpecialViews() const override; + std::vector contourMapViews() const; + + void buildResultChildNodes(); protected: caf::PdmField m_flipXAxis; @@ -157,8 +160,6 @@ class RimEclipseCase : public RimCase private: caf::PdmField m_releaseResultMemory; - caf::PdmChildField m_contourMapCollection; - cvf::ref m_rigEclipseCase; QString m_timeStepFormatString; std::map m_wellToColorMap; @@ -170,6 +171,7 @@ class RimEclipseCase : public RimCase caf::PdmField> m_filesContainingFaults; - // Fields: - caf::PdmChildArrayField m_reservoirViews_OBSOLETE; + // Obsolete fields: + caf::PdmChildArrayField m_reservoirViews_OBSOLETE; + caf::PdmChildField m_contourMapCollection_OBSOLETE; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp index bda217ec3cb..469a349b9e3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp @@ -31,6 +31,7 @@ #include "RigHexIntersectionTools.h" #include "RigMainGrid.h" +#include "Rim3dView.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseContourMapView.h" @@ -385,7 +386,8 @@ std::vector RimEclipseContourMapProjection::retrieveParameterWeights() //-------------------------------------------------------------------------------------------------- RimEclipseCase* RimEclipseContourMapProjection::eclipseCase() const { - return firstAncestorOrThisOfType(); + if ( auto view = firstAncestorOrThisOfType() ) return dynamic_cast( view->ownerCase() ); + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimOilField.cpp b/ApplicationLibCode/ProjectDataModel/RimOilField.cpp index 2b35e845e1f..0497cf065f7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimOilField.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimOilField.cpp @@ -23,6 +23,7 @@ #include "RimAnnotationCollection.h" #include "RimCompletionTemplateCollection.h" #include "RimEclipseCaseCollection.h" +#include "RimEclipseContourMapViewCollection.h" #include "RimEclipseViewCollection.h" #include "RimEnsembleWellLogsCollection.h" #include "RimFormationNamesCollection.h" @@ -79,6 +80,9 @@ RimOilField::RimOilField() CAF_PDM_InitFieldNoDefault( &eclipseViewCollection, "EclipseViewCollection", "Eclipse Views", ":/3DView16x16.png" ); eclipseViewCollection = new RimEclipseViewCollection(); + CAF_PDM_InitFieldNoDefault( &eclipseContourMapCollection, "ContourMaps", "2d Contour Maps" ); + eclipseContourMapCollection = new RimEclipseContourMapViewCollection; + completionTemplateCollection = new RimCompletionTemplateCollection; analysisModels = new RimEclipseCaseCollection(); wellPathCollection = new RimWellPathCollection(); diff --git a/ApplicationLibCode/ProjectDataModel/RimOilField.h b/ApplicationLibCode/ProjectDataModel/RimOilField.h index 7c060b68c7e..246ad5ea0fc 100644 --- a/ApplicationLibCode/ProjectDataModel/RimOilField.h +++ b/ApplicationLibCode/ProjectDataModel/RimOilField.h @@ -43,6 +43,7 @@ class RimSurfaceCollection; class RimEnsembleWellLogsCollection; class RimPolygonCollection; class RimEclipseViewCollection; +class RimEclipseContourMapViewCollection; //================================================================================================== /// @@ -62,21 +63,22 @@ class RimOilField : public caf::PdmObject RimValveTemplateCollection* valveTemplateCollection(); const RimValveTemplateCollection* valveTemplateCollection() const; - caf::PdmChildField analysisModels; - caf::PdmChildField geoMechModels; - caf::PdmChildField wellPathCollection; - caf::PdmChildField completionTemplateCollection; - caf::PdmChildField summaryCaseMainCollection; - caf::PdmChildField observedDataCollection; - caf::PdmChildField formationNamesCollection; - caf::PdmChildField annotationCollection; - caf::PdmChildField measurement; - caf::PdmChildField surfaceCollection; - caf::PdmChildField seismicDataCollection; - caf::PdmChildField seismicViewCollection; - caf::PdmChildField eclipseViewCollection; - caf::PdmChildField ensembleWellLogsCollection; - caf::PdmChildField polygonCollection; + caf::PdmChildField analysisModels; + caf::PdmChildField geoMechModels; + caf::PdmChildField wellPathCollection; + caf::PdmChildField completionTemplateCollection; + caf::PdmChildField summaryCaseMainCollection; + caf::PdmChildField observedDataCollection; + caf::PdmChildField formationNamesCollection; + caf::PdmChildField annotationCollection; + caf::PdmChildField measurement; + caf::PdmChildField surfaceCollection; + caf::PdmChildField seismicDataCollection; + caf::PdmChildField seismicViewCollection; + caf::PdmChildField eclipseViewCollection; + caf::PdmChildField ensembleWellLogsCollection; + caf::PdmChildField polygonCollection; + caf::PdmChildField eclipseContourMapCollection; protected: void initAfterRead() override; diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index cbc3cb84c09..c1d40598e9b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -49,6 +49,7 @@ #include "RimDialogData.h" #include "RimEclipseCase.h" #include "RimEclipseCaseCollection.h" +#include "RimEclipseContourMapViewCollection.h" #include "RimEclipseViewCollection.h" #include "RimEnsembleWellLogsCollection.h" #include "RimFileWellPath.h" @@ -1537,6 +1538,7 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q if ( oilField->formationNamesCollection() ) uiTreeOrdering.add( oilField->formationNamesCollection() ); if ( oilField->completionTemplateCollection() ) uiTreeOrdering.add( oilField->completionTemplateCollection() ); if ( oilField->annotationCollection() ) uiTreeOrdering.add( oilField->annotationCollection() ); + if ( oilField->eclipseContourMapCollection() ) uiTreeOrdering.add( oilField->eclipseContourMapCollection() ); } uiTreeOrdering.add( colorLegendCollection() );