From 0f1e27b2b64e98efcf93d47e972b05864a90a905 Mon Sep 17 00:00:00 2001 From: Gabriel Ozouf Date: Fri, 2 Oct 2020 17:56:12 +0200 Subject: [PATCH] [apps/sequence] Add Y range to interestingRanges The computation of Sequence's graph default Y range used to rely on Yauto. As this feature does not exist anymore, this work is now done int Sequence::GraphController::interestingRanges. Change-Id: Idba8560d5f25d0bf34dd0e1dd98c2af67f427709 --- apps/sequence/graph/graph_controller.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/sequence/graph/graph_controller.cpp b/apps/sequence/graph/graph_controller.cpp index b4643df10..dda21f17b 100644 --- a/apps/sequence/graph/graph_controller.cpp +++ b/apps/sequence/graph/graph_controller.cpp @@ -60,6 +60,19 @@ void GraphController::interestingRanges(InteractiveCurveViewRange * range) const range->setXMin(nmin); range->setXMax(nmax); + + Context * context = textFieldDelegateApp()->localContext(); + float yMin = FLT_MAX, yMax = -FLT_MAX; + for (int i = 0; i < nbOfActiveModels; i++) { + Shared::Sequence * s = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i)); + Zoom::ValueAtAbscissa evaluation = [](float x, Context * context, const void * auxiliary) { + return static_cast(auxiliary)->evaluateXYAtParameter(x, context).x2(); + }; + Zoom::RefinedYRangeForDisplay(evaluation, nmin, nmax, &yMin, &yMax, context, s); + } + + range->setYMin(yMin); + range->setYMax(yMax); } bool GraphController::textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) {