From 147c26b2deafbd134e406e56083cd17bc3c8040c Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Mon, 12 Sep 2016 15:08:04 +0300 Subject: [PATCH] Moving altitude chart diagram to the middle of the canvas. --- map/chart_generator.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/map/chart_generator.cpp b/map/chart_generator.cpp index 55c5468a12..30442a22e8 100644 --- a/map/chart_generator.cpp +++ b/map/chart_generator.cpp @@ -166,10 +166,18 @@ bool GenerateYAxisChartData(uint32_t height, double minMetersPerPxl, return false; } + double const freeHeightSpacePxl = drawHeightPxl - deltaAltM / metersPerPxl; + if (freeHeightSpacePxl < 0 || freeHeightSpacePxl > drawHeightPxl) + { + LOG(LERROR, ("freeHeightSpacePxl is out of the range [0, drawHeightPxl].")); + return false; + } + + double const shift = heightIndentPxl + freeHeightSpacePxl / 2.0; size_t const altitudeDataSize = altitudeDataM.size(); yAxisDataPxl.resize(altitudeDataSize); for (size_t i = 0; i < altitudeDataSize; ++i) - yAxisDataPxl[i] = height - heightIndentPxl - (altitudeDataM[i] - minAltM) / metersPerPxl; + yAxisDataPxl[i] = height - shift - (altitudeDataM[i] - minAltM) / metersPerPxl; return true; }