mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 15:10:22 -05:00
Replace the built-in formation filter with ensemble data filters. Load ensemble data filters after project read, and parent new views before assigning the case so the ensemble filter collection is resolved correctly.
182 lines
6.3 KiB
C++
182 lines
6.3 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2024 Equinor ASA
|
|
//
|
|
// 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 <http://www.gnu.org/licenses/gpl.html>
|
|
// for more details.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RimEclipseViewCollection.h"
|
|
|
|
#include "RiaLogging.h"
|
|
#include "RiaPreferences.h"
|
|
|
|
#include "RigCaseCellResultsData.h"
|
|
|
|
#include "QuickAccess/RimQuickAccessCollection.h"
|
|
#include "Rim3dView.h"
|
|
#include "RimCase.h"
|
|
#include "RimCellEdgeColors.h"
|
|
#include "RimEclipseCase.h"
|
|
#include "RimEclipseCellColors.h"
|
|
#include "RimEclipseView.h"
|
|
#include "RimFaultInViewCollection.h"
|
|
#include "RimGridView.h"
|
|
#include "RimProject.h"
|
|
#include "RimStimPlanColors.h"
|
|
|
|
CAF_PDM_SOURCE_INIT( RimEclipseViewCollection, "EclipseViewCollection", "EclipseViewCollection" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimEclipseViewCollection::RimEclipseViewCollection()
|
|
{
|
|
CAF_PDM_InitObject( "Views", ":/3DView16x16.png" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_views, "Views", "Eclipse Views" );
|
|
|
|
setDeletable( false );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimEclipseViewCollection::~RimEclipseViewCollection()
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<RimEclipseView*> RimEclipseViewCollection::views() const
|
|
{
|
|
return m_views.childrenByType();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimEclipseViewCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& referringObjects )
|
|
{
|
|
// If a view is child of a case, the view collection object is hidden in the tree view. Find the parent case and update connected editors.
|
|
if ( auto parentCase = firstAncestorOrThisOfType<RimCase>() )
|
|
{
|
|
parentCase->updateConnectedEditors();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimEclipseViewCollection::isEmpty()
|
|
{
|
|
return !m_views.hasChildren();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimEclipseView* RimEclipseViewCollection::addView( RimEclipseCase* eclipseCase )
|
|
{
|
|
RimEclipseView* view = new RimEclipseView();
|
|
|
|
// Parent before assigning the case: setEclipseCase() resolves the owning ensemble via the PDM
|
|
// ancestor chain, which only works once the view is attached to the tree. See #14710.
|
|
m_views.push_back( view );
|
|
|
|
view->setEclipseCase( eclipseCase );
|
|
|
|
// Configure case provider callback
|
|
applyCallbackToView( view );
|
|
|
|
auto prefs = RiaPreferences::current();
|
|
view->faultCollection()->setActive( prefs->enableFaultsByDefault() );
|
|
|
|
view->cellEdgeResult()->setResultVariable( "MULT" );
|
|
view->cellEdgeResult()->setActive( false );
|
|
view->fractureColors()->setDefaultResultName();
|
|
|
|
caf::PdmDocument::updateUiIconStateRecursively( view );
|
|
|
|
RimQuickAccessCollection::instance()->addQuickAccessFields( view );
|
|
|
|
view->loadDataAndUpdate();
|
|
|
|
// Set default values
|
|
if ( view->currentGridCellResults() )
|
|
{
|
|
auto defaultResult = view->currentGridCellResults()->defaultResult();
|
|
view->cellResult()->setFromEclipseResultAddress( defaultResult );
|
|
}
|
|
|
|
updateConnectedEditors();
|
|
|
|
return view;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimEclipseViewCollection::addView( RimEclipseView* view )
|
|
{
|
|
// Configure case provider callback
|
|
applyCallbackToView( view );
|
|
|
|
m_views.push_back( view );
|
|
updateConnectedEditors();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimEclipseViewCollection::removeView( RimEclipseView* view )
|
|
{
|
|
m_views.removeChild( view );
|
|
updateConnectedEditors();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimEclipseViewCollection::setEclipseCaseProvider( std::function<std::vector<RimEclipseCase*>()> provider )
|
|
{
|
|
// Store the callback for future views
|
|
if ( provider )
|
|
{
|
|
m_eclipseCaseProvider = provider;
|
|
}
|
|
else
|
|
{
|
|
m_eclipseCaseProvider = nullptr;
|
|
}
|
|
|
|
// Apply the callback to all existing views in the collection
|
|
for ( auto view : m_views )
|
|
{
|
|
applyCallbackToView( view );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimEclipseViewCollection::applyCallbackToView( RimEclipseView* view )
|
|
{
|
|
if ( m_eclipseCaseProvider )
|
|
{
|
|
// Use the stored custom callback
|
|
view->setEclipseCaseProvider( m_eclipseCaseProvider );
|
|
}
|
|
}
|