[graph] Fix Graph controllers to take a StorageCartesianFunction instead

of a CartesianFunction
This commit is contained in:
Émilie Feral
2018-10-12 09:39:49 +02:00
parent 3cedfb84e9
commit 3412463e84
19 changed files with 94 additions and 92 deletions

View File

@@ -13,7 +13,7 @@ using namespace Poincare;
namespace Graph {
IntegralGraphController::IntegralGraphController(Responder * parentResponder, GraphView * graphView, InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor) :
SumGraphController(parentResponder, graphView, graphRange, cursor, Ion::Charset::Integral)
StorageSumGraphController(parentResponder, graphView, graphRange, cursor, Ion::Charset::Integral)
{
}
@@ -36,10 +36,13 @@ double IntegralGraphController::cursorNextStep(double x, int direction) {
return (direction > 0 ? x + m_graphRange->xGridUnit()/k_numberOfCursorStepsInGradUnit : x - m_graphRange->xGridUnit()/k_numberOfCursorStepsInGradUnit);
}
Layout IntegralGraphController::createFunctionLayout(const char * functionName) {
char buffer[7] = "0(x)dx";
buffer[0] = functionName[0];
return LayoutHelper::String(buffer, strlen(buffer), KDFont::SmallFont);
Layout IntegralGraphController::createFunctionLayout(StorageFunction * function) {
constexpr size_t bufferSize = SymbolAbstract::k_maxNameSize+5; // f(x)dx
char buffer[bufferSize];
const char * dx = "dx";
int numberOfChars = function->nameWithArgument(buffer, bufferSize-strlen(dx), 'x');
strlcpy(buffer+numberOfChars, dx, bufferSize-numberOfChars);
return LayoutHelper::String(buffer, strlen(buffer), KFont::SmallFont);
}
}