[apps/graph] init Range to -5..5 if polar/param

This commit is contained in:
Léa Saviot
2019-09-02 15:19:17 +02:00
parent 27859dc923
commit 18a458bae5
5 changed files with 27 additions and 4 deletions

View File

@@ -34,10 +34,15 @@ void GraphController::viewWillAppear() {
}
float GraphController::interestingXHalfRange() const {
if (displaysNonCartesianFunctions())
{
return 5.0f;
}
float characteristicRange = 0.0f;
Poincare::Context * context = textFieldDelegateApp()->localContext();
for (int i = 0; i < functionStore()->numberOfActiveFunctions(); i++) {
ExpiringPointer<CartesianFunction> f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
CartesianFunctionStore * store = functionStore();
for (int i = 0; i < store->numberOfActiveFunctions(); i++) {
ExpiringPointer<CartesianFunction> f = store->modelForRecord(store->activeRecordAtIndex(i));
float fRange = f->expressionReduced(context).characteristicXRange(context, Poincare::Preferences::sharedPreferences()->angleUnit());
if (!std::isnan(fRange)) {
characteristicRange = maxFloat(fRange, characteristicRange);
@@ -83,4 +88,10 @@ double GraphController::defaultCursorT(Ion::Storage::Record record) {
return function->tMin();
}
bool GraphController::displaysNonCartesianFunctions() const {
CartesianFunctionStore * store = functionStore();
return store->numberOfActiveFunctionsOfType(CartesianFunction::PlotType::Polar) > 0
|| store->numberOfActiveFunctionsOfType(CartesianFunction::PlotType::Parametric) > 0;
}
}