Merge changes I630dd13e,I744cb8e8

* changes:
  [apps/regression] Adapt display mode to preferences
  [apps/statisctics] Adjust to display mode to preferences
This commit is contained in:
Émilie Feral
2017-02-13 11:10:23 +01:00
committed by Gerrit
5 changed files with 23 additions and 13 deletions

View File

@@ -1,5 +1,6 @@
#include "calculation_controller.h"
#include "../constant.h"
#include "../apps_container.h"
#include <poincare.h>
#include <assert.h>
@@ -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;
}

View File

@@ -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);
}

View File

@@ -1,4 +1,5 @@
#include "box_controller.h"
#include "../apps_container.h"
#include <math.h>
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);
}

View File

@@ -1,5 +1,6 @@
#include "calculation_controller.h"
#include "../constant.h"
#include "../apps_container.h"
#include <poincare.h>
#include <assert.h>
@@ -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);
}
}

View File

@@ -1,4 +1,5 @@
#include "histogram_controller.h"
#include "../apps_container.h"
#include <assert.h>
#include <math.h>
#include <float.h>
@@ -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);
}