[solver] Display the solutions controller when resolving equation system

This commit is contained in:
Émilie Feral
2018-05-30 18:06:51 +02:00
parent 3434202b48
commit b3ce8e2bc9
5 changed files with 32 additions and 5 deletions

View File

@@ -12,9 +12,7 @@ ListController::ListController(Responder * parentResponder, EquationStore * equa
m_equationStore(equationStore),
m_resolveButton(this, I18n::Message::Resolve, Invocation([](void * context, void * sender) {
ListController * list = (ListController *)context;
StackViewController * stackController = list->stackController();
// TODO
//stackController->push(list->solutionPage ??)
list->resolveEquations();
}, this), KDText::FontSize::Small, Palette::PurpleBright),
m_modelsParameterController(this, equationStore, this),
m_modelsStackController(nullptr, &m_modelsParameterController, KDColorWhite, Palette::PurpleDark, Palette::PurpleDark)
@@ -142,6 +140,27 @@ bool ListController::expressionLayoutFieldDidReceiveEvent(ExpressionLayoutField
return false;
}
void ListController::resolveEquations() {
EquationStore::Error e = m_equationStore->exactSolve(static_cast<App *>(app())->localContext());
switch (e) {
case EquationStore::Error::TooManyVariables:
app()->displayWarning(I18n::Message::TooManyVariables);
return;
case EquationStore::Error::NonLinearSystem:
app()->displayWarning(I18n::Message::NonLinearSystem);
return;
case EquationStore::Error::RequireApproximateSolution:
return;
default:
{
assert(e == EquationStore::Error::NoError);
StackViewController * stack = stackController();
App * solverApp = static_cast<App *>(app());
stack->push(solverApp->solutionsControllerStack(), KDColorWhite, Palette::PurpleBright, Palette::PurpleBright);
}
}
}
void ListController::addEmptyModel() {
app()->displayModalViewController(&m_modelsStackController, 0.f, 0.f, Metric::CommonTopMargin, Metric::CommonRightMargin, 0, Metric::CommonLeftMargin);
}