2020-01-03 06:49:12 -06: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"
|
|
|
|
|
2020-01-06 04:30:06 -06:00
|
|
|
#include "RiaApplication.h"
|
2020-01-08 04:56:48 -06:00
|
|
|
#include "RimGridView.h"
|
2020-01-21 08:13:29 -06:00
|
|
|
#include "RimIntersectionResultDefinition.h"
|
2020-01-06 04:30:06 -06:00
|
|
|
#include "RimOilField.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimSurfaceCollection.h"
|
2020-01-03 06:49:12 -06:00
|
|
|
#include "RimSurfaceInView.h"
|
|
|
|
|
2020-01-08 04:56:48 -06:00
|
|
|
#include "RivSurfacePartMgr.h"
|
|
|
|
|
|
|
|
#include "cvfModelBasicList.h"
|
|
|
|
|
2020-01-03 06:49:12 -06:00
|
|
|
CAF_PDM_SOURCE_INIT( RimSurfaceInViewCollection, "SurfaceInViewCollection" );
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimSurfaceInViewCollection::RimSurfaceInViewCollection()
|
|
|
|
{
|
2020-01-06 04:30:06 -06:00
|
|
|
CAF_PDM_InitObject( "Surfaces", ":/ReservoirSurfaces16x16.png", "", "" );
|
|
|
|
|
|
|
|
CAF_PDM_InitField( &m_isActive, "isActive", true, "Active", "", "", "" );
|
|
|
|
m_isActive.uiCapability()->setUiHidden( true );
|
2020-01-03 06:49:12 -06:00
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_surfacesInView, "SurfacesInViewField", "SurfacesInViewField", "", "", "" );
|
2020-01-06 04:30:06 -06:00
|
|
|
m_surfacesInView.uiCapability()->setUiTreeHidden( true );
|
2020-01-03 06:49:12 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:13:38 -06:00
|
|
|
RimSurfaceInViewCollection::~RimSurfaceInViewCollection()
|
|
|
|
{
|
|
|
|
}
|
2020-01-03 06:49:12 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-01-06 04:30:06 -06:00
|
|
|
void RimSurfaceInViewCollection::updateFromSurfaceCollection()
|
|
|
|
{
|
|
|
|
// Delete surfaceInView without any real Surface connection
|
|
|
|
|
|
|
|
std::vector<RimSurfaceInView*> surfsInView = m_surfacesInView.childObjects();
|
|
|
|
|
|
|
|
for ( auto surf : surfsInView )
|
|
|
|
{
|
|
|
|
if ( !surf->surface() )
|
|
|
|
{
|
|
|
|
m_surfacesInView.removeChildObject( surf );
|
|
|
|
delete surf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create new entries
|
|
|
|
|
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
|
|
|
RimSurfaceCollection* surfColl = proj->activeOilField()->surfaceCollection();
|
|
|
|
|
|
|
|
if ( surfColl )
|
|
|
|
{
|
|
|
|
std::vector<RimSurface*> surfs = surfColl->surfaces();
|
|
|
|
|
|
|
|
for ( auto surf : surfs )
|
|
|
|
{
|
|
|
|
if ( !this->hasSurfaceInViewForSurface( surf ) )
|
|
|
|
{
|
|
|
|
RimSurfaceInView* newSurfInView = new RimSurfaceInView();
|
|
|
|
newSurfInView->setSurface( surf );
|
|
|
|
m_surfacesInView.push_back( newSurfInView );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this->updateConnectedEditors();
|
|
|
|
}
|
|
|
|
|
2020-01-08 04:56:48 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSurfaceInViewCollection::appendPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform )
|
|
|
|
{
|
|
|
|
if ( !m_isActive() ) return;
|
|
|
|
|
|
|
|
for ( RimSurfaceInView* surf : m_surfacesInView )
|
|
|
|
{
|
|
|
|
if ( surf->isActive() )
|
|
|
|
{
|
2020-01-17 06:23:37 -06:00
|
|
|
// surf->surfacePartMgr()->appendNativeGeometryPartsToModel( model, scaleTransform );
|
|
|
|
surf->surfacePartMgr()->appendIntersectionGeometryPartsToModel( model, scaleTransform );
|
2020-01-08 04:56:48 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
model->updateBoundingBoxesRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSurfaceInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
|
|
|
const QVariant& oldValue,
|
|
|
|
const QVariant& newValue )
|
|
|
|
{
|
|
|
|
if ( changedField == &m_isActive )
|
|
|
|
{
|
|
|
|
RimGridView* ownerView;
|
|
|
|
this->firstAncestorOrThisOfTypeAsserted( ownerView );
|
|
|
|
ownerView->scheduleCreateDisplayModelAndRedraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-06 04:30:06 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimSurfaceInViewCollection::hasSurfaceInViewForSurface( const RimSurface* surf ) const
|
|
|
|
{
|
|
|
|
for ( auto surfInView : m_surfacesInView )
|
|
|
|
{
|
|
|
|
if ( surfInView->surface() == surf )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmFieldHandle* RimSurfaceInViewCollection::objectToggleField()
|
|
|
|
{
|
|
|
|
return &m_isActive;
|
|
|
|
}
|
2020-01-09 07:20:10 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSurfaceInViewCollection::updateCellResultColor( bool hasGeneralCellResult, size_t timeStepIndex )
|
|
|
|
{
|
|
|
|
if ( !this->m_isActive() ) return;
|
|
|
|
|
|
|
|
for ( RimSurfaceInView* surf : m_surfacesInView )
|
|
|
|
{
|
|
|
|
if ( surf->isActive() )
|
|
|
|
{
|
2020-01-21 08:13:29 -06:00
|
|
|
bool showResults = surf->activeSeparateResultDefinition()
|
|
|
|
? surf->activeSeparateResultDefinition()->hasResult()
|
|
|
|
: hasGeneralCellResult;
|
|
|
|
|
|
|
|
if ( showResults )
|
2020-01-09 07:20:10 -06:00
|
|
|
{
|
|
|
|
surf->surfacePartMgr()->updateCellResultColor( timeStepIndex );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
surf->surfacePartMgr()->applySingleColor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-21 08:13:29 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSurfaceInViewCollection::applySingleColorEffect()
|
|
|
|
{
|
|
|
|
if ( !this->m_isActive() ) return;
|
|
|
|
|
|
|
|
for ( RimSurfaceInView* surf : m_surfacesInView )
|
|
|
|
{
|
|
|
|
if ( surf->isActive() )
|
|
|
|
{
|
|
|
|
surf->surfacePartMgr()->applySingleColor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimSurfaceInViewCollection::hasAnyActiveSeparateResults()
|
|
|
|
{
|
|
|
|
if ( !this->m_isActive() ) return false;
|
|
|
|
|
|
|
|
for ( RimSurfaceInView* surf : m_surfacesInView )
|
|
|
|
{
|
|
|
|
if ( surf->isActive() && surf->activeSeparateResultDefinition() &&
|
|
|
|
surf->activeSeparateResultDefinition()->hasResult() )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|