[apps/graph] Round x before evaluating graph cursor on scroll

Change-Id: I13500669963eb8130e188a898bed0bf63655add6
This commit is contained in:
Hugo Saint-Vignes
2020-07-09 10:14:59 +02:00
committed by Émilie Feral
parent bd2609bcba
commit 9e12b61849
6 changed files with 50 additions and 7 deletions

View File

@@ -2,6 +2,7 @@
#include "function_app.h"
#include <assert.h>
#include <cmath>
#include <ion/display.h>
namespace Shared {
@@ -15,6 +16,10 @@ bool FunctionGoToParameterController::confirmParameterAtIndex(int parameterIndex
assert(parameterIndex == 0);
FunctionApp * myApp = FunctionApp::app();
ExpiringPointer<Function> function = myApp->functionStore()->modelForRecord(m_record);
// If possible, round f so that we go to the evaluation of the displayed f
double pixelWidth = (m_graphRange->xMax() - m_graphRange->xMin()) / Ion::Display::Width;
f = FunctionBannerDelegate::getValueDisplayedOnBanner(f, myApp->localContext(), pixelWidth, false);
Poincare::Coordinate2D<double> xy = function->evaluateXYAtParameter(f, myApp->localContext());
m_cursor->moveTo(f, xy.x1(), xy.x2());
m_graphRange->centerAxisAround(CurveViewRange::Axis::X, m_cursor->x());