From 3737e85417cc69aa593135af63ec6ab6e86b17cc Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 27 Aug 2012 08:33:00 +0000 Subject: [PATCH] 0021813: [CEA 642] Tool tips not always available in multi curve display in Plot2D view Fix the bug: tooltip is returned for only first curve found by iterator --- src/Plot2d/Plot2d_ViewFrame.cxx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index 6995c9fa3..6a431e7b3 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -3910,16 +3910,20 @@ Plot2d_Curve* Plot2d_ViewFrame::getClosestCurve( QPoint p, double& distance, int { CurveDict aCurves = getCurves(); CurveDict::iterator it = aCurves.begin(); - QwtPlotCurve* aCurve; + Plot2d_Curve* pCurve = 0; + distance = -1.; for ( ; it != aCurves.end(); it++ ) { - aCurve = it.key(); + QwtPlotCurve* aCurve = it.key(); if ( !aCurve ) continue; - index = aCurve->closestPoint( p, &distance ); - if ( index > -1 ) - return it.value(); + double d; + index = aCurve->closestPoint( p, &d ); + if ( index > -1 && ( distance < 0 || d < distance ) ) { + pCurve = it.value(); + distance = d; + } } - return 0; + return pCurve; } /*! -- 2.39.2