#6033 Surface Properties : Add result selection object

This commit is contained in:
Magne Sjaastad 2020-06-10 10:31:43 +02:00
parent b2444568be
commit 0799a9cf83
8 changed files with 293 additions and 6 deletions

View File

@ -6,6 +6,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimGridCaseSurface.h
${CMAKE_CURRENT_LIST_DIR}/RimSurfaceCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimSurfaceInView.h
${CMAKE_CURRENT_LIST_DIR}/RimSurfaceInViewCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimSurfaceResultDefinition.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -15,6 +16,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimGridCaseSurface.cpp
${CMAKE_CURRENT_LIST_DIR}/RimSurfaceCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimSurfaceInView.cpp
${CMAKE_CURRENT_LIST_DIR}/RimSurfaceInViewCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimSurfaceResultDefinition.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -119,6 +119,16 @@ bool RimFileSurface::updateSurfaceDataFromFile()
surface->setTriangleData( tringleIndices, vertices );
}
if ( m_gocadData )
{
auto propertyNames = m_gocadData->propertyNames();
for ( const auto& name : propertyNames )
{
auto values = m_gocadData->propertyValues( name );
surface->addVerticeResult( name, values );
}
}
setSurfaceData( surface );
return result;

View File

@ -20,6 +20,7 @@
#include "RimGridView.h"
#include "RimSurface.h"
#include "RimSurfaceResultDefinition.h"
#include "RigFemPartCollection.h"
#include "RimEclipseView.h"
@ -47,6 +48,12 @@ RimSurfaceInView::RimSurfaceInView()
CAF_PDM_InitField( &m_depthOffset, "DepthOffset", 0.0, "Depth Offset", "", "", "" );
m_depthOffset.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_resultDefinition, "ResultDefinition", "Result Definition", "", "", "" );
m_resultDefinition.uiCapability()->setUiHidden( true );
m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( false );
m_resultDefinition = new RimSurfaceResultDefinition;
m_resultDefinition->setSurfaceInView( this );
}
//--------------------------------------------------------------------------------------------------

View File

@ -17,6 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmProxyValueField.h"
@ -27,10 +28,13 @@
#include "RimIntersection.h"
class RimSurface;
class RimSurfaceResultDefinition;
class RivSurfacePartMgr;
class RivIntersectionHexGridInterface;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RimSurfaceInView : public RimIntersection
{
CAF_PDM_HEADER_INIT;
@ -63,7 +67,8 @@ private:
caf::PdmProxyValueField<QString> m_name;
caf::PdmPtrField<RimSurface*> m_surface;
caf::PdmField<double> m_depthOffset;
caf::PdmField<double> m_depthOffset;
caf::PdmChildField<RimSurfaceResultDefinition*> m_resultDefinition;
cvf::ref<RivSurfacePartMgr> m_surfacePartMgr;
};

View File

@ -0,0 +1,162 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimSurfaceResultDefinition.h"
#include "RiaDefines.h"
#include "RigStatisticsMath.h"
#include "RigSurface.h"
#include "RimRegularLegendConfig.h"
#include "RimSurface.h"
#include "RimSurfaceInView.h"
CAF_PDM_SOURCE_INIT( RimSurfaceResultDefinition, "SurfaceResultDefinition" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSurfaceResultDefinition::RimSurfaceResultDefinition()
{
CAF_PDM_InitObject( "Surface", ":/ReservoirSurface16x16.png", "", "" );
CAF_PDM_InitFieldNoDefault( &m_propertyName, "PropertyName", "Property Name", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendConfig", "Legend", "", "", "" );
m_legendConfig.uiCapability()->setUiHidden( true );
m_legendConfig.uiCapability()->setUiTreeChildrenHidden( false );
m_legendConfig = new RimRegularLegendConfig;
setName( "Result Definition" );
CAF_PDM_InitFieldNoDefault( &m_surfaceInView, "SurfaceInView", "Surface In View", "", "", "" );
m_surfaceInView.uiCapability()->setUiHidden( true );
m_surfaceInView.uiCapability()->setUiTreeChildrenHidden( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSurfaceResultDefinition::~RimSurfaceResultDefinition()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSurfaceResultDefinition::setSurfaceInView( RimSurfaceInView* surfaceInView )
{
m_surfaceInView = surfaceInView;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimRegularLegendConfig* RimSurfaceResultDefinition::legendConfig()
{
return m_legendConfig();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSurfaceResultDefinition::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
if ( changedField == &m_propertyName && m_propertyName != RiaDefines::undefinedResultName() )
{
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::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_propertyName );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RimSurfaceResultDefinition::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_propertyName )
{
options.push_back( caf::PdmOptionItemInfo( RiaDefines::undefinedResultName(), RiaDefines::undefinedResultName() ) );
RigSurface* surfData = surfaceData();
if ( surfData )
{
auto propertyNames = surfData->propertyNames();
for ( auto name : propertyNames )
{
options.push_back( caf::PdmOptionItemInfo( name, name ) );
}
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigSurface* RimSurfaceResultDefinition::surfaceData()
{
if ( m_surfaceInView && m_surfaceInView->surface() && m_surfaceInView->surface()->surfaceData() )
{
return m_surfaceInView->surface()->surfaceData();
}
return nullptr;
}

View File

@ -0,0 +1,61 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimCheckableNamedObject.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include "cvfObject.h"
class RimRegularLegendConfig;
class RimSurfaceInView;
class RigSurface;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RimSurfaceResultDefinition : public RimCheckableNamedObject
{
CAF_PDM_HEADER_INIT;
public:
RimSurfaceResultDefinition();
~RimSurfaceResultDefinition() override;
void setSurfaceInView( RimSurfaceInView* surfaceInView );
RimRegularLegendConfig* legendConfig();
private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
RigSurface* surfaceData();
private:
caf::PdmField<QString> m_propertyName;
caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig;
caf::PdmPtrField<RimSurfaceInView*> m_surfaceInView;
};

View File

@ -55,3 +55,40 @@ void RigSurface::setTriangleData( const std::vector<unsigned>& tringleIndices, c
m_triangleIndices = tringleIndices;
m_vertices = vertices;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigSurface::addVerticeResult( const QString resultName, const std::vector<float>& resultValues )
{
m_verticeResults[resultName] = resultValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<float> RigSurface::propertyValues( const QString& propertyName ) const
{
auto it = m_verticeResults.find( propertyName );
if ( it != m_verticeResults.end() )
{
return it->second;
}
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QString> RigSurface::propertyNames() const
{
std::vector<QString> names;
for ( const auto& propertyResult : m_verticeResults )
{
names.push_back( propertyResult.first );
}
return names;
}

View File

@ -35,10 +35,13 @@ public:
const std::vector<cvf::Vec3d>& vertices();
void setTriangleData( const std::vector<unsigned>& tringleIndices, const std::vector<cvf::Vec3d>& vertices );
void addVerticeResult( const QString resultName, const std::vector<double>& resultValues );
void addVerticeResult( const QString resultName, const std::vector<float>& resultValues );
std::vector<float> propertyValues( const QString& propertyName ) const;
std::vector<QString> propertyNames() const;
private:
std::vector<unsigned> m_triangleIndices;
std::vector<cvf::Vec3d> m_vertices;
std::map<QString, std::vector<double>> m_verticeResults;
std::vector<unsigned> m_triangleIndices;
std::vector<cvf::Vec3d> m_vertices;
std::map<QString, std::vector<float>> m_verticeResults;
};