mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#9369 Curve Probing: Show data from other curves in tooltip text
Optionally show data from other curves in tooltip text when hoovering over a curve point
This commit is contained in:
@@ -295,6 +295,31 @@ void RimWellLogCurve::setOverrideCurveData( const std::vector<double>&
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimWellLogCurve::closestYValueForX( double xValue ) const
|
||||
{
|
||||
if ( m_curveData.isNull() ) return std::numeric_limits<double>::infinity();
|
||||
|
||||
auto depths = m_curveData->depths( RiaDefines::DepthTypeEnum::MEASURED_DEPTH );
|
||||
auto values = m_curveData->propertyValues();
|
||||
|
||||
if ( depths.empty() || values.empty() ) return std::numeric_limits<double>::infinity();
|
||||
|
||||
auto it = std::upper_bound( depths.begin(), depths.end(), xValue );
|
||||
if ( it == depths.begin() ) return values.front();
|
||||
if ( it == depths.end() ) return values.back();
|
||||
|
||||
auto index = std::distance( depths.begin(), it - 1 );
|
||||
|
||||
double firstDistance = std::abs( xValue - depths[index] );
|
||||
double secondDistance = std::abs( xValue - depths[index + 1] );
|
||||
|
||||
if ( firstDistance < secondDistance ) return values[index];
|
||||
return values[index + 1];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user