[apps] Graph: create a RootGraphController

This commit is contained in:
Émilie Feral
2018-01-19 17:19:45 +01:00
committed by EmilieNumworks
parent d1840dfe17
commit 37c3f6189d
5 changed files with 49 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ app_objs += $(addprefix apps/graph/,\
graph/graph_view.o\
graph/integral_graph_controller.o\
graph/tangent_graph_controller.o\
graph/root_graph_controller.o\
list/list_controller.o\
values/derivative_parameter_controller.o\
values/function_parameter_controller.o\

View File

@@ -15,7 +15,8 @@ CalculationParameterController::CalculationParameterController(Responder * paren
m_tangentGraphController(nullptr, graphView, bannerView, range, cursor),
m_integralGraphController(nullptr, graphView, range, cursor),
m_minimumGraphController(nullptr, graphView, bannerView, range, cursor),
m_maximumGraphController(nullptr, graphView, bannerView, range, cursor)
m_maximumGraphController(nullptr, graphView, bannerView, range, cursor),
m_rootGraphController(nullptr, graphView, bannerView, range, cursor)
{
}
@@ -44,6 +45,10 @@ bool CalculationParameterController::handleEvent(Ion::Events::Event event) {
m_minimumGraphController.setFunction(m_function);
controller = &m_minimumGraphController;
break;
case 3:
m_rootGraphController.setFunction(m_function);
controller = &m_rootGraphController;
break;
case 4:
m_tangentGraphController.setFunction(m_function);
controller = &m_tangentGraphController;

View File

@@ -6,6 +6,7 @@
#include "tangent_graph_controller.h"
#include "extremum_graph_controller.h"
#include "integral_graph_controller.h"
#include "root_graph_controller.h"
#include "graph_view.h"
#include "banner_view.h"
#include "../../i18n.h"
@@ -34,6 +35,7 @@ private:
IntegralGraphController m_integralGraphController;
MinimumGraphController m_minimumGraphController;
MaximumGraphController m_maximumGraphController;
RootGraphController m_rootGraphController;
};
}

View File

@@ -0,0 +1,22 @@
#include "root_graph_controller.h"
#include "../app.h"
using namespace Shared;
using namespace Poincare;
namespace Graph {
RootGraphController::RootGraphController(Responder * parentResponder, GraphView * graphView, BannerView * bannerView, Shared::InteractiveCurveViewRange * curveViewRange, CurveViewCursor * cursor) :
CalculationGraphController(parentResponder, graphView, bannerView, curveViewRange, cursor, I18n::Message::NoZeroFound)
{
}
const char * RootGraphController::title() {
return I18n::translate(I18n::Message::Zeros);
}
CartesianFunction::Point RootGraphController::computeNewPointOfInterest(double start, double step, double max, Context * context) {
return {.abscissa = m_function->nextRootFrom(start, step, max, context), .value = 0.0};
}
}

View File

@@ -0,0 +1,18 @@
#ifndef GRAPH_ROOT_GRAPH_CONTROLLER_H
#define GRAPH_ROOT_GRAPH_CONTROLLER_H
#include "calculation_graph_controller.h"
namespace Graph {
class RootGraphController : public CalculationGraphController {
public:
RootGraphController(Responder * parentResponder, GraphView * graphView, BannerView * bannerView, Shared::InteractiveCurveViewRange * curveViewRange, Shared::CurveViewCursor * cursor);
const char * title() override;
private:
CartesianFunction::Point computeNewPointOfInterest(double start, double step, double max, Poincare::Context * context) override;
};
}
#endif