From a827558b64df8b77a8fdaa375df10b5d1efac1fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 9 Jan 2017 15:50:13 +0100 Subject: [PATCH] [apps] In curve view, correct programming style Change-Id: Idff43411da499ed17ced6d18475f11eff01051d2 --- apps/curve_view.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/apps/curve_view.cpp b/apps/curve_view.cpp index de465d5f0..deca9d6ec 100644 --- a/apps/curve_view.cpp +++ b/apps/curve_view.cpp @@ -286,19 +286,20 @@ void CurveView::drawHistogram(KDContext * ctx, KDRect rect, Model * model, float float rectMaxUpperBound = firstBarAbscissa + (rectMaxBinNumber+1)*barWidth + barWidth; for (float x = rectMinLowerBound; x < rectMaxUpperBound; x += barWidth) { float y = evaluateModelWithParameter(model, x+barWidth/2.0f); - if (!isnan(y)) { - float pxf = floatToPixel(Axis::Horizontal, x); - float pyf = floatToPixel(Axis::Vertical, y); - KDRect binRect(pxf, roundf(pyf), pixelBarWidth+1 , floatToPixel(Axis::Vertical, 0.0f) - roundf(pyf)); - if (floatToPixel(Axis::Vertical, 0.0f) < roundf(pyf)) { - binRect = KDRect(pxf, floatToPixel(Axis::Vertical, 0.0f), pixelBarWidth+1, roundf(pyf) - floatToPixel(Axis::Vertical, 0.0f)); - } - KDColor binColor = defaultColor; - if (x + barWidth/2.0f >= highlightLowerBound && x + barWidth/2.0f <= highlightUpperBound) { - binColor = highlightColor; - } - ctx->fillRect(binRect, binColor); + if (isnan(y)) { + continue; } + float pxf = floatToPixel(Axis::Horizontal, x); + float pyf = floatToPixel(Axis::Vertical, y); + KDRect binRect(pxf, roundf(pyf), pixelBarWidth+1 , floatToPixel(Axis::Vertical, 0.0f) - roundf(pyf)); + if (floatToPixel(Axis::Vertical, 0.0f) < roundf(pyf)) { + binRect = KDRect(pxf, floatToPixel(Axis::Vertical, 0.0f), pixelBarWidth+1, roundf(pyf) - floatToPixel(Axis::Vertical, 0.0f)); + } + KDColor binColor = defaultColor; + if (x + barWidth/2.0f >= highlightLowerBound && x + barWidth/2.0f <= highlightUpperBound) { + binColor = highlightColor; + } + ctx->fillRect(binRect, binColor); } }