mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[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
This commit is contained in:
committed by
RubenNumworks
parent
aab8974934
commit
53705fb333
@@ -133,11 +133,43 @@ Responder * InteractiveCurveViewController::defaultController() {
|
||||
return tabController();
|
||||
}
|
||||
|
||||
bool InteractiveCurveViewController::previousModelsWereAllDeleted() {
|
||||
bool result = true;
|
||||
const int modelsCount = numberOfCurves();
|
||||
const int memoizationCount = numberOfMemoizedVersions();
|
||||
|
||||
// Look for a current model that is the same as in the previous version
|
||||
for (int i = 0; i < modelsCount; i++) {
|
||||
uint32_t currentVersion = modelVersionAtIndex(i);
|
||||
for (int j = 0; j < memoizationCount; j++) {
|
||||
uint32_t * previousVersion = m_previousModelsVersions + j;
|
||||
if (currentVersion == *previousVersion) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Update the memoization
|
||||
for (int i = 0; i < memoizationCount; i++) {
|
||||
uint32_t * previousVersion = m_previousModelsVersions + i;
|
||||
uint32_t newVersion = modelVersionAtIndex(i);
|
||||
if (*previousVersion != newVersion) {
|
||||
*previousVersion = newVersion;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void InteractiveCurveViewController::viewWillAppear() {
|
||||
SimpleInteractiveCurveViewController::viewWillAppear();
|
||||
uint32_t newModelVersion = modelVersion();
|
||||
if (*m_modelVersion != newModelVersion) {
|
||||
if (*m_modelVersion == 0 || numberOfCurves() == 1 || shouldSetDefaultOnModelChange()) {
|
||||
// Put previousModelsWereAllDeleted first to update the model versions
|
||||
if (previousModelsWereAllDeleted() || *m_modelVersion == 0 || numberOfCurves() == 1 || shouldSetDefaultOnModelChange()) {
|
||||
interactiveCurveViewRange()->setDefault();
|
||||
}
|
||||
*m_modelVersion = newModelVersion;
|
||||
|
||||
Reference in New Issue
Block a user