[apps/graph] Fix graph selection when a function is undef

For instance, input f(x)=1/0 and g(x)=1, the graph tab now selects g
correctly
This commit is contained in:
Léa Saviot
2018-06-26 11:37:50 +02:00
committed by Ecco
parent 8c0aae9778
commit a166903659
3 changed files with 19 additions and 1 deletions

View File

@@ -81,7 +81,6 @@ bool GraphController::moveCursorHorizontally(int direction) {
void GraphController::initCursorParameters() {
double x = (interactiveCurveViewRange()->xMin()+interactiveCurveViewRange()->xMax())/2.0f;
selectFunctionWithCursor(0);
TextFieldDelegateApp * myApp = (TextFieldDelegateApp *)app();
int functionIndex = 0;
double y = 0;
@@ -90,6 +89,8 @@ void GraphController::initCursorParameters() {
y = firstFunction->evaluateAtAbscissa(x, myApp->localContext());
} while (std::isnan(y) && functionIndex < functionStore()->numberOfActiveFunctions());
m_cursor->moveTo(x, y);
int functionSelected = functionStore()->activeFunctionStoreIndex(functionIndex-1);
selectFunctionWithCursor(functionSelected < 0 ? 0 : functionSelected);
interactiveCurveViewRange()->panToMakePointVisible(x, y, k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio);
}