Merge changes Ic5b222a4,If3eb5588,I7754b4a5,I646e605c,I47eeefb5

* changes:
  [apps/graph] Fix bug: select the right column title when hiding and displaying derivative column in value page
  [escher] In container, avoir useless switchApp
  [poincare] Change name DisplayMode -> FloatDisplayMode
  [apps/shared] Avoid container casting when possible
  [apps/shared] Correct bug in checksum
This commit is contained in:
Émilie Feral
2017-02-20 09:35:17 +01:00
committed by Gerrit
75 changed files with 204 additions and 190 deletions

View File

@@ -82,8 +82,7 @@ bool EditExpressionController::textFieldDidReceiveEvent(::TextField * textField,
bool EditExpressionController::textFieldDidFinishEditing(::TextField * textField, const char * text) {
App * calculationApp = (App *)app();
AppsContainer * appsContainer = (AppsContainer *)calculationApp->container();
m_calculationStore->push(textBody(), calculationApp->localContext(), appsContainer->preferences());
m_calculationStore->push(textBody(), calculationApp->localContext(), calculationApp->container()->preferences());
m_historyController->reload();
m_contentView.mainView()->scrollToCell(0, m_historyController->numberOfRows()-1);
m_contentView.textField()->setText("");

View File

@@ -71,8 +71,7 @@ bool HistoryController::handleEvent(Ion::Events::Event event) {
}
m_selectableTableView.deselectTable();
App * calculationApp = (App *)app();
AppsContainer * appsContainer = (AppsContainer *)calculationApp->container();
m_calculationStore->push(text, calculationApp->localContext(), appsContainer->preferences());
m_calculationStore->push(text, calculationApp->localContext(), calculationApp->container()->preferences());
reload();
m_selectableTableView.scrollToCell(0, numberOfRows()-1);
app()->setFirstResponder(editController);

View File

@@ -28,8 +28,7 @@ float GoToParameterController::parameterAtIndex(int index) {
void GoToParameterController::setParameterAtIndex(int parameterIndex, float f) {
assert(parameterIndex == 0);
App * graphApp = (Graph::App *)app();
AppsContainer * container = (AppsContainer *)graphApp->container();
float y = m_function->evaluateAtAbscissa(f, graphApp->localContext(), container->preferences()->angleUnit());
float y = m_function->evaluateAtAbscissa(f, graphApp->localContext(), graphApp->container()->preferences()->angleUnit());
m_graphRange->centerAxisAround(CurveViewRange::Axis::X, f);
m_graphRange->centerAxisAround(CurveViewRange::Axis::Y, y);
m_cursor->moveTo(f, y);

View File

@@ -44,8 +44,7 @@ void GraphController::didBecomeFirstResponder() {
if (m_view.context() == nullptr) {
App * graphApp = (Graph::App *)app();
m_view.setContext(graphApp->localContext());
AppsContainer * container = (AppsContainer *)graphApp->container();
m_view.setPreferences(container->preferences());
m_view.setPreferences(graphApp->container()->preferences());
}
InteractiveCurveViewController::didBecomeFirstResponder();
}
@@ -55,7 +54,6 @@ bool GraphController::didChangeRange(InteractiveCurveViewRange * interactiveCurv
return false;
}
App * graphApp = (Graph::App *)app();
AppsContainer * myContainer = (AppsContainer *)graphApp->container();
if (m_functionStore->numberOfActiveFunctions() <= 0) {
return false;
}
@@ -69,7 +67,7 @@ bool GraphController::didChangeRange(InteractiveCurveViewRange * interactiveCurv
float y = 0.0f;
for (int i = 0; i <= Ion::Display::Width; i++) {
float x = xMin + i*step;
y = f->evaluateAtAbscissa(x, graphApp->localContext(), myContainer->preferences()->angleUnit());
y = f->evaluateAtAbscissa(x, graphApp->localContext(), graphApp->container()->preferences()->angleUnit());
if (!isnan(y) && !isinf(y)) {
min = min < y ? min : y;
max = max > y ? max : y;
@@ -113,13 +111,12 @@ bool GraphController::handleEnter() {
}
void GraphController::reloadBannerView() {
App * myApp = (App *)app();
AppsContainer * myContainer = (AppsContainer *)myApp->container();
App * graphApp = (App *)app();
char buffer[k_maxNumberOfCharacters+Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
const char * legend = "x = ";
int legendLength = strlen(legend);
strlcpy(buffer, legend, legendLength+1);
Complex::convertFloatToText(m_cursor.x(), buffer+ legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, myContainer->preferences()->displayMode());
Complex::convertFloatToText(m_cursor.x(), buffer+ legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, graphApp->container()->preferences()->displayMode());
m_bannerView.setLegendAtIndex(buffer, 0);
legend = "00(x) = ";
@@ -127,15 +124,15 @@ void GraphController::reloadBannerView() {
strlcpy(buffer, legend, legendLength+1);
Function * f = m_functionStore->activeFunctionAtIndex(m_indexFunctionSelectedByCursor);
buffer[1] = f->name()[0];
Complex::convertFloatToText(m_cursor.y(), buffer+legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, myContainer->preferences()->displayMode());
Complex::convertFloatToText(m_cursor.y(), buffer+legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, graphApp->container()->preferences()->displayMode());
m_bannerView.setLegendAtIndex(buffer+1, 1);
if (m_bannerView.displayDerivative()) {
buffer[0] = f->name()[0];
buffer[1] = '\'';
App * graphApp = (Graph::App *)app();
float y = f->approximateDerivative(m_cursor.x(), graphApp->localContext(), myContainer->preferences()->angleUnit());
Complex::convertFloatToText(y, buffer + legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, myContainer->preferences()->displayMode());
float y = f->approximateDerivative(m_cursor.x(), graphApp->localContext(), graphApp->container()->preferences()->angleUnit());
Complex::convertFloatToText(y, buffer + legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, graphApp->container()->preferences()->displayMode());
m_bannerView.setLegendAtIndex(buffer, 2);
}
}
@@ -150,12 +147,11 @@ void GraphController::initCursorParameters() {
float x = (m_graphRange.xMin()+m_graphRange.xMax())/2.0f;
m_indexFunctionSelectedByCursor = 0;
App * graphApp = (Graph::App *)app();
AppsContainer * myContainer = (AppsContainer *)graphApp->container();
int functionIndex = 0;
float y = 0;
do {
Function * firstFunction = m_functionStore->activeFunctionAtIndex(functionIndex++);
y = firstFunction->evaluateAtAbscissa(x, graphApp->localContext(), myContainer->preferences()->angleUnit());
y = firstFunction->evaluateAtAbscissa(x, graphApp->localContext(), graphApp->container()->preferences()->angleUnit());
} while (isnan(y) && functionIndex < m_functionStore->numberOfActiveFunctions());
m_cursor.moveTo(x, y);
m_graphRange.panToMakePointVisible(x, y, k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio);
@@ -167,8 +163,7 @@ bool GraphController::moveCursorHorizontally(int direction) {
xCursorPosition - m_graphRange.xGridUnit()/k_numberOfCursorStepsInGradUnit;
Function * f = m_functionStore->activeFunctionAtIndex(m_indexFunctionSelectedByCursor);
App * graphApp = (Graph::App *)app();
AppsContainer * myContainer = (AppsContainer *)graphApp->container();
float y = f->evaluateAtAbscissa(x, graphApp->localContext(), myContainer->preferences()->angleUnit());
float y = f->evaluateAtAbscissa(x, graphApp->localContext(), graphApp->container()->preferences()->angleUnit());
m_cursor.moveTo(x, y);
m_graphRange.panToMakePointVisible(x, y, k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio);
return true;
@@ -177,13 +172,12 @@ bool GraphController::moveCursorHorizontally(int direction) {
bool GraphController::moveCursorVertically(int direction) {
Function * actualFunction = m_functionStore->activeFunctionAtIndex(m_indexFunctionSelectedByCursor);
App * graphApp = (Graph::App *)app();
AppsContainer * myContainer = (AppsContainer *)graphApp->container();
float y = actualFunction->evaluateAtAbscissa(m_cursor.x(), graphApp->localContext(), myContainer->preferences()->angleUnit());
float y = actualFunction->evaluateAtAbscissa(m_cursor.x(), graphApp->localContext(), graphApp->container()->preferences()->angleUnit());
Function * nextFunction = actualFunction;
float nextY = direction > 0 ? FLT_MAX : -FLT_MAX;
for (int i = 0; i < m_functionStore->numberOfActiveFunctions(); i++) {
Function * f = m_functionStore->activeFunctionAtIndex(i);
float newY = f->evaluateAtAbscissa(m_cursor.x(), graphApp->localContext(), myContainer->preferences()->angleUnit());
float newY = f->evaluateAtAbscissa(m_cursor.x(), graphApp->localContext(), graphApp->container()->preferences()->angleUnit());
bool isNextFunction = direction > 0 ? (newY > y && newY < nextY) : (newY < y && newY > nextY);
if (isNextFunction) {
m_indexFunctionSelectedByCursor = i;

View File

@@ -1,4 +1,5 @@
#include "initialisation_parameter_controller.h"
#include "../app.h"
#include "../../apps_container.h"
#include <assert.h>
#include <math.h>
@@ -31,8 +32,8 @@ void InitialisationParameterController::didBecomeFirstResponder() {
bool InitialisationParameterController::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::OK) {
if (m_selectableTableView.selectedRow() == 0) {
AppsContainer * container = (AppsContainer *)app()->container();
m_graphRange->setTrigonometric(container->preferences()->angleUnit());
App * graphApp = (App *)app();
m_graphRange->setTrigonometric(graphApp->container()->preferences()->angleUnit());
} else {
RangeMethodPointer rangeMethods[k_totalNumberOfCells-1] = {&InteractiveCurveViewRange::roundAbscissa,
&InteractiveCurveViewRange::normalize, &InteractiveCurveViewRange::setDefault};

View File

@@ -1,16 +1,18 @@
#include "derivative_parameter_controller.h"
#include "values_controller.h"
#include <assert.h>
namespace Graph {
DerivativeParameterController::DerivativeParameterController(Responder * parentResponder) :
ViewController(parentResponder),
DerivativeParameterController::DerivativeParameterController(ValuesController * valuesController) :
ViewController(valuesController),
m_pageTitle{"Colonne f'(x)"},
m_hideColumn(MenuListCell((char*)"Masquer la colonne de la derivee")),
m_copyColumn(ChevronMenuListCell((char*)"Copier la colonne dans une liste")),
m_selectableTableView(SelectableTableView(this, this, Metric::TopMargin, Metric::RightMargin,
Metric::BottomMargin, Metric::LeftMargin)),
m_function(nullptr)
m_function(nullptr),
m_valuesController(valuesController)
{
}
@@ -42,7 +44,9 @@ bool DerivativeParameterController::handleEvent(Ion::Events::Event event) {
switch (m_selectableTableView.selectedRow()) {
case 0:
{
m_valuesController->selectCellAtLocation(0, -1);
m_function->setDisplayDerivative(false);
m_valuesController->selectCellAtLocation(m_valuesController->activeColumn()-1, m_valuesController->activeRow());
StackViewController * stack = (StackViewController *)(parentResponder());
stack->pop();
return true;

View File

@@ -5,9 +5,12 @@
#include "../function.h"
namespace Graph {
class ValuesController;
class DerivativeParameterController : public ViewController, public SimpleListViewDataSource {
public:
DerivativeParameterController(Responder * parentResponder);
DerivativeParameterController(ValuesController * valuesController);
View * view() override;
const char * title() const override;
@@ -27,6 +30,7 @@ private:
ChevronMenuListCell m_copyColumn;
SelectableTableView m_selectableTableView;
Function * m_function;
ValuesController * m_valuesController;
};
}

View File

@@ -47,6 +47,7 @@ bool FunctionParameterController::handleEvent(Ion::Events::Event event) {
{
m_function->setDisplayDerivative(!m_function->displayDerivative());
if (m_function->displayDerivative()) {
m_valuesController->selectCellAtLocation(0, -1);
m_valuesController->selectCellAtLocation(m_valuesController->activeColumn()+1, m_valuesController->activeRow());
}
m_selectableTableView.reloadData();

View File

@@ -28,7 +28,7 @@ ValuesController::ValuesController(Responder * parentResponder, FunctionStore *
StackViewController * stack = ((StackViewController *)valuesController->stackController());
stack->push(valuesController->intervalParameterController());
}, this), KDText::FontSize::Small)),
m_displayModeVersion(Expression::DisplayMode::Auto)
m_displayModeVersion(Expression::FloatDisplayMode::Auto)
{
m_interval.setStart(0);
m_interval.setEnd(10);
@@ -40,11 +40,11 @@ const char * ValuesController::title() const {
}
View * ValuesController::view() {
AppsContainer * myContainer = (AppsContainer *)app()->container();
Expression::DisplayMode displayMode = myContainer->preferences()->displayMode();
if (displayMode != m_displayModeVersion) {
App * graphApp = (App *)app();
Expression::FloatDisplayMode FloatDisplayMode = graphApp->container()->preferences()->displayMode();
if (FloatDisplayMode != m_displayModeVersion) {
m_selectableTableView.reloadData();
m_displayModeVersion = displayMode;
m_displayModeVersion = FloatDisplayMode;
}
return EditableCellTableViewController::view();
}
@@ -136,8 +136,8 @@ int ValuesController::numberOfColumns() {
}
void ValuesController::willDisplayCellAtLocation(TableViewCell * cell, int i, int j) {
AppsContainer * myContainer = (AppsContainer *)app()->container();
willDisplayCellAtLocationWithDisplayMode(cell, i, j, myContainer->preferences()->displayMode());
App * graphApp = (App *)app();
willDisplayCellAtLocationWithDisplayMode(cell, i, j, graphApp->container()->preferences()->displayMode());
if (cellAtLocationIsEditable(i, j)) {
return;
}
@@ -179,12 +179,11 @@ void ValuesController::willDisplayCellAtLocation(TableViewCell * cell, int i, in
// The cell is a value cell
EvenOddBufferTextCell * myValueCell = (EvenOddBufferTextCell *)cell;
Function * function = functionAtColumn(i);
App * graphApp = (Graph::App *)app();
float x = m_interval.element(j-1);
if (isDerivativeColumn(i)) {
Complex::convertFloatToText(function->approximateDerivative(x, graphApp->localContext(), myContainer->preferences()->angleUnit()), buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, myContainer->preferences()->displayMode());
Complex::convertFloatToText(function->approximateDerivative(x, graphApp->localContext(), graphApp->container()->preferences()->angleUnit()), buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, graphApp->container()->preferences()->displayMode());
} else {
Complex::convertFloatToText(function->evaluateAtAbscissa(x, graphApp->localContext(), myContainer->preferences()->angleUnit()), buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, myContainer->preferences()->displayMode());
Complex::convertFloatToText(function->evaluateAtAbscissa(x, graphApp->localContext(), graphApp->container()->preferences()->angleUnit()), buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, graphApp->container()->preferences()->displayMode());
}
myValueCell->setText(buffer);
}

View File

@@ -72,7 +72,7 @@ private:
FunctionParameterController m_functionParameterController;
DerivativeParameterController m_derivativeParameterController;
Button m_setIntervalButton;
Poincare::Expression::DisplayMode m_displayModeVersion;
Poincare::Expression::FloatDisplayMode m_displayModeVersion;
};
}

View File

@@ -4,7 +4,7 @@ using namespace Poincare;
Preferences::Preferences() :
m_angleUnit(Expression::AngleUnit::Degree),
m_displayMode(Expression::DisplayMode::Auto),
m_displayMode(Expression::FloatDisplayMode::Auto),
m_numberType(NumberType::Reel),
m_complexFormat(ComplexFormat::Algebric),
m_language(Language::French)
@@ -21,13 +21,13 @@ void Preferences::setAngleUnit(Expression::AngleUnit angleUnit) {
}
}
Expression::DisplayMode Preferences::displayMode() const {
Expression::FloatDisplayMode Preferences::displayMode() const {
return m_displayMode;
}
void Preferences::setDisplayMode(Expression::DisplayMode displayMode) {
if (displayMode != m_displayMode) {
m_displayMode = displayMode;
void Preferences::setDisplayMode(Expression::FloatDisplayMode FloatDisplayMode) {
if (FloatDisplayMode != m_displayMode) {
m_displayMode = FloatDisplayMode;
}
}

View File

@@ -20,8 +20,8 @@ public:
Preferences();
Poincare::Expression::AngleUnit angleUnit() const;
void setAngleUnit(Poincare::Expression::AngleUnit angleUnit);
Poincare::Expression::DisplayMode displayMode() const;
void setDisplayMode(Poincare::Expression::DisplayMode displayMode);
Poincare::Expression::FloatDisplayMode displayMode() const;
void setDisplayMode(Poincare::Expression::FloatDisplayMode FloatDisplayMode);
NumberType numberType() const;
void setNumberType(NumberType numberType);
ComplexFormat complexFormat() const;
@@ -30,7 +30,7 @@ public:
void setLanguage(Language language);
private:
Poincare::Expression::AngleUnit m_angleUnit;
Poincare::Expression::DisplayMode m_displayMode;
Poincare::Expression::FloatDisplayMode m_displayMode;
NumberType m_numberType;
ComplexFormat m_complexFormat;
Language m_language;

View File

@@ -69,7 +69,7 @@ View * CalculationController::ContentView::subviewAtIndex(int index) {
void CalculationController::ContentView::willDisplayEditableCellAtIndex(int index) {
char buffer[Complex::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits)];
Complex::convertFloatToText(m_calculation->parameterAtIndex(index), buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits), Constant::ShortNumberOfSignificantDigits, Expression::DisplayMode::Auto);
Complex::convertFloatToText(m_calculation->parameterAtIndex(index), buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits), Constant::ShortNumberOfSignificantDigits, Expression::FloatDisplayMode::Auto);
m_calculationCell[index].setText(buffer);
}
@@ -204,9 +204,9 @@ bool CalculationController::textFieldDidReceiveEvent(TextField * textField, Ion:
}
bool CalculationController::textFieldDidFinishEditing(TextField * textField, const char * text) {
AppsContainer * appsContainer = (AppsContainer *)app()->container();
Context * globalContext = appsContainer->globalContext();
float floatBody = Expression::parse(text)->approximate(*globalContext, appsContainer->preferences()->angleUnit());
App * probaApp = (App *)app();
Context * globalContext = probaApp->container()->globalContext();
float floatBody = Expression::parse(text)->approximate(*globalContext, probaApp->container()->preferences()->angleUnit());
m_calculation->setParameterAtIndex(floatBody, m_highlightedSubviewIndex-1);
for (int k = 0; k < m_calculation->numberOfParameters(); k++) {
m_contentView.willDisplayEditableCellAtIndex(k);
@@ -243,7 +243,7 @@ void CalculationController::updateTitle() {
strlcpy(m_titleBuffer+currentChar, " = ", 4);
currentChar += 3;
char buffer[Complex::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits)];
Complex::convertFloatToText(m_law->parameterValueAtIndex(index), buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits), Constant::ShortNumberOfSignificantDigits, Expression::DisplayMode::Auto);
Complex::convertFloatToText(m_law->parameterValueAtIndex(index), buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits), Constant::ShortNumberOfSignificantDigits, Expression::FloatDisplayMode::Auto);
strlcpy(m_titleBuffer+currentChar, buffer, strlen(buffer)+1);
currentChar += strlen(buffer);
m_titleBuffer[currentChar++] = ' ';

View File

@@ -127,7 +127,7 @@ void CalculationController::willDisplayCellAtLocation(TableViewCell * cell, int
myCell->setText(titles[j-1]);
return;
}
AppsContainer * container = (AppsContainer *)app()->container();
App * regApp = (App *)app();
if (i == 1 && j > 0 && j < 6) {
ArgCalculPointer calculationMethods[(k_totalNumberOfRows-1)/2] = {&Store::meanOfColumn, &Store::sumOfColumn,
&Store::squaredValueSumOfColumn, &Store::standardDeviationOfColumn, &Store::varianceOfColumn};
@@ -135,9 +135,9 @@ void CalculationController::willDisplayCellAtLocation(TableViewCell * cell, int
float calculation2 = (m_store->*calculationMethods[j-1])(1);
EvenOddDoubleBufferTextCell * myCell = (EvenOddDoubleBufferTextCell *)cell;
char buffer[Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
Complex::convertFloatToText(calculation1, buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode());
Complex::convertFloatToText(calculation1, buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, regApp->container()->preferences()->displayMode());
myCell->setFirstText(buffer);
Complex::convertFloatToText(calculation2, buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode());
Complex::convertFloatToText(calculation2, buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, regApp->container()->preferences()->displayMode());
myCell->setSecondText(buffer);
return;
}
@@ -147,7 +147,7 @@ void CalculationController::willDisplayCellAtLocation(TableViewCell * cell, int
float calculation = (m_store->*calculationMethods[j-6])();
EvenOddBufferTextCell * myCell = (EvenOddBufferTextCell *)cell;
char buffer[Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
Complex::convertFloatToText(calculation, buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode());
Complex::convertFloatToText(calculation, buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, regApp->container()->preferences()->displayMode());
myCell->setText(buffer);
return;
}

View File

@@ -57,7 +57,7 @@ bool GraphController::handleEnter() {
}
void GraphController::reloadBannerView() {
AppsContainer * container = (AppsContainer *)app()->container();
AppsContainer * container = ((App *)app())->container();
m_bannerView.setLegendAtIndex((char *)"y = ax+b", 0);
char buffer[k_maxNumberOfCharacters + Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
const char * legend = "a = ";

View File

@@ -4,12 +4,12 @@
namespace Settings {
const SettingsNode angleChildren[2] = {SettingsNode("Degre"), SettingsNode("Radian")};
const SettingsNode displayModeChildren[2] = {SettingsNode("Auto"), SettingsNode("Scientifique")};
const SettingsNode FloatDisplayModeChildren[2] = {SettingsNode("Auto"), SettingsNode("Scientifique")};
const SettingsNode numberTypeChildren[2] = {SettingsNode("Reel"), SettingsNode("Complexe")};
const SettingsNode complexFormatChildren[2] = {SettingsNode("Algebrique"), SettingsNode("Polaire")};
const SettingsNode languageChildren[3] = {SettingsNode("Anglais"), SettingsNode("Francais"), SettingsNode("Espagnol")};
const SettingsNode menu[5] = {SettingsNode("Unite d'angles", angleChildren, 2), SettingsNode("Format resultat", displayModeChildren, 2),
const SettingsNode menu[5] = {SettingsNode("Unite d'angles", angleChildren, 2), SettingsNode("Format resultat", FloatDisplayModeChildren, 2),
SettingsNode("Reel ou complexe", numberTypeChildren, 2), SettingsNode("Format complexe", complexFormatChildren, 2),
SettingsNode("Langue", languageChildren, 3)};
const SettingsNode model = SettingsNode("Parametres", menu, 5);

View File

@@ -90,7 +90,7 @@ void SubController::setPreferenceAtIndexWithValueIndex(int preferenceIndex, int
m_preferences->setAngleUnit((Expression::AngleUnit)valueIndex);
break;
case 1:
m_preferences->setDisplayMode((Expression::DisplayMode)valueIndex);
m_preferences->setDisplayMode((Expression::FloatDisplayMode)valueIndex);
break;
case 2:
m_preferences->setNumberType((Preferences::NumberType)valueIndex);

View File

@@ -87,7 +87,7 @@ void CurveView::computeLabels(Axis axis) {
for (int index = 0; index < numberOfLabels(axis); index++) {
Complex::convertFloatToText(2.0f*step*(ceilf(min(axis)/(2.0f*step)))+index*2.0f*step, buffer,
Complex::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits),
Constant::ShortNumberOfSignificantDigits, Expression::DisplayMode::Auto);
Constant::ShortNumberOfSignificantDigits, Expression::FloatDisplayMode::Auto);
//TODO: check for size of label?
strlcpy(label(axis, index), buffer, strlen(buffer)+1);
}

View File

@@ -25,7 +25,7 @@ bool EditableCellTableViewController::textFieldDidReceiveEvent(TextField * textF
}
bool EditableCellTableViewController::textFieldDidFinishEditing(TextField * textField, const char * text) {
AppsContainer * appsContainer = (AppsContainer *)app()->container();
AppsContainer * appsContainer = ((TextFieldDelegateApp *)app())->container();
Context * globalContext = appsContainer->globalContext();
float floatBody = Expression::parse(text)->approximate(*globalContext, appsContainer->preferences()->angleUnit());
setDataAtLocation(floatBody, m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow());
@@ -67,7 +67,7 @@ int EditableCellTableViewController::indexFromCumulatedHeight(KDCoordinate offse
return (offsetY-1) / k_cellHeight;
}
void EditableCellTableViewController::willDisplayCellAtLocationWithDisplayMode(TableViewCell * cell, int i, int j, Expression::DisplayMode displayMode) {
void EditableCellTableViewController::willDisplayCellAtLocationWithDisplayMode(TableViewCell * cell, int i, int j, Expression::FloatDisplayMode FloatDisplayMode) {
EvenOddCell * myCell = (EvenOddCell *)cell;
myCell->setEven(j%2 == 0);
// The cell is editable
@@ -85,7 +85,7 @@ void EditableCellTableViewController::willDisplayCellAtLocationWithDisplayMode(T
}
}
if (!myEditableValueCell->isEditing()) {
Complex::convertFloatToText(dataAtLocation(i, j), buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, displayMode);
Complex::convertFloatToText(dataAtLocation(i, j), buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, FloatDisplayMode);
myEditableValueCell->setText(buffer);
}
return;

View File

@@ -17,7 +17,7 @@ public:
void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY) override;
int numberOfRows() override;
void willDisplayCellAtLocationWithDisplayMode(TableViewCell * cell, int i, int j, Poincare::Expression::DisplayMode displayMode);
void willDisplayCellAtLocationWithDisplayMode(TableViewCell * cell, int i, int j, Poincare::Expression::FloatDisplayMode FloatDisplayMode);
KDCoordinate rowHeight(int j) override;
KDCoordinate cumulatedHeightFromIndex(int j) override;
int indexFromCumulatedHeight(KDCoordinate offsetY) override;

View File

@@ -59,7 +59,7 @@ float FloatPairStore::sumOfColumn(int i) {
}
uint32_t FloatPairStore::storeChecksum() {
size_t dataLengthInBytes = m_numberOfPairs*2*sizeof(float);
size_t dataLengthInBytes = k_maxNumberOfPairs*2*sizeof(float);
assert((dataLengthInBytes & 0x3) == 0); // Assert that dataLengthInBytes is a multiple of 4
return Ion::crc32((uint32_t *)m_data, dataLengthInBytes>>2);
}

View File

@@ -31,12 +31,12 @@ int FloatParameterController::activeCell() {
void FloatParameterController::willDisplayCellForIndex(TableViewCell * cell, int index) {
EditableTextMenuListCell * myCell = (EditableTextMenuListCell *) cell;
char buffer[Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
Complex::convertFloatToText(parameterAtIndex(index), buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Expression::DisplayMode::Auto);
Complex::convertFloatToText(parameterAtIndex(index), buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Expression::FloatDisplayMode::Auto);
myCell->setAccessoryText(buffer);
}
bool FloatParameterController::textFieldDidFinishEditing(TextField * textField, const char * text) {
AppsContainer * appsContainer = (AppsContainer *)app()->container();
AppsContainer * appsContainer = ((TextFieldDelegateApp *)app())->container();
Context * globalContext = appsContainer->globalContext();
float floatBody = Expression::parse(text)->approximate(*globalContext, appsContainer->preferences()->angleUnit());
setParameterAtIndex(m_selectableTableView.selectedRow(), floatBody);

View File

@@ -1,4 +1,5 @@
#include "interactive_curve_view_controller.h"
#include "text_field_delegate_app.h"
#include "../apps_container.h"
#include <assert.h>
#include <math.h>
@@ -29,7 +30,7 @@ InteractiveCurveViewController::InteractiveCurveViewController(Responder * paren
StackViewController * stack = graphController->stackController();
stack->push(graphController->initialisationParameterController());
}, this), KDText::FontSize::Small),
m_displayModeVersion(Expression::DisplayMode::Auto)
m_displayModeVersion(Expression::FloatDisplayMode::Auto)
{
}
@@ -38,12 +39,12 @@ const char * InteractiveCurveViewController::title() const {
}
View * InteractiveCurveViewController::view() {
AppsContainer * myContainer = (AppsContainer *)app()->container();
Expression::DisplayMode displayMode = myContainer->preferences()->displayMode();
if (displayMode != m_displayModeVersion) {
AppsContainer * myContainer = ((TextFieldDelegateApp *)app())->container();
Expression::FloatDisplayMode FloatDisplayMode = myContainer->preferences()->displayMode();
if (FloatDisplayMode != m_displayModeVersion) {
reloadBannerView();
curveView()->reload();
m_displayModeVersion = displayMode;
m_displayModeVersion = FloatDisplayMode;
}
return curveView();
}

View File

@@ -55,7 +55,7 @@ private:
Button m_rangeButton;
Button m_zoomButton;
Button m_defaultInitialisationButton;
Poincare::Expression::DisplayMode m_displayModeVersion;
Poincare::Expression::FloatDisplayMode m_displayModeVersion;
};
}

View File

@@ -1,4 +1,5 @@
#include "range_parameter_controller.h"
#include "text_field_delegate_app.h"
#include "../apps_container.h"
#include <assert.h>
@@ -36,7 +37,7 @@ void RangeParameterController::willDisplayCellForIndex(TableViewCell * cell, int
}
bool RangeParameterController::textFieldDidFinishEditing(TextField * textField, const char * text) {
AppsContainer * appsContainer = (AppsContainer *)app()->container();
AppsContainer * appsContainer = ((TextFieldDelegateApp *)app())->container();
Context * globalContext = appsContainer->globalContext();
float floatBody = Expression::parse(text)->approximate(*globalContext, appsContainer->preferences()->angleUnit());
setParameterAtIndex(m_selectableTableView.selectedRow(), floatBody);

View File

@@ -67,7 +67,7 @@ int StoreController::typeAtLocation(int i, int j) {
}
void StoreController::willDisplayCellAtLocation(TableViewCell * cell, int i, int j) {
willDisplayCellAtLocationWithDisplayMode(cell, i, j, Expression::DisplayMode::Auto);
willDisplayCellAtLocationWithDisplayMode(cell, i, j, Expression::FloatDisplayMode::Auto);
}
bool StoreController::handleEvent(Ion::Events::Event event) {

View File

@@ -13,8 +13,11 @@ TextFieldDelegateApp::TextFieldDelegateApp(Container * container, ViewController
}
Context * TextFieldDelegateApp::localContext() {
AppsContainer * appsContainer = (AppsContainer *)app()->container();
return appsContainer->globalContext();
return container()->globalContext();
}
AppsContainer * TextFieldDelegateApp::container() {
return (AppsContainer *)app()->container();
}
}

View File

@@ -4,12 +4,15 @@
#include <escher.h>
#include "expression_text_field_delegate.h"
class AppsContainer;
namespace Shared {
class TextFieldDelegateApp : public ::App, public ExpressionTextFieldDelegate {
public:
TextFieldDelegateApp(Container * container, ViewController * rootViewController, const char * name = nullptr, const char * upperName = nullptr, const Image * icon = nullptr);
virtual Poincare::Context * localContext() override;
AppsContainer * container();
};
}

View File

@@ -1,5 +1,6 @@
#include "box_controller.h"
#include "../apps_container.h"
#include "app.h"
#include <math.h>
using namespace Poincare;
@@ -12,7 +13,7 @@ BoxController::BoxController(Responder * parentResponder, HeaderViewController *
m_boxBannerView(BoxBannerView()),
m_view(BoxView(store, &m_boxBannerView)),
m_store(store),
m_displayModeVersion(Expression::DisplayMode::Auto)
m_displayModeVersion(Expression::FloatDisplayMode::Auto)
{
}
@@ -21,12 +22,12 @@ const char * BoxController::title() const {
}
View * BoxController::view() {
AppsContainer * myContainer = (AppsContainer *)app()->container();
Expression::DisplayMode displayMode = myContainer->preferences()->displayMode();
if (displayMode != m_displayModeVersion) {
AppsContainer * myContainer = ((App *)app())->container();
Expression::FloatDisplayMode FloatDisplayMode = myContainer->preferences()->displayMode();
if (FloatDisplayMode != m_displayModeVersion) {
reloadBannerView();
m_view.reload();
m_displayModeVersion = displayMode;
m_displayModeVersion = FloatDisplayMode;
}
return &m_view;
}
@@ -79,7 +80,7 @@ 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()])();
AppsContainer * container = (AppsContainer *)app()->container();
AppsContainer * container = ((App *)app())->container();
Complex::convertFloatToText(calculation, buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode());
m_boxBannerView.setLegendAtIndex(buffer, 1);
}

View File

@@ -24,7 +24,7 @@ private:
BoxBannerView m_boxBannerView;
BoxView m_view;
Store * m_store;
Poincare::Expression::DisplayMode m_displayModeVersion;
Poincare::Expression::FloatDisplayMode m_displayModeVersion;
};
}

View File

@@ -1,6 +1,7 @@
#include "calculation_controller.h"
#include "../constant.h"
#include "../apps_container.h"
#include "app.h"
#include <poincare.h>
#include <assert.h>
@@ -90,7 +91,7 @@ void CalculationController::willDisplayCellAtLocation(TableViewCell * cell, int
float calculation = (m_store->*calculationMethods[j])();
EvenOddBufferTextCell * myCell = (EvenOddBufferTextCell *)cell;
char buffer[Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
AppsContainer * container = (AppsContainer *)app()->container();
AppsContainer * container = ((App *)app())->container();
Complex::convertFloatToText(calculation, buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, container->preferences()->displayMode());
myCell->setText(buffer);
}

View File

@@ -1,5 +1,6 @@
#include "histogram_controller.h"
#include "../apps_container.h"
#include "app.h"
#include <assert.h>
#include <math.h>
#include <float.h>
@@ -22,7 +23,7 @@ HistogramController::HistogramController(Responder * parentResponder, HeaderView
m_store(store),
m_cursor(CurveViewCursor()),
m_histogramParameterController(nullptr, store),
m_displayModeVersion(Expression::DisplayMode::Auto)
m_displayModeVersion(Expression::FloatDisplayMode::Auto)
{
}
@@ -31,12 +32,12 @@ const char * HistogramController::title() const {
}
View * HistogramController::view() {
AppsContainer * myContainer = (AppsContainer *)app()->container();
Expression::DisplayMode displayMode = myContainer->preferences()->displayMode();
if (displayMode != m_displayModeVersion) {
AppsContainer * container = ((App *)app())->container();
Expression::FloatDisplayMode FloatDisplayMode = container->preferences()->displayMode();
if (FloatDisplayMode != m_displayModeVersion) {
reloadBannerView();
m_view.reload();
m_displayModeVersion = displayMode;
m_displayModeVersion = FloatDisplayMode;
}
return &m_view;
}
@@ -135,7 +136,7 @@ Responder * HistogramController::tabController() const {
}
void HistogramController::reloadBannerView() {
AppsContainer * container = (AppsContainer *)app()->container();
AppsContainer * container = ((App *)app())->container();
char buffer[k_maxNumberOfCharacters+ Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)*2];
const char * legend = "Interval [";
int legendLength = strlen(legend);

View File

@@ -47,7 +47,7 @@ private:
uint32_t m_rangeVersion;
int m_selectedBarIndex;
HistogramParameterController m_histogramParameterController;
Poincare::Expression::DisplayMode m_displayModeVersion;
Poincare::Expression::FloatDisplayMode m_displayModeVersion;
};
}

View File

@@ -49,7 +49,7 @@ void TitleBarView::layoutSubviews() {
void TitleBarView::setPreferences(Preferences * preferences) {
char buffer[13];
int numberOfChar = 0;
if (preferences->displayMode() == Expression::DisplayMode::Scientific) {
if (preferences->displayMode() == Expression::FloatDisplayMode::Scientific) {
strlcpy(buffer, "sci/", 5);
numberOfChar += 4;
}

View File

@@ -10,6 +10,9 @@ Container::Container() :
}
void Container::switchTo(App * app) {
if (m_activeApp == app) {
return;
}
if (m_activeApp) {
m_activeApp->willBecomeInactive();
}

View File

@@ -13,7 +13,7 @@ public:
Type type() const override;
Expression * cloneWithDifferentOperands(Expression ** newOperands,
int numberOfOperands, bool cloneOperands = true) const override;
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
};
}

View File

@@ -9,7 +9,7 @@ class Addition : public BinaryOperation {
using BinaryOperation::BinaryOperation;
public:
Type type() const override;
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
float approximate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
Expression * cloneWithDifferentOperands(Expression** newOperands,
int numnerOfOperands, bool cloneOperands = true) const override;

View File

@@ -12,7 +12,7 @@ public:
const char * fractionalPart, int fractionalPartLength,
const char * exponent, int exponentLength, bool exponentNegative);
void setNumberOfSignificantDigits(int numberOfDigits);
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
float approximate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
Expression * evaluate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
Type type() const override;
@@ -34,7 +34,7 @@ public:
* is truncated at the end of the buffer.
* ConvertFloat to Text return the number of characters that have been written
* in buffer (excluding the last \O character) */
static int convertFloatToText(float f, char * buffer, int bufferSize, int numberOfSignificantDigits, DisplayMode mode = DisplayMode::Scientific);
static int convertFloatToText(float f, char * buffer, int bufferSize, int numberOfSignificantDigits, FloatDisplayMode mode = FloatDisplayMode::Scientific);
constexpr static int bufferSizeForFloatsWithPrecision(int numberOfSignificantDigits) {
// The wors case is -1.234E-38
return numberOfSignificantDigits + 7;
@@ -50,8 +50,8 @@ private:
constexpr static int k_maxComplexBufferLength = 13+13+1;
/* convertComplexToText and convertFloatToTextPrivate return the string length
* of the buffer (does not count the 0 last char)*/
int convertComplexToText(char * buffer, int bufferSize, DisplayMode displayMode) const;
static int convertFloatToTextPrivate(float f, char * buffer, int numberOfSignificantDigits, DisplayMode mode);
int convertComplexToText(char * buffer, int bufferSize, FloatDisplayMode FloatDisplayMode) const;
static int convertFloatToTextPrivate(float f, char * buffer, int numberOfSignificantDigits, FloatDisplayMode mode);
/* This function prints the int i in the buffer with a '.' at the position
* specified by the decimalMarkerPosition. It starts printing at the end of the
* buffer and print from right to left. The integer given should be of the right

View File

@@ -39,18 +39,18 @@ class Expression {
Symbol,
Tangent,
};
enum class DisplayMode {
Auto = 0,
Scientific = 1
};
enum class AngleUnit {
Degree = 0,
Radian = 1
};
enum class FloatDisplayMode {
Auto = 0,
Scientific = 1
};
static Expression * parse(char const * string);
virtual ~Expression();
virtual ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const = 0; // Returned object must be deleted
virtual ExpressionLayout * createLayout(Expression::FloatDisplayMode FloatDisplayMode = Expression::FloatDisplayMode::Auto) const = 0; // Returned object must be deleted
virtual const Expression * operand(int i) const = 0;
virtual int numberOfOperands() const = 0;
virtual Expression * clone() const = 0;

View File

@@ -8,7 +8,7 @@ namespace Poincare {
class Fraction : public BinaryOperation {
using BinaryOperation::BinaryOperation;
public:
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
float approximate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
Type type() const override;
Expression * cloneWithDifferentOperands(Expression** newOperands,

View File

@@ -15,7 +15,7 @@ public:
~Function();
void setArgument(Expression ** args, int numberOfArguments, bool clone = true);
void setArgument(ListData * listData, bool clone = true);
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
const Expression * operand(int i) const override;
int numberOfOperands() const override;
Expression * clone() const override;

View File

@@ -33,7 +33,7 @@ class Integer : public LeafExpression {
bool valueEquals(const Expression * e) const override;
Expression * clone() const override;
virtual ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
virtual ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
float approximate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
Expression * evaluate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
private:

View File

@@ -13,7 +13,7 @@ public:
Type type() const override;
Expression * cloneWithDifferentOperands(Expression ** newOperands,
int numberOfOperands, bool cloneOperands = true) const override;
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
private:
struct DetailedResult
{

View File

@@ -12,7 +12,7 @@ public:
Type type() const override;
Expression * cloneWithDifferentOperands(Expression ** newOperands,
int numberOfOperands, bool cloneOperands = true) const override;
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
};
}

View File

@@ -15,7 +15,7 @@ class Matrix : public Expression {
const Expression * operand(int i) const override;
int numberOfOperands() const override;
Expression * clone() const override;
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
float approximate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
Expression * evaluate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
Type type() const override;

View File

@@ -9,7 +9,7 @@ class Multiplication : public BinaryOperation {
using BinaryOperation::BinaryOperation;
public:
Type type() const override;
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
float approximate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
Expression * cloneWithDifferentOperands(Expression** newOperands,
int numnerOfOperands, bool cloneOperands = true) const override;

View File

@@ -12,7 +12,7 @@ public:
Type type() const override;
Expression * cloneWithDifferentOperands(Expression ** newOperands,
int numberOfOperands, bool cloneOperands = true) const override;
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
Expression * evaluate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
};

View File

@@ -14,7 +14,7 @@ class Opposite : public Expression {
int numberOfOperands() const override;
Expression * clone() const override;
Expression * evaluate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
float approximate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
Type type() const override;
Expression * cloneWithDifferentOperands(Expression** newOperands,

View File

@@ -12,7 +12,7 @@ class Parenthesis : public Expression {
const Expression * operand(int i) const override;
int numberOfOperands() const override;
Expression * clone() const override;
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
float approximate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
Expression * evaluate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
Type type() const override;

View File

@@ -8,7 +8,7 @@ namespace Poincare {
class Power : public BinaryOperation {
using BinaryOperation::BinaryOperation;
public:
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
float approximate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
Type type() const override;
Expression * cloneWithDifferentOperands(Expression** newOperands,

View File

@@ -12,7 +12,7 @@ public:
Type type() const override;
Expression * cloneWithDifferentOperands(Expression ** newOperands,
int numberOfOperands, bool cloneOperands = true) const override;
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
Expression * evaluate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
};

View File

@@ -12,7 +12,7 @@ public:
Type type() const override;
Expression * cloneWithDifferentOperands(Expression ** newOperands,
int numberOfOperands, bool cloneOperands = true) const override;
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
Expression * evaluate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
};

View File

@@ -8,7 +8,7 @@ namespace Poincare {
class Subtraction : public BinaryOperation {
using BinaryOperation::BinaryOperation;
public:
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
float approximate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
Type type() const override;
Expression * cloneWithDifferentOperands(Expression** newOperands,

View File

@@ -12,7 +12,7 @@ public:
Type type() const override;
Expression * cloneWithDifferentOperands(Expression ** newOperands,
int numberOfOperands, bool cloneOperands = true) const override;
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
Expression * evaluate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
};

View File

@@ -11,7 +11,7 @@ public:
Ans = '^'
};
Symbol(char name);
ExpressionLayout * createLayout(DisplayMode displayMode = DisplayMode::Auto) const override;
ExpressionLayout * createLayout(FloatDisplayMode FloatDisplayMode = FloatDisplayMode::Auto) const override;
float approximate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
Expression * evaluate(Context& context, AngleUnit angleUnit = AngleUnit::Radian) const override;
Type type() const override;

View File

@@ -53,8 +53,8 @@ Expression * AbsoluteValue::evaluate(Context& context, AngleUnit angleUnit) cons
return result;
}
ExpressionLayout * AbsoluteValue::createLayout(DisplayMode displayMode) const {
return new AbsoluteValueLayout(m_args[0]->createLayout(displayMode));
ExpressionLayout * AbsoluteValue::createLayout(FloatDisplayMode FloatDisplayMode) const {
return new AbsoluteValueLayout(m_args[0]->createLayout(FloatDisplayMode));
}
}

View File

@@ -13,11 +13,11 @@ Expression::Type Addition::type() const {
return Type::Addition;
}
ExpressionLayout * Addition::createLayout(DisplayMode displayMode) const {
ExpressionLayout * Addition::createLayout(FloatDisplayMode FloatDisplayMode) const {
ExpressionLayout** children_layouts = (ExpressionLayout **)malloc(3*sizeof(ExpressionLayout *));
children_layouts[0] = m_operands[0]->createLayout(displayMode);
children_layouts[0] = m_operands[0]->createLayout(FloatDisplayMode);
children_layouts[1] = new StringLayout("+", 1);
children_layouts[2] = m_operands[1]->type() == Type::Opposite ? new ParenthesisLayout(m_operands[1]->createLayout(displayMode)) : m_operands[1]->createLayout(displayMode);
children_layouts[2] = m_operands[1]->type() == Type::Opposite ? new ParenthesisLayout(m_operands[1]->createLayout(FloatDisplayMode)) : m_operands[1]->createLayout(FloatDisplayMode);
return new HorizontalLayout(children_layouts, 3);
}

View File

@@ -78,14 +78,14 @@ Expression::Type Complex::type() const {
return Type::Complex;
}
ExpressionLayout * Complex::createLayout(DisplayMode displayMode) const {
ExpressionLayout * Complex::createLayout(FloatDisplayMode displayMode) const {
char buffer[k_maxComplexBufferLength];
int numberOfChars = convertComplexToText(buffer, k_maxComplexBufferLength, displayMode);
return new StringLayout(buffer, numberOfChars);
}
int Complex::writeTextInBuffer(char * buffer, int bufferSize) {
return convertComplexToText(buffer, bufferSize, DisplayMode::Auto);
return convertComplexToText(buffer, bufferSize, FloatDisplayMode::Auto);
}
float Complex::a() {
@@ -116,7 +116,7 @@ float Complex::absoluteValue() {
}
int Complex::convertFloatToText(float f, char * buffer, int bufferSize,
int numberOfSignificantDigits, DisplayMode mode) {
int numberOfSignificantDigits, FloatDisplayMode mode) {
char tempBuffer[k_maxFloatBufferLength];
int requiredLength = convertFloatToTextPrivate(f, tempBuffer, numberOfSignificantDigits, mode);
/* if the required buffer size overflows the buffer size, we first force the
@@ -124,18 +124,18 @@ int Complex::convertFloatToText(float f, char * buffer, int bufferSize,
* fit the buffer size. If the buffer size is still to small, we only write
* the beginning of the float and truncate it (which can result in a non sense
* text) */
if (mode == DisplayMode::Auto && requiredLength >= bufferSize) {
requiredLength = convertFloatToTextPrivate(f, tempBuffer, numberOfSignificantDigits, DisplayMode::Scientific);
if (mode == FloatDisplayMode::Auto && requiredLength >= bufferSize) {
requiredLength = convertFloatToTextPrivate(f, tempBuffer, numberOfSignificantDigits, FloatDisplayMode::Scientific);
}
if (requiredLength >= bufferSize) {
requiredLength = convertFloatToTextPrivate(f, tempBuffer, numberOfSignificantDigits - requiredLength + bufferSize - 1, DisplayMode::Scientific);
requiredLength = convertFloatToTextPrivate(f, tempBuffer, numberOfSignificantDigits - requiredLength + bufferSize - 1, FloatDisplayMode::Scientific);
}
requiredLength = requiredLength < bufferSize ? requiredLength : bufferSize;
strlcpy(buffer, tempBuffer, bufferSize);
return requiredLength;
}
int Complex::convertComplexToText(char * buffer, int bufferSize, DisplayMode displayMode) const {
int Complex::convertComplexToText(char * buffer, int bufferSize, FloatDisplayMode displayMode) const {
int numberOfChars = 0;
if (m_a != 0.0f || m_b == 0.0f) {
numberOfChars = convertFloatToText(m_a, buffer, bufferSize, m_numberOfSignificantDigits, displayMode);
@@ -160,7 +160,7 @@ int Complex::convertComplexToText(char * buffer, int bufferSize, DisplayMode dis
}
int Complex::convertFloatToTextPrivate(float f, char * buffer, int numberOfSignificantDigits, DisplayMode mode) {
int Complex::convertFloatToTextPrivate(float f, char * buffer, int numberOfSignificantDigits, FloatDisplayMode mode) {
if (isinf(f)) {
buffer[0] = f > 0 ? '+' : '-';
buffer[1] = 'I';
@@ -187,12 +187,12 @@ int Complex::convertFloatToTextPrivate(float f, char * buffer, int numberOfSigni
exponentInBase10--;
}
DisplayMode displayMode = mode;
if ((exponentInBase10 >= numberOfSignificantDigits || exponentInBase10 <= -numberOfSignificantDigits) && mode == DisplayMode::Auto) {
displayMode = DisplayMode::Scientific;
FloatDisplayMode displayMode = mode;
if ((exponentInBase10 >= numberOfSignificantDigits || exponentInBase10 <= -numberOfSignificantDigits) && mode == FloatDisplayMode::Auto) {
displayMode = FloatDisplayMode::Scientific;
}
int decimalMarkerPosition = exponentInBase10 < 0 || displayMode == DisplayMode::Scientific ?
int decimalMarkerPosition = exponentInBase10 < 0 || displayMode == FloatDisplayMode::Scientific ?
1 : exponentInBase10+1;
// Number of char available for the mantissa
@@ -205,11 +205,11 @@ int Complex::convertFloatToTextPrivate(float f, char * buffer, int numberOfSigni
* threshold during computation. */
int numberMaximalOfCharsInInteger = log10f(powf(2, 31));
assert(availableCharsForMantissaWithoutSign - 1 < numberMaximalOfCharsInInteger);
int numberOfDigitBeforeDecimal = exponentInBase10 >= 0 || displayMode == DisplayMode::Scientific ?
int numberOfDigitBeforeDecimal = exponentInBase10 >= 0 || displayMode == FloatDisplayMode::Scientific ?
exponentInBase10 + 1 : 1;
int mantissa = roundf(f * powf(10, availableCharsForMantissaWithoutSign - 1 - numberOfDigitBeforeDecimal));
// Correct the number of digits in mantissa after rounding
int mantissaExponentInBase10 = exponentInBase10 > 0 || displayMode == DisplayMode::Scientific ? availableCharsForMantissaWithoutSign - 1 : availableCharsForMantissaWithoutSign + exponentInBase10;
int mantissaExponentInBase10 = exponentInBase10 > 0 || displayMode == FloatDisplayMode::Scientific ? availableCharsForMantissaWithoutSign - 1 : availableCharsForMantissaWithoutSign + exponentInBase10;
if ((int)(mantissa * powf(10, - mantissaExponentInBase10)) > 0) {
mantissa = mantissa/10;
exponentInBase10++;
@@ -225,9 +225,9 @@ int Complex::convertFloatToTextPrivate(float f, char * buffer, int numberOfSigni
int dividend = fabsf((float)mantissa);
int quotien = dividend/10;
int digit = dividend - quotien*10;
int minimumNumberOfCharsInMantissa = displayMode == DisplayMode::Scientific ? 3 : 1;
int minimumNumberOfCharsInMantissa = displayMode == FloatDisplayMode::Scientific ? 3 : 1;
while (digit == 0 && availableCharsForMantissaWithSign > minimumNumberOfCharsInMantissa &&
(availableCharsForMantissaWithoutSign > exponentInBase10+2 || displayMode == DisplayMode::Scientific)) {
(availableCharsForMantissaWithoutSign > exponentInBase10+2 || displayMode == FloatDisplayMode::Scientific)) {
mantissa = mantissa/10;
availableCharsForMantissaWithoutSign--;
availableCharsForMantissaWithSign--;
@@ -237,13 +237,13 @@ int Complex::convertFloatToTextPrivate(float f, char * buffer, int numberOfSigni
}
// Suppress the decimal marker if no fractional part
if (displayMode == DisplayMode::Auto && availableCharsForMantissaWithoutSign == exponentInBase10+2) {
if (displayMode == FloatDisplayMode::Auto && availableCharsForMantissaWithoutSign == exponentInBase10+2) {
availableCharsForMantissaWithSign--;
}
// Print mantissa
printBase10IntegerWithDecimalMarker(buffer, availableCharsForMantissaWithSign, mantissa, decimalMarkerPosition);
if (displayMode == DisplayMode::Auto) {
if (displayMode == FloatDisplayMode::Auto) {
buffer[availableCharsForMantissaWithSign] = 0;
return availableCharsForMantissaWithSign;
}

View File

@@ -15,8 +15,8 @@ Expression * Fraction::cloneWithDifferentOperands(Expression** newOperands,
return new Fraction(newOperands, cloneOperands);
}
ExpressionLayout * Fraction::createLayout(DisplayMode displayMode) const {
return new FractionLayout(m_operands[0]->createLayout(displayMode), m_operands[1]->createLayout(displayMode));
ExpressionLayout * Fraction::createLayout(FloatDisplayMode FloatDisplayMode) const {
return new FractionLayout(m_operands[0]->createLayout(FloatDisplayMode), m_operands[1]->createLayout(FloatDisplayMode));
}
float Fraction::approximate(Context& context, AngleUnit angleUnit) const {

View File

@@ -67,13 +67,13 @@ Expression * Function::clone() const {
return this->cloneWithDifferentOperands(m_args, m_numberOfArguments, true);
}
ExpressionLayout * Function::createLayout(DisplayMode displayMode) const {
ExpressionLayout * Function::createLayout(FloatDisplayMode FloatDisplayMode) const {
ExpressionLayout ** grandChildrenLayouts = (ExpressionLayout **)malloc((2*m_numberOfArguments-1)*sizeof(ExpressionLayout *));
int layoutIndex = 0;
grandChildrenLayouts[layoutIndex++] = m_args[0]->createLayout(displayMode);
grandChildrenLayouts[layoutIndex++] = m_args[0]->createLayout(FloatDisplayMode);
for (int i = 1; i < m_numberOfArguments; i++) {
grandChildrenLayouts[layoutIndex++] = new StringLayout(",", 1);
grandChildrenLayouts[layoutIndex++] = m_args[i]->createLayout(displayMode);
grandChildrenLayouts[layoutIndex++] = m_args[i]->createLayout(FloatDisplayMode);
}
ExpressionLayout * argumentLayouts = new HorizontalLayout(grandChildrenLayouts, 2*m_numberOfArguments-1);
ExpressionLayout ** childrenLayouts = (ExpressionLayout **)malloc(2*sizeof(ExpressionLayout *));

View File

@@ -318,7 +318,7 @@ Expression::Type Integer::type() const {
return Type::Integer;
}
ExpressionLayout * Integer::createLayout(DisplayMode displayMode) const {
ExpressionLayout * Integer::createLayout(FloatDisplayMode FloatDisplayMode) const {
char buffer[255];
Integer base = Integer(10);

View File

@@ -46,11 +46,11 @@ float Integral::approximate(Context& context, AngleUnit angleUnit) const {
#endif
}
ExpressionLayout * Integral::createLayout(DisplayMode displayMode) const {
ExpressionLayout * Integral::createLayout(FloatDisplayMode FloatDisplayMode) const {
ExpressionLayout ** childrenLayouts = (ExpressionLayout **)malloc(2*sizeof(ExpressionLayout *));
childrenLayouts[0] = m_args[0]->createLayout(displayMode);
childrenLayouts[0] = m_args[0]->createLayout(FloatDisplayMode);
childrenLayouts[1] = new StringLayout("dx", 2);
return new IntegralLayout(m_args[1]->createLayout(displayMode), m_args[2]->createLayout(displayMode), new HorizontalLayout(childrenLayouts, 2));
return new IntegralLayout(m_args[1]->createLayout(FloatDisplayMode), m_args[2]->createLayout(FloatDisplayMode), new HorizontalLayout(childrenLayouts, 2));
}
float Integral::functionValueAtAbscissa(float x, VariableContext xContext, AngleUnit angleUnit) const {

View File

@@ -36,13 +36,13 @@ float Logarithm::approximate(Context& context, AngleUnit angleUnit) const {
return log10f(m_args[1]->approximate(context, angleUnit))/log10f(m_args[0]->approximate(context, angleUnit));
}
ExpressionLayout * Logarithm::createLayout(DisplayMode displayMode) const {
ExpressionLayout * Logarithm::createLayout(FloatDisplayMode FloatDisplayMode) const {
if (m_numberOfArguments == 1) {
return Function::createLayout(displayMode);
return Function::createLayout(FloatDisplayMode);
}
ExpressionLayout ** childrenLayouts = (ExpressionLayout **)malloc(2*sizeof(ExpressionLayout *));
childrenLayouts[0] = new BaselineRelativeLayout(new StringLayout(m_name, strlen(m_name)), m_args[0]->createLayout(displayMode), BaselineRelativeLayout::Type::Subscript);
childrenLayouts[1] = new ParenthesisLayout(m_args[1]->createLayout(displayMode));
childrenLayouts[0] = new BaselineRelativeLayout(new StringLayout(m_name, strlen(m_name)), m_args[0]->createLayout(FloatDisplayMode), BaselineRelativeLayout::Type::Subscript);
childrenLayouts[1] = new ParenthesisLayout(m_args[1]->createLayout(FloatDisplayMode));
return new HorizontalLayout(childrenLayouts, 2);
}

View File

@@ -43,10 +43,10 @@ Expression * Matrix::clone() const {
return this->cloneWithDifferentOperands(m_matrixData->operands(), numberOfOperands(), true);
}
ExpressionLayout * Matrix::createLayout(DisplayMode displayMode) const {
ExpressionLayout * Matrix::createLayout(FloatDisplayMode FloatDisplayMode) const {
ExpressionLayout ** childrenLayouts = (ExpressionLayout **)malloc(numberOfOperands()*sizeof(ExpressionLayout *));
for (int i = 0; i < numberOfOperands(); i++) {
childrenLayouts[i] = operand(i)->createLayout(displayMode);
childrenLayouts[i] = operand(i)->createLayout(FloatDisplayMode);
}
return new MatrixLayout(childrenLayouts, numberOfRows(), numberOfColumns());
}

View File

@@ -15,11 +15,11 @@ Expression::Type Multiplication::type() const {
return Expression::Type::Multiplication;
}
ExpressionLayout * Multiplication::createLayout(DisplayMode displayMode) const {
ExpressionLayout * Multiplication::createLayout(FloatDisplayMode FloatDisplayMode) const {
ExpressionLayout** children_layouts = (ExpressionLayout **)malloc(3*sizeof(ExpressionLayout *));
children_layouts[0] = m_operands[0]->createLayout(displayMode);
children_layouts[0] = m_operands[0]->createLayout(FloatDisplayMode);
children_layouts[1] = new StringLayout("*", 1);
children_layouts[2] = m_operands[1]->type() == Type::Opposite ? new ParenthesisLayout(m_operands[1]->createLayout(displayMode)) : m_operands[1]->createLayout(displayMode);
children_layouts[2] = m_operands[1]->type() == Type::Opposite ? new ParenthesisLayout(m_operands[1]->createLayout(FloatDisplayMode)) : m_operands[1]->createLayout(FloatDisplayMode);
return new HorizontalLayout(children_layouts, 3);
}

View File

@@ -33,8 +33,8 @@ float NthRoot::approximate(Context& context, AngleUnit angleUnit) const {
return powf(m_args[0]->approximate(context, angleUnit), 1.0f/m_args[1]->approximate(context, angleUnit));
}
ExpressionLayout * NthRoot::createLayout(DisplayMode displayMode) const {
return new NthRootLayout(m_args[0]->createLayout(displayMode), m_args[1]->createLayout(displayMode));
ExpressionLayout * NthRoot::createLayout(FloatDisplayMode FloatDisplayMode) const {
return new NthRootLayout(m_args[0]->createLayout(FloatDisplayMode), m_args[1]->createLayout(FloatDisplayMode));
}
Expression * NthRoot::evaluate(Context& context, AngleUnit angleUnit) const {

View File

@@ -52,11 +52,11 @@ Expression * Opposite::evaluate(Context& context, AngleUnit angleUnit) const {
return result;
}
ExpressionLayout * Opposite::createLayout(DisplayMode displayMode) const {
ExpressionLayout * Opposite::createLayout(FloatDisplayMode FloatDisplayMode) const {
ExpressionLayout** children_layouts = (ExpressionLayout **)malloc(2*sizeof(ExpressionLayout *));
char string[2] = {'-', '\0'};
children_layouts[0] = new StringLayout(string, 1);
children_layouts[1] = m_operand->type() == Type::Opposite ? new ParenthesisLayout(m_operand->createLayout(displayMode)) : m_operand->createLayout(displayMode);
children_layouts[1] = m_operand->type() == Type::Opposite ? new ParenthesisLayout(m_operand->createLayout(FloatDisplayMode)) : m_operand->createLayout(FloatDisplayMode);
return new HorizontalLayout(children_layouts, 2);
}

View File

@@ -33,8 +33,8 @@ Expression * Parenthesis::clone() const {
return this->cloneWithDifferentOperands((Expression**) &m_operand, 1, true);
}
ExpressionLayout * Parenthesis::createLayout(DisplayMode displayMode) const {
return new ParenthesisLayout(m_operand->createLayout(displayMode));
ExpressionLayout * Parenthesis::createLayout(FloatDisplayMode FloatDisplayMode) const {
return new ParenthesisLayout(m_operand->createLayout(FloatDisplayMode));
}
float Parenthesis::approximate(Context& context, AngleUnit angleUnit) const {

View File

@@ -22,13 +22,13 @@ Expression * Power::cloneWithDifferentOperands(Expression** newOperands,
return new Power(newOperands, cloneOperands);
}
ExpressionLayout * Power::createLayout(DisplayMode displayMode) const {
ExpressionLayout * Power::createLayout(FloatDisplayMode FloatDisplayMode) const {
Expression * indiceOperand = m_operands[1];
// Delete eventual parentheses of the indice in the pretty print
if (m_operands[1]->type() == Type::Parenthesis) {
indiceOperand = (Expression *)m_operands[1]->operand(0);
}
return new BaselineRelativeLayout(m_operands[0]->createLayout(displayMode),indiceOperand->createLayout(displayMode), BaselineRelativeLayout::Type::Superscript);
return new BaselineRelativeLayout(m_operands[0]->createLayout(FloatDisplayMode),indiceOperand->createLayout(FloatDisplayMode), BaselineRelativeLayout::Type::Superscript);
}
Expression * Power::evaluateOnComplex(Complex * c, Complex * d, Context& context, AngleUnit angleUnit) const {

View File

@@ -46,11 +46,11 @@ float Product::approximate(Context& context, AngleUnit angleUnit) const {
return result;
}
ExpressionLayout * Product::createLayout(DisplayMode displayMode) const {
ExpressionLayout * Product::createLayout(FloatDisplayMode FloatDisplayMode) const {
ExpressionLayout ** childrenLayouts = (ExpressionLayout **)malloc(2*sizeof(ExpressionLayout *));
childrenLayouts[0] = new StringLayout("n=", 2);
childrenLayouts[1] = m_args[1]->createLayout(displayMode);
return new ProductLayout(new HorizontalLayout(childrenLayouts, 2), m_args[2]->createLayout(displayMode), m_args[0]->createLayout(displayMode));
childrenLayouts[1] = m_args[1]->createLayout(FloatDisplayMode);
return new ProductLayout(new HorizontalLayout(childrenLayouts, 2), m_args[2]->createLayout(FloatDisplayMode), m_args[0]->createLayout(FloatDisplayMode));
}
Expression * Product::evaluate(Context& context, AngleUnit angleUnit) const {

View File

@@ -31,8 +31,8 @@ float SquareRoot::approximate(Context& context, AngleUnit angleUnit) const {
return powf(m_args[0]->approximate(context, angleUnit), 1.0f/2.0f);
}
ExpressionLayout * SquareRoot::createLayout(DisplayMode displayMode) const {
return new NthRootLayout(m_args[0]->createLayout(displayMode),nullptr);
ExpressionLayout * SquareRoot::createLayout(FloatDisplayMode FloatDisplayMode) const {
return new NthRootLayout(m_args[0]->createLayout(FloatDisplayMode),nullptr);
}
Expression * SquareRoot::evaluate(Context& context, AngleUnit angleUnit) const {

View File

@@ -26,12 +26,12 @@ Expression::Type Subtraction::type() const {
return Expression::Type::Subtraction;
}
ExpressionLayout * Subtraction::createLayout(DisplayMode displayMode) const {
ExpressionLayout * Subtraction::createLayout(FloatDisplayMode FloatDisplayMode) const {
ExpressionLayout** children_layouts = (ExpressionLayout **)malloc(3*sizeof(ExpressionLayout *));
children_layouts[0] = m_operands[0]->createLayout(displayMode);
children_layouts[0] = m_operands[0]->createLayout(FloatDisplayMode);
char string[2] = {'-', '\0'};
children_layouts[1] = new StringLayout(string, 1);
children_layouts[2] = m_operands[1]->type() == Type::Opposite ? new ParenthesisLayout(m_operands[1]->createLayout(displayMode)) : m_operands[1]->createLayout(displayMode);
children_layouts[2] = m_operands[1]->type() == Type::Opposite ? new ParenthesisLayout(m_operands[1]->createLayout(FloatDisplayMode)) : m_operands[1]->createLayout(FloatDisplayMode);
return new HorizontalLayout(children_layouts, 3);
}

View File

@@ -46,11 +46,11 @@ float Sum::approximate(Context& context, AngleUnit angleUnit) const {
return result;
}
ExpressionLayout * Sum::createLayout(DisplayMode displayMode) const {
ExpressionLayout * Sum::createLayout(FloatDisplayMode FloatDisplayMode) const {
ExpressionLayout ** childrenLayouts = (ExpressionLayout **)malloc(2*sizeof(ExpressionLayout *));
childrenLayouts[0] = new StringLayout("n=", 2);
childrenLayouts[1] = m_args[1]->createLayout(displayMode);
return new SumLayout(new HorizontalLayout(childrenLayouts, 2), m_args[2]->createLayout(displayMode), m_args[0]->createLayout(displayMode));
childrenLayouts[1] = m_args[1]->createLayout(FloatDisplayMode);
return new SumLayout(new HorizontalLayout(childrenLayouts, 2), m_args[2]->createLayout(FloatDisplayMode), m_args[0]->createLayout(FloatDisplayMode));
}
Expression * Sum::evaluate(Context& context, AngleUnit angleUnit) const {

View File

@@ -33,7 +33,7 @@ const char Symbol::name() const {
return m_name;
}
ExpressionLayout * Symbol::createLayout(DisplayMode displayMode) const {
ExpressionLayout * Symbol::createLayout(FloatDisplayMode FloatDisplayMode) const {
if (m_name == SpecialSymbols::Ans) {
return new StringLayout("ans", 4);
}

View File

@@ -38,23 +38,23 @@ QUIZ_CASE(poincare_complex_to_text) {
Complex::convertFloatToText(10000000000000000000000000000.0f, buffer, 14, 7);
char result10[20] = {'1','.','0',Ion::Charset::Exponent,'2','8',0};
assert(strcmp(buffer, result10) == 0);
Complex::convertFloatToText(10000000000000000000000000000.0f, buffer, 14, 7, Expression::DisplayMode::Auto);
Complex::convertFloatToText(10000000000000000000000000000.0f, buffer, 14, 7, Expression::FloatDisplayMode::Auto);
assert(strcmp(buffer, result10) == 0);
Complex::convertFloatToText(1000000.0f, buffer, 14, 7, Expression::DisplayMode::Auto);
Complex::convertFloatToText(1000000.0f, buffer, 14, 7, Expression::FloatDisplayMode::Auto);
assert(strcmp(buffer, "1000000") == 0);
Complex::convertFloatToText(10000000.0f, buffer, 14, 7, Expression::DisplayMode::Auto);
Complex::convertFloatToText(10000000.0f, buffer, 14, 7, Expression::FloatDisplayMode::Auto);
char result11[20] = {'1','.','0',Ion::Charset::Exponent,'7',0};
assert(strcmp(buffer, result11) == 0);
Complex::convertFloatToText(0.000001f, buffer, 14, 7, Expression::DisplayMode::Auto);
Complex::convertFloatToText(0.000001f, buffer, 14, 7, Expression::FloatDisplayMode::Auto);
assert(strcmp(buffer, "0.000001") == 0);
Complex::convertFloatToText(0.0000001f, buffer, 14, 7, Expression::DisplayMode::Auto);
Complex::convertFloatToText(0.0000001f, buffer, 14, 7, Expression::FloatDisplayMode::Auto);
char result12[20] = {'1','.','0',Ion::Charset::Exponent,'-','7',0};
assert(strcmp(buffer, result12) == 0);
char buffer2[6];
Complex::convertFloatToText(123.421f, buffer2, 6, 4, Expression::DisplayMode::Auto);
Complex::convertFloatToText(123.421f, buffer2, 6, 4, Expression::FloatDisplayMode::Auto);
assert(strcmp(buffer2, "123.4") == 0);
char buffer3[6];
Complex::convertFloatToText(123.421f, buffer3, 6, 5, Expression::DisplayMode::Auto);
Complex::convertFloatToText(123.421f, buffer3, 6, 5, Expression::FloatDisplayMode::Auto);
char result13[20] = {'1','.','2',Ion::Charset::Exponent,'2',0};
assert(strcmp(buffer3, result13) == 0);