Surface: click on surface in 3d view to display value (#7702)

* Support showing result info for surfaces when clicking on them in the 3d view
This commit is contained in:
jonjenssen 2021-05-20 10:29:20 +02:00 committed by GitHub
parent 242e23a7c9
commit 2e08f278ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 0 deletions

View File

@ -226,6 +226,44 @@ void RivSurfacePartMgr::updateNativeSurfaceColors()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RivSurfacePartMgr::resultInfoText( Rim3dView* view, uint hitPart, cvf::Vec3d hitPoint )
{
QString retval;
if ( m_surfaceInView->surfaceResultDefinition()->isChecked() )
{
const auto& values =
m_usedSurfaceData->propertyValues( m_surfaceInView->surfaceResultDefinition()->propertyName() );
const auto& ind = m_usedSurfaceData->triangleIndices();
const auto& vert = m_usedSurfaceData->vertices();
size_t indIndex = ( size_t )( hitPart * 3 );
// find closest triangle corner point to hit point and show that value
if ( ind.size() > ( indIndex + 2 ) )
{
uint vertIndex1 = ind[indIndex];
uint vertIndex2 = ind[indIndex + 1];
uint vertIndex3 = ind[indIndex + 2];
double dist1 = vert[vertIndex1].pointDistance( hitPoint );
double dist2 = vert[vertIndex2].pointDistance( hitPoint );
double dist3 = vert[vertIndex3].pointDistance( hitPoint );
double resultValue = values[vertIndex1];
if ( dist2 < dist1 ) resultValue = values[vertIndex2];
if ( ( dist3 < dist1 ) && ( dist3 < dist2 ) ) resultValue = values[vertIndex3];
retval +=
QString( "%1 : %2\n\n" ).arg( m_surfaceInView->surfaceResultDefinition()->propertyName() ).arg( resultValue );
}
}
return retval;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -33,6 +33,7 @@ class DrawableGeo;
class RimSurfaceInView;
class RigSurface;
class RigResultAccessor;
class Rim3dView;
class RivSurfaceIntersectionGeometryGenerator;
@ -47,6 +48,8 @@ public:
void appendNativeGeometryPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
QString resultInfoText( Rim3dView* view, uint hitPart, cvf::Vec3d hitPoint );
private:
void generatePartGeometry();

View File

@ -85,6 +85,7 @@
#include "RivSimWellConnectionSourceInfo.h"
#include "RivSimWellPipeSourceInfo.h"
#include "RivSourceInfo.h"
#include "RivSurfacePartMgr.h"
#include "RivTernarySaturationOverlayItem.h"
#include "RivWellConnectionSourceInfo.h"
#include "RivWellFracturePartMgr.h"
@ -794,6 +795,24 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
if ( surf )
{
RiuMainWindow::instance()->selectAsCurrentItem( surf, true );
cvf::ref<caf::DisplayCoordTransform> transForm = mainOrComparisonView->displayCoordTransform();
cvf::Vec3d domainCoord = transForm->transformToDomainCoord( globalIntersectionPoint );
// Set surface resultInfo text
QString resultInfoText = "Surface: " + surf->name() + "\n\n";
RivSurfacePartMgr* partMgr = surf->surfacePartMgr();
resultInfoText += partMgr->resultInfoText( mainOrComparisonView, firstPartTriangleIndex, domainCoord );
// Set intersection point result text
QString intersectionPointText = QString( "Intersection point : Global [E: %1, N: %2, Depth: %3]" )
.arg( domainCoord.x(), 5, 'f', 2 )
.arg( domainCoord.y(), 5, 'f', 2 )
.arg( -domainCoord.z(), 5, 'f', 2 );
resultInfoText.append( intersectionPointText );
// Display result info text
RiuMainWindow::instance()->setResultInfo( resultInfoText );
}
}
else if ( const RivReservoirSurfaceIntersectionSourceInfo* surfIntersectSourceInfo =