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:
@@ -30,4 +30,5 @@ class RiuPlotCurveInfoTextProvider
|
||||
{
|
||||
public:
|
||||
virtual QString curveInfoText( RiuPlotCurve* curve ) const = 0;
|
||||
virtual QString additionalText( RiuPlotCurve* curve, int sampleIndex ) const { return {}; };
|
||||
};
|
||||
|
||||
@@ -219,6 +219,15 @@ QPointF RiuQwtCurvePointTracker::closestCurvePoint( const QPoint& cursorPosition
|
||||
{
|
||||
*valueAxisValueString = valueAxisScaleDraw->label( valueAxisSampleVal ).text();
|
||||
}
|
||||
|
||||
auto additionalText = m_curveInfoTextProvider->additionalText( dynamic_cast<RiuPlotCurve*>( closestCurve ),
|
||||
closestPointSampleIndex );
|
||||
|
||||
if ( !additionalText.isEmpty() )
|
||||
{
|
||||
*valueAxisValueString += "\n";
|
||||
*valueAxisValueString += additionalText;
|
||||
}
|
||||
}
|
||||
|
||||
return samplePoint;
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "RimWellLogExtractionCurve.h"
|
||||
#include "RimWellLogTrack.h"
|
||||
|
||||
#include "RigWellLogCurveData.h"
|
||||
|
||||
#include "RiuGuiTheme.h"
|
||||
#include "RiuPlotCurve.h"
|
||||
#include "RiuPlotCurveInfoTextProvider.h"
|
||||
@@ -114,10 +116,9 @@ public:
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString curveInfoText( RiuPlotCurve* riuCurve ) const override
|
||||
{
|
||||
RimWellLogCurve* wlCurve = nullptr;
|
||||
if ( riuCurve )
|
||||
{
|
||||
wlCurve = dynamic_cast<RimWellLogCurve*>( riuCurve->ownerRimCurve() );
|
||||
RimWellLogCurve* wlCurve = dynamic_cast<RimWellLogCurve*>( riuCurve->ownerRimCurve() );
|
||||
if ( wlCurve )
|
||||
{
|
||||
return QString( "%1" ).arg( wlCurve->curveName() );
|
||||
@@ -126,6 +127,51 @@ public:
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString additionalText( RiuPlotCurve* curve, int sampleIndex ) const override
|
||||
{
|
||||
if ( !curve ) return {};
|
||||
|
||||
std::vector<std::pair<QString, double>> propertyNameValues;
|
||||
|
||||
auto* sourceCurve = curve->ownerRimCurve();
|
||||
if ( !sourceCurve ) return {};
|
||||
|
||||
auto annotationCurves = sourceCurve->additionalDataSources();
|
||||
for ( auto annotationCurve : annotationCurves )
|
||||
{
|
||||
RimDepthTrackPlot* depthTrackPlot = nullptr;
|
||||
annotationCurve->firstAncestorOfType( depthTrackPlot );
|
||||
if ( depthTrackPlot )
|
||||
{
|
||||
auto [xValue, yValue] = curve->sample( sampleIndex );
|
||||
|
||||
auto depth = depthTrackPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL ? yValue
|
||||
: xValue;
|
||||
|
||||
auto propertyValue = annotationCurve->closestYValueForX( depth );
|
||||
|
||||
// Use template to get as short label as possible. The default curve name will often
|
||||
// contain too much and redundant information.
|
||||
QString templateText = RiaDefines::namingVariableResultName() + ", " +
|
||||
RiaDefines::namingVariableResultType();
|
||||
auto resultName = annotationCurve->createCurveNameFromTemplate( templateText );
|
||||
|
||||
propertyNameValues.push_back( std::make_pair( resultName, propertyValue ) );
|
||||
}
|
||||
}
|
||||
|
||||
QString txt;
|
||||
for ( const auto& [name, value] : propertyNameValues )
|
||||
{
|
||||
txt += QString( "%1 : %2\n" ).arg( name ).arg( value );
|
||||
}
|
||||
|
||||
return txt;
|
||||
}
|
||||
};
|
||||
static WellLogCurveInfoTextProvider wellLogCurveInfoTextProvider;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user