From 936b624fb9ede2691e88208a4ea63eb2fb9feda8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Mon, 23 Sep 2019 11:32:54 +0200 Subject: [PATCH] [apps/graph] Block navigation to definition domain --- apps/graph/graph/graph_controller_helper.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/graph/graph/graph_controller_helper.cpp b/apps/graph/graph/graph_controller_helper.cpp index db5e4a147..f3e61fd8b 100644 --- a/apps/graph/graph/graph_controller_helper.cpp +++ b/apps/graph/graph/graph_controller_helper.cpp @@ -10,6 +10,9 @@ using namespace Poincare; namespace Graph { +static inline double minDouble(double x, double y) { return x < y ? x : y; } +static inline double maxDouble(double x, double y) { return x > y ? x : y; } + bool GraphControllerHelper::privateMoveCursorHorizontally(Shared::CurveViewCursor * cursor, int direction, Shared::InteractiveCurveViewRange * range, int numberOfStepsInGradUnit, Ion::Storage::Record record) { ExpiringPointer function = App::app()->functionStore()->modelForRecord(record); double tCursorPosition = cursor->t(); @@ -19,11 +22,12 @@ bool GraphControllerHelper::privateMoveCursorHorizontally(Shared::CurveViewCurso double dir = (direction > 0 ? 1.0 : -1.0); ContinuousFunction::PlotType type = function->plotType(); if (type == ContinuousFunction::PlotType::Cartesian) { - t+= dir * range->xGridUnit()/numberOfStepsInGradUnit; + t += dir * range->xGridUnit()/numberOfStepsInGradUnit; } else { assert(type == ContinuousFunction::PlotType::Polar || type == ContinuousFunction::PlotType::Parametric); t += dir * (tMax-tMin)/k_definitionDomainDivisor; } + t = maxDouble(tMin, minDouble(tMax, t)); Coordinate2D xy = function->evaluateXYAtParameter(t, App::app()->localContext()); cursor->moveTo(t, xy.x1(), xy.x2()); return true;