diff --git a/apps/graph/Makefile b/apps/graph/Makefile index 470b83c1a..c014d5ea7 100644 --- a/apps/graph/Makefile +++ b/apps/graph/Makefile @@ -3,8 +3,6 @@ app_headers += apps/graph/app.h app_objs += $(addprefix apps/graph/,\ app.o\ - cartesian_function.o\ - cartesian_function_store.o\ storage_cartesian_function_store.o\ graph/banner_view.o\ graph/calculation_graph_controller.o\ diff --git a/apps/graph/cartesian_function.h b/apps/graph/cartesian_function.h deleted file mode 100644 index b9339d68e..000000000 --- a/apps/graph/cartesian_function.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef GRAPH_CARTESIAN_FUNCTION_H -#define GRAPH_CARTESIAN_FUNCTION_H - -#include "../shared/function.h" - -namespace Graph { - -class CartesianFunction : public Shared::Function { -public: - using Shared::Function::Function; - CartesianFunction(const char * text = nullptr, KDColor color = KDColorBlack); - bool displayDerivative(); - void setDisplayDerivative(bool display); - double approximateDerivative(double x, Poincare::Context * context) const; - double sumBetweenBounds(double start, double end, Poincare::Context * context) const override; - Poincare::Expression::Coordinate2D nextMinimumFrom(double start, double step, double max, Poincare::Context * context) const; - Poincare::Expression::Coordinate2D nextMaximumFrom(double start, double step, double max, Poincare::Context * context) const; - double nextRootFrom(double start, double step, double max, Poincare::Context * context) const; - Poincare::Expression::Coordinate2D nextIntersectionFrom(double start, double step, double max, Poincare::Context * context, const Shared::Function * function) const; - const char * symbol() const override { return "x"; } -private: - bool m_displayDerivative; -}; - -} - -#endif diff --git a/apps/graph/cartesian_function_store.cpp b/apps/graph/cartesian_function_store.cpp deleted file mode 100644 index 4b2215624..000000000 --- a/apps/graph/cartesian_function_store.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "cartesian_function_store.h" -extern "C" { -#include -#include -} -#include - -namespace Graph { - -constexpr int CartesianFunctionStore::k_maxNumberOfFunctions; -constexpr const char * CartesianFunctionStore::k_functionNames[k_maxNumberOfFunctions]; - -CartesianFunctionStore::CartesianFunctionStore() : - Shared::FunctionStore() -{ - addEmptyModel(); -} - -uint32_t CartesianFunctionStore::storeChecksum() { - size_t dataLengthInBytes = k_maxNumberOfFunctions*sizeof(uint32_t); - assert((dataLengthInBytes & 0x3) == 0); // Assert that dataLengthInBytes is a multiple of 4 - uint32_t checksums[k_maxNumberOfFunctions]; - for (int i = 0; i < k_maxNumberOfFunctions; i++) { - checksums[i] = m_functions[i].checksum(); - } - return Ion::crc32((uint32_t *)checksums, dataLengthInBytes/sizeof(uint32_t)); -} - - -char CartesianFunctionStore::symbol() const { - return 'x'; -} - -void CartesianFunctionStore::removeAll() { - FunctionStore::removeAll(); - addEmptyModel(); -} - -CartesianFunction * CartesianFunctionStore::emptyModel() { - static CartesianFunction addedFunction("", KDColorBlack); - addedFunction = CartesianFunction(firstAvailableName(), firstAvailableColor()); - return &addedFunction; -} - -CartesianFunction * CartesianFunctionStore::nullModel() { - static CartesianFunction emptyFunction("", KDColorBlack); - return &emptyFunction; -} - -void CartesianFunctionStore::setModelAtIndex(Shared::ExpressionModel * e, int i) { - assert(i>=0 && i(e)); -} - -} diff --git a/apps/graph/cartesian_function_store.h b/apps/graph/cartesian_function_store.h deleted file mode 100644 index f71851f9b..000000000 --- a/apps/graph/cartesian_function_store.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef GRAPH_CARTESIAN_FUNCTION_STORE_H -#define GRAPH_CARTESIAN_FUNCTION_STORE_H - -#include "cartesian_function.h" -#include "../shared/function_store.h" -#include -#include - -namespace Graph { - -class CartesianFunctionStore : public Shared::FunctionStore { -public: - CartesianFunctionStore(); - uint32_t storeChecksum() override; - CartesianFunction * modelAtIndex(int i) override { return &m_functions[i]; } - CartesianFunction * activeFunctionAtIndex(int i) override { return (CartesianFunction *)Shared::FunctionStore::activeFunctionAtIndex(i); } - CartesianFunction * definedFunctionAtIndex(int i) override { return (CartesianFunction *)Shared::FunctionStore::definedFunctionAtIndex(i); } - int maxNumberOfModels() const override { - return k_maxNumberOfFunctions; - } - char symbol() const override; - void removeAll() override; - static constexpr int k_maxNumberOfFunctions = 4; -private: - static constexpr const char * k_functionNames[k_maxNumberOfFunctions] = { - "f", "g", "h", "p", - }; - CartesianFunction * emptyModel() override; - CartesianFunction * nullModel() override; - void setModelAtIndex(Shared::ExpressionModel * f, int i) override; - const char * firstAvailableName() override { - return firstAvailableAttribute(k_functionNames, FunctionStore::name); - } - CartesianFunction m_functions[k_maxNumberOfFunctions]; -}; - -} - -#endif diff --git a/apps/shared/storage_cartesian_function.cpp b/apps/shared/storage_cartesian_function.cpp index b227ae20f..b7c4df953 100644 --- a/apps/shared/storage_cartesian_function.cpp +++ b/apps/shared/storage_cartesian_function.cpp @@ -1,6 +1,8 @@ #include "storage_cartesian_function.h" #include "storage_expression_model_store.h" #include "poincare_helpers.h" +#include +#include #include #include