diff --git a/apps/graph/Makefile b/apps/graph/Makefile index 71fd982ac..67c70667d 100644 --- a/apps/graph/Makefile +++ b/apps/graph/Makefile @@ -21,6 +21,7 @@ app_graph_src = $(addprefix apps/graph/,\ list/list_controller.cpp \ list/list_parameter_controller.cpp \ list/text_field_function_title_cell.cpp \ + list/type_helper.cpp \ values/derivative_parameter_controller.cpp \ values/function_parameter_controller.cpp \ values/values_controller.cpp \ diff --git a/apps/graph/list/type_helper.cpp b/apps/graph/list/type_helper.cpp new file mode 100644 index 000000000..917dc245c --- /dev/null +++ b/apps/graph/list/type_helper.cpp @@ -0,0 +1,37 @@ +#include "type_helper.h" +#include +#include +#include + +namespace Graph { + +namespace PlotTypeHelper { + +I18n::Message Message(int index) { + assert(0 <= index && index < NumberOfTypes); + static constexpr I18n::Message message[NumberOfTypes] = { + I18n::Message::Cartesian, + I18n::Message::Polar, + I18n::Message::Parametric + }; + return message[index]; +} + +Poincare::Layout Layout(int index) { + assert(0 <= index && index < NumberOfTypes); + static constexpr const char * texts[NumberOfTypes] = { + "y=f(x)", + "r=f(θ)", + "[[x][y]]=f(t)" + }; + const char * text = texts[index]; + if (index < 2) { + return Poincare::LayoutHelper::String(text, strlen(text)); + } + Poincare::Expression parametric = Poincare::Expression::Parse(text); + return parametric.createLayout(Poincare::Preferences::PrintFloatMode::Decimal, 1); +} + +} + +} diff --git a/apps/graph/list/type_helper.h b/apps/graph/list/type_helper.h new file mode 100644 index 000000000..0d5aef810 --- /dev/null +++ b/apps/graph/list/type_helper.h @@ -0,0 +1,19 @@ +#ifndef GRAPH_LIST_TYPE_HELPER_H +#define GRAPH_LIST_TYPE_HELPER_H + +#include +#include + +namespace Graph { + +namespace PlotTypeHelper { + +constexpr static int NumberOfTypes = 3; +I18n::Message Message(int index); +Poincare::Layout Layout(int index); + +} + +} + +#endif