[shared] Create helper functions for ranges

These functions are used to test the full algorithm used to compute
ranges.

Change-Id: I48069e245aa6e879f66aecc29709fc6f992f5220
This commit is contained in:
Gabriel Ozouf
2020-11-26 15:01:08 +01:00
committed by LeaNumworks
parent 1e7babadb8
commit a9aeae94df
4 changed files with 66 additions and 46 deletions

View File

@@ -154,27 +154,8 @@ int FunctionGraphController::numberOfCurves() const {
}
void FunctionGraphController::interestingRanges(InteractiveCurveViewRange * range) {
Poincare::Context * context = textFieldDelegateApp()->localContext();
constexpr int maxLength = 10;
float xMins[maxLength], xMaxs[maxLength], yMins[maxLength], yMaxs[maxLength];
int length = functionStore()->numberOfActiveFunctions();
float ratio = InteractiveCurveViewRange::NormalYXRatio() / (1 + cursorTopMarginRatio() + cursorBottomMarginRatio());
for (int i = 0; i < length; i++) {
ExpiringPointer<Function> f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
f->rangeForDisplay(xMins + i, xMaxs + i, yMins + i, yMaxs + i, ratio, context);
}
float xMin, xMax, yMin, yMax;
Poincare::Zoom::CombineRanges(length, xMins, xMaxs, &xMin, &xMax);
Poincare::Zoom::CombineRanges(length, yMins, yMaxs, &yMin, &yMax);
Poincare::Zoom::SanitizeRange(&xMin, &xMax, &yMin, &yMax, range->NormalYXRatio());
range->setXMin(xMin);
range->setXMax(xMax);
range->setYMin(yMin);
range->setYMax(yMax);
InterestingRangesHelper(range, textFieldDelegateApp()->localContext(), functionStore(), ratio);
}
}