[apps/graph] Change name: function->cartesian_function

Change-Id: I138bd13fec8514144cfde7164ec9aff081454609
This commit is contained in:
Émilie Feral
2017-02-14 17:57:55 +01:00
parent dc7a629dfa
commit 6b524737b4
25 changed files with 98 additions and 100 deletions

View File

@@ -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\

View File

@@ -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)),

View File

@@ -3,7 +3,7 @@
#include <escher.h>
#include <poincare.h>
#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;

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
#include "function_store.h"
#include "cartesian_function_store.h"
extern "C" {
#include <assert.h>
#include <stddef.h>
@@ -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<m_numberOfFunctions);
return &m_functions[i];
}
Function * FunctionStore::activeFunctionAtIndex(int i) {
return (Function *)Shared::FunctionStore::activeFunctionAtIndex(i);
CartesianFunction * CartesianFunctionStore::activeFunctionAtIndex(int i) {
return (CartesianFunction *)Shared::FunctionStore::activeFunctionAtIndex(i);
}
Function * FunctionStore::definedFunctionAtIndex(int i) {
return (Function *)Shared::FunctionStore::definedFunctionAtIndex(i);
CartesianFunction * CartesianFunctionStore::definedFunctionAtIndex(int i) {
return (CartesianFunction *)Shared::FunctionStore::definedFunctionAtIndex(i);
}
Function * FunctionStore::addEmptyFunction() {
CartesianFunction * CartesianFunctionStore::addEmptyFunction() {
assert(m_numberOfFunctions < k_maxNumberOfFunctions);
const char * name = firstAvailableName();
KDColor color = firstAvailableColor();
Function addedFunction = Function(name, color);
CartesianFunction addedFunction = CartesianFunction(name, color);
m_functions[m_numberOfFunctions] = addedFunction;
Function * result = &m_functions[m_numberOfFunctions];
CartesianFunction * result = &m_functions[m_numberOfFunctions];
m_numberOfFunctions++;
return result;
}
void FunctionStore::removeFunction(Shared::Function * f) {
void CartesianFunctionStore::removeFunction(Shared::Function * f) {
int i = 0;
while (&m_functions[i] != f && i < m_numberOfFunctions) {
i++;
@@ -60,11 +59,11 @@ void FunctionStore::removeFunction(Shared::Function * f) {
}
}
int FunctionStore::maxNumberOfFunctions() {
int CartesianFunctionStore::maxNumberOfFunctions() {
return k_maxNumberOfFunctions;
}
const char * FunctionStore::firstAvailableName() {
const char * CartesianFunctionStore::firstAvailableName() {
for (int k = 0; k < k_maxNumberOfFunctions; k++) {
int j = 0;
while (j < m_numberOfFunctions) {
@@ -80,7 +79,7 @@ const char * FunctionStore::firstAvailableName() {
return k_functionNames[0];
}
const KDColor FunctionStore::firstAvailableColor() {
const KDColor CartesianFunctionStore::firstAvailableColor() {
for (int k = 0; k < k_numberOfDefaultColors; k++) {
int j = 0;
while (j < m_numberOfFunctions) {

View File

@@ -1,20 +1,20 @@
#ifndef GRAPH_FUNCTION_STORE_H
#define GRAPH_FUNCTION_STORE_H
#ifndef GRAPH_CARTESIAN_FUNCTION_STORE_H
#define GRAPH_CARTESIAN_FUNCTION_STORE_H
#include "function.h"
#include "cartesian_function.h"
#include "../shared/function_store.h"
#include <stdint.h>
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];
};
}

View File

@@ -82,7 +82,7 @@ KDCoordinate CurveParameterController::cellHeight() {
return Metric::ParameterCellHeight;
}
void CurveParameterController::setFunction(Function * function) {
void CurveParameterController::setFunction(CartesianFunction * function) {
m_function = function;
}

View File

@@ -4,7 +4,7 @@
#include <escher.h>
#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;

View File

@@ -47,7 +47,7 @@ int GoToParameterController::reusableCellCount() {
return 1;
}
void GoToParameterController::setFunction(Function * function) {
void GoToParameterController::setFunction(CartesianFunction * function) {
m_function = function;
}

View File

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

View File

@@ -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; i<m_functionStore->numberOfActiveFunctions(); 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) {

View File

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

View File

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

View File

@@ -4,14 +4,14 @@
#include <escher.h>
#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;
};

View File

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

View File

@@ -2,15 +2,15 @@
#define GRAPH_FUNCTION_EXPRESSION_CELL_H
#include <escher.h>
#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;
};

View File

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

View File

@@ -4,7 +4,7 @@
#include <escher.h>
#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:

View File

@@ -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] == '(') {

View File

@@ -2,7 +2,7 @@
#define GRAPH_DERIVATIVE_PARAM_CONTROLLER_H
#include <escher.h>
#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;
};

View File

@@ -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] == '(') {

View File

@@ -2,7 +2,7 @@
#define GRAPH_FUNCTION_PARAM_CONTROLLER_H
#include <escher.h>
#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;
};

View File

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

View File

@@ -2,7 +2,7 @@
#define GRAPH_VALUES_CONTROLLER_H
#include <escher.h>
#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;