[function_graph_controller] Fix Y range expansion

The method FunctionGraphController::yRangeForCursorFirstMove expands the
Y range to include the values of the first cursor moves on the left and
the right of the center. It has been modified to preserve
orthonormality.

Change-Id: I898ab9721e45e2acde261f8b94b80cab81b39a92
This commit is contained in:
Gabriel Ozouf
2020-10-12 10:11:27 +02:00
committed by Émilie Feral
parent f54b15b9c8
commit bcb4b3095b
3 changed files with 11 additions and 2 deletions

View File

@@ -165,6 +165,8 @@ void FunctionGraphController::yRangeForCursorFirstMove(InteractiveCurveViewRange
float cursorStep = range->xGridUnit() / k_numberOfCursorStepsInGradUnit;
float yN, yP;
bool normalized = range->isOrthonormal();
for (int i = 0; i < functionsCount; i++) {
ExpiringPointer<Function> f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
yN = f->evaluateXYAtParameter(range->xCenter() - cursorStep, context).x2();
@@ -172,6 +174,10 @@ void FunctionGraphController::yRangeForCursorFirstMove(InteractiveCurveViewRange
range->setYMin(std::min(range->yMin(), std::min(yN, yP)));
range->setYMax(std::max(range->yMax(), std::max(yN, yP)));
}
if (normalized) {
range->normalize();
}
}
}