[apps/graph] Do not restrain the cursor to the domain of definition in

the Graph
This commit is contained in:
Émilie Feral
2019-09-02 15:29:14 +02:00
parent a7285ba1ca
commit beac710e0e

View File

@@ -9,9 +9,6 @@ using namespace Poincare;
namespace Graph {
static inline float minFloat(float x, float y) { return x < y ? x : y; }
static inline float maxFloat(float x, float y) { return x > y ? x : y; }
bool GraphControllerHelper::privateMoveCursorHorizontally(Shared::CurveViewCursor * cursor, int direction, Shared::InteractiveCurveViewRange * range, int numberOfStepsInGradUnit, Ion::Storage::Record record) {
ExpiringPointer<CartesianFunction> function = App::app()->functionStore()->modelForRecord(record);
double tCursorPosition = cursor->t();
@@ -20,18 +17,12 @@ bool GraphControllerHelper::privateMoveCursorHorizontally(Shared::CurveViewCurso
double tMax = function->tMax();
double dir = (direction > 0 ? 1.0 : -1.0);
CartesianFunction::PlotType type = function->plotType();
if ((dir > 0 && t >= tMax) || (dir < 0 && t <= tMin)) {
// Stay inside the definition domain
assert((t == tMax) || (t == tMin));
return true;
}
if (type == CartesianFunction::PlotType::Cartesian) {
t+= dir * range->xGridUnit()/numberOfStepsInGradUnit;
} else {
assert(type == CartesianFunction::PlotType::Polar || type == CartesianFunction::PlotType::Parametric);
t += dir * (tMax-tMin)/k_definitionDomainDivisor;
}
t = maxFloat(minFloat(t, tMax), tMin); // Stay inside the definition domain
Coordinate2D<double> xy = function->evaluateXYAtParameter(t, App::app()->localContext());
cursor->moveTo(t, xy.x1(), xy.x2());
return true;