From 1908c9c674aeb110570c5d244bd264333b98cf30 Mon Sep 17 00:00:00 2001 From: Ruben Dashyan Date: Mon, 9 Sep 2019 13:52:33 +0200 Subject: [PATCH] [apps/graph] GraphView gets the function store through App instead of passing a pointer at contruction. --- apps/graph/app.cpp | 2 +- apps/graph/graph/graph_controller.cpp | 4 ++-- apps/graph/graph/graph_controller.h | 2 +- apps/graph/graph/graph_view.cpp | 13 +++++++------ apps/graph/graph/graph_view.h | 4 +--- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/apps/graph/app.cpp b/apps/graph/app.cpp index 30cfe80ea..c634af459 100644 --- a/apps/graph/app.cpp +++ b/apps/graph/app.cpp @@ -62,7 +62,7 @@ App::App(Snapshot * snapshot) : m_listFooter(&m_listHeader, &m_listController, &m_listController, ButtonRowController::Position::Bottom, ButtonRowController::Style::EmbossedGrey), m_listHeader(&m_listStackViewController, &m_listFooter, &m_listController), m_listStackViewController(&m_tabViewController, &m_listHeader), - m_graphController(&m_graphAlternateEmptyViewController, this, snapshot->functionStore(), snapshot->graphRange(), snapshot->cursor(), snapshot->indexFunctionSelectedByCursor(), snapshot->modelVersion(), snapshot->rangeVersion(), snapshot->angleUnitVersion(), &m_graphHeader), + m_graphController(&m_graphAlternateEmptyViewController, this, snapshot->graphRange(), snapshot->cursor(), snapshot->indexFunctionSelectedByCursor(), snapshot->modelVersion(), snapshot->rangeVersion(), snapshot->angleUnitVersion(), &m_graphHeader), m_graphAlternateEmptyViewController(&m_graphHeader, &m_graphController, &m_graphController), m_graphHeader(&m_graphStackViewController, &m_graphAlternateEmptyViewController, &m_graphController), m_graphStackViewController(&m_tabViewController, &m_graphHeader), diff --git a/apps/graph/graph/graph_controller.cpp b/apps/graph/graph/graph_controller.cpp index 832a201f4..eeba09afc 100644 --- a/apps/graph/graph/graph_controller.cpp +++ b/apps/graph/graph/graph_controller.cpp @@ -9,10 +9,10 @@ namespace Graph { static inline float minFloat(float x, float y) { return x < y ? x : y; } static inline float maxFloat(float x, float y) { return x > y ? x : y; } -GraphController::GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, CartesianFunctionStore * functionStore, Shared::InteractiveCurveViewRange * curveViewRange, CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * modelVersion, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion, ButtonRowController * header) : +GraphController::GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, Shared::InteractiveCurveViewRange * curveViewRange, CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * modelVersion, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion, ButtonRowController * header) : FunctionGraphController(parentResponder, inputEventHandlerDelegate, header, curveViewRange, &m_view, cursor, indexFunctionSelectedByCursor, modelVersion, rangeVersion, angleUnitVersion), m_bannerView(this, inputEventHandlerDelegate, this), - m_view(functionStore, curveViewRange, m_cursor, &m_bannerView, &m_cursorView), + m_view(curveViewRange, m_cursor, &m_bannerView, &m_cursorView), m_graphRange(curveViewRange), m_curveParameterController(inputEventHandlerDelegate, curveViewRange, &m_bannerView, m_cursor, &m_view, this), m_displayDerivativeInBanner(false) diff --git a/apps/graph/graph/graph_controller.h b/apps/graph/graph/graph_controller.h index 5ca2348cf..d5fd35799 100644 --- a/apps/graph/graph/graph_controller.h +++ b/apps/graph/graph/graph_controller.h @@ -15,7 +15,7 @@ namespace Graph { class GraphController : public Shared::FunctionGraphController, public GraphControllerHelper { public: - GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, CartesianFunctionStore * functionStore, Shared::InteractiveCurveViewRange * curveViewRange, Shared::CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * modelVersion, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion, ButtonRowController * header); + GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, Shared::InteractiveCurveViewRange * curveViewRange, Shared::CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * modelVersion, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion, ButtonRowController * header); I18n::Message emptyMessage() override; void viewWillAppear() override; bool displayDerivativeInBanner() const { return m_displayDerivativeInBanner; } diff --git a/apps/graph/graph/graph_view.cpp b/apps/graph/graph/graph_view.cpp index 470183725..5f57ac34c 100644 --- a/apps/graph/graph/graph_view.cpp +++ b/apps/graph/graph/graph_view.cpp @@ -1,14 +1,14 @@ #include "graph_view.h" +#include "../app.h" #include using namespace Shared; namespace Graph { -GraphView::GraphView(CartesianFunctionStore * functionStore, InteractiveCurveViewRange * graphRange, - CurveViewCursor * cursor, BannerView * bannerView, CursorView * cursorView) : +GraphView::GraphView(InteractiveCurveViewRange * graphRange, + CurveViewCursor * cursor, Shared::BannerView * bannerView, CursorView * cursorView) : FunctionGraphView(graphRange, cursor, bannerView, cursorView), - m_functionStore(functionStore), m_tangent(false) { } @@ -23,9 +23,10 @@ void GraphView::reload() { void GraphView::drawRect(KDContext * ctx, KDRect rect) const { FunctionGraphView::drawRect(ctx, rect); - for (int i = 0; i < m_functionStore->numberOfActiveFunctions(); i++) { - Ion::Storage::Record record = m_functionStore->activeRecordAtIndex(i); - ExpiringPointer f = m_functionStore->modelForRecord(record);; + CartesianFunctionStore * functionStore = App::app()->functionStore(); + for (int i = 0; i < functionStore->numberOfActiveFunctions(); i++) { + Ion::Storage::Record record = functionStore->activeRecordAtIndex(i); + ExpiringPointer f = functionStore->modelForRecord(record);; Shared::CartesianFunction::PlotType type = f->plotType(); float tmin = f->tMin(); float tmax = f->tMax(); diff --git a/apps/graph/graph/graph_view.h b/apps/graph/graph/graph_view.h index 23dea0330..c3e190a3a 100644 --- a/apps/graph/graph/graph_view.h +++ b/apps/graph/graph/graph_view.h @@ -2,13 +2,12 @@ #define GRAPH_GRAPH_VIEW_H #include "../../shared/function_graph_view.h" -#include "../cartesian_function_store.h" namespace Graph { class GraphView : public Shared::FunctionGraphView { public: - GraphView(CartesianFunctionStore * functionStore, Shared::InteractiveCurveViewRange * graphRange, + GraphView(Shared::InteractiveCurveViewRange * graphRange, Shared::CurveViewCursor * cursor, Shared::BannerView * bannerView, Shared::CursorView * cursorView); void reload() override; void drawRect(KDContext * ctx, KDRect rect) const override; @@ -19,7 +18,6 @@ public: * of the graph where the area under the curve is colored. */ void setAreaHighlightColor(bool highlightColor) override {}; private: - CartesianFunctionStore * m_functionStore; bool m_tangent; };