#ifndef SHARED_STORAGE_FUNCTION_GRAPH_CONTROLLER_H #define SHARED_STORAGE_FUNCTION_GRAPH_CONTROLLER_H #include #include "initialisation_parameter_controller.h" #include "storage_function_banner_delegate.h" #include "interactive_curve_view_controller.h" #include "storage_function_store.h" #include "storage_function_graph_view.h" #include "storage_function_curve_parameter_controller.h" namespace Shared { class StorageFunctionGraphController : public InteractiveCurveViewController, public StorageFunctionBannerDelegate { public: StorageFunctionGraphController(Responder * parentResponder, ButtonRowController * header, InteractiveCurveViewRange * interactiveRange, CurveView * curveView, CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * modelVersion, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion); bool isEmpty() const override; ViewController * initialisationParameterController() override; void viewWillAppear() override; protected: float cursorTopMarginRatio() { return 0.068f; // (cursorHeight/2)/graphViewHeight; } float cursorBottomMarginRatio(); void reloadBannerView() override; bool handleEnter() override; int indexFunctionSelectedByCursor() const { return *m_indexFunctionSelectedByCursor; } virtual void selectFunctionWithCursor(int functionIndex); virtual double defaultCursorAbscissa(); private: constexpr static float k_viewHeight = 174.0f; // TODO Taken from Regresssion/graph_controller. Maybe we should compute and/or put in common ? // InteractiveCurveViewController /* When y auto is ticked, we use a display margin to be ensure that the user * can move the cursor along the curve without panning the window */ float displayTopMarginRatio() override { return 0.09f; // cursorHeight/graphViewHeight } float displayBottomMarginRatio() override; // InteractiveCurveViewRangeDelegate InteractiveCurveViewRangeDelegate::Range computeYRange(InteractiveCurveViewRange * interactiveCurveViewRange) override; float estimatedBannerHeight() const; virtual int estimatedBannerNumberOfLines() const { return 1; } void initRangeParameters() override; void initCursorParameters() override; bool moveCursorVertically(int direction) override; CurveView * curveView() override; uint32_t modelVersion() override; uint32_t rangeVersion() override; bool isCursorVisible() override; virtual StorageFunctionGraphView * functionGraphView() = 0; virtual View * cursorView() = 0; virtual StorageFunctionStore * functionStore() const = 0; virtual StorageFunctionCurveParameterController * curveParameterController() = 0; InitialisationParameterController m_initialisationParameterController; Poincare::Preferences::AngleUnit * m_angleUnitVersion; int * m_indexFunctionSelectedByCursor; }; } #endif