From f34f258cafca5a5b8256f1863a2a24d43ba104c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 20 Dec 2016 16:10:13 +0100 Subject: [PATCH] [apps/statistics] Add a bin width variable in data model Change-Id: Ie64230acdcb618e8c01f99da03f06801ab9c4152 --- apps/statistics/data.cpp | 9 +++++++-- apps/statistics/data.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/statistics/data.cpp b/apps/statistics/data.cpp index db1c5667b..c1bc2140f 100644 --- a/apps/statistics/data.cpp +++ b/apps/statistics/data.cpp @@ -4,7 +4,8 @@ namespace Statistics { Data::Data() : - m_numberOfPairs(0) + m_numberOfPairs(0), + m_binWidth(1.0f) { } @@ -12,6 +13,10 @@ int Data::numberOfPairs() const { return m_numberOfPairs; } +float Data::binWidth() { + return m_binWidth; +} + float Data::valueAtIndex(int index) { return m_values[index]; } @@ -77,7 +82,7 @@ float Data::xMax() { if (valueMax - valueMin > k_maxRangeValue) { valueMax = valueMin + 10.0f; } - return valueMax; + return valueMax + binWidth(); } float Data::yMin() { diff --git a/apps/statistics/data.h b/apps/statistics/data.h index 61b6bdc40..1bb607028 100644 --- a/apps/statistics/data.h +++ b/apps/statistics/data.h @@ -11,6 +11,7 @@ public: // Delete the implicit copy constructor: the object is heavy Data(const Data&) = delete; int numberOfPairs() const; + float binWidth(); float valueAtIndex(int index); int sizeAtIndex(int index); void setValueAtIndex(float value, int index); @@ -30,6 +31,7 @@ private: int m_sizes[k_maxNumberOfPairs]; float m_values[k_maxNumberOfPairs]; int m_numberOfPairs; + float m_binWidth; }; }