diff --git a/apps/graph/app.cpp b/apps/graph/app.cpp index 9845cecc1..e64c100ac 100644 --- a/apps/graph/app.cpp +++ b/apps/graph/app.cpp @@ -54,7 +54,7 @@ App::App(Snapshot * snapshot) : m_listFooter(&m_listHeader, &m_listController, &m_listController, ButtonRowController::Position::Bottom, ButtonRowController::Style::EmbossedGray), m_listHeader(&m_listStackViewController, &m_listFooter, &m_listController), m_listStackViewController(&m_tabViewController, &m_listHeader), - m_graphController(&m_graphAlternateEmptyViewController, this, snapshot->graphRange(), snapshot->cursor(), snapshot->indexFunctionSelectedByCursor(), snapshot->modelVersion(), snapshot->previousModelsVersions(), snapshot->rangeVersion(), snapshot->angleUnitVersion(), &m_graphHeader), + m_graphController(&m_graphAlternateEmptyViewController, this, snapshot->graphRange(), snapshot->cursor(), snapshot->indexFunctionSelectedByCursor(), 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 14232d717..36b5a9e7c 100644 --- a/apps/graph/graph/graph_controller.cpp +++ b/apps/graph/graph/graph_controller.cpp @@ -7,8 +7,8 @@ using namespace Shared; namespace Graph { -GraphController::GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, Shared::InteractiveCurveViewRange * curveViewRange, CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * modelVersion, uint32_t * previousModelsVersions, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion, ButtonRowController * header) : - FunctionGraphController(parentResponder, inputEventHandlerDelegate, header, curveViewRange, &m_view, cursor, indexFunctionSelectedByCursor, modelVersion, previousModelsVersions, rangeVersion, angleUnitVersion), +GraphController::GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, Shared::InteractiveCurveViewRange * curveViewRange, CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion, ButtonRowController * header) : + FunctionGraphController(parentResponder, inputEventHandlerDelegate, header, curveViewRange, &m_view, cursor, indexFunctionSelectedByCursor, rangeVersion, angleUnitVersion), m_bannerView(this, inputEventHandlerDelegate, this), m_view(curveViewRange, m_cursor, &m_bannerView, &m_cursorView), m_graphRange(curveViewRange), @@ -79,10 +79,6 @@ double GraphController::defaultCursorT(Ion::Storage::Record record) { return function->tMin(); } -bool GraphController::shouldSetDefaultOnModelChange() const { - return functionStore()->displaysNonCartesianFunctions(); -} - void GraphController::jumpToLeftRightCurve(double t, int direction, int functionsCount, Ion::Storage::Record record) { if (functionsCount == 1) { return; diff --git a/apps/graph/graph/graph_controller.h b/apps/graph/graph/graph_controller.h index 347ceabc6..0d558f211 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, Shared::InteractiveCurveViewRange * curveViewRange, Shared::CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * modelVersion, uint32_t * previousModelsVersions, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion, ButtonRowController * header); + GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, Shared::InteractiveCurveViewRange * curveViewRange, Shared::CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion, ButtonRowController * header); I18n::Message emptyMessage() override; void viewWillAppear() override; bool displayDerivativeInBanner() const { return m_displayDerivativeInBanner; } @@ -34,7 +34,6 @@ private: ContinuousFunctionStore * functionStore() const override { return static_cast(Shared::FunctionGraphController::functionStore()); } bool defaultRangeIsNormalized() const override; void interestingFunctionRange(Shared::ExpiringPointer f, float tMin, float tMax, float step, float * xm, float * xM, float * ym, float * yM) const; - bool shouldSetDefaultOnModelChange() const override; void jumpToLeftRightCurve(double t, int direction, int functionsCount, Ion::Storage::Record record) override; Shared::RoundCursorView m_cursorView; diff --git a/apps/regression/app.cpp b/apps/regression/app.cpp index 9331fdefc..c81fc7596 100644 --- a/apps/regression/app.cpp +++ b/apps/regression/app.cpp @@ -23,7 +23,6 @@ App::Snapshot::Snapshot() : m_store(), m_cursor(), m_graphSelectedDotIndex(-1), - m_modelVersion(0), m_rangeVersion(0), m_selectedSeriesIndex(-1) { @@ -35,7 +34,6 @@ App * App::Snapshot::unpack(Container * container) { void App::Snapshot::reset() { m_store.reset(); - m_modelVersion = 0; m_rangeVersion = 0; setActiveTab(0); } @@ -55,7 +53,7 @@ App::App(Snapshot * snapshot, Poincare::Context * parentContext) : m_calculationController(&m_calculationAlternateEmptyViewController, &m_calculationHeader, snapshot->store()), m_calculationAlternateEmptyViewController(&m_calculationHeader, &m_calculationController, &m_calculationController), m_calculationHeader(&m_tabViewController, &m_calculationAlternateEmptyViewController, &m_calculationController), - m_graphController(&m_graphAlternateEmptyViewController, this, &m_graphHeader, snapshot->store(), snapshot->cursor(), snapshot->modelVersion(), snapshot->previousModelsVersions(), snapshot->rangeVersion(), snapshot->graphSelectedDotIndex(), snapshot->selectedSeriesIndex()), + m_graphController(&m_graphAlternateEmptyViewController, this, &m_graphHeader, snapshot->store(), snapshot->cursor(), snapshot->rangeVersion(), snapshot->graphSelectedDotIndex(), snapshot->selectedSeriesIndex()), 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/regression/app.h b/apps/regression/app.h index 5ebb06f1b..140b83114 100644 --- a/apps/regression/app.h +++ b/apps/regression/app.h @@ -30,15 +30,12 @@ public: Shared::CurveViewCursor * cursor() { return &m_cursor; } int * graphSelectedDotIndex() { return &m_graphSelectedDotIndex; } int * selectedSeriesIndex() { return &m_selectedSeriesIndex; } - uint32_t * modelVersion() { return &m_modelVersion; } - uint32_t * previousModelsVersions() { return m_store.seriesChecksum(); } uint32_t * rangeVersion() { return &m_rangeVersion; } private: void tidy() override; Store m_store; Shared::CurveViewCursor m_cursor; int m_graphSelectedDotIndex; - uint32_t m_modelVersion; uint32_t m_rangeVersion; int m_selectedSeriesIndex; }; diff --git a/apps/regression/graph_controller.cpp b/apps/regression/graph_controller.cpp index 2d936eecd..9e56ce98d 100644 --- a/apps/regression/graph_controller.cpp +++ b/apps/regression/graph_controller.cpp @@ -11,8 +11,8 @@ using namespace Shared; namespace Regression { -GraphController::GraphController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, Store * store, CurveViewCursor * cursor, uint32_t * modelVersion, uint32_t * previousModelsVersions, uint32_t * rangeVersion, int * selectedDotIndex, int * selectedSeriesIndex) : - InteractiveCurveViewController(parentResponder, inputEventHandlerDelegate, header, store, &m_view, cursor, modelVersion, previousModelsVersions, rangeVersion), +GraphController::GraphController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, Store * store, CurveViewCursor * cursor, uint32_t * rangeVersion, int * selectedDotIndex, int * selectedSeriesIndex) : + InteractiveCurveViewController(parentResponder, inputEventHandlerDelegate, header, store, &m_view, cursor, rangeVersion), m_crossCursorView(), m_roundCursorView(), m_bannerView(this, inputEventHandlerDelegate, this), @@ -338,15 +338,6 @@ bool GraphController::moveCursorVertically(int direction) { return false; } -uint32_t GraphController::modelVersion() { - return m_store->storeChecksum(); -} - -uint32_t GraphController::modelVersionAtIndex(int i) { - assert(i < numberOfMemoizedVersions()); - return *(m_store->seriesChecksum() + i); -} - uint32_t GraphController::rangeVersion() { return m_store->rangeChecksum(); } diff --git a/apps/regression/graph_controller.h b/apps/regression/graph_controller.h index 852027573..fbe9b121c 100644 --- a/apps/regression/graph_controller.h +++ b/apps/regression/graph_controller.h @@ -15,7 +15,7 @@ namespace Regression { class GraphController : public Shared::InteractiveCurveViewController { public: - GraphController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, Store * store, Shared::CurveViewCursor * cursor, uint32_t * modelVersion, uint32_t * previousModelsVersions, uint32_t * rangeVersion, int * selectedDotIndex, int * selectedSeriesIndex); + GraphController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, Store * store, Shared::CurveViewCursor * cursor, uint32_t * rangeVersion, int * selectedDotIndex, int * selectedSeriesIndex); bool isEmpty() const override; I18n::Message emptyMessage() override; void viewWillAppear() override; @@ -40,10 +40,7 @@ private: // InteractiveCurveViewController void initCursorParameters() override; - uint32_t modelVersion() override; - uint32_t modelVersionAtIndex(int i) override; uint32_t rangeVersion() override; - size_t numberOfMemoizedVersions() const override { return Store::k_numberOfSeries; } int selectedCurveIndex() const override { return *m_selectedSeriesIndex; } bool closestCurveIndexIsSuitable(int newIndex, int currentIndex) const override; Poincare::Coordinate2D xyValues(int curveIndex, double x, Poincare::Context * context) const override; diff --git a/apps/sequence/app.cpp b/apps/sequence/app.cpp index 3f01d17bc..3a4ee7191 100644 --- a/apps/sequence/app.cpp +++ b/apps/sequence/app.cpp @@ -50,7 +50,7 @@ App::App(Snapshot * snapshot) : m_listFooter(&m_listHeader, &m_listController, &m_listController, ButtonRowController::Position::Bottom, ButtonRowController::Style::EmbossedGray), m_listHeader(nullptr, &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->previousModelsVersions(), snapshot->rangeVersion(), snapshot->angleUnitVersion(), &m_graphHeader), + m_graphController(&m_graphAlternateEmptyViewController, this, snapshot->functionStore(), snapshot->graphRange(), snapshot->cursor(), snapshot->indexFunctionSelectedByCursor(), 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/sequence/graph/graph_controller.cpp b/apps/sequence/graph/graph_controller.cpp index 458218aca..b4643df10 100644 --- a/apps/sequence/graph/graph_controller.cpp +++ b/apps/sequence/graph/graph_controller.cpp @@ -12,8 +12,8 @@ using namespace Poincare; namespace Sequence { -GraphController::GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, SequenceStore * sequenceStore, CurveViewRange * graphRange, CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * modelVersion, uint32_t * previousModelsVersions, uint32_t * rangeVersion, Preferences::AngleUnit * angleUnitVersion, ButtonRowController * header) : - FunctionGraphController(parentResponder, inputEventHandlerDelegate, header, graphRange, &m_view, cursor, indexFunctionSelectedByCursor, modelVersion, previousModelsVersions, rangeVersion, angleUnitVersion), +GraphController::GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, SequenceStore * sequenceStore, CurveViewRange * graphRange, CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * rangeVersion, Preferences::AngleUnit * angleUnitVersion, ButtonRowController * header) : + FunctionGraphController(parentResponder, inputEventHandlerDelegate, header, graphRange, &m_view, cursor, indexFunctionSelectedByCursor, rangeVersion, angleUnitVersion), m_bannerView(this, inputEventHandlerDelegate, this), m_view(sequenceStore, graphRange, m_cursor, &m_bannerView, &m_cursorView), m_graphRange(graphRange), diff --git a/apps/sequence/graph/graph_controller.h b/apps/sequence/graph/graph_controller.h index 76accdee8..cbb17d948 100644 --- a/apps/sequence/graph/graph_controller.h +++ b/apps/sequence/graph/graph_controller.h @@ -14,7 +14,7 @@ namespace Sequence { class GraphController final : public Shared::FunctionGraphController { public: - GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, Shared::SequenceStore * sequenceStore, CurveViewRange * graphRange, Shared::CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * modelVersion, uint32_t * previousModelsVersions, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion, ButtonRowController * header); + GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, Shared::SequenceStore * sequenceStore, CurveViewRange * graphRange, Shared::CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion, ButtonRowController * header); I18n::Message emptyMessage() override; void viewWillAppear() override; TermSumController * termSumController() { return &m_termSumController; } diff --git a/apps/shared/function_app.cpp b/apps/shared/function_app.cpp index b9de91e5a..b66b01d1a 100644 --- a/apps/shared/function_app.cpp +++ b/apps/shared/function_app.cpp @@ -7,18 +7,13 @@ namespace Shared { FunctionApp::Snapshot::Snapshot() : m_cursor(), m_indexFunctionSelectedByCursor(0), - m_modelVersion(0), m_rangeVersion(0), m_angleUnitVersion(Preferences::AngleUnit::Radian) { - assert(m_previousModelsVersions[0] == 0); } void FunctionApp::Snapshot::reset() { m_indexFunctionSelectedByCursor = 0; - m_modelVersion = 0; - assert(sizeof(m_previousModelsVersions) == sizeof(uint32_t) * FunctionGraphController::sNumberOfMemoizedModelVersions); - memset(m_previousModelsVersions, 0, sizeof(m_previousModelsVersions)); m_rangeVersion = 0; setActiveTab(0); } diff --git a/apps/shared/function_app.h b/apps/shared/function_app.h index 4763906b5..df932d2af 100644 --- a/apps/shared/function_app.h +++ b/apps/shared/function_app.h @@ -16,8 +16,6 @@ public: public: Snapshot(); CurveViewCursor * cursor() { return &m_cursor; } - uint32_t * modelVersion() { return &m_modelVersion; } - uint32_t * previousModelsVersions() { return m_previousModelsVersions; } uint32_t * rangeVersion() { return &m_rangeVersion; } Poincare::Preferences::AngleUnit * angleUnitVersion() { return &m_angleUnitVersion; } virtual FunctionStore * functionStore() = 0; @@ -28,8 +26,6 @@ public: CurveViewCursor m_cursor; private: int m_indexFunctionSelectedByCursor; - uint32_t m_modelVersion; - uint32_t m_previousModelsVersions[FunctionGraphController::sNumberOfMemoizedModelVersions]; uint32_t m_rangeVersion; Poincare::Preferences::AngleUnit m_angleUnitVersion; }; diff --git a/apps/shared/function_graph_controller.cpp b/apps/shared/function_graph_controller.cpp index 2ca8ae180..869de86b8 100644 --- a/apps/shared/function_graph_controller.cpp +++ b/apps/shared/function_graph_controller.cpp @@ -11,8 +11,8 @@ using namespace Poincare; namespace Shared { -FunctionGraphController::FunctionGraphController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, InteractiveCurveViewRange * interactiveRange, CurveView * curveView, CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * modelVersion, uint32_t * previousModelsVersions, uint32_t * rangeVersion, Preferences::AngleUnit * angleUnitVersion) : - InteractiveCurveViewController(parentResponder, inputEventHandlerDelegate, header, interactiveRange, curveView, cursor, modelVersion, previousModelsVersions, rangeVersion), +FunctionGraphController::FunctionGraphController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, InteractiveCurveViewRange * interactiveRange, CurveView * curveView, CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * rangeVersion, Preferences::AngleUnit * angleUnitVersion) : + InteractiveCurveViewController(parentResponder, inputEventHandlerDelegate, header, interactiveRange, curveView, cursor, rangeVersion), m_angleUnitVersion(angleUnitVersion), m_indexFunctionSelectedByCursor(indexFunctionSelectedByCursor) { @@ -120,14 +120,6 @@ CurveView * FunctionGraphController::curveView() { return functionGraphView(); } -uint32_t FunctionGraphController::modelVersion() { - return functionStore()->storeChecksum(); -} - -uint32_t FunctionGraphController::modelVersionAtIndex(int i) { - return functionStore()->storeChecksumAtIndex(i); -} - uint32_t FunctionGraphController::rangeVersion() { return interactiveCurveViewRange()->rangeChecksum(); } diff --git a/apps/shared/function_graph_controller.h b/apps/shared/function_graph_controller.h index 2604bd078..fca17d753 100644 --- a/apps/shared/function_graph_controller.h +++ b/apps/shared/function_graph_controller.h @@ -12,8 +12,7 @@ namespace Shared { class FunctionGraphController : public InteractiveCurveViewController, public FunctionBannerDelegate { public: - static constexpr size_t sNumberOfMemoizedModelVersions = 5; - FunctionGraphController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, InteractiveCurveViewRange * interactiveRange, CurveView * curveView, CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * modelVersion, uint32_t * previousModelsVersions, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion); + FunctionGraphController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, InteractiveCurveViewRange * interactiveRange, CurveView * curveView, CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion); bool isEmpty() const override; void didBecomeFirstResponder() override; void viewWillAppear() override; @@ -50,10 +49,7 @@ private: // InteractiveCurveViewController bool moveCursorVertically(int direction) override; - uint32_t modelVersion() override; - uint32_t modelVersionAtIndex(int i) override; uint32_t rangeVersion() override; - size_t numberOfMemoizedVersions() const override { return sNumberOfMemoizedModelVersions; } Poincare::Preferences::AngleUnit * m_angleUnitVersion; int * m_indexFunctionSelectedByCursor; diff --git a/apps/shared/function_store.cpp b/apps/shared/function_store.cpp index 4ef45d956..77ed25132 100644 --- a/apps/shared/function_store.cpp +++ b/apps/shared/function_store.cpp @@ -6,11 +6,4 @@ uint32_t FunctionStore::storeChecksum() { return Ion::Storage::sharedStorage()->checksum(); } -uint32_t FunctionStore::storeChecksumAtIndex(int i) { - if (numberOfActiveFunctions() <= i) { - return 0; - } - return activeRecordAtIndex(i).checksum(); -} - } diff --git a/apps/shared/function_store.h b/apps/shared/function_store.h index 0233a37dd..2790f6703 100644 --- a/apps/shared/function_store.h +++ b/apps/shared/function_store.h @@ -13,7 +13,6 @@ class FunctionStore : public ExpressionModelStore { public: FunctionStore() : ExpressionModelStore() {} uint32_t storeChecksum(); - uint32_t storeChecksumAtIndex(int i); int numberOfActiveFunctions() const { return numberOfModelsSatisfyingTest(&isFunctionActive, nullptr); } diff --git a/apps/shared/interactive_curve_view_controller.cpp b/apps/shared/interactive_curve_view_controller.cpp index fb5fe865a..56ab2d993 100644 --- a/apps/shared/interactive_curve_view_controller.cpp +++ b/apps/shared/interactive_curve_view_controller.cpp @@ -8,11 +8,9 @@ using namespace Poincare; namespace Shared { -InteractiveCurveViewController::InteractiveCurveViewController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, InteractiveCurveViewRange * interactiveRange, CurveView * curveView, CurveViewCursor * cursor, uint32_t * modelVersion, uint32_t * previousModelsVersions, uint32_t * rangeVersion) : +InteractiveCurveViewController::InteractiveCurveViewController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, InteractiveCurveViewRange * interactiveRange, CurveView * curveView, CurveViewCursor * cursor, uint32_t * rangeVersion) : SimpleInteractiveCurveViewController(parentResponder, cursor), ButtonRowDelegate(header, nullptr), - m_modelVersion(modelVersion), - m_previousModelsVersions(previousModelsVersions), m_rangeVersion(rangeVersion), m_rangeParameterController(this, inputEventHandlerDelegate, interactiveRange), m_zoomParameterController(this, interactiveRange, curveView), @@ -135,58 +133,13 @@ Responder * InteractiveCurveViewController::defaultController() { return tabController(); } -bool InteractiveCurveViewController::previousModelsWereAllDeleted() { - bool result = true; - const int modelsCount = numberOfCurves(); - const int memoizationCount = numberOfMemoizedVersions(); - - // Look for a current model that is the same as in the previous version - for (int i = 0; i < modelsCount; i++) { - uint32_t currentVersion = modelVersionAtIndex(i); - for (int j = 0; j < memoizationCount; j++) { - uint32_t * previousVersion = m_previousModelsVersions + j; - if (currentVersion == *previousVersion) { - result = false; - break; - } - } - if (!result) { - break; - } - } - - // Update the memoization - for (int i = 0; i < memoizationCount; i++) { - uint32_t * previousVersion = m_previousModelsVersions + i; - uint32_t newVersion = modelVersionAtIndex(i); - if (*previousVersion != newVersion) { - *previousVersion = newVersion; - } - } - return result; -} - void InteractiveCurveViewController::viewWillAppear() { SimpleInteractiveCurveViewController::viewWillAppear(); - uint32_t newModelVersion = modelVersion(); - if (*m_modelVersion != newModelVersion) { - // Put previousModelsWereAllDeleted first to update the model versions - if (previousModelsWereAllDeleted() || *m_modelVersion == 0 || numberOfCurves() == 1 || shouldSetDefaultOnModelChange()) { - interactiveCurveViewRange()->setDefault(); - } - *m_modelVersion = newModelVersion; - didChangeRange(interactiveCurveViewRange()); - /* Warning: init cursor parameter before reloading banner view. Indeed, - * reloading banner view needs an updated cursor to load the right data. */ - initCursorParameters(); - } - uint32_t newRangeVersion = rangeVersion(); - if (*m_rangeVersion != newRangeVersion) { - *m_rangeVersion = newRangeVersion; - if (!isCursorVisible()) { - initCursorParameters(); - } - } + + /* Warning: init cursor parameter before reloading banner view. Indeed, + * reloading banner view needs an updated cursor to load the right data. */ + initCursorParameters(); + curveView()->setOkView(&m_okView); if (!curveView()->isMainViewSelected()) { curveView()->selectMainView(true); diff --git a/apps/shared/interactive_curve_view_controller.h b/apps/shared/interactive_curve_view_controller.h index aec24ea02..4e8523c91 100644 --- a/apps/shared/interactive_curve_view_controller.h +++ b/apps/shared/interactive_curve_view_controller.h @@ -12,7 +12,7 @@ namespace Shared { class InteractiveCurveViewController : public SimpleInteractiveCurveViewController, public InteractiveCurveViewRangeDelegate, public ButtonRowDelegate, public AlternateEmptyViewDefaultDelegate { public: - InteractiveCurveViewController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, InteractiveCurveViewRange * interactiveRange, CurveView * curveView, CurveViewCursor * cursor, uint32_t * modelVersion, uint32_t * previousModelsVersions, uint32_t * rangeVersion); + InteractiveCurveViewController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, InteractiveCurveViewRange * interactiveRange, CurveView * curveView, CurveViewCursor * cursor, uint32_t * rangeVersion); const char * title() override; bool handleEvent(Ion::Events::Event event) override; @@ -27,8 +27,6 @@ public: Responder * defaultController() override; - bool previousModelsWereAllDeleted(); - void viewWillAppear() override; void viewDidDisappear() override; void willExitResponderChain(Responder * nextFirstResponder) override; @@ -40,8 +38,6 @@ protected: virtual StackViewController * stackController() const; virtual void initCursorParameters() = 0; virtual bool moveCursorVertically(int direction) = 0; - virtual uint32_t modelVersion() = 0; - virtual uint32_t modelVersionAtIndex(int i) = 0; virtual uint32_t rangeVersion() = 0; bool isCursorVisible(); @@ -70,10 +66,6 @@ private: // InteractiveCurveViewRangeDelegate float addMargin(float x, float range, bool isVertical, bool isMin) override; - virtual bool shouldSetDefaultOnModelChange() const { return false; } - virtual size_t numberOfMemoizedVersions() const = 0; - uint32_t * m_modelVersion; - uint32_t * m_previousModelsVersions; uint32_t * m_rangeVersion; RangeParameterController m_rangeParameterController; ZoomParameterController m_zoomParameterController;