From e0774cba4b5ddd78bdca6d58c569cc9054848b8a Mon Sep 17 00:00:00 2001 From: Ruben Dashyan Date: Tue, 2 Apr 2019 11:31:35 +0200 Subject: [PATCH] [apps/graph/graph] Define PreimageGraphController class --- apps/graph/Makefile | 1 + .../graph/graph/preimage_graph_controller.cpp | 29 +++++++++++++++++++ apps/graph/graph/preimage_graph_controller.h | 22 ++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 apps/graph/graph/preimage_graph_controller.cpp create mode 100644 apps/graph/graph/preimage_graph_controller.h diff --git a/apps/graph/Makefile b/apps/graph/Makefile index 5f8ea6f7e..9d5696b8e 100644 --- a/apps/graph/Makefile +++ b/apps/graph/Makefile @@ -12,6 +12,7 @@ app_src += $(addprefix apps/graph/,\ graph/graph_controller.cpp \ graph/graph_controller_helper.cpp \ graph/graph_view.cpp \ + graph/preimage_graph_controller.cpp\ graph/integral_graph_controller.cpp \ graph/intersection_graph_controller.cpp \ graph/root_graph_controller.cpp \ diff --git a/apps/graph/graph/preimage_graph_controller.cpp b/apps/graph/graph/preimage_graph_controller.cpp new file mode 100644 index 000000000..818de7210 --- /dev/null +++ b/apps/graph/graph/preimage_graph_controller.cpp @@ -0,0 +1,29 @@ +#include "preimage_graph_controller.h" + +namespace Graph { + +PreimageGraphController::PreimageGraphController( + Responder * parentResponder, + GraphView * graphView, + BannerView * bannerView, + Shared::InteractiveCurveViewRange * curveViewRange, + Shared::CurveViewCursor * cursor +) : + CalculationGraphController( + parentResponder, + graphView, + bannerView, + curveViewRange, + cursor, + I18n::Message::NoPreimageFound + ), + m_image(NAN) +{ +} + +Poincare::Expression::Coordinate2D PreimageGraphController::computeNewPointOfInterest(double start, double step, double max, Poincare::Context * context) { + Poincare::Expression expression = Poincare::Float::Builder(m_image); + return functionStore()->modelForRecord(m_record)->nextIntersectionFrom(start, step, max, context, expression); +} + +} diff --git a/apps/graph/graph/preimage_graph_controller.h b/apps/graph/graph/preimage_graph_controller.h new file mode 100644 index 000000000..995b06b0a --- /dev/null +++ b/apps/graph/graph/preimage_graph_controller.h @@ -0,0 +1,22 @@ +#include "calculation_graph_controller.h" + +namespace Graph { + +class PreimageGraphController : public CalculationGraphController { +public: + PreimageGraphController( + Responder * parentResponder, + GraphView * graphView, + BannerView * bannerView, + Shared::InteractiveCurveViewRange * curveViewRange, + Shared::CurveViewCursor * cursor + ); + const char * title() override { return I18n::translate(I18n::Message::Preimage); } + double image() { return m_image; } + void setImage(double value) { m_image = value; } +private: + Poincare::Expression::Coordinate2D computeNewPointOfInterest(double start, double step, double max, Poincare::Context * context) override; + double m_image; +}; + +}