From 3702238d73f393e771abdff92dd3443148f879e7 Mon Sep 17 00:00:00 2001 From: rnv Date: Wed, 1 Feb 2012 07:43:33 +0000 Subject: [PATCH] Additional fix for the 0021407: [CEA 515] Plot2d Display error labels around the point issue. --- src/Plot2d/Plot2d.cxx | 20 ++++++++++++-------- src/Plot2d/Plot2d.h | 4 ++-- src/Plot2d/Plot2d_Curve.cxx | 12 +++++++----- src/Plot2d/Plot2d_PlotItems.cxx | 4 ++-- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/Plot2d/Plot2d.cxx b/src/Plot2d/Plot2d.cxx index b864720b9..efeba138d 100755 --- a/src/Plot2d/Plot2d.cxx +++ b/src/Plot2d/Plot2d.cxx @@ -98,19 +98,23 @@ bool Plot2d_Point::deviation(double& min, double& max) const { /*! Return minimal deviation value. */ -double Plot2d_Point::minDeviation() const { - if(hasDeviation()) - return deviationPtr[0]; - return 0.; +bool Plot2d_Point::minDeviation(double& min) const { + if(hasDeviation()) { + min = deviationPtr[0]; + return true; + } + return false; } /*! Return minimal deviation value. */ -double Plot2d_Point::maxDeviation() const { - if(hasDeviation()) - return deviationPtr[1]; - return 0.; +bool Plot2d_Point::maxDeviation(double& max) const { + if(hasDeviation()) { + max = deviationPtr[1]; + return true; + } + return false; } diff --git a/src/Plot2d/Plot2d.h b/src/Plot2d/Plot2d.h index 648c81344..a278ec2e5 100755 --- a/src/Plot2d/Plot2d.h +++ b/src/Plot2d/Plot2d.h @@ -60,8 +60,8 @@ struct PLOT2D_EXPORT Plot2d_Point bool hasDeviation() const; void setDeviation(double min, double max); void clearDeviation(); - double minDeviation() const; - double maxDeviation() const; + bool minDeviation(double& min) const; + bool maxDeviation(double& max) const; }; typedef QList pointList; diff --git a/src/Plot2d/Plot2d_Curve.cxx b/src/Plot2d/Plot2d_Curve.cxx index 06e264b22..8afc8c1dc 100755 --- a/src/Plot2d/Plot2d_Curve.cxx +++ b/src/Plot2d/Plot2d_Curve.cxx @@ -338,9 +338,10 @@ double Plot2d_Curve::getMinY() const double aMinY = 1e150; pointList::const_iterator aIt; double coeff = 0.0; - for (aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) { - coeff = (*aIt).minDeviation(); - aMinY = qMin( aMinY, myScale * (*aIt).y - coeff ); + for (aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) { + aMinY = qMin( aMinY, myScale * (*aIt).y ); + if((*aIt).minDeviation(coeff)) + aMinY = qMin( aMinY, coeff ); } return aMinY; } @@ -354,8 +355,9 @@ double Plot2d_Curve::getMaxY() const pointList::const_iterator aIt; double coeff = 0.0; for (aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) { - coeff = (*aIt).maxDeviation(); - aMaxY = qMax( aMaxY, myScale * (*aIt).y + coeff ); + aMaxY = qMax( aMaxY, myScale * (*aIt).y); + if((*aIt).maxDeviation(coeff)) + aMaxY = qMax( aMaxY, coeff); } return aMaxY; } \ No newline at end of file diff --git a/src/Plot2d/Plot2d_PlotItems.cxx b/src/Plot2d/Plot2d_PlotItems.cxx index 8bdb2a796..cc91401de 100644 --- a/src/Plot2d/Plot2d_PlotItems.cxx +++ b/src/Plot2d/Plot2d_PlotItems.cxx @@ -324,8 +324,8 @@ void Plot2d_QwtPlotCurve::draw(QPainter *painter, xi = x(i); yi = y(i); xp = xMap.transform(xi); - ytop = yMap.transform(yi + max); - ybtm = yMap.transform(yi - min); + ytop = yMap.transform(max); + ybtm = yMap.transform(min); tickl = xp - tickSz; tickr = xp + tickSz; painter->drawLine(tickl,ytop,tickr,ytop); -- 2.39.2