[apps/probability] Forbid impossible value in parameters and calculation

parameters

Change-Id: I47aae775dc031d5b78d6995ca63f49d537848cb1
This commit is contained in:
Émilie Feral
2017-03-03 10:25:10 +01:00
committed by Romain Goyet
parent f636974c0f
commit 9b2bc019e4
9 changed files with 30 additions and 1 deletions

View File

@@ -203,6 +203,14 @@ bool CalculationController::textFieldDidFinishEditing(TextField * textField, con
App * probaApp = (App *)app();
Context * globalContext = probaApp->container()->globalContext();
float floatBody = Expression::parse(text)->approximate(*globalContext);
if (m_calculation->type() != Calculation::Type::FiniteIntegral && m_highlightedSubviewIndex == 2) {
if (floatBody < 0.0f) {
floatBody = 0.0f;
}
if (floatBody > 1.0f) {
floatBody = 1.0f;
}
}
m_calculation->setParameterAtIndex(floatBody, m_highlightedSubviewIndex-1);
for (int k = 0; k < m_calculation->numberOfParameters(); k++) {
m_contentView.willDisplayEditableCellAtIndex(k);