mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/graph/list] Define PlotTypeHelper
This commit is contained in:
committed by
Léa Saviot
parent
0f3fc46ad1
commit
5a79139fb7
@@ -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 \
|
||||
|
||||
37
apps/graph/list/type_helper.cpp
Normal file
37
apps/graph/list/type_helper.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "type_helper.h"
|
||||
#include <apps/i18n.h>
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
19
apps/graph/list/type_helper.h
Normal file
19
apps/graph/list/type_helper.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef GRAPH_LIST_TYPE_HELPER_H
|
||||
#define GRAPH_LIST_TYPE_HELPER_H
|
||||
|
||||
#include <escher/i18n.h>
|
||||
#include <poincare/layout.h>
|
||||
|
||||
namespace Graph {
|
||||
|
||||
namespace PlotTypeHelper {
|
||||
|
||||
constexpr static int NumberOfTypes = 3;
|
||||
I18n::Message Message(int index);
|
||||
Poincare::Layout Layout(int index);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user