diff --git a/ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.cpp b/ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.cpp index 4b82118d802..dc9c9c4eb0a 100644 --- a/ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.cpp @@ -44,19 +44,13 @@ void RicNewViewForGridEnsembleFeature::addView( RimEclipseCaseEnsemble* eclipseC std::vector cases = eclipseCaseEnsemble->cases(); if ( cases.empty() ) return; - bool addToViews = false; - RimEclipseView* newView = cases[0]->createAndAddReservoirView( addToViews ); + auto newView = eclipseCaseEnsemble->addViewForCase( cases[0] ); + eclipseCaseEnsemble->updateConnectedEditors(); - if ( newView ) - { - eclipseCaseEnsemble->addView( newView ); - eclipseCaseEnsemble->updateConnectedEditors(); - - Riu3DMainWindowTools::setExpanded( newView ); + Riu3DMainWindowTools::setExpanded( newView ); - // Select the new view to make sure RiaApplication::setActiveReservoirView() is called - Riu3DMainWindowTools::selectAsCurrentItem( newView ); - } + // Select the new view to make sure RiaApplication::setActiveReservoirView() is called + Riu3DMainWindowTools::selectAsCurrentItem( newView ); } //-------------------------------------------------------------------------------------------------- @@ -85,38 +79,6 @@ void RicNewViewForGridEnsembleFeature::setupActionLook( QAction* actionToSetup ) actionToSetup->setIcon( QIcon( ":/3DView16x16.png" ) ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -// Rim3dView* RicNewViewForGridEnsembleFeature::createReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase ) -// { -// RimGridView* insertedView = nullptr; - -// if ( eclipseCase ) -// { -// insertedView = eclipseCase->createAndAddReservoirView(); -// } -// else if ( geomCase ) -// { -// insertedView = geomCase->createAndAddReservoirView(); -// } - -// // Must be run before buildViewItems, as wells are created in this function -// if ( insertedView ) insertedView->loadDataAndUpdate(); - -// if ( eclipseCase ) -// { -// eclipseCase->updateConnectedEditors(); -// } - -// if ( geomCase ) -// { -// geomCase->updateConnectedEditors(); -// } - -// return insertedView; -// } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp index 134dd84059b..c6996c81e88 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp @@ -24,6 +24,7 @@ #include "RimEclipseCellColors.h" #include "RimEclipseResultCase.h" #include "RimEclipseView.h" +#include "RimEclipseViewCollection.h" #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" @@ -42,14 +43,14 @@ RimEclipseCaseEnsemble::RimEclipseCaseEnsemble() m_groupId.capability()->setIOWriteable( false ); CAF_PDM_InitFieldNoDefault( &m_caseCollection, "CaseCollection", "Ensemble Cases" ); - m_caseCollection = new RimCaseCollection; m_caseCollection->uiCapability()->setUiName( "Cases" ); m_caseCollection->uiCapability()->setUiIconFromResourceString( ":/Cases16x16.png" ); CAF_PDM_InitFieldNoDefault( &m_selectedCase, "SelectedCase", "Selected Case" ); - CAF_PDM_InitFieldNoDefault( &m_views, "Views", "Views" ); + CAF_PDM_InitFieldNoDefault( &m_viewCollection, "ViewCollection", "Views" ); + m_viewCollection = new RimEclipseViewCollection; setDeletable( true ); } @@ -61,6 +62,9 @@ RimEclipseCaseEnsemble::~RimEclipseCaseEnsemble() { delete m_caseCollection; m_caseCollection = nullptr; + + delete m_viewCollection; + m_viewCollection = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -118,7 +122,15 @@ std::vector RimEclipseCaseEnsemble::cases() const //-------------------------------------------------------------------------------------------------- void RimEclipseCaseEnsemble::addView( RimEclipseView* view ) { - m_views.push_back( view ); + m_viewCollection->addView( view ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseView* RimEclipseCaseEnsemble::addViewForCase( RimEclipseCase* eclipseCase ) +{ + return m_viewCollection->addView( eclipseCase ); } //-------------------------------------------------------------------------------------------------- @@ -148,7 +160,7 @@ void RimEclipseCaseEnsemble::fieldChangedByUi( const caf::PdmFieldHandle* change { if ( changedField == &m_selectedCase ) { - for ( auto view : m_views ) + for ( auto view : m_viewCollection->views() ) { view->setEclipseCase( m_selectedCase() ); view->loadDataAndUpdate(); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h index 1b78c1ad1b3..3b9bc7dfdd7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h @@ -28,6 +28,7 @@ class RimCaseCollection; class RimEclipseCase; class RimEclipseView; +class RimEclipseViewCollection; //================================================================================================== // @@ -48,15 +49,16 @@ class RimEclipseCaseEnsemble : public RimNamedObject std::vector cases() const; - void addView( RimEclipseView* view ); + void addView( RimEclipseView* view ); + RimEclipseView* addViewForCase( RimEclipseCase* eclipseCase ); protected: QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; private: - caf::PdmField m_groupId; - caf::PdmChildField m_caseCollection; - caf::PdmChildArrayField m_views; - caf::PdmPtrField m_selectedCase; + caf::PdmField m_groupId; + caf::PdmChildField m_caseCollection; + caf::PdmChildField m_viewCollection; + caf::PdmPtrField m_selectedCase; };