#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:
Magne Sjaastad
2022-10-17 19:48:24 +02:00
parent 7c2941aedd
commit 760bfaeec2
19 changed files with 268 additions and 57 deletions

View File

@@ -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];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------