#6033 Surface Properties : Add legend and adjust update functions

This commit is contained in:
Magne Sjaastad 2020-06-11 13:31:36 +02:00
parent c92b3e3024
commit 8cc167568c
10 changed files with 314 additions and 101 deletions

View File

@ -24,13 +24,16 @@
#include "ProjectDataModel/RimCase.h" #include "ProjectDataModel/RimCase.h"
#include "RigSurface.h" #include "RigSurface.h"
#include "Rim3dView.h" #include "Rim3dView.h"
#include "RimRegularLegendConfig.h"
#include "RimSurface.h" #include "RimSurface.h"
#include "RimSurfaceInView.h" #include "RimSurfaceInView.h"
#include "RimSurfaceResultDefinition.h"
#include "RivIntersectionResultsColoringTools.h" #include "RivIntersectionResultsColoringTools.h"
#include "RivMeshLinesSourceInfo.h" #include "RivMeshLinesSourceInfo.h"
#include "RivPartPriority.h" #include "RivPartPriority.h"
#include "RivReservoirSurfaceIntersectionSourceInfo.h" #include "RivReservoirSurfaceIntersectionSourceInfo.h"
#include "RivScalarMapperUtils.h"
#include "RivSurfaceIntersectionGeometryGenerator.h" #include "RivSurfaceIntersectionGeometryGenerator.h"
#include "cafEffectGenerator.h" #include "cafEffectGenerator.h"
@ -40,6 +43,8 @@
#include "cvfPart.h" #include "cvfPart.h"
#include "cvfPrimitiveSetIndexedUInt.h" #include "cvfPrimitiveSetIndexedUInt.h"
#include <limits>
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -48,10 +53,11 @@ RivSurfacePartMgr::RivSurfacePartMgr( RimSurfaceInView* surface )
{ {
CVF_ASSERT( surface ); CVF_ASSERT( surface );
m_intersectionFacesTextureCoords = new cvf::Vec2fArray;
cvf::ref<RivIntersectionHexGridInterface> hexGrid = m_surfaceInView->createHexGridInterface(); cvf::ref<RivIntersectionHexGridInterface> hexGrid = m_surfaceInView->createHexGridInterface();
m_intersectionGenerator = new RivSurfaceIntersectionGeometryGenerator( m_surfaceInView, hexGrid.p() ); m_intersectionGenerator = new RivSurfaceIntersectionGeometryGenerator( m_surfaceInView, hexGrid.p() );
m_intersectionFacesTextureCoords = new cvf::Vec2fArray;
m_nativeTrianglesTextureCoords = new cvf::Vec2fArray;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -67,7 +73,7 @@ void RivSurfacePartMgr::appendNativeGeometryPartsToModel( cvf::ModelBasicList* m
if ( m_nativeTrianglesPart.notNull() ) if ( m_nativeTrianglesPart.notNull() )
{ {
m_nativeTrianglesPart->setTransform( scaleTransform ); m_nativeTrianglesPart->setTransform( scaleTransform );
this->applySingleColor(); this->updateNativeSurfaceColors();
model->addPart( m_nativeTrianglesPart.p() ); model->addPart( m_nativeTrianglesPart.p() );
@ -102,34 +108,37 @@ void RivSurfacePartMgr::updateCellResultColor( size_t timeStepIndex )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivSurfacePartMgr::appendIntersectionGeometryPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ) void RivSurfacePartMgr::appendIntersectionGeometryPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform )
{ {
if ( m_intersectionFaces.isNull() ) if ( !m_surfaceInView->surfaceResultDefinition()->isChecked() )
{ {
generatePartGeometry(); if ( m_intersectionFaces.isNull() )
} {
generatePartGeometry();
}
if ( m_intersectionFaces.notNull() ) if ( m_intersectionFaces.notNull() )
{ {
m_intersectionFaces->setTransform( scaleTransform ); m_intersectionFaces->setTransform( scaleTransform );
model->addPart( m_intersectionFaces.p() ); model->addPart( m_intersectionFaces.p() );
} }
// Mesh Lines // Mesh Lines
if ( m_intersectionGridLines.isNull() ) if ( m_intersectionGridLines.isNull() )
{ {
generatePartGeometry(); generatePartGeometry();
} }
if ( m_intersectionGridLines.notNull() ) if ( m_intersectionGridLines.notNull() )
{ {
m_intersectionGridLines->setTransform( scaleTransform ); m_intersectionGridLines->setTransform( scaleTransform );
model->addPart( m_intersectionGridLines.p() ); model->addPart( m_intersectionGridLines.p() );
} }
if ( m_intersectionFaultGridLines.notNull() ) if ( m_intersectionFaultGridLines.notNull() )
{ {
m_intersectionFaultGridLines->setTransform( scaleTransform ); m_intersectionFaultGridLines->setTransform( scaleTransform );
model->addPart( m_intersectionFaultGridLines.p() ); model->addPart( m_intersectionFaultGridLines.p() );
}
} }
appendNativeGeometryPartsToModel( model, scaleTransform ); appendNativeGeometryPartsToModel( model, scaleTransform );
@ -138,25 +147,67 @@ void RivSurfacePartMgr::appendIntersectionGeometryPartsToModel( cvf::ModelBasicL
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivSurfacePartMgr::applySingleColor() void RivSurfacePartMgr::updateNativeSurfaceColors()
{ {
if ( m_surfaceInView->surfaceResultDefinition()->isChecked() )
{ {
caf::SurfaceEffectGenerator surfaceGen( cvf::Color4f( m_surfaceInView->surface()->color() ), caf::PO_1 ); if ( m_usedSurfaceData.isNull() ) generateNativePartGeometry();
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
auto mapper = m_surfaceInView->surfaceResultDefinition()->legendConfig()->scalarMapper();
{
QString propertyName = m_surfaceInView->surfaceResultDefinition()->propertyName();
auto values = m_usedSurfaceData->propertyValues( propertyName );
const std::vector<cvf::Vec3d>& vertices = m_usedSurfaceData->vertices();
m_nativeTrianglesTextureCoords->resize( vertices.size() );
m_nativeTrianglesTextureCoords->setAll( cvf::Vec2f( 0.5f, 1.0f ) );
for ( size_t i = 0; i < values.size(); i++ )
{
const double val = values[i];
if ( val < std::numeric_limits<double>::infinity() && val == val )
{
m_nativeTrianglesTextureCoords->set( i, mapper->mapToTextureCoord( val ) );
}
}
float effectiveOpacityLevel = 1.0;
bool disableLighting = false;
Rim3dView* view = nullptr;
m_surfaceInView->firstAncestorOfType( view );
if ( view )
{
disableLighting = view->isLightingDisabled();
}
RivScalarMapperUtils::applyTextureResultsToPart( m_nativeTrianglesPart.p(),
m_nativeTrianglesTextureCoords.p(),
mapper,
effectiveOpacityLevel,
caf::FC_NONE,
disableLighting );
}
}
else
{
caf::SurfaceEffectGenerator surfaceGenBehind( cvf::Color4f( m_surfaceInView->surface()->color() ), caf::SurfaceEffectGenerator surfaceGenBehind( cvf::Color4f( m_surfaceInView->surface()->color() ),
caf::PO_POS_LARGE ); caf::PO_POS_LARGE );
cvf::ref<cvf::Effect> effBehind = surfaceGenBehind.generateCachedEffect();
cvf::ref<cvf::Effect> effBehind = surfaceGenBehind.generateCachedEffect();
if ( m_nativeTrianglesPart.notNull() ) if ( m_nativeTrianglesPart.notNull() )
{ {
m_nativeTrianglesPart->setEffect( effBehind.p() ); m_nativeTrianglesPart->setEffect( effBehind.p() );
} }
}
if ( m_intersectionFaces.notNull() ) if ( m_intersectionFaces.notNull() )
{ {
m_intersectionFaces->setEffect( eff.p() ); caf::SurfaceEffectGenerator surfaceGen( cvf::Color4f( m_surfaceInView->surface()->color() ), caf::PO_1 );
} cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
m_intersectionFaces->setEffect( eff.p() );
} }
// Update mesh colors as well, in case of change // Update mesh colors as well, in case of change
@ -267,7 +318,7 @@ void RivSurfacePartMgr::generatePartGeometry()
} }
} }
applySingleColor(); updateNativeSurfaceColors();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -41,7 +41,7 @@ class RivSurfacePartMgr : public cvf::Object
public: public:
explicit RivSurfacePartMgr( RimSurfaceInView* surface ); explicit RivSurfacePartMgr( RimSurfaceInView* surface );
void applySingleColor(); void updateNativeSurfaceColors();
void updateCellResultColor( size_t timeStepIndex ); void updateCellResultColor( size_t timeStepIndex );
void appendIntersectionGeometryPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); void appendIntersectionGeometryPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
@ -65,4 +65,5 @@ private:
cvf::ref<cvf::Part> m_intersectionFaultGridLines; cvf::ref<cvf::Part> m_intersectionFaultGridLines;
cvf::ref<cvf::Vec2fArray> m_intersectionFacesTextureCoords; cvf::ref<cvf::Vec2fArray> m_intersectionFacesTextureCoords;
cvf::ref<cvf::Vec2fArray> m_nativeTrianglesTextureCoords;
}; };

View File

@ -586,6 +586,7 @@ void RimEclipseView::onCreateDisplayModel()
m_surfaceVizModel->removeAllParts(); m_surfaceVizModel->removeAllParts();
if ( m_surfaceCollection ) if ( m_surfaceCollection )
{ {
m_surfaceCollection->clearGeometry();
m_surfaceCollection->appendPartsToModel( m_surfaceVizModel.p(), m_reservoirGridPartManager->scaleTransform() ); m_surfaceCollection->appendPartsToModel( m_surfaceVizModel.p(), m_reservoirGridPartManager->scaleTransform() );
nativeOrOverrideViewer()->addStaticModelOnce( m_surfaceVizModel.p(), isUsingOverrideViewer() ); nativeOrOverrideViewer()->addStaticModelOnce( m_surfaceVizModel.p(), isUsingOverrideViewer() );
} }
@ -670,6 +671,8 @@ void RimEclipseView::onUpdateDisplayModelForCurrentTimeStep()
{ {
clearReservoirCellVisibilities(); clearReservoirCellVisibilities();
// m_surfaceCollection->clearGeometry();
m_propertyFilterCollection()->updateFromCurrentTimeStep(); m_propertyFilterCollection()->updateFromCurrentTimeStep();
onUpdateLegends(); // To make sure the scalar mappers are set up correctly onUpdateLegends(); // To make sure the scalar mappers are set up correctly
@ -1435,6 +1438,11 @@ void RimEclipseView::onUpdateLegends()
} }
} }
} }
if ( m_surfaceCollection && m_surfaceCollection->isChecked() )
{
m_surfaceCollection->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(), isUsingOverrideViewer() );
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -18,13 +18,18 @@
#include "RimSurfaceInView.h" #include "RimSurfaceInView.h"
#include "RigFemPartCollection.h"
#include "RigSurface.h"
#include "RimEclipseView.h"
#include "RimGeoMechView.h"
#include "RimGridView.h" #include "RimGridView.h"
#include "RimRegularLegendConfig.h"
#include "RimSurface.h" #include "RimSurface.h"
#include "RimSurfaceResultDefinition.h" #include "RimSurfaceResultDefinition.h"
#include "RigFemPartCollection.h" #include "RiuViewer.h"
#include "RimEclipseView.h"
#include "RimGeoMechView.h"
#include "RivHexGridIntersectionTools.h" #include "RivHexGridIntersectionTools.h"
#include "RivSurfacePartMgr.h" #include "RivSurfacePartMgr.h"
@ -51,8 +56,9 @@ RimSurfaceInView::RimSurfaceInView()
CAF_PDM_InitFieldNoDefault( &m_resultDefinition, "ResultDefinition", "Result Definition", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_resultDefinition, "ResultDefinition", "Result Definition", "", "", "" );
m_resultDefinition.uiCapability()->setUiHidden( true ); m_resultDefinition.uiCapability()->setUiHidden( true );
m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( false ); m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( true );
m_resultDefinition = new RimSurfaceResultDefinition; m_resultDefinition = new RimSurfaceResultDefinition;
m_resultDefinition->setCheckState( false );
m_resultDefinition->setSurfaceInView( this ); m_resultDefinition->setSurfaceInView( this );
} }
@ -87,6 +93,36 @@ RimSurface* RimSurfaceInView::surface() const
void RimSurfaceInView::setSurface( RimSurface* surf ) void RimSurfaceInView::setSurface( RimSurface* surf )
{ {
m_surface = surf; m_surface = surf;
if ( surface()->surfaceData() && surface()->surfaceData()->propertyNames().empty() )
{
m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( true );
m_resultDefinition->setCheckState( false );
}
else
{
m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( false );
m_resultDefinition->setCheckState( true );
m_resultDefinition->assignDefaultProperty();
m_resultDefinition->updateMinMaxValues();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSurfaceInView::isNativeSurfaceResultsActive() const
{
return m_resultDefinition->isChecked();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSurfaceResultDefinition* RimSurfaceInView::surfaceResultDefinition()
{
return m_resultDefinition();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -115,6 +151,39 @@ RivSurfacePartMgr* RimSurfaceInView::surfacePartMgr()
return m_surfacePartMgr.p(); return m_surfacePartMgr.p();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSurfaceInView::loadDataAndUpdate()
{
if ( surface() )
{
surface()->loadDataIfRequired();
m_resultDefinition->updateMinMaxValues();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSurfaceInView::updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer )
{
if ( m_resultDefinition->legendConfig() )
{
RimRegularLegendConfig* legendConfig = m_resultDefinition->legendConfig();
legendConfig->setTitle(
QString( "Surface : \n%1\n%2" ).arg( this->name() ).arg( m_resultDefinition->propertyName() ) );
if ( this->isActive() && m_resultDefinition->isChecked() && legendConfig->showLegend() )
{
nativeOrOverrideViewer->addColorLegendToBottomLeftCorner( legendConfig->titledOverlayFrame(),
isUsingOverrideViewer );
}
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -31,6 +31,7 @@ class RimSurface;
class RimSurfaceResultDefinition; class RimSurfaceResultDefinition;
class RivSurfacePartMgr; class RivSurfacePartMgr;
class RivIntersectionHexGridInterface; class RivIntersectionHexGridInterface;
class RiuViewer;
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@ -47,11 +48,18 @@ public:
RimSurface* surface() const; RimSurface* surface() const;
void setSurface( RimSurface* surf ); void setSurface( RimSurface* surf );
bool isNativeSurfaceResultsActive() const;
RimSurfaceResultDefinition* surfaceResultDefinition();
double depthOffset() const; double depthOffset() const;
void clearGeometry(); void clearGeometry();
RivSurfacePartMgr* surfacePartMgr(); RivSurfacePartMgr* surfacePartMgr();
void loadDataAndUpdate();
void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer );
protected: protected:
void defineEditorAttribute( const caf::PdmFieldHandle* field, void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName, QString uiConfigName,

View File

@ -39,11 +39,10 @@ RimSurfaceInViewCollection::RimSurfaceInViewCollection()
{ {
CAF_PDM_InitObject( "Surfaces", ":/ReservoirSurfaces16x16.png", "", "" ); CAF_PDM_InitObject( "Surfaces", ":/ReservoirSurfaces16x16.png", "", "" );
CAF_PDM_InitField( &m_isActive, "isActive", true, "Active", "", "", "" );
m_isActive.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_surfacesInView, "SurfacesInViewField", "SurfacesInViewField", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_surfacesInView, "SurfacesInViewField", "SurfacesInViewField", "", "", "" );
m_surfacesInView.uiCapability()->setUiTreeHidden( true ); m_surfacesInView.uiCapability()->setUiTreeHidden( true );
setName( "Surfaces" );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -101,25 +100,35 @@ void RimSurfaceInViewCollection::loadData()
{ {
for ( RimSurfaceInView* surf : m_surfacesInView ) for ( RimSurfaceInView* surf : m_surfacesInView )
{ {
if ( surf->isActive() && surf->surface() ) if ( surf->isActive() )
{ {
surf->surface()->loadDataIfRequired(); surf->loadDataAndUpdate();
} }
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSurfaceInViewCollection::clearGeometry()
{
for ( RimSurfaceInView* surf : m_surfacesInView )
{
surf->clearGeometry();
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimSurfaceInViewCollection::appendPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ) void RimSurfaceInViewCollection::appendPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform )
{ {
if ( !m_isActive() ) return; if ( !isChecked() ) return;
for ( RimSurfaceInView* surf : m_surfacesInView ) for ( RimSurfaceInView* surf : m_surfacesInView )
{ {
if ( surf->isActive() ) if ( surf->isActive() )
{ {
// surf->surfacePartMgr()->appendNativeGeometryPartsToModel( model, scaleTransform );
surf->surfacePartMgr()->appendIntersectionGeometryPartsToModel( model, scaleTransform ); surf->surfacePartMgr()->appendIntersectionGeometryPartsToModel( model, scaleTransform );
} }
} }
@ -134,7 +143,7 @@ void RimSurfaceInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* ch
const QVariant& oldValue, const QVariant& oldValue,
const QVariant& newValue ) const QVariant& newValue )
{ {
if ( changedField == &m_isActive ) if ( changedField == &m_isChecked )
{ {
RimGridView* ownerView; RimGridView* ownerView;
this->firstAncestorOrThisOfTypeAsserted( ownerView ); this->firstAncestorOrThisOfTypeAsserted( ownerView );
@ -158,36 +167,40 @@ bool RimSurfaceInViewCollection::hasSurfaceInViewForSurface( const RimSurface* s
return false; return false;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimSurfaceInViewCollection::objectToggleField()
{
return &m_isActive;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimSurfaceInViewCollection::updateCellResultColor( bool hasGeneralCellResult, size_t timeStepIndex ) void RimSurfaceInViewCollection::updateCellResultColor( bool hasGeneralCellResult, size_t timeStepIndex )
{ {
if ( !this->m_isActive() ) return; if ( !this->isChecked() ) return;
for ( RimSurfaceInView* surf : m_surfacesInView ) for ( RimSurfaceInView* surf : m_surfacesInView )
{ {
if ( surf->isActive() ) if ( surf->isActive() )
{ {
bool showResults = surf->activeSeparateResultDefinition() bool useNativeSurfaceColors = false;
? surf->activeSeparateResultDefinition()->hasResult()
: hasGeneralCellResult;
if ( showResults ) if ( surf->isNativeSurfaceResultsActive() ) useNativeSurfaceColors = true;
if ( !useNativeSurfaceColors )
{ {
surf->surfacePartMgr()->updateCellResultColor( timeStepIndex ); bool showResults = surf->activeSeparateResultDefinition()
? surf->activeSeparateResultDefinition()->hasResult()
: hasGeneralCellResult;
if ( showResults )
{
surf->surfacePartMgr()->updateCellResultColor( timeStepIndex );
}
else
{
useNativeSurfaceColors = true;
}
} }
else
if ( useNativeSurfaceColors )
{ {
surf->surfacePartMgr()->applySingleColor(); surf->surfacePartMgr()->updateNativeSurfaceColors();
} }
} }
} }
@ -198,13 +211,13 @@ void RimSurfaceInViewCollection::updateCellResultColor( bool hasGeneralCellResul
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimSurfaceInViewCollection::applySingleColorEffect() void RimSurfaceInViewCollection::applySingleColorEffect()
{ {
if ( !this->m_isActive() ) return; if ( !this->isChecked() ) return;
for ( RimSurfaceInView* surf : m_surfacesInView ) for ( RimSurfaceInView* surf : m_surfacesInView )
{ {
if ( surf->isActive() ) if ( surf->isActive() )
{ {
surf->surfacePartMgr()->applySingleColor(); surf->surfacePartMgr()->updateNativeSurfaceColors();
} }
} }
} }
@ -214,7 +227,7 @@ void RimSurfaceInViewCollection::applySingleColorEffect()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimSurfaceInViewCollection::hasAnyActiveSeparateResults() bool RimSurfaceInViewCollection::hasAnyActiveSeparateResults()
{ {
if ( !this->m_isActive() ) return false; if ( !this->isChecked() ) return false;
for ( RimSurfaceInView* surf : m_surfacesInView ) for ( RimSurfaceInView* surf : m_surfacesInView )
{ {
@ -227,3 +240,15 @@ bool RimSurfaceInViewCollection::hasAnyActiveSeparateResults()
return false; return false;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSurfaceInViewCollection::updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer,
bool isUsingOverrideViewer )
{
for ( RimSurfaceInView* surf : m_surfacesInView )
{
surf->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer, isUsingOverrideViewer );
}
}

View File

@ -17,6 +17,8 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#pragma once #pragma once
#include "RimCheckableNamedObject.h"
#include "cafPdmChildArrayField.h" #include "cafPdmChildArrayField.h"
#include "cafPdmField.h" #include "cafPdmField.h"
#include "cafPdmObject.h" #include "cafPdmObject.h"
@ -30,8 +32,9 @@ class ScalarMapper;
class RimSurfaceInView; class RimSurfaceInView;
class RimSurface; class RimSurface;
class RiuViewer;
class RimSurfaceInViewCollection : public caf::PdmObject class RimSurfaceInViewCollection : public RimCheckableNamedObject
{ {
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
@ -41,19 +44,19 @@ public:
void updateFromSurfaceCollection(); void updateFromSurfaceCollection();
void loadData(); void loadData();
void clearGeometry();
void appendPartsToModel( cvf::ModelBasicList* surfaceVizModel, cvf::Transform* scaleTransform ); void appendPartsToModel( cvf::ModelBasicList* surfaceVizModel, cvf::Transform* scaleTransform );
void updateCellResultColor( bool hasGeneralCellResult, size_t timeStepIndex ); void updateCellResultColor( bool hasGeneralCellResult, size_t timeStepIndex );
void applySingleColorEffect(); void applySingleColorEffect();
bool hasAnyActiveSeparateResults(); bool hasAnyActiveSeparateResults();
void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer );
private: private:
caf::PdmFieldHandle* objectToggleField() override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
bool hasSurfaceInViewForSurface( const RimSurface* surf ) const; bool hasSurfaceInViewForSurface( const RimSurface* surf ) const;
caf::PdmField<bool> m_isActive;
caf::PdmChildArrayField<RimSurfaceInView*> m_surfacesInView; caf::PdmChildArrayField<RimSurfaceInView*> m_surfacesInView;
}; };

View File

@ -23,6 +23,7 @@
#include "RigStatisticsMath.h" #include "RigStatisticsMath.h"
#include "RigSurface.h" #include "RigSurface.h"
#include "Rim3dView.h"
#include "RimRegularLegendConfig.h" #include "RimRegularLegendConfig.h"
#include "RimSurface.h" #include "RimSurface.h"
#include "RimSurfaceInView.h" #include "RimSurfaceInView.h"
@ -43,7 +44,7 @@ RimSurfaceResultDefinition::RimSurfaceResultDefinition()
m_legendConfig.uiCapability()->setUiTreeChildrenHidden( false ); m_legendConfig.uiCapability()->setUiTreeChildrenHidden( false );
m_legendConfig = new RimRegularLegendConfig; m_legendConfig = new RimRegularLegendConfig;
setName( "Result Definition" ); setName( "Result Property" );
CAF_PDM_InitFieldNoDefault( &m_surfaceInView, "SurfaceInView", "Surface In View", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_surfaceInView, "SurfaceInView", "Surface In View", "", "", "" );
m_surfaceInView.uiCapability()->setUiHidden( true ); m_surfaceInView.uiCapability()->setUiHidden( true );
@ -63,6 +64,16 @@ RimSurfaceResultDefinition::~RimSurfaceResultDefinition()
void RimSurfaceResultDefinition::setSurfaceInView( RimSurfaceInView* surfaceInView ) void RimSurfaceResultDefinition::setSurfaceInView( RimSurfaceInView* surfaceInView )
{ {
m_surfaceInView = surfaceInView; m_surfaceInView = surfaceInView;
assignDefaultProperty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimSurfaceResultDefinition::propertyName() const
{
return m_propertyName;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -73,6 +84,57 @@ RimRegularLegendConfig* RimSurfaceResultDefinition::legendConfig()
return m_legendConfig(); return m_legendConfig();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSurfaceResultDefinition::updateMinMaxValues()
{
RigSurface* surfData = surfaceData();
if ( surfData )
{
double globalMin = 0.0;
double globalMax = 0.0;
double globalPosClosestToZero = 0.0;
double globalNegClosestToZero = 0.0;
{
MinMaxAccumulator minMaxAccumulator;
PosNegAccumulator posNegAccumulator;
auto values = surfData->propertyValues( m_propertyName );
minMaxAccumulator.addData( values );
posNegAccumulator.addData( values );
globalPosClosestToZero = posNegAccumulator.pos;
globalNegClosestToZero = posNegAccumulator.neg;
globalMin = minMaxAccumulator.min;
globalMax = minMaxAccumulator.max;
}
m_legendConfig->setClosestToZeroValues( globalPosClosestToZero,
globalNegClosestToZero,
globalPosClosestToZero,
globalNegClosestToZero );
m_legendConfig->setAutomaticRanges( globalMin, globalMax, globalMin, globalMax );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSurfaceResultDefinition::assignDefaultProperty()
{
if ( m_surfaceInView->surface() && m_surfaceInView->surface()->surfaceData() )
{
auto propNames = m_surfaceInView->surface()->surfaceData()->propertyNames();
if ( !propNames.empty() )
{
m_propertyName = m_surfaceInView->surface()->surfaceData()->propertyNames().front();
}
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -80,37 +142,17 @@ void RimSurfaceResultDefinition::fieldChangedByUi( const caf::PdmFieldHandle* ch
const QVariant& oldValue, const QVariant& oldValue,
const QVariant& newValue ) const QVariant& newValue )
{ {
if ( changedField == &m_propertyName && m_propertyName != RiaDefines::undefinedResultName() ) if ( changedField == &m_propertyName )
{ {
RigSurface* surfData = surfaceData(); updateMinMaxValues();
if ( surfData ) }
{
double globalMin = 0.0;
double globalMax = 0.0;
double globalPosClosestToZero = 0.0;
double globalNegClosestToZero = 0.0;
{ Rim3dView* view = nullptr;
MinMaxAccumulator minMaxAccumulator; this->firstAncestorOrThisOfType( view );
PosNegAccumulator posNegAccumulator;
auto values = surfData->propertyValues( m_propertyName ); if ( view )
minMaxAccumulator.addData( values ); {
posNegAccumulator.addData( values ); view->scheduleCreateDisplayModelAndRedraw();
globalPosClosestToZero = posNegAccumulator.pos;
globalNegClosestToZero = posNegAccumulator.neg;
globalMin = minMaxAccumulator.min;
globalMax = minMaxAccumulator.max;
}
m_legendConfig->setClosestToZeroValues( globalPosClosestToZero,
globalNegClosestToZero,
globalPosClosestToZero,
globalNegClosestToZero );
m_legendConfig->setAutomaticRanges( globalMin, globalMax, globalMin, globalMax );
}
} }
} }
@ -120,6 +162,8 @@ void RimSurfaceResultDefinition::fieldChangedByUi( const caf::PdmFieldHandle* ch
void RimSurfaceResultDefinition::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) void RimSurfaceResultDefinition::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{ {
uiOrdering.add( &m_propertyName ); uiOrdering.add( &m_propertyName );
uiOrdering.skipRemainingFields();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -41,10 +41,14 @@ public:
RimSurfaceResultDefinition(); RimSurfaceResultDefinition();
~RimSurfaceResultDefinition() override; ~RimSurfaceResultDefinition() override;
void setSurfaceInView( RimSurfaceInView* surfaceInView ); void setSurfaceInView( RimSurfaceInView* surfaceInView );
QString propertyName() const;
RimRegularLegendConfig* legendConfig(); RimRegularLegendConfig* legendConfig();
void updateMinMaxValues();
void assignDefaultProperty();
private: private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;

View File

@ -217,7 +217,7 @@ bool HexGridIntersectionTools::planeTriangleIntersection(const cvf::Plane& plane
CVF_ASSERT(false); CVF_ASSERT(false);
} }
CVF_TIGHT_ASSERT(ok1 && ok2); //CVF_TIGHT_ASSERT(ok1 && ok2);
return true; return true;
} }