#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

@@ -23,6 +23,7 @@
#include "RigStatisticsMath.h"
#include "RigSurface.h"
#include "Rim3dView.h"
#include "RimRegularLegendConfig.h"
#include "RimSurface.h"
#include "RimSurfaceInView.h"
@@ -43,7 +44,7 @@ RimSurfaceResultDefinition::RimSurfaceResultDefinition()
m_legendConfig.uiCapability()->setUiTreeChildrenHidden( false );
m_legendConfig = new RimRegularLegendConfig;
setName( "Result Definition" );
setName( "Result Property" );
CAF_PDM_InitFieldNoDefault( &m_surfaceInView, "SurfaceInView", "Surface In View", "", "", "" );
m_surfaceInView.uiCapability()->setUiHidden( true );
@@ -63,6 +64,16 @@ RimSurfaceResultDefinition::~RimSurfaceResultDefinition()
void RimSurfaceResultDefinition::setSurfaceInView( RimSurfaceInView* surfaceInView )
{
m_surfaceInView = surfaceInView;
assignDefaultProperty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimSurfaceResultDefinition::propertyName() const
{
return m_propertyName;
}
//--------------------------------------------------------------------------------------------------
@@ -73,6 +84,57 @@ RimRegularLegendConfig* RimSurfaceResultDefinition::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& newValue )
{
if ( changedField == &m_propertyName && m_propertyName != RiaDefines::undefinedResultName() )
if ( changedField == &m_propertyName )
{
RigSurface* surfData = surfaceData();
if ( surfData )
{
double globalMin = 0.0;
double globalMax = 0.0;
double globalPosClosestToZero = 0.0;
double globalNegClosestToZero = 0.0;
updateMinMaxValues();
}
{
MinMaxAccumulator minMaxAccumulator;
PosNegAccumulator posNegAccumulator;
Rim3dView* view = nullptr;
this->firstAncestorOrThisOfType( view );
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 );
}
if ( view )
{
view->scheduleCreateDisplayModelAndRedraw();
}
}
@@ -120,6 +162,8 @@ void RimSurfaceResultDefinition::fieldChangedByUi( const caf::PdmFieldHandle* ch
void RimSurfaceResultDefinition::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_propertyName );
uiOrdering.skipRemainingFields();
}
//--------------------------------------------------------------------------------------------------