[apps/reg] Fix cursor navigation bug

When going UP, the cursor was sometimes stuck on a point on a regression, switching
between the point and the regression endlessly. Example data set:
X1 = [1, 2, 3, 4, 5] and Y1 = [1, 5, 6, 77, 5]
This commit is contained in:
Léa Saviot
2018-07-10 15:13:54 +02:00
committed by Émilie Feral
parent 68d915fb3e
commit 42d2a06eee
2 changed files with 6 additions and 6 deletions

View File

@@ -61,7 +61,7 @@ void Store::setSeriesRegressionType(int series, Model::Type type) {
}
}
int Store::closestVerticalRegression(int direction, float x, float y, int currentRegressionSeries, Poincare::Context * globalContext) {
int Store::closestVerticalRegression(int direction, double x, double y, int currentRegressionSeries, Poincare::Context * globalContext) {
int regressionSeries = -1;
float closestDistance = INFINITY;
/* The conditions to test on all the regressions are in this order:
@@ -85,9 +85,9 @@ int Store::closestVerticalRegression(int direction, float x, float y, int curren
/* Dots */
int Store::closestVerticalDot(int direction, float x, float y, int currentSeries, int currentDot, int * nextSeries, Poincare::Context * globalContext) {
float nextX = INFINITY;
float nextY = INFINITY;
int Store::closestVerticalDot(int direction, double x, double y, int currentSeries, int currentDot, int * nextSeries, Poincare::Context * globalContext) {
double nextX = INFINITY;
double nextY = INFINITY;
int selectedDot = -1;
/* The conditions to test on all dots are in this order:
* - if the currentDot is valid, the next series should not be the current series

View File

@@ -30,11 +30,11 @@ public:
}
/* Return the series index of the closest regression at abscissa x, above
* ordinate y if direction > 0, below otherwise */
int closestVerticalRegression(int direction, float x, float y, int currentRegressionSeries, Poincare::Context * globalContext);
int closestVerticalRegression(int direction, double x, double y, int currentRegressionSeries, Poincare::Context * globalContext);
// Dots
/* Return the closest dot to abscissa x above the regression curve if
* direction > 0, below otherwise */
int closestVerticalDot(int direction, float x, float y, int currentSeries, int currentDot, int * nextSeries, Poincare::Context * globalContext);
int closestVerticalDot(int direction, double x, double y, int currentSeries, int currentDot, int * nextSeries, Poincare::Context * globalContext);
/* Return the closest dot to given dot, on the right if direction > 0,
* on the left otherwise */
int nextDot(int series, int direction, int dot);