2020-01-03 13:49:12 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2020- 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 "RimSurfaceInViewCollection.h"
|
|
|
|
|
|
2026-08-17 15:49:06 +02:00
|
|
|
#include "Surface/RigSurface.h"
|
|
|
|
|
|
2023-08-07 16:35:59 +02:00
|
|
|
#include "Rim3dView.h"
|
2021-09-13 10:16:09 +02:00
|
|
|
#include "RimEnsembleSurface.h"
|
2020-01-08 11:56:48 +01:00
|
|
|
#include "RimGridView.h"
|
2020-01-21 15:13:29 +01:00
|
|
|
#include "RimIntersectionResultDefinition.h"
|
2021-10-05 14:28:00 +02:00
|
|
|
#include "RimIntersectionResultsDefinitionCollection.h"
|
2020-01-06 11:30:06 +01:00
|
|
|
#include "RimOilField.h"
|
|
|
|
|
#include "RimProject.h"
|
2020-05-03 11:35:06 +02:00
|
|
|
#include "RimSurface.h"
|
2020-01-06 11:30:06 +01:00
|
|
|
#include "RimSurfaceCollection.h"
|
2020-01-03 13:49:12 +01:00
|
|
|
#include "RimSurfaceInView.h"
|
2020-06-17 13:26:11 +02:00
|
|
|
#include "RimSurfaceResultDefinition.h"
|
2020-01-03 13:49:12 +01:00
|
|
|
|
2020-01-08 11:56:48 +01:00
|
|
|
#include "RivSurfacePartMgr.h"
|
|
|
|
|
|
2021-10-05 14:28:00 +02:00
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
2026-01-24 08:18:19 +01:00
|
|
|
|
2020-01-08 11:56:48 +01:00
|
|
|
#include "cvfModelBasicList.h"
|
|
|
|
|
|
2026-08-17 15:49:06 +02:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
2020-01-03 13:49:12 +01:00
|
|
|
CAF_PDM_SOURCE_INIT( RimSurfaceInViewCollection, "SurfaceInViewCollection" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimSurfaceInViewCollection::RimSurfaceInViewCollection()
|
|
|
|
|
{
|
2022-01-07 08:31:52 +01:00
|
|
|
CAF_PDM_InitObject( "Surfaces", ":/ReservoirSurfaces16x16.png" );
|
2020-01-06 11:30:06 +01:00
|
|
|
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_collectionName, "CollectionName", "Name" );
|
2020-08-26 12:31:23 +02:00
|
|
|
m_collectionName.registerGetMethod( this, &RimSurfaceInViewCollection::name );
|
|
|
|
|
m_collectionName.uiCapability()->setUiReadOnly( true );
|
2020-08-24 11:09:22 +02:00
|
|
|
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_collectionsInView, "SurfacesInViewFieldCollections", "SurfacesInViewFieldCollections" );
|
2020-08-24 11:09:22 +02:00
|
|
|
|
2023-08-07 16:35:59 +02:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_surfacesInView, "SurfacesInViewField", "Surfaces" );
|
2020-06-11 13:31:36 +02:00
|
|
|
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_surfaceCollection, "SurfaceCollectionRef", "SurfaceCollection" );
|
2020-08-26 12:31:23 +02:00
|
|
|
m_surfaceCollection.uiCapability()->setUiHidden( true );
|
2020-08-24 11:09:22 +02:00
|
|
|
|
2026-01-24 08:18:19 +01:00
|
|
|
CAF_PDM_InitField( &m_surfaceColorMode, "SurfaceColorMode", caf::AppEnum<SurfaceColorMode>( SurfaceColorMode::BOTH ), "Color Mode" );
|
|
|
|
|
caf::AppEnum<SurfaceColorMode>::setEnumSubset( &m_surfaceColorMode,
|
|
|
|
|
{ SurfaceColorMode::BOTH, SurfaceColorMode::SURFACE_COLOR, SurfaceColorMode::RESULT_COLORS } );
|
|
|
|
|
|
2020-08-24 11:09:22 +02:00
|
|
|
nameField()->uiCapability()->setUiHidden( true );
|
2020-01-03 13:49:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 11:13:38 +01:00
|
|
|
RimSurfaceInViewCollection::~RimSurfaceInViewCollection()
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-01-03 13:49:12 +01:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-08-24 11:09:22 +02:00
|
|
|
caf::PdmFieldHandle* RimSurfaceInViewCollection::userDescriptionField()
|
|
|
|
|
{
|
2020-08-26 12:31:23 +02:00
|
|
|
return &m_collectionName;
|
2020-08-24 11:09:22 +02:00
|
|
|
}
|
|
|
|
|
|
2021-10-05 14:28:00 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 10:48:40 +01:00
|
|
|
void RimSurfaceInViewCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ )
|
2021-10-05 14:28:00 +02:00
|
|
|
{
|
2023-05-12 21:41:34 +02:00
|
|
|
auto gridView = firstAncestorOfType<RimGridView>();
|
|
|
|
|
auto surfViewColl = firstAncestorOfType<RimSurfaceInViewCollection>();
|
2021-10-05 14:28:00 +02:00
|
|
|
|
|
|
|
|
if ( gridView && !surfViewColl )
|
|
|
|
|
{
|
|
|
|
|
auto uiTree = gridView->separateSurfaceResultsCollection()->uiTreeOrdering();
|
|
|
|
|
|
|
|
|
|
uiTreeOrdering.appendChild( uiTree );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-24 11:09:22 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QString RimSurfaceInViewCollection::name() const
|
|
|
|
|
{
|
2020-08-26 12:31:23 +02:00
|
|
|
if ( m_surfaceCollection ) return m_surfaceCollection->collectionName();
|
2020-08-24 11:09:22 +02:00
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-24 08:18:19 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimSurfaceInViewCollection::SurfaceColorMode RimSurfaceInViewCollection::surfaceColorMode() const
|
|
|
|
|
{
|
|
|
|
|
return m_surfaceColorMode();
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-24 11:09:22 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimSurfaceCollection* RimSurfaceInViewCollection::surfaceCollection() const
|
|
|
|
|
{
|
2020-08-26 12:31:23 +02:00
|
|
|
return m_surfaceCollection;
|
2020-08-24 11:09:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSurfaceInViewCollection::setSurfaceCollection( RimSurfaceCollection* surfcoll )
|
|
|
|
|
{
|
2020-08-26 12:31:23 +02:00
|
|
|
m_surfaceCollection = surfcoll;
|
2020-08-24 11:09:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSurfaceInViewCollection::updateAllViewItems()
|
|
|
|
|
{
|
|
|
|
|
syncCollectionsWithView();
|
|
|
|
|
syncSurfacesWithView();
|
|
|
|
|
updateConnectedEditors();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSurfaceInViewCollection::syncCollectionsWithView()
|
|
|
|
|
{
|
|
|
|
|
// check that we have surface in view collections for all sub-collections
|
2023-05-12 21:41:34 +02:00
|
|
|
std::vector<RimSurfaceInViewCollection*> colls = m_collectionsInView.childrenByType();
|
2020-08-24 11:09:22 +02:00
|
|
|
|
|
|
|
|
for ( auto surfcoll : colls )
|
|
|
|
|
{
|
|
|
|
|
if ( !surfcoll->surfaceCollection() )
|
|
|
|
|
{
|
2022-05-31 13:08:07 +02:00
|
|
|
m_collectionsInView.removeChild( surfcoll );
|
2020-08-24 11:09:22 +02:00
|
|
|
delete surfcoll;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create new collection entries and reorder
|
|
|
|
|
std::vector<RimSurfaceInViewCollection*> orderedColls;
|
2020-08-26 12:31:23 +02:00
|
|
|
if ( m_surfaceCollection )
|
2020-08-24 11:09:22 +02:00
|
|
|
{
|
|
|
|
|
// pick up the collections and the order from the surface collection
|
2020-08-26 12:31:23 +02:00
|
|
|
std::vector<RimSurfaceCollection*> surfcolls = m_surfaceCollection->subCollections();
|
2020-08-24 11:09:22 +02:00
|
|
|
for ( auto surfcoll : surfcolls )
|
|
|
|
|
{
|
|
|
|
|
// check if this is a collection we need to create
|
|
|
|
|
|
2023-08-04 09:04:14 +02:00
|
|
|
RimSurfaceInViewCollection* viewSurfColl = getCollectionInViewForCollection( surfcoll );
|
2020-08-24 11:09:22 +02:00
|
|
|
if ( viewSurfColl == nullptr )
|
|
|
|
|
{
|
|
|
|
|
RimSurfaceInViewCollection* newColl = new RimSurfaceInViewCollection();
|
|
|
|
|
newColl->setSurfaceCollection( surfcoll );
|
|
|
|
|
orderedColls.push_back( newColl );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
orderedColls.push_back( viewSurfColl );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// make sure our view surfaces have the same order as the source surface collection
|
2022-05-31 13:08:07 +02:00
|
|
|
m_collectionsInView.clearWithoutDelete();
|
2020-08-24 11:09:22 +02:00
|
|
|
for ( auto viewColl : orderedColls )
|
|
|
|
|
{
|
|
|
|
|
m_collectionsInView.push_back( viewColl );
|
|
|
|
|
viewColl->updateAllViewItems();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSurfaceInViewCollection::syncSurfacesWithView()
|
2020-01-06 11:30:06 +01:00
|
|
|
{
|
|
|
|
|
// Delete surfaceInView without any real Surface connection
|
|
|
|
|
|
2023-05-12 21:41:34 +02:00
|
|
|
std::vector<RimSurfaceInView*> surfsInView = m_surfacesInView.childrenByType();
|
2020-01-06 11:30:06 +01:00
|
|
|
|
|
|
|
|
for ( auto surf : surfsInView )
|
|
|
|
|
{
|
|
|
|
|
if ( !surf->surface() )
|
|
|
|
|
{
|
2022-05-31 13:08:07 +02:00
|
|
|
m_surfacesInView.removeChild( surf );
|
2020-01-06 11:30:06 +01:00
|
|
|
delete surf;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-13 10:16:09 +02:00
|
|
|
// Create new surface entries and reorder
|
2020-08-24 11:09:22 +02:00
|
|
|
std::vector<RimSurfaceInView*> orderedSurfs;
|
2020-01-06 11:30:06 +01:00
|
|
|
|
2020-08-26 12:31:23 +02:00
|
|
|
if ( m_surfaceCollection )
|
2020-01-06 11:30:06 +01:00
|
|
|
{
|
2020-08-24 11:09:22 +02:00
|
|
|
// pick up the surfaces and the order from the surface collection
|
2020-08-26 12:31:23 +02:00
|
|
|
std::vector<RimSurface*> surfs = m_surfaceCollection->surfaces();
|
2020-01-06 11:30:06 +01:00
|
|
|
for ( auto surf : surfs )
|
|
|
|
|
{
|
2020-08-24 11:09:22 +02:00
|
|
|
// check if this is a surface we need to create
|
2023-08-04 09:04:14 +02:00
|
|
|
RimSurfaceInView* viewSurf = getSurfaceInViewForSurface( surf );
|
2020-08-24 11:09:22 +02:00
|
|
|
if ( viewSurf == nullptr )
|
2020-01-06 11:30:06 +01:00
|
|
|
{
|
|
|
|
|
RimSurfaceInView* newSurfInView = new RimSurfaceInView();
|
|
|
|
|
newSurfInView->setSurface( surf );
|
2021-09-13 10:16:09 +02:00
|
|
|
|
|
|
|
|
if ( m_surfaceCollection->collectionName() == RimEnsembleSurface::ensembleSourceFileCollectionName() )
|
|
|
|
|
{
|
|
|
|
|
newSurfInView->setActive( false );
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-07 13:21:25 +01:00
|
|
|
newSurfInView->setMeshLinesEnabled( surf->isMeshLinesEnabledDefault() );
|
|
|
|
|
|
2020-08-24 11:09:22 +02:00
|
|
|
orderedSurfs.push_back( newSurfInView );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
orderedSurfs.push_back( viewSurf );
|
2020-01-06 11:30:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
2020-08-24 11:09:22 +02:00
|
|
|
|
|
|
|
|
// make sure our view surfaces have the same order as the source surface collection
|
2022-05-31 13:08:07 +02:00
|
|
|
m_surfacesInView.clearWithoutDelete();
|
2020-08-24 11:09:22 +02:00
|
|
|
for ( auto viewSurf : orderedSurfs )
|
|
|
|
|
{
|
|
|
|
|
m_surfacesInView.push_back( viewSurf );
|
|
|
|
|
}
|
2020-01-06 11:30:06 +01:00
|
|
|
}
|
2020-08-24 11:09:22 +02:00
|
|
|
}
|
2020-01-06 11:30:06 +01:00
|
|
|
|
2020-08-24 11:09:22 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSurfaceInViewCollection::updateFromSurfaceCollection()
|
|
|
|
|
{
|
|
|
|
|
updateAllViewItems();
|
2020-01-06 11:30:06 +01:00
|
|
|
}
|
|
|
|
|
|
2026-08-17 15:49:06 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RimSurfaceInViewCollection::setSurfaceVisible( RimSurface* surface, bool visible )
|
|
|
|
|
{
|
|
|
|
|
updateFromSurfaceCollection();
|
|
|
|
|
|
|
|
|
|
auto* surfaceInView = findSurfaceInView( surface );
|
|
|
|
|
if ( !surfaceInView ) return false;
|
|
|
|
|
|
|
|
|
|
surfaceInView->setActive( visible );
|
|
|
|
|
surfaceInView->updateConnectedEditors();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::expected<void, QString> RimSurfaceInViewCollection::setSurfaceProperty( RimSurface* surface, const QString& propertyName )
|
|
|
|
|
{
|
|
|
|
|
updateFromSurfaceCollection();
|
|
|
|
|
|
|
|
|
|
auto* surfaceInView = findSurfaceInView( surface );
|
|
|
|
|
if ( !surfaceInView )
|
|
|
|
|
{
|
|
|
|
|
return std::unexpected( QString( "Surface is not available in this view." ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
surface->loadDataIfRequired();
|
|
|
|
|
auto* surfaceData = surface->surfaceData();
|
|
|
|
|
if ( !surfaceData )
|
|
|
|
|
{
|
|
|
|
|
return std::unexpected( QString( "Surface '%1' has no surface data." ).arg( surface->fullName() ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const auto propertyNames = surfaceData->propertyNames();
|
|
|
|
|
if ( std::find( propertyNames.begin(), propertyNames.end(), propertyName ) == propertyNames.end() )
|
|
|
|
|
{
|
|
|
|
|
return std::unexpected( QString( "Property '%1' is not available for surface '%2'." ).arg( propertyName, surface->fullName() ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
surfaceInView->surfaceResultDefinition()->setPropertyName( propertyName );
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RimSurfaceInViewCollection::isSurfaceVisible( const RimSurface* surface ) const
|
|
|
|
|
{
|
|
|
|
|
auto* surfaceInView = findSurfaceInView( surface );
|
|
|
|
|
return surfaceInView && surfaceInView->isActive();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QString RimSurfaceInViewCollection::surfaceProperty( const RimSurface* surface ) const
|
|
|
|
|
{
|
|
|
|
|
auto* surfaceInView = findSurfaceInView( surface );
|
|
|
|
|
if ( !surfaceInView ) return {};
|
|
|
|
|
|
|
|
|
|
return surfaceInView->surfaceResultDefinition()->propertyName();
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-08 11:56:48 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-05-03 11:35:06 +02:00
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-01-17 14:45:42 +01:00
|
|
|
void RimSurfaceInViewCollection::loadData( int timeStep )
|
2020-05-03 11:35:06 +02:00
|
|
|
{
|
2020-08-24 11:09:22 +02:00
|
|
|
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
|
|
|
|
{
|
2025-01-17 14:45:42 +01:00
|
|
|
coll->loadData( timeStep );
|
2020-08-24 11:09:22 +02:00
|
|
|
}
|
|
|
|
|
|
2020-05-03 11:35:06 +02:00
|
|
|
for ( RimSurfaceInView* surf : m_surfacesInView )
|
|
|
|
|
{
|
2020-06-11 13:31:36 +02:00
|
|
|
if ( surf->isActive() )
|
2020-05-03 11:35:06 +02:00
|
|
|
{
|
2025-01-17 14:45:42 +01:00
|
|
|
surf->loadDataAndUpdate( timeStep );
|
2020-05-03 11:35:06 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-11 13:31:36 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSurfaceInViewCollection::clearGeometry()
|
|
|
|
|
{
|
2020-08-24 11:09:22 +02:00
|
|
|
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
|
|
|
|
{
|
|
|
|
|
coll->clearGeometry();
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-11 13:31:36 +02:00
|
|
|
for ( RimSurfaceInView* surf : m_surfacesInView )
|
|
|
|
|
{
|
|
|
|
|
surf->clearGeometry();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-03 11:35:06 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-01-08 11:56:48 +01:00
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-08-07 16:35:59 +02:00
|
|
|
void RimSurfaceInViewCollection::appendPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform, bool onlyNativeParts )
|
2020-01-08 11:56:48 +01:00
|
|
|
{
|
2020-06-11 13:31:36 +02:00
|
|
|
if ( !isChecked() ) return;
|
2020-01-08 11:56:48 +01:00
|
|
|
|
2020-08-24 11:09:22 +02:00
|
|
|
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
|
|
|
|
{
|
|
|
|
|
if ( coll->isChecked() )
|
|
|
|
|
{
|
2023-08-07 16:35:59 +02:00
|
|
|
coll->appendPartsToModel( model, scaleTransform, onlyNativeParts );
|
2020-08-24 11:09:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-08 11:56:48 +01:00
|
|
|
for ( RimSurfaceInView* surf : m_surfacesInView )
|
|
|
|
|
{
|
|
|
|
|
if ( surf->isActive() )
|
|
|
|
|
{
|
2023-08-07 16:35:59 +02:00
|
|
|
if ( onlyNativeParts )
|
|
|
|
|
{
|
|
|
|
|
surf->nativeSurfacePartMgr()->appendNativeGeometryPartsToModel( model, scaleTransform );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
surf->surfacePartMgr()->appendIntersectionGeometryPartsToModel( model, scaleTransform );
|
|
|
|
|
}
|
2020-01-08 11:56:48 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model->updateBoundingBoxesRecursive();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 10:48:40 +01:00
|
|
|
void RimSurfaceInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
2020-01-08 11:56:48 +01:00
|
|
|
{
|
2026-01-24 08:18:19 +01:00
|
|
|
if ( changedField == &m_isChecked || changedField == &m_surfaceColorMode )
|
2020-01-08 11:56:48 +01:00
|
|
|
{
|
2023-08-07 16:35:59 +02:00
|
|
|
auto ownerView = firstAncestorOrThisOfTypeAsserted<Rim3dView>();
|
2020-01-08 11:56:48 +01:00
|
|
|
ownerView->scheduleCreateDisplayModelAndRedraw();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-06 11:30:06 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-08-24 11:09:22 +02:00
|
|
|
RimSurfaceInView* RimSurfaceInViewCollection::getSurfaceInViewForSurface( const RimSurface* surf ) const
|
2020-01-06 11:30:06 +01:00
|
|
|
{
|
|
|
|
|
for ( auto surfInView : m_surfacesInView )
|
|
|
|
|
{
|
|
|
|
|
if ( surfInView->surface() == surf )
|
|
|
|
|
{
|
2020-08-24 11:09:22 +02:00
|
|
|
return surfInView;
|
2020-01-06 11:30:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-24 11:09:22 +02:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-17 15:49:06 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimSurfaceInView* RimSurfaceInViewCollection::findSurfaceInView( const RimSurface* surface ) const
|
|
|
|
|
{
|
|
|
|
|
if ( auto* surfaceInView = getSurfaceInViewForSurface( surface ) ) return surfaceInView;
|
|
|
|
|
|
|
|
|
|
for ( auto collection : m_collectionsInView )
|
|
|
|
|
{
|
|
|
|
|
if ( auto* surfaceInView = collection->findSurfaceInView( surface ) ) return surfaceInView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-24 11:09:22 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 10:48:40 +01:00
|
|
|
RimSurfaceInViewCollection* RimSurfaceInViewCollection::getCollectionInViewForCollection( const RimSurfaceCollection* coll ) const
|
2020-08-24 11:09:22 +02:00
|
|
|
{
|
|
|
|
|
for ( auto collInView : m_collectionsInView )
|
|
|
|
|
{
|
|
|
|
|
if ( collInView->surfaceCollection() == coll )
|
|
|
|
|
{
|
|
|
|
|
return collInView;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
2020-01-06 11:30:06 +01:00
|
|
|
}
|
|
|
|
|
|
2020-01-09 14:20:10 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-01-18 14:42:33 +01:00
|
|
|
void RimSurfaceInViewCollection::updateCellResultColor( bool hasGeneralCellResult, int timeStepIndex )
|
2020-01-09 14:20:10 +01:00
|
|
|
{
|
2023-08-04 09:04:14 +02:00
|
|
|
if ( !isChecked() ) return;
|
2020-01-09 14:20:10 +01:00
|
|
|
|
2020-08-24 11:09:22 +02:00
|
|
|
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
|
|
|
|
{
|
|
|
|
|
if ( coll->isChecked() )
|
|
|
|
|
{
|
|
|
|
|
coll->updateCellResultColor( hasGeneralCellResult, timeStepIndex );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-09 14:20:10 +01:00
|
|
|
for ( RimSurfaceInView* surf : m_surfacesInView )
|
|
|
|
|
{
|
|
|
|
|
if ( surf->isActive() )
|
|
|
|
|
{
|
2020-06-11 13:31:36 +02:00
|
|
|
bool useNativeSurfaceColors = false;
|
|
|
|
|
|
|
|
|
|
if ( surf->isNativeSurfaceResultsActive() ) useNativeSurfaceColors = true;
|
2020-01-21 15:13:29 +01:00
|
|
|
|
2020-06-11 13:31:36 +02:00
|
|
|
if ( !useNativeSurfaceColors )
|
2020-01-09 14:20:10 +01:00
|
|
|
{
|
2023-02-26 10:48:40 +01:00
|
|
|
bool showResults = surf->activeSeparateResultDefinition() ? surf->activeSeparateResultDefinition()->hasResult()
|
|
|
|
|
: hasGeneralCellResult;
|
2020-06-11 13:31:36 +02:00
|
|
|
|
|
|
|
|
if ( showResults )
|
|
|
|
|
{
|
|
|
|
|
surf->surfacePartMgr()->updateCellResultColor( timeStepIndex );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
useNativeSurfaceColors = true;
|
|
|
|
|
}
|
2020-01-09 14:20:10 +01:00
|
|
|
}
|
2020-06-11 13:31:36 +02:00
|
|
|
|
|
|
|
|
if ( useNativeSurfaceColors )
|
2020-01-09 14:20:10 +01:00
|
|
|
{
|
2020-06-11 13:31:36 +02:00
|
|
|
surf->surfacePartMgr()->updateNativeSurfaceColors();
|
2020-01-09 14:20:10 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-21 15:13:29 +01:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSurfaceInViewCollection::applySingleColorEffect()
|
|
|
|
|
{
|
2023-08-04 09:04:14 +02:00
|
|
|
if ( !isChecked() ) return;
|
2020-01-21 15:13:29 +01:00
|
|
|
|
2020-08-24 11:09:22 +02:00
|
|
|
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
|
|
|
|
{
|
|
|
|
|
if ( coll->isChecked() )
|
|
|
|
|
{
|
|
|
|
|
coll->applySingleColorEffect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-21 15:13:29 +01:00
|
|
|
for ( RimSurfaceInView* surf : m_surfacesInView )
|
|
|
|
|
{
|
|
|
|
|
if ( surf->isActive() )
|
|
|
|
|
{
|
2020-06-11 13:31:36 +02:00
|
|
|
surf->surfacePartMgr()->updateNativeSurfaceColors();
|
2020-01-21 15:13:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RimSurfaceInViewCollection::hasAnyActiveSeparateResults()
|
|
|
|
|
{
|
2023-08-04 09:04:14 +02:00
|
|
|
if ( !isChecked() ) return false;
|
2020-01-21 15:13:29 +01:00
|
|
|
|
2020-08-24 11:09:22 +02:00
|
|
|
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
|
|
|
|
{
|
|
|
|
|
if ( coll->isChecked() )
|
|
|
|
|
{
|
|
|
|
|
bool found = coll->hasAnyActiveSeparateResults();
|
|
|
|
|
if ( found ) return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-21 15:13:29 +01:00
|
|
|
for ( RimSurfaceInView* surf : m_surfacesInView )
|
|
|
|
|
{
|
2023-02-26 10:48:40 +01:00
|
|
|
if ( surf->isActive() && surf->activeSeparateResultDefinition() && surf->activeSeparateResultDefinition()->hasResult() )
|
2020-01-21 15:13:29 +01:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2020-06-11 13:31:36 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 10:48:40 +01:00
|
|
|
void RimSurfaceInViewCollection::updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer )
|
2020-06-11 13:31:36 +02:00
|
|
|
{
|
2020-08-24 11:09:22 +02:00
|
|
|
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
|
|
|
|
{
|
2023-02-26 10:48:40 +01:00
|
|
|
if ( coll->isChecked() ) coll->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer, isUsingOverrideViewer );
|
2020-08-24 11:09:22 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-11 13:31:36 +02:00
|
|
|
for ( RimSurfaceInView* surf : m_surfacesInView )
|
|
|
|
|
{
|
|
|
|
|
surf->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer, isUsingOverrideViewer );
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-17 13:26:11 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::vector<RimRegularLegendConfig*> RimSurfaceInViewCollection::legendConfigs()
|
|
|
|
|
{
|
|
|
|
|
std::vector<RimRegularLegendConfig*> configs;
|
|
|
|
|
|
2020-08-24 11:09:22 +02:00
|
|
|
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
|
|
|
|
{
|
|
|
|
|
if ( coll->isChecked() )
|
|
|
|
|
{
|
|
|
|
|
std::vector<RimRegularLegendConfig*> collconfigs = coll->legendConfigs();
|
|
|
|
|
configs.insert( configs.end(), collconfigs.begin(), collconfigs.end() );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-17 13:26:11 +02:00
|
|
|
for ( RimSurfaceInView* surf : m_surfacesInView )
|
|
|
|
|
{
|
2020-08-24 11:09:22 +02:00
|
|
|
if ( surf->isActive() && surf->surfaceResultDefinition() )
|
2020-06-17 13:26:11 +02:00
|
|
|
{
|
|
|
|
|
configs.push_back( surf->surfaceResultDefinition()->legendConfig() );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return configs;
|
|
|
|
|
}
|
2021-05-31 08:09:13 +02:00
|
|
|
|
2026-09-01 15:13:57 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::vector<RimSurfaceInView*> RimSurfaceInViewCollection::visibleSurfacesInView() const
|
|
|
|
|
{
|
|
|
|
|
if ( !isChecked() ) return {};
|
|
|
|
|
|
|
|
|
|
std::vector<RimSurfaceInView*> surfaces;
|
|
|
|
|
|
|
|
|
|
for ( RimSurfaceInViewCollection* coll : m_collectionsInView )
|
|
|
|
|
{
|
|
|
|
|
if ( !coll ) continue;
|
|
|
|
|
|
|
|
|
|
std::vector<RimSurfaceInView*> collSurfaces = coll->visibleSurfacesInView();
|
|
|
|
|
surfaces.insert( surfaces.end(), collSurfaces.begin(), collSurfaces.end() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ( RimSurfaceInView* surf : m_surfacesInView )
|
|
|
|
|
{
|
|
|
|
|
if ( surf && surf->isActive() ) surfaces.push_back( surf );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return surfaces;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-31 08:09:13 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-10-15 16:57:18 +02:00
|
|
|
std::vector<const RivIntersectionGeometryGeneratorInterface*> RimSurfaceInViewCollection::intersectionGeometryGenerators() const
|
2021-05-31 08:09:13 +02:00
|
|
|
{
|
2021-10-15 16:57:18 +02:00
|
|
|
std::vector<const RivIntersectionGeometryGeneratorInterface*> generators;
|
2021-05-31 08:09:13 +02:00
|
|
|
|
|
|
|
|
for ( auto surf : m_surfacesInView )
|
|
|
|
|
{
|
|
|
|
|
if ( surf->isActive() && surf->isNativeSurfaceResultsActive() )
|
|
|
|
|
{
|
|
|
|
|
auto generator = surf->intersectionGeometryGenerator();
|
|
|
|
|
|
|
|
|
|
if ( generator ) generators.push_back( generator );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ( auto child : m_collectionsInView )
|
|
|
|
|
{
|
|
|
|
|
auto childGenerators = child->intersectionGeometryGenerators();
|
|
|
|
|
generators.insert( generators.end(), childGenerators.begin(), childGenerators.end() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return generators;
|
|
|
|
|
}
|