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
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();