From dd4d6c49367f4db61aaad103f1726e976319c941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 31 Jan 2017 16:34:27 +0100 Subject: [PATCH 1/2] [apps/statisctics] Adjust to display mode to preferences Change-Id: I744cb8e88fd2c5d14bf4c288037762b8f3a8fa8c --- apps/statistics/box_controller.cpp | 4 +++- apps/statistics/calculation_controller.cpp | 4 +++- apps/statistics/histogram_controller.cpp | 10 ++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/statistics/box_controller.cpp b/apps/statistics/box_controller.cpp index 20975b333..fa43a54ab 100644 --- a/apps/statistics/box_controller.cpp +++ b/apps/statistics/box_controller.cpp @@ -1,4 +1,5 @@ #include "box_controller.h" +#include "../apps_container.h" #include namespace Statistics { @@ -68,7 +69,8 @@ void BoxController::reloadBannerView() { CalculPointer calculationMethods[5] = {&Store::minValue, &Store::firstQuartile, &Store::median, &Store::thirdQuartile, &Store::maxValue}; float calculation = (m_store->*calculationMethods[(int)m_view.selectedQuantile()])(); - Float(calculation).convertFloatToText(buffer, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + AppsContainer * container = (AppsContainer *)app()->container(); + Float(calculation).convertFloatToText(buffer, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode()); m_boxBannerView.setLegendAtIndex(buffer, 1); } diff --git a/apps/statistics/calculation_controller.cpp b/apps/statistics/calculation_controller.cpp index a6ce8305f..d3a2a9ff3 100644 --- a/apps/statistics/calculation_controller.cpp +++ b/apps/statistics/calculation_controller.cpp @@ -1,5 +1,6 @@ #include "calculation_controller.h" #include "../constant.h" +#include "../apps_container.h" #include #include @@ -87,7 +88,8 @@ void CalculationController::willDisplayCellAtLocation(TableViewCell * cell, int float calculation = (m_store->*calculationMethods[j])(); EvenOddBufferTextCell * myCell = (EvenOddBufferTextCell *)cell; char buffer[Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; - Float(calculation).convertFloatToText(buffer, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + AppsContainer * container = (AppsContainer *)app()->container(); + Float(calculation).convertFloatToText(buffer, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode()); myCell->setText(buffer); } } diff --git a/apps/statistics/histogram_controller.cpp b/apps/statistics/histogram_controller.cpp index d1b2c6dc2..26cb43ffd 100644 --- a/apps/statistics/histogram_controller.cpp +++ b/apps/statistics/histogram_controller.cpp @@ -1,4 +1,5 @@ #include "histogram_controller.h" +#include "../apps_container.h" #include #include #include @@ -123,15 +124,16 @@ Responder * HistogramController::tabController() const { } void HistogramController::reloadBannerView() { + AppsContainer * container = (AppsContainer *)app()->container(); char buffer[k_maxNumberOfCharacters+ Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)*2]; const char * legend = "Interval ["; int legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); float lowerBound = m_store->startOfBarAtIndex(m_selectedBarIndex); - int lowerBoundNumberOfChar = Float(lowerBound).convertFloatToText(buffer+legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + int lowerBoundNumberOfChar = Float(lowerBound).convertFloatToText(buffer+legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode()); buffer[legendLength+lowerBoundNumberOfChar] = ';'; float upperBound = m_store->endOfBarAtIndex(m_selectedBarIndex); - int upperBoundNumberOfChar = Float(upperBound).convertFloatToText(buffer+legendLength+lowerBoundNumberOfChar+1, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + int upperBoundNumberOfChar = Float(upperBound).convertFloatToText(buffer+legendLength+lowerBoundNumberOfChar+1, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode()); buffer[legendLength+lowerBoundNumberOfChar+upperBoundNumberOfChar+1] = '['; buffer[legendLength+lowerBoundNumberOfChar+upperBoundNumberOfChar+2] = 0; m_bannerView.setLegendAtIndex(buffer, 0); @@ -140,14 +142,14 @@ void HistogramController::reloadBannerView() { legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); float size = m_store->heightOfBarAtIndex(m_selectedBarIndex); - Float(size).convertFloatToText(buffer+legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + Float(size).convertFloatToText(buffer+legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode()); m_bannerView.setLegendAtIndex(buffer, 1); legend = "Frequence: "; legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); float frequency = size/m_store->sumOfColumn(1); - Float(frequency).convertFloatToText(buffer+legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + Float(frequency).convertFloatToText(buffer+legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode()); m_bannerView.setLegendAtIndex(buffer, 2); } From 98eb48a4e91b8f6d30a0b40b8fa4904c1f3b9a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 31 Jan 2017 16:38:53 +0100 Subject: [PATCH 2/2] [apps/regression] Adapt display mode to preferences Change-Id: I630dd13e494747ca686cbd449643f4f6ccb4e9c2 --- apps/regression/calculation_controller.cpp | 8 +++++--- apps/regression/graph_controller.cpp | 10 ++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/regression/calculation_controller.cpp b/apps/regression/calculation_controller.cpp index 19c48b5d3..044caf082 100644 --- a/apps/regression/calculation_controller.cpp +++ b/apps/regression/calculation_controller.cpp @@ -1,5 +1,6 @@ #include "calculation_controller.h" #include "../constant.h" +#include "../apps_container.h" #include #include @@ -124,6 +125,7 @@ void CalculationController::willDisplayCellAtLocation(TableViewCell * cell, int myCell->setText(titles[j-1]); return; } + AppsContainer * container = (AppsContainer *)app()->container(); if (i == 1 && j > 0 && j < 6) { ArgCalculPointer calculationMethods[(k_totalNumberOfRows-1)/2] = {&Store::meanOfColumn, &Store::sumOfColumn, &Store::squaredValueSumOfColumn, &Store::standardDeviationOfColumn, &Store::varianceOfColumn}; @@ -131,9 +133,9 @@ void CalculationController::willDisplayCellAtLocation(TableViewCell * cell, int float calculation2 = (m_store->*calculationMethods[j-1])(1); EvenOddDoubleBufferTextCell * myCell = (EvenOddDoubleBufferTextCell *)cell; char buffer[Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; - Float(calculation1).convertFloatToText(buffer, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + Float(calculation1).convertFloatToText(buffer, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode()); myCell->setFirstText(buffer); - Float(calculation2).convertFloatToText(buffer, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + Float(calculation2).convertFloatToText(buffer, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode()); myCell->setSecondText(buffer); return; } @@ -143,7 +145,7 @@ void CalculationController::willDisplayCellAtLocation(TableViewCell * cell, int float calculation = (m_store->*calculationMethods[j-6])(); EvenOddBufferTextCell * myCell = (EvenOddBufferTextCell *)cell; char buffer[Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; - Float(calculation).convertFloatToText(buffer, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + Float(calculation).convertFloatToText(buffer, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode()); myCell->setText(buffer); return; } diff --git a/apps/regression/graph_controller.cpp b/apps/regression/graph_controller.cpp index bd033a5f7..709a229d8 100644 --- a/apps/regression/graph_controller.cpp +++ b/apps/regression/graph_controller.cpp @@ -1,4 +1,5 @@ #include "graph_controller.h" +#include "../apps_container.h" namespace Regression { @@ -53,20 +54,21 @@ bool GraphController::handleEnter() { } void GraphController::reloadBannerView() { + AppsContainer * container = (AppsContainer *)app()->container(); m_bannerView.setLegendAtIndex((char *)"y = ax+b", 0); char buffer[k_maxNumberOfCharacters + Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; const char * legend = "a = "; float slope = m_store->slope(); int legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); - Float(slope).convertFloatToText(buffer+legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + Float(slope).convertFloatToText(buffer+legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode()); m_bannerView.setLegendAtIndex(buffer, 1); legend = "b = "; float yIntercept = m_store->yIntercept(); legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); - Float(yIntercept).convertFloatToText(buffer+legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + Float(yIntercept).convertFloatToText(buffer+legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode()); m_bannerView.setLegendAtIndex(buffer, 2); legend = "x = "; @@ -79,7 +81,7 @@ void GraphController::reloadBannerView() { } legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); - Float(x).convertFloatToText(buffer+legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + Float(x).convertFloatToText(buffer+legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode()); m_bannerView.setLegendAtIndex(buffer, 3); legend = "y = "; @@ -91,7 +93,7 @@ void GraphController::reloadBannerView() { } legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); - Float(y).convertFloatToText(buffer+legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + Float(y).convertFloatToText(buffer+legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode()); m_bannerView.setLegendAtIndex(buffer, 4); }