Skip to content

Commit

Permalink
Update to changes in case and view connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
kriben committed Apr 10, 2024
1 parent 926e102 commit ea08e12
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 52 deletions.
48 changes: 5 additions & 43 deletions ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,13 @@ void RicNewViewForGridEnsembleFeature::addView( RimEclipseCaseEnsemble* eclipseC
std::vector<RimEclipseCase*> 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 );
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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;
// }

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
20 changes: 16 additions & 4 deletions ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "RimEclipseCellColors.h"
#include "RimEclipseResultCase.h"
#include "RimEclipseView.h"
#include "RimEclipseViewCollection.h"

#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
Expand All @@ -42,14 +43,14 @@ RimEclipseCaseEnsemble::RimEclipseCaseEnsemble()
m_groupId.capability<caf::PdmAbstractFieldScriptingCapability>()->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 );
}
Expand All @@ -61,6 +62,9 @@ RimEclipseCaseEnsemble::~RimEclipseCaseEnsemble()
{
delete m_caseCollection;
m_caseCollection = nullptr;

delete m_viewCollection;
m_viewCollection = nullptr;
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -118,7 +122,15 @@ std::vector<RimEclipseCase*> 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 );
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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();
Expand Down
12 changes: 7 additions & 5 deletions ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
class RimCaseCollection;
class RimEclipseCase;
class RimEclipseView;
class RimEclipseViewCollection;

//==================================================================================================
//
Expand All @@ -48,15 +49,16 @@ class RimEclipseCaseEnsemble : public RimNamedObject

std::vector<RimEclipseCase*> cases() const;

void addView( RimEclipseView* view );
void addView( RimEclipseView* view );
RimEclipseView* addViewForCase( RimEclipseCase* eclipseCase );

protected:
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;

private:
caf::PdmField<int> m_groupId;
caf::PdmChildField<RimCaseCollection*> m_caseCollection;
caf::PdmChildArrayField<RimEclipseView*> m_views;
caf::PdmPtrField<RimEclipseCase*> m_selectedCase;
caf::PdmField<int> m_groupId;
caf::PdmChildField<RimCaseCollection*> m_caseCollection;
caf::PdmChildField<RimEclipseViewCollection*> m_viewCollection;
caf::PdmPtrField<RimEclipseCase*> m_selectedCase;
};

0 comments on commit ea08e12

Please sign in to comment.