From 6b524737b40891fce6963ade6f46b445fbaa99d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 14 Feb 2017 17:57:55 +0100 Subject: [PATCH 1/3] [apps/graph] Change name: function->cartesian_function Change-Id: I138bd13fec8514144cfde7164ec9aff081454609 --- apps/graph/Makefile | 4 +- apps/graph/app.cpp | 2 +- apps/graph/app.h | 4 +- .../{function.cpp => cartesian_function.cpp} | 12 +++--- .../{function.h => cartesian_function.h} | 8 ++-- ...store.cpp => cartesian_function_store.cpp} | 39 +++++++++---------- ...ion_store.h => cartesian_function_store.h} | 20 +++++----- .../graph/curve_parameter_controller.cpp | 2 +- apps/graph/graph/curve_parameter_controller.h | 6 +-- .../graph/graph/goto_parameter_controller.cpp | 2 +- apps/graph/graph/goto_parameter_controller.h | 4 +- apps/graph/graph/graph_controller.cpp | 18 ++++----- apps/graph/graph/graph_controller.h | 6 +-- apps/graph/graph/graph_view.cpp | 6 +-- apps/graph/graph/graph_view.h | 6 +-- apps/graph/list/function_expression_cell.cpp | 5 +-- apps/graph/list/function_expression_cell.h | 8 ++-- apps/graph/list/list_controller.cpp | 6 +-- apps/graph/list/list_controller.h | 4 +- .../derivative_parameter_controller.cpp | 2 +- .../values/derivative_parameter_controller.h | 6 +-- .../values/function_parameter_controller.cpp | 2 +- .../values/function_parameter_controller.h | 6 +-- apps/graph/values/values_controller.cpp | 12 +++--- apps/graph/values/values_controller.h | 8 ++-- 25 files changed, 98 insertions(+), 100 deletions(-) rename apps/graph/{function.cpp => cartesian_function.cpp} (56%) rename apps/graph/{function.h => cartesian_function.h} (65%) rename apps/graph/{function_store.cpp => cartesian_function_store.cpp} (54%) rename apps/graph/{function_store.h => cartesian_function_store.h} (63%) diff --git a/apps/graph/Makefile b/apps/graph/Makefile index a2ebfeba0..e0791c3fa 100644 --- a/apps/graph/Makefile +++ b/apps/graph/Makefile @@ -1,7 +1,7 @@ app_objs += $(addprefix apps/graph/,\ app.o\ - function.o\ - function_store.o\ + cartesian_function.o\ + cartesian_function_store.o\ function_title_cell.o\ graph/banner_view.o\ graph/curve_parameter_controller.o\ diff --git a/apps/graph/app.cpp b/apps/graph/app.cpp index 94dd4b14f..0892f92d5 100644 --- a/apps/graph/app.cpp +++ b/apps/graph/app.cpp @@ -8,7 +8,7 @@ namespace Graph { App::App(Container * container, Context * context) : TextFieldDelegateApp(container, &m_inputViewController, "Fonctions", "FONCTIONS", ImageStore::GraphIcon), - m_functionStore(FunctionStore()), + m_functionStore(CartesianFunctionStore()), m_xContext(VariableContext('x', context)), m_listController(ListController(&m_listHeader, &m_functionStore, &m_listHeader)), m_listHeader(HeaderViewController(&m_listStackViewController, &m_listController, &m_listController)), diff --git a/apps/graph/app.h b/apps/graph/app.h index a5b54b82d..4d214d542 100644 --- a/apps/graph/app.h +++ b/apps/graph/app.h @@ -3,7 +3,7 @@ #include #include -#include "function_store.h" +#include "cartesian_function_store.h" #include "graph/graph_controller.h" #include "list/list_controller.h" #include "values/values_controller.h" @@ -17,7 +17,7 @@ public: InputViewController * inputViewController(); Poincare::Context * localContext() override; private: - FunctionStore m_functionStore; + CartesianFunctionStore m_functionStore; Poincare::VariableContext m_xContext; ListController m_listController; HeaderViewController m_listHeader; diff --git a/apps/graph/function.cpp b/apps/graph/cartesian_function.cpp similarity index 56% rename from apps/graph/function.cpp rename to apps/graph/cartesian_function.cpp index 34e766f68..67c686734 100644 --- a/apps/graph/function.cpp +++ b/apps/graph/cartesian_function.cpp @@ -1,22 +1,22 @@ -#include "function.h" +#include "cartesian_function.h" namespace Graph { -Function::Function(const char * text, KDColor color) : +CartesianFunction::CartesianFunction(const char * text, KDColor color) : Shared::Function(text, color), m_displayDerivative(false) { } -bool Function::displayDerivative() { +bool CartesianFunction::displayDerivative() { return m_displayDerivative; } -void Function::setDisplayDerivative(bool display) { +void CartesianFunction::setDisplayDerivative(bool display) { m_displayDerivative = display; } -float Function::approximateDerivative(float x, Poincare::Context * context) const { +float CartesianFunction::approximateDerivative(float x, Poincare::Context * context) const { Poincare::Complex abscissa = Poincare::Complex::Float(x); Poincare::Expression * args[2] = {m_expression, &abscissa}; Poincare::Derivative derivative = Poincare::Derivative(); @@ -24,7 +24,7 @@ float Function::approximateDerivative(float x, Poincare::Context * context) cons return derivative.approximate(*context); } -char Function::symbol() const { +char CartesianFunction::symbol() const { return 'x'; } diff --git a/apps/graph/function.h b/apps/graph/cartesian_function.h similarity index 65% rename from apps/graph/function.h rename to apps/graph/cartesian_function.h index 1d8543ab9..3f84dbeb1 100644 --- a/apps/graph/function.h +++ b/apps/graph/cartesian_function.h @@ -1,15 +1,15 @@ -#ifndef GRAPH_FUNCTION_H -#define GRAPH_FUNCTION_H +#ifndef GRAPH_CARTESIAN_FUNCTION_H +#define GRAPH_CARTESIAN_FUNCTION_H #include "../shared/function.h" namespace Graph { -class Function : public Shared::Function { +class CartesianFunction : public Shared::Function { public: static constexpr const char * Parameter = "(x)"; using Shared::Function::Function; - Function(const char * text = nullptr, KDColor color = KDColorBlack); + CartesianFunction(const char * text = nullptr, KDColor color = KDColorBlack); bool displayDerivative(); void setDisplayDerivative(bool display); float approximateDerivative(float x, Poincare::Context * context) const; diff --git a/apps/graph/function_store.cpp b/apps/graph/cartesian_function_store.cpp similarity index 54% rename from apps/graph/function_store.cpp rename to apps/graph/cartesian_function_store.cpp index fa5590b5f..c616bcb42 100644 --- a/apps/graph/function_store.cpp +++ b/apps/graph/cartesian_function_store.cpp @@ -1,4 +1,4 @@ -#include "function_store.h" +#include "cartesian_function_store.h" extern "C" { #include #include @@ -7,48 +7,47 @@ extern "C" { namespace Graph { -constexpr int FunctionStore::k_numberOfDefaultColors; -constexpr KDColor FunctionStore::k_defaultColors[k_numberOfDefaultColors]; -constexpr const char * FunctionStore::k_functionNames[k_maxNumberOfFunctions]; +constexpr int CartesianFunctionStore::k_numberOfDefaultColors; +constexpr KDColor CartesianFunctionStore::k_defaultColors[k_numberOfDefaultColors]; +constexpr const char * CartesianFunctionStore::k_functionNames[k_maxNumberOfFunctions]; -FunctionStore::FunctionStore() : +CartesianFunctionStore::CartesianFunctionStore() : Shared::FunctionStore() { addEmptyFunction(); } -uint32_t FunctionStore::storeChecksum() { - size_t dataLengthInBytes = m_numberOfFunctions*sizeof(Function); +uint32_t CartesianFunctionStore::storeChecksum() { + size_t dataLengthInBytes = m_numberOfFunctions*sizeof(CartesianFunction); assert((dataLengthInBytes & 0x3) == 0); // Assert that dataLengthInBytes is a multiple of 4 return Ion::crc32((uint32_t *)m_functions, dataLengthInBytes>>2); } -Function * FunctionStore::functionAtIndex(int i) { +CartesianFunction * CartesianFunctionStore::functionAtIndex(int i) { assert(i>=0 && i namespace Graph { -class FunctionStore : public Shared::FunctionStore { +class CartesianFunctionStore : public Shared::FunctionStore { public: - FunctionStore(); + CartesianFunctionStore(); uint32_t storeChecksum() override; - Function * functionAtIndex(int i) override; - Function * activeFunctionAtIndex(int i) override; - Function * definedFunctionAtIndex(int i) override; - Function * addEmptyFunction() override; + CartesianFunction * functionAtIndex(int i) override; + CartesianFunction * activeFunctionAtIndex(int i) override; + CartesianFunction * definedFunctionAtIndex(int i) override; + CartesianFunction * addEmptyFunction() override; void removeFunction(Shared::Function * f) override; int maxNumberOfFunctions() override; static constexpr int k_maxNumberOfFunctions = 8; @@ -29,7 +29,7 @@ private: static constexpr const char * k_functionNames[k_maxNumberOfFunctions] = { "f", "g", "h", "p", "q", "r", "s", "t" }; - Function m_functions[k_maxNumberOfFunctions]; + CartesianFunction m_functions[k_maxNumberOfFunctions]; }; } diff --git a/apps/graph/graph/curve_parameter_controller.cpp b/apps/graph/graph/curve_parameter_controller.cpp index 5dbf11ef3..c6685be0d 100644 --- a/apps/graph/graph/curve_parameter_controller.cpp +++ b/apps/graph/graph/curve_parameter_controller.cpp @@ -82,7 +82,7 @@ KDCoordinate CurveParameterController::cellHeight() { return Metric::ParameterCellHeight; } -void CurveParameterController::setFunction(Function * function) { +void CurveParameterController::setFunction(CartesianFunction * function) { m_function = function; } diff --git a/apps/graph/graph/curve_parameter_controller.h b/apps/graph/graph/curve_parameter_controller.h index 454bcfdf8..dab6e3bbc 100644 --- a/apps/graph/graph/curve_parameter_controller.h +++ b/apps/graph/graph/curve_parameter_controller.h @@ -4,7 +4,7 @@ #include #include "goto_parameter_controller.h" #include "banner_view.h" -#include "../function.h" +#include "../cartesian_function.h" #include "../../shared/curve_view_cursor.h" #include "../../shared/interactive_curve_view_range.h" @@ -23,10 +23,10 @@ public: TableViewCell * reusableCell(int index) override; int reusableCellCount() override; void willDisplayCellForIndex(TableViewCell * cell, int index) override; - void setFunction(Function * function); + void setFunction(CartesianFunction * function); private: BannerView * m_bannerView; - Function * m_function; + CartesianFunction * m_function; constexpr static int k_totalNumberOfCells = 3; ChevronMenuListCell m_calculationCell; ChevronMenuListCell m_goToCell; diff --git a/apps/graph/graph/goto_parameter_controller.cpp b/apps/graph/graph/goto_parameter_controller.cpp index ca25191ce..1382ed5da 100644 --- a/apps/graph/graph/goto_parameter_controller.cpp +++ b/apps/graph/graph/goto_parameter_controller.cpp @@ -47,7 +47,7 @@ int GoToParameterController::reusableCellCount() { return 1; } -void GoToParameterController::setFunction(Function * function) { +void GoToParameterController::setFunction(CartesianFunction * function) { m_function = function; } diff --git a/apps/graph/graph/goto_parameter_controller.h b/apps/graph/graph/goto_parameter_controller.h index 65beedbe0..a5b3399b5 100644 --- a/apps/graph/graph/goto_parameter_controller.h +++ b/apps/graph/graph/goto_parameter_controller.h @@ -15,7 +15,7 @@ public: int numberOfRows() override; TableViewCell * reusableCell(int index) override; int reusableCellCount() override; - void setFunction(Function * function); + void setFunction(CartesianFunction * function); bool textFieldDidFinishEditing(TextField * textField, const char * text) override; private: float parameterAtIndex(int index) override; @@ -24,7 +24,7 @@ private: EditableTextMenuListCell m_abscisseCell; Shared::InteractiveCurveViewRange * m_graphRange; Shared::CurveViewCursor * m_cursor; - Function * m_function; + CartesianFunction * m_function; }; } diff --git a/apps/graph/graph/graph_controller.cpp b/apps/graph/graph/graph_controller.cpp index 2a4ff91d8..2bb32a048 100644 --- a/apps/graph/graph/graph_controller.cpp +++ b/apps/graph/graph/graph_controller.cpp @@ -10,7 +10,7 @@ using namespace Shared; namespace Graph { -GraphController::GraphController(Responder * parentResponder, FunctionStore * functionStore, HeaderViewController * header) : +GraphController::GraphController(Responder * parentResponder, CartesianFunctionStore * functionStore, HeaderViewController * header) : InteractiveCurveViewController(parentResponder, header, &m_graphRange, &m_view), m_bannerView(BannerView()), m_view(GraphView(functionStore, &m_graphRange, &m_cursor, &m_bannerView, &m_cursorView)), @@ -62,7 +62,7 @@ bool GraphController::didChangeRange(InteractiveCurveViewRange * interactiveCurv float xMax = m_graphRange.xMax(); float step = (xMax - xMin)/Ion::Display::Width; for (int i=0; inumberOfActiveFunctions(); i++) { - Function * f = m_functionStore->activeFunctionAtIndex(i); + CartesianFunction * f = m_functionStore->activeFunctionAtIndex(i); float y = 0.0f; for (int i = 0; i <= Ion::Display::Width; i++) { float x = xMin + i*step; @@ -102,7 +102,7 @@ BannerView * GraphController::bannerView() { } bool GraphController::handleEnter() { - Function * f = m_functionStore->activeFunctionAtIndex(m_indexFunctionSelectedByCursor); + CartesianFunction * f = m_functionStore->activeFunctionAtIndex(m_indexFunctionSelectedByCursor); m_curveParameterController.setFunction(f); StackViewController * stack = stackController(); stack->push(&m_curveParameterController); @@ -123,7 +123,7 @@ void GraphController::reloadBannerView() { if (m_functionStore->numberOfActiveFunctions() == 0) { return; } - Function * f = m_functionStore->activeFunctionAtIndex(m_indexFunctionSelectedByCursor); + CartesianFunction * f = m_functionStore->activeFunctionAtIndex(m_indexFunctionSelectedByCursor); buffer[1] = f->name()[0]; Complex::convertFloatToText(m_cursor.y(), buffer+legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); m_bannerView.setLegendAtIndex(buffer+1, 1); @@ -151,7 +151,7 @@ void GraphController::initCursorParameters() { int functionIndex = 0; float y = 0; do { - Function * firstFunction = m_functionStore->activeFunctionAtIndex(functionIndex++); + CartesianFunction * firstFunction = m_functionStore->activeFunctionAtIndex(functionIndex++); y = firstFunction->evaluateAtAbscissa(x, graphApp->localContext()); } while (isnan(y) && functionIndex < m_functionStore->numberOfActiveFunctions()); m_cursor.moveTo(x, y); @@ -162,7 +162,7 @@ bool GraphController::moveCursorHorizontally(int direction) { float xCursorPosition = m_cursor.x(); float x = direction > 0 ? xCursorPosition + m_graphRange.xGridUnit()/k_numberOfCursorStepsInGradUnit : xCursorPosition - m_graphRange.xGridUnit()/k_numberOfCursorStepsInGradUnit; - Function * f = m_functionStore->activeFunctionAtIndex(m_indexFunctionSelectedByCursor); + CartesianFunction * f = m_functionStore->activeFunctionAtIndex(m_indexFunctionSelectedByCursor); App * graphApp = (Graph::App *)app(); float y = f->evaluateAtAbscissa(x, graphApp->localContext()); m_cursor.moveTo(x, y); @@ -171,13 +171,13 @@ bool GraphController::moveCursorHorizontally(int direction) { } bool GraphController::moveCursorVertically(int direction) { - Function * actualFunction = m_functionStore->activeFunctionAtIndex(m_indexFunctionSelectedByCursor); + CartesianFunction * actualFunction = m_functionStore->activeFunctionAtIndex(m_indexFunctionSelectedByCursor); App * graphApp = (Graph::App *)app(); float y = actualFunction->evaluateAtAbscissa(m_cursor.x(), graphApp->localContext()); - Function * nextFunction = actualFunction; + CartesianFunction * 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); + CartesianFunction * f = m_functionStore->activeFunctionAtIndex(i); float newY = f->evaluateAtAbscissa(m_cursor.x(), graphApp->localContext()); bool isNextFunction = direction > 0 ? (newY > y && newY < nextY) : (newY < y && newY > nextY); if (isNextFunction) { diff --git a/apps/graph/graph/graph_controller.h b/apps/graph/graph/graph_controller.h index 16b9b4450..7ed0470de 100644 --- a/apps/graph/graph/graph_controller.h +++ b/apps/graph/graph/graph_controller.h @@ -7,12 +7,12 @@ #include "curve_parameter_controller.h" #include "initialisation_parameter_controller.h" #include "../../shared/interactive_curve_view_controller.h" -#include "../function_store.h" +#include "../cartesian_function_store.h" namespace Graph { class GraphController : public Shared::InteractiveCurveViewController, public Shared::InteractiveCurveViewRangeDelegate { public: - GraphController(Responder * parentResponder, FunctionStore * functionStore, HeaderViewController * header); + GraphController(Responder * parentResponder, CartesianFunctionStore * functionStore, HeaderViewController * header); void didBecomeFirstResponder() override; ViewController * initialisationParameterController() override; @@ -48,7 +48,7 @@ private: Shared::InteractiveCurveViewRange m_graphRange; InitialisationParameterController m_initialisationParameterController; CurveParameterController m_curveParameterController; - FunctionStore * m_functionStore; + CartesianFunctionStore * m_functionStore; int m_indexFunctionSelectedByCursor; }; diff --git a/apps/graph/graph/graph_view.cpp b/apps/graph/graph/graph_view.cpp index a52a76d57..ecd1333ba 100644 --- a/apps/graph/graph/graph_view.cpp +++ b/apps/graph/graph/graph_view.cpp @@ -7,7 +7,7 @@ using namespace Shared; namespace Graph { -GraphView::GraphView(FunctionStore * functionStore, InteractiveCurveViewRange * graphRange, +GraphView::GraphView(CartesianFunctionStore * functionStore, InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor, BannerView * bannerView, View * cursorView) : CurveView(graphRange, cursor, bannerView, cursorView), m_functionStore(functionStore), @@ -23,7 +23,7 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const { drawLabels(ctx, rect, Axis::Horizontal, true); drawLabels(ctx, rect, Axis::Vertical, true); for (int i = 0; i < m_functionStore->numberOfActiveFunctions(); i++) { - Function * f = m_functionStore->activeFunctionAtIndex(i); + CartesianFunction * f = m_functionStore->activeFunctionAtIndex(i); drawCurve(ctx, rect, f, f->color()); } } @@ -41,7 +41,7 @@ char * GraphView::label(Axis axis, int index) const { } float GraphView::evaluateModelWithParameter(Model * curve, float abscissa) const { - Function * f = (Function *)curve; + CartesianFunction * f = (CartesianFunction *)curve; return f->evaluateAtAbscissa(abscissa, m_context); } diff --git a/apps/graph/graph/graph_view.h b/apps/graph/graph/graph_view.h index 631921b3d..4fccb1d2f 100644 --- a/apps/graph/graph/graph_view.h +++ b/apps/graph/graph/graph_view.h @@ -4,14 +4,14 @@ #include #include "../../shared/curve_view.h" #include "../../constant.h" -#include "../function_store.h" +#include "../cartesian_function_store.h" #include "../../shared/interactive_curve_view_range.h" namespace Graph { class GraphView : public Shared::CurveView { public: - GraphView(FunctionStore * functionStore, Shared::InteractiveCurveViewRange * graphRange, + GraphView(CartesianFunctionStore * functionStore, Shared::InteractiveCurveViewRange * graphRange, Shared::CurveViewCursor * cursor, Shared::BannerView * bannerView, View * cursorView); void drawRect(KDContext * ctx, KDRect rect) const override; void setContext(Poincare::Context * context); @@ -21,7 +21,7 @@ private: float evaluateModelWithParameter(Model * expression, float abscissa) const override; char m_xLabels[k_maxNumberOfXLabels][Poincare::Complex::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits)]; char m_yLabels[k_maxNumberOfYLabels][Poincare::Complex::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits)]; - FunctionStore * m_functionStore; + CartesianFunctionStore * m_functionStore; Poincare::Context * m_context; }; diff --git a/apps/graph/list/function_expression_cell.cpp b/apps/graph/list/function_expression_cell.cpp index 87eec09db..4c9994d44 100644 --- a/apps/graph/list/function_expression_cell.cpp +++ b/apps/graph/list/function_expression_cell.cpp @@ -10,13 +10,12 @@ FunctionExpressionCell::FunctionExpressionCell() : { } -void FunctionExpressionCell::setFunction(Function * f) { +void FunctionExpressionCell::setFunction(CartesianFunction * f) { m_function = f; m_expressionView.setExpression(m_function->layout()); bool active = m_function->isActive(); KDColor textColor = active ? KDColorBlack : Palette::GreyDark; m_expressionView.setTextColor(textColor); - //layoutSubviews(); } void FunctionExpressionCell::setEven(bool even) { @@ -29,7 +28,7 @@ void FunctionExpressionCell::setHighlighted(bool highlight) { m_expressionView.setBackgroundColor(backgroundColor()); } -Function * FunctionExpressionCell::function() { +CartesianFunction * FunctionExpressionCell::function() { return m_function; } diff --git a/apps/graph/list/function_expression_cell.h b/apps/graph/list/function_expression_cell.h index 4539621b6..5bf0f090b 100644 --- a/apps/graph/list/function_expression_cell.h +++ b/apps/graph/list/function_expression_cell.h @@ -2,15 +2,15 @@ #define GRAPH_FUNCTION_EXPRESSION_CELL_H #include -#include "../function.h" +#include "../cartesian_function.h" namespace Graph { class FunctionExpressionCell : public EvenOddCell { public: FunctionExpressionCell(); - virtual void setFunction(Function * f); - Function * function(); + virtual void setFunction(CartesianFunction * f); + CartesianFunction * function(); void setEven(bool even) override; void setHighlighted(bool highlight) override; int numberOfSubviews() const override; @@ -19,7 +19,7 @@ public: void drawRect(KDContext * ctx, KDRect rect) const override; private: constexpr static KDCoordinate k_separatorThickness = 1; - Function * m_function; + CartesianFunction * m_function; ExpressionView m_expressionView; }; diff --git a/apps/graph/list/list_controller.cpp b/apps/graph/list/list_controller.cpp index 834a7cd2d..cecd51dee 100644 --- a/apps/graph/list/list_controller.cpp +++ b/apps/graph/list/list_controller.cpp @@ -6,7 +6,7 @@ using namespace Shared; namespace Graph { -ListController::ListController(Responder * parentResponder, FunctionStore * functionStore, HeaderViewController * header) : +ListController::ListController(Responder * parentResponder, CartesianFunctionStore * functionStore, HeaderViewController * header) : Shared::ListController(parentResponder, functionStore, header, "Ajouter une fonction"), m_functionTitleCells{FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator)}, @@ -113,7 +113,7 @@ void ListController::configureFunction(Shared::Function * function) { void ListController::willDisplayTitleCellAtIndex(TableViewCell * cell, int j) { FunctionTitleCell * myFunctionCell = (FunctionTitleCell *)cell; - Function * function = ((FunctionStore *)m_functionStore)->functionAtIndex(j); + CartesianFunction * function = ((CartesianFunctionStore *)m_functionStore)->functionAtIndex(j); char bufferName[5] = {*function->name(),'(',function->symbol(),')', 0}; myFunctionCell->setText(bufferName); KDColor functionNameColor = function->isActive() ? function->color() : Palette::GreyDark; @@ -122,7 +122,7 @@ void ListController::willDisplayTitleCellAtIndex(TableViewCell * cell, int j) { void ListController::willDisplayExpressionCellAtIndex(TableViewCell * cell, int j) { FunctionExpressionCell * myCell = (FunctionExpressionCell *)cell; - myCell->setFunction(((FunctionStore *)m_functionStore)->functionAtIndex(j)); + myCell->setFunction(((CartesianFunctionStore *)m_functionStore)->functionAtIndex(j)); } } diff --git a/apps/graph/list/list_controller.h b/apps/graph/list/list_controller.h index dd3fe9cc1..0e0189298 100644 --- a/apps/graph/list/list_controller.h +++ b/apps/graph/list/list_controller.h @@ -4,7 +4,7 @@ #include #include "../function_title_cell.h" #include "function_expression_cell.h" -#include "../function_store.h" +#include "../cartesian_function_store.h" #include "../../shared/new_function_cell.h" #include "../../shared/list_controller.h" #include "../../shared/list_parameter_controller.h" @@ -13,7 +13,7 @@ namespace Graph { class ListController : public Shared::ListController { public: - ListController(Responder * parentResponder, FunctionStore * functionStore, HeaderViewController * header); + ListController(Responder * parentResponder, CartesianFunctionStore * functionStore, HeaderViewController * header); const char * title() const override; bool handleEvent(Ion::Events::Event event) override; private: diff --git a/apps/graph/values/derivative_parameter_controller.cpp b/apps/graph/values/derivative_parameter_controller.cpp index dd3fb6966..6c7bcf1d8 100644 --- a/apps/graph/values/derivative_parameter_controller.cpp +++ b/apps/graph/values/derivative_parameter_controller.cpp @@ -24,7 +24,7 @@ View * DerivativeParameterController::view() { return &m_selectableTableView; } -void DerivativeParameterController::setFunction(Function * function) { +void DerivativeParameterController::setFunction(CartesianFunction * function) { m_function = function; for (int currentChar = 0; currentChar < k_maxNumberOfCharsInTitle; currentChar++) { if (m_pageTitle[currentChar] == '(') { diff --git a/apps/graph/values/derivative_parameter_controller.h b/apps/graph/values/derivative_parameter_controller.h index 0b9746257..13045ca4d 100644 --- a/apps/graph/values/derivative_parameter_controller.h +++ b/apps/graph/values/derivative_parameter_controller.h @@ -2,7 +2,7 @@ #define GRAPH_DERIVATIVE_PARAM_CONTROLLER_H #include -#include "../function.h" +#include "../cartesian_function.h" namespace Graph { @@ -21,7 +21,7 @@ public: TableViewCell * reusableCell(int index) override; int reusableCellCount() override; - void setFunction(Function * function); + void setFunction(CartesianFunction * function); private: constexpr static int k_totalNumberOfCell = 2; constexpr static int k_maxNumberOfCharsInTitle = 16; @@ -29,7 +29,7 @@ private: MenuListCell m_hideColumn; ChevronMenuListCell m_copyColumn; SelectableTableView m_selectableTableView; - Function * m_function; + CartesianFunction * m_function; ValuesController * m_valuesController; }; diff --git a/apps/graph/values/function_parameter_controller.cpp b/apps/graph/values/function_parameter_controller.cpp index 5ee66ff89..23bef9252 100644 --- a/apps/graph/values/function_parameter_controller.cpp +++ b/apps/graph/values/function_parameter_controller.cpp @@ -24,7 +24,7 @@ View * FunctionParameterController::view() { return &m_selectableTableView; } -void FunctionParameterController::setFunction(Function * function) { +void FunctionParameterController::setFunction(CartesianFunction * function) { m_function = function; for (int currentChar = 0; currentChar < k_maxNumberOfCharsInTitle; currentChar++) { if (m_pageTitle[currentChar] == '(') { diff --git a/apps/graph/values/function_parameter_controller.h b/apps/graph/values/function_parameter_controller.h index 06eb17eb6..6799b473f 100644 --- a/apps/graph/values/function_parameter_controller.h +++ b/apps/graph/values/function_parameter_controller.h @@ -2,7 +2,7 @@ #define GRAPH_FUNCTION_PARAM_CONTROLLER_H #include -#include "../function.h" +#include "../cartesian_function.h" namespace Graph { @@ -22,7 +22,7 @@ public: int reusableCellCount() override; void willDisplayCellForIndex(TableViewCell * cell, int index) override; - void setFunction(Function * function); + void setFunction(CartesianFunction * function); private: constexpr static int k_totalNumberOfCell = 2; constexpr static int k_maxNumberOfCharsInTitle = 16; @@ -30,7 +30,7 @@ private: SwitchMenuListCell m_displayDerivativeColumn; ChevronMenuListCell m_copyColumn; SelectableTableView m_selectableTableView; - Function * m_function; + CartesianFunction * m_function; ValuesController * m_valuesController; }; diff --git a/apps/graph/values/values_controller.cpp b/apps/graph/values/values_controller.cpp index ae4c475fd..a5e8ecab3 100644 --- a/apps/graph/values/values_controller.cpp +++ b/apps/graph/values/values_controller.cpp @@ -9,7 +9,7 @@ using namespace Shared; namespace Graph { -ValuesController::ValuesController(Responder * parentResponder, FunctionStore * functionStore, HeaderViewController * header) : +ValuesController::ValuesController(Responder * parentResponder, CartesianFunctionStore * functionStore, HeaderViewController * header) : EditableCellTableViewController(parentResponder, k_topMargin, k_rightMargin, k_bottomMargin, k_leftMargin), HeaderViewDelegate(header), m_abscissaTitleCell(EvenOddPointerTextCell(KDText::FontSize::Small)), @@ -138,7 +138,7 @@ void ValuesController::willDisplayCellAtLocation(TableViewCell * cell, int i, in return; } FunctionTitleCell * myFunctionCell = (FunctionTitleCell *)cell; - Function * function = functionAtColumn(i); + CartesianFunction * function = functionAtColumn(i); char bufferName[6] = {0, 0, '(', 'x', ')', 0}; const char * name = bufferName; if (isDerivativeColumn(i)) { @@ -167,7 +167,7 @@ void ValuesController::willDisplayCellAtLocation(TableViewCell * cell, int i, in } // The cell is a value cell EvenOddBufferTextCell * myValueCell = (EvenOddBufferTextCell *)cell; - Function * function = functionAtColumn(i); + CartesianFunction * function = functionAtColumn(i); float x = m_interval.element(j-1); if (isDerivativeColumn(i)) { Complex::convertFloatToText(function->approximateDerivative(x, graphApp->localContext()), buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); @@ -290,7 +290,7 @@ void ValuesController::viewWillAppear() { m_selectableTableView.reloadData(); } -Function * ValuesController::functionAtColumn(int i) { +CartesianFunction * ValuesController::functionAtColumn(int i) { assert(i > 0); int index = 1; for (int k = 0; k < m_functionStore->numberOfDefinedFunctions(); k++) { @@ -346,14 +346,14 @@ void ValuesController::configureAbscissa() { } void ValuesController::configureFunction() { - Function * function = functionAtColumn(activeColumn()); + CartesianFunction * function = functionAtColumn(activeColumn()); m_functionParameterController.setFunction(function); StackViewController * stack = stackController(); stack->push(&m_functionParameterController); } void ValuesController::configureDerivativeFunction() { - Function * function = functionAtColumn(activeColumn()); + CartesianFunction * function = functionAtColumn(activeColumn()); m_derivativeParameterController.setFunction(function); StackViewController * stack = stackController(); stack->push(&m_derivativeParameterController); diff --git a/apps/graph/values/values_controller.h b/apps/graph/values/values_controller.h index 7a6d1e34d..c4e2550d5 100644 --- a/apps/graph/values/values_controller.h +++ b/apps/graph/values/values_controller.h @@ -2,7 +2,7 @@ #define GRAPH_VALUES_CONTROLLER_H #include -#include "../function_store.h" +#include "../cartesian_function_store.h" #include "../function_title_cell.h" #include "../../shared/editable_cell_table_view_controller.h" #include "interval.h" @@ -15,7 +15,7 @@ namespace Graph { class ValuesController : public Shared::EditableCellTableViewController, public HeaderViewDelegate, public AlternateEmptyViewDelegate { public: - ValuesController(Responder * parentResponder, FunctionStore * functionStore, HeaderViewController * header); + ValuesController(Responder * parentResponder, CartesianFunctionStore * functionStore, HeaderViewController * header); const char * title() const override; Interval * interval(); bool handleEvent(Ion::Events::Event event) override; @@ -45,7 +45,7 @@ public: static constexpr KDCoordinate k_abscissaCellWidth = 150; static constexpr KDCoordinate k_ordinateCellWidth = 100; private: - Function * functionAtColumn(int i); + CartesianFunction * functionAtColumn(int i); bool isDerivativeColumn(int i); Responder * tabController() const; StackViewController * stackController() const; @@ -65,7 +65,7 @@ private: EvenOddBufferTextCell m_floatCells[k_maxNumberOfCells]; char m_draftTextBuffer[EditableTextCell::k_bufferLength]; EvenOddEditableTextCell m_abscissaCells[k_maxNumberOfAbscissaCells]; - FunctionStore * m_functionStore; + CartesianFunctionStore * m_functionStore; Interval m_interval; IntervalParameterController m_intervalParameterController; AbscissaParameterController m_abscissaParameterController; From a447eb8560689209e488b4c6887eb9e81a51a213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 15 Feb 2017 10:27:15 +0100 Subject: [PATCH 2/3] [escher] In app, dismiss any modal view when changing app Change-Id: I0f739ed2871c1d014f52b45162cf44336e7cec65 --- apps/toolbox_controller.cpp | 4 ++++ apps/toolbox_controller.h | 1 + escher/src/app.cpp | 3 +++ 3 files changed, 8 insertions(+) diff --git a/apps/toolbox_controller.cpp b/apps/toolbox_controller.cpp index 1d1f09265..b77edfb2f 100644 --- a/apps/toolbox_controller.cpp +++ b/apps/toolbox_controller.cpp @@ -118,6 +118,10 @@ void ToolboxController::didBecomeFirstResponder() { app()->setFirstResponder(&m_listViewController); } +void ToolboxController::viewWillDisappear() { + m_listViewController.deselectTable(); +} + void ToolboxController::setTextFieldCaller(TextField * textField) { m_textFieldCaller = textField; } diff --git a/apps/toolbox_controller.h b/apps/toolbox_controller.h index 18bc87635..19c1a2d87 100644 --- a/apps/toolbox_controller.h +++ b/apps/toolbox_controller.h @@ -11,6 +11,7 @@ public: const char * title() const override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; + void viewWillDisappear() override; void setTextFieldCaller(TextField * textField); private: class Stack { diff --git a/escher/src/app.cpp b/escher/src/app.cpp index 0c1d37e28..231ed086c 100644 --- a/escher/src/app.cpp +++ b/escher/src/app.cpp @@ -85,5 +85,8 @@ void App::didBecomeActive(Window * window) { } void App::willBecomeInactive() { + if (m_modalViewController.isDisplayingModal()) { + dismissModalViewController(); + } m_modalViewController.viewWillDisappear(); } From 5c69897133151f7d9e276fdedbd1b73bbb1519c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 15 Feb 2017 11:36:07 +0100 Subject: [PATCH 3/3] [apps/sequence] Correct bug Change-Id: If4cd812780f9d1fc1a02180326ec10a745612ffd --- apps/sequence/list/change_type_parameter_controller.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/sequence/list/change_type_parameter_controller.cpp b/apps/sequence/list/change_type_parameter_controller.cpp index 894402855..730e4d0ba 100644 --- a/apps/sequence/list/change_type_parameter_controller.cpp +++ b/apps/sequence/list/change_type_parameter_controller.cpp @@ -43,7 +43,6 @@ bool ChangeTypeParameterController::handleEvent(Ion::Events::Event event) { m_sequence->setType((Sequence::Type)m_selectableTableView.selectedRow()); StackViewController * stack = stackController(); stack->pop(); - stack->pop(); return true; } return false;