Files
Upsilon/apps/shared/function_app.cpp
Léa Saviot 53705fb333 [apps/graph_ctrlr] Reload range if no previous model is present
We memoize the checksum of the x first models, and we check that one of
these models is still present when the graph view appears. If so, we do
not reload the range, other wise we reload it.

Scenario:
f(t) = [t^2  t+1] in parametric
Display the graph
f(x) = 1 on ]-inf;0]
g(x) = 2 on [0;inf[
Display the graph -> the range did not change
2020-03-11 11:43:36 +01:00

50 lines
1.6 KiB
C++

#include "function_app.h"
using namespace Poincare;
namespace Shared {
FunctionApp::Snapshot::Snapshot() :
m_cursor(),
m_indexFunctionSelectedByCursor(0),
m_modelVersion(0),
m_rangeVersion(0),
m_angleUnitVersion(Preferences::AngleUnit::Radian)
{
assert(m_previousModelsVersions[0] == 0);
}
void FunctionApp::Snapshot::reset() {
m_indexFunctionSelectedByCursor = 0;
m_modelVersion = 0;
assert(sizeof(m_previousModelsVersions) == sizeof(uint32_t) * FunctionGraphController::sNumberOfMemoizedModelVersions);
memset(m_previousModelsVersions, 0, sizeof(m_previousModelsVersions));
m_rangeVersion = 0;
setActiveTab(0);
}
void FunctionApp::Snapshot::storageDidChangeForRecord(const Ion::Storage::Record record) {
functionStore()->storageDidChangeForRecord(record);
}
void FunctionApp::willBecomeInactive() {
if (m_modalViewController.isDisplayingModal()) {
m_modalViewController.dismissModalViewController(true);
}
if (inputViewController()->isDisplayingModal()) {
inputViewController()->abortEditionAndDismiss();
}
::App::willBecomeInactive();
}
bool FunctionApp::isAcceptableExpression(const Poincare::Expression expression) {
/* We forbid functions whose type is equal because the input "2+f(3)" would be
* simplify to an expression with an nested equal node which makes no sense. */
if (!TextFieldDelegateApp::ExpressionCanBeSerialized(expression, false, Expression(), localContext()) || expression.type() == ExpressionNode::Type::Equal) {
return false;
}
return TextFieldDelegateApp::isAcceptableExpression(expression);
}
}