mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 15:10:22 -05:00
- Added RimGeneric3dView, a 3D view that is not tied to any grid case, useful for wells, surfaces and other data not requiring a reservoir grid. The view supports a custom name. - Introduced RimGenericViewCollection, a new top-level collection that holds both Eclipse views and RimGeneric3dView instances. It overrides defineUiTreeOrdering() to display both types as a single flat list under the top-level 'Views' node. - RimOilField now exposes a single genericViewCollection instead of a plain eclipseViewCollection field. - RimEclipseViewCollection is unchanged and continues to be used for per-case and ensemble view collections. - Updated RimEclipseCase::globalViewCollection() and related helpers to use RimGenericViewCollection, and added matching overloads in RicNewViewFeature for creating eclipse views from the merged collection. - Added RicNewGenericDataViewFeature to create a new generic data view from the context menu.
194 lines
6.9 KiB
C++
194 lines
6.9 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2026 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 "RimGenericViewCollection.h"
|
|
|
|
#include "RiaPreferences.h"
|
|
|
|
#include "QuickAccess/RimQuickAccessCollection.h"
|
|
#include "RimCase.h"
|
|
#include "RimCellEdgeColors.h"
|
|
#include "RimEclipseCase.h"
|
|
#include "RimEclipseCellColors.h"
|
|
#include "RimEclipseView.h"
|
|
#include "RimFaultInViewCollection.h"
|
|
#include "RimGeneric3dView.h"
|
|
#include "RimStimPlanColors.h"
|
|
|
|
#include "cafPdmDocument.h"
|
|
#include "cafPdmUiTreeOrdering.h"
|
|
|
|
#include "cafCmdFeatureMenuBuilder.h"
|
|
|
|
CAF_PDM_SOURCE_INIT( RimGenericViewCollection, "GenericViewCollection", "GenericViewCollection" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimGenericViewCollection::RimGenericViewCollection()
|
|
{
|
|
CAF_PDM_InitObject( "Views", ":/3DView16x16.png" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_eclipseViews, "Views", "Views" );
|
|
CAF_PDM_InitFieldNoDefault( &m_genericViews, "GenericViews", "Views" );
|
|
|
|
setDeletable( false );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimGenericViewCollection::~RimGenericViewCollection()
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimGenericViewCollection::isEmpty() const
|
|
{
|
|
return !m_eclipseViews.hasChildren() && !m_genericViews.hasChildren();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<RimEclipseView*> RimGenericViewCollection::views() const
|
|
{
|
|
return m_eclipseViews.childrenByType();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimEclipseView* RimGenericViewCollection::addView( RimEclipseCase* eclipseCase )
|
|
{
|
|
RimEclipseView* view = new RimEclipseView();
|
|
|
|
view->setEclipseCase( eclipseCase );
|
|
|
|
auto prefs = RiaPreferences::current();
|
|
view->faultCollection()->setActive( prefs->enableFaultsByDefault() );
|
|
|
|
view->cellEdgeResult()->setResultVariable( "MULT" );
|
|
view->cellEdgeResult()->setActive( false );
|
|
view->fractureColors()->setDefaultResultName();
|
|
|
|
caf::PdmDocument::updateUiIconStateRecursively( view );
|
|
|
|
m_eclipseViews.push_back( 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 RimGenericViewCollection::addView( RimEclipseView* view )
|
|
{
|
|
m_eclipseViews.push_back( view );
|
|
updateConnectedEditors();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimGenericViewCollection::removeView( RimEclipseView* view )
|
|
{
|
|
m_eclipseViews.removeChild( view );
|
|
updateConnectedEditors();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimGeneric3dView* RimGenericViewCollection::addGenericView()
|
|
{
|
|
auto* view = new RimGeneric3dView();
|
|
|
|
// Add before loadDataAndUpdate() so RimProject::assignViewIdToView() sees the view in the project tree
|
|
m_genericViews.push_back( view );
|
|
caf::PdmDocument::updateUiIconStateRecursively( view );
|
|
|
|
view->loadDataAndUpdate();
|
|
|
|
updateConnectedEditors();
|
|
|
|
return view;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<RimGeneric3dView*> RimGenericViewCollection::genericViews() const
|
|
{
|
|
return m_genericViews.childrenByType();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimGenericViewCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName )
|
|
{
|
|
// Display Eclipse views and generic 3D views together as a single flat list.
|
|
for ( auto view : m_eclipseViews.childrenByType() )
|
|
{
|
|
uiTreeOrdering.add( view );
|
|
}
|
|
|
|
for ( auto view : m_genericViews.childrenByType() )
|
|
{
|
|
uiTreeOrdering.add( view );
|
|
}
|
|
|
|
uiTreeOrdering.skipRemainingChildren( true );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimGenericViewCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& referringObjects )
|
|
{
|
|
if ( auto parentCase = firstAncestorOrThisOfType<RimCase>() )
|
|
{
|
|
parentCase->updateConnectedEditors();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimGenericViewCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
|
|
{
|
|
menuBuilder << "RicNewViewFeature";
|
|
menuBuilder << "RicNewGenericDataViewFeature";
|
|
}
|