mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Improve visual appearance for depth surface
- disable intersection geometry with cell property colors - allow opacity - set default color to blue, as most user use this plane for oil-water contact
This commit is contained in:
parent
0fd27a3a8d
commit
64a559756f
@ -44,6 +44,10 @@ void RicNewDepthSurfaceFeature::onActionTriggered( bool isChecked )
|
||||
|
||||
auto surface = new RimDepthSurface;
|
||||
|
||||
// As this surface is usually a oil-water contact, we set the color to blue
|
||||
surface->setColor( cvf::Color3f::BLUE );
|
||||
surface->setOpacity( true, 0.6f );
|
||||
|
||||
auto allCases = RimProject::current()->allGridCases();
|
||||
if ( !allCases.empty() )
|
||||
{
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||
#include "cvfRenderStateBlending.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
@ -121,7 +122,8 @@ void RivSurfacePartMgr::updateCellResultColor( int timeStepIndex )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivSurfacePartMgr::appendIntersectionGeometryPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform )
|
||||
{
|
||||
if ( !m_surfaceInView->surfaceResultDefinition()->isChecked() )
|
||||
if ( m_surfaceInView->surface() && m_surfaceInView->surface()->showIntersectionCellResults() &&
|
||||
!m_surfaceInView->surfaceResultDefinition()->isChecked() )
|
||||
{
|
||||
if ( m_intersectionFaces.isNull() )
|
||||
{
|
||||
@ -162,6 +164,9 @@ void RivSurfacePartMgr::appendIntersectionGeometryPartsToModel( cvf::ModelBasicL
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivSurfacePartMgr::updateNativeSurfaceColors()
|
||||
{
|
||||
const auto [opacityEnabled, surfaceOpacityValue] = m_surfaceInView->surface()->opacity();
|
||||
const auto opacityValueToUse = opacityEnabled ? surfaceOpacityValue : 1.0f;
|
||||
|
||||
if ( m_surfaceInView->surfaceResultDefinition()->isChecked() )
|
||||
{
|
||||
if ( m_usedSurfaceData.isNull() ) generateNativePartGeometry();
|
||||
@ -199,19 +204,35 @@ void RivSurfacePartMgr::updateNativeSurfaceColors()
|
||||
}
|
||||
else
|
||||
{
|
||||
caf::SurfaceEffectGenerator surfaceGenBehind( cvf::Color4f( m_surfaceInView->surface()->color() ), caf::PO_POS_LARGE );
|
||||
const auto color = cvf::Color4f( m_surfaceInView->surface()->color(), opacityValueToUse );
|
||||
caf::SurfaceEffectGenerator surfaceGenBehind( color, caf::PO_POS_LARGE );
|
||||
|
||||
cvf::ref<cvf::Effect> effBehind = surfaceGenBehind.generateCachedEffect();
|
||||
if ( m_nativeTrianglesPart.notNull() )
|
||||
{
|
||||
if ( opacityEnabled )
|
||||
{
|
||||
m_nativeTrianglesPart->setPriority( RivPartPriority::PartType::Transparent );
|
||||
cvf::ref<cvf::RenderStateBlending> blending = new cvf::RenderStateBlending;
|
||||
blending->configureTransparencyBlending();
|
||||
effBehind->setRenderState( blending.p() );
|
||||
}
|
||||
|
||||
m_nativeTrianglesPart->setEffect( effBehind.p() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_intersectionFaces.notNull() )
|
||||
{
|
||||
caf::SurfaceEffectGenerator surfaceGen( cvf::Color4f( m_surfaceInView->surface()->color() ), caf::PO_1 );
|
||||
caf::SurfaceEffectGenerator surfaceGen( cvf::Color4f( m_surfaceInView->surface()->color(), opacityValueToUse ), caf::PO_1 );
|
||||
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
|
||||
if ( opacityEnabled )
|
||||
{
|
||||
m_intersectionFaces->setPriority( RivPartPriority::PartType::Transparent );
|
||||
cvf::ref<cvf::RenderStateBlending> blending = new cvf::RenderStateBlending;
|
||||
blending->configureTransparencyBlending();
|
||||
eff->setRenderState( blending.p() );
|
||||
}
|
||||
|
||||
m_intersectionFaces->setEffect( eff.p() );
|
||||
}
|
||||
|
@ -81,6 +81,15 @@ RimSurface* RimDepthSurface::createCopy()
|
||||
return copyObject<RimDepthSurface>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimDepthSurface::showIntersectionCellResults()
|
||||
{
|
||||
// Avoid use of cell intersection results color for depth surfaces
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -141,6 +150,8 @@ void RimDepthSurface::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDepthSurface::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
RimSurface::defineEditorAttribute( field, uiConfigName, attribute );
|
||||
|
||||
caf::PdmUiDoubleValueEditorAttribute::testAndSetFixedWithTwoDecimals( attribute );
|
||||
|
||||
if ( field == &m_depth )
|
||||
@ -199,6 +210,9 @@ void RimDepthSurface::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
|
||||
auto group = uiOrdering.addNewGroup( "Appearance" );
|
||||
group->add( &m_userDescription );
|
||||
group->add( &m_color );
|
||||
|
||||
group->add( &m_enableOpacity );
|
||||
group->add( &m_opacity );
|
||||
}
|
||||
|
||||
uiOrdering.skipRemainingFields();
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include "RimSurface.h"
|
||||
|
||||
#include "cafPdmCoreVec3d.h"
|
||||
|
||||
class RimDepthSurface : public RimSurface
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
@ -31,6 +33,8 @@ public:
|
||||
bool onLoadData() override;
|
||||
RimSurface* createCopy() override;
|
||||
|
||||
bool showIntersectionCellResults() override;
|
||||
|
||||
void setPlaneExtent( double minX, double minY, double maxX, double maxY );
|
||||
void setDepth( double depth );
|
||||
void setDepthSliderLimits( double lower, double upper );
|
||||
|
@ -56,7 +56,11 @@ RimSurface::RimSurface()
|
||||
CAF_PDM_InitScriptableObject( "Surface", ":/ReservoirSurface16x16.png" );
|
||||
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_userDescription, "SurfaceUserDecription", "Name" );
|
||||
|
||||
CAF_PDM_InitField( &m_color, "SurfaceColor", cvf::Color3f( 0.5f, 0.3f, 0.2f ), "Color" );
|
||||
CAF_PDM_InitField( &m_enableOpacity, "EnableOpacity", false, "Enable Opacity" );
|
||||
CAF_PDM_InitField( &m_opacity, "Opacity", 0.6, "Opacity Value [0..1]" );
|
||||
m_opacity.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitScriptableField( &m_depthOffset, "DepthOffset", 0.0, "Depth Offset" );
|
||||
m_depthOffset.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
|
||||
@ -94,6 +98,31 @@ cvf::Color3f RimSurface::color() const
|
||||
return m_color();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<bool, float> RimSurface::opacity() const
|
||||
{
|
||||
return std::make_pair( m_enableOpacity(), m_opacity() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurface::setOpacity( bool useOpacity, float opacity )
|
||||
{
|
||||
m_enableOpacity.setValue( useOpacity );
|
||||
m_opacity.setValue( opacity );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSurface::showIntersectionCellResults()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -162,6 +191,9 @@ double RimSurface::depthOffset() const
|
||||
return m_depthOffset;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurface::setDepthOffset( double depthoffset )
|
||||
{
|
||||
m_depthOffset.setValue( depthoffset );
|
||||
@ -273,4 +305,13 @@ void RimSurface::defineEditorAttribute( const caf::PdmFieldHandle* field, QStrin
|
||||
doubleSliderAttrib->m_maximum = minimumExtent;
|
||||
}
|
||||
}
|
||||
|
||||
if ( field == &m_opacity )
|
||||
{
|
||||
if ( auto attr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute ) )
|
||||
{
|
||||
attr->m_minimum = 0.0;
|
||||
attr->m_maximum = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,11 @@ public:
|
||||
void setColor( const cvf::Color3f& color );
|
||||
cvf::Color3f color() const;
|
||||
|
||||
std::pair<bool, float> opacity() const;
|
||||
void setOpacity( bool useOpacity, float opacity );
|
||||
|
||||
virtual bool showIntersectionCellResults();
|
||||
|
||||
RigSurface* surfaceData();
|
||||
QString userDescription();
|
||||
void setUserDescription( const QString& description );
|
||||
@ -80,8 +85,11 @@ protected:
|
||||
virtual void clearCachedNativeData() = 0;
|
||||
|
||||
protected:
|
||||
caf::PdmField<QString> m_userDescription;
|
||||
caf::PdmField<QString> m_userDescription;
|
||||
|
||||
caf::PdmField<cvf::Color3f> m_color;
|
||||
caf::PdmField<bool> m_enableOpacity;
|
||||
caf::PdmField<double> m_opacity;
|
||||
|
||||
cvf::ref<RigSurface> m_surfaceData;
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmProxyValueField.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
class RimWellPathGeometryDef;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user