mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 16:57:31 +01:00
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
50 lines
1.6 KiB
C++
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);
|
|
}
|
|
|
|
}
|