diff --git a/apps/shared.de.i18n b/apps/shared.de.i18n index d300411ef..46029c6e0 100644 --- a/apps/shared.de.i18n +++ b/apps/shared.de.i18n @@ -29,7 +29,6 @@ CountryWarning1 = "Diese Einstellung definiert die verwendeten" CountryWarning2 = "mathematischen Konventionen." DataNotSuitable = "Daten nicht geeignet" DataTab = "Daten" -DefaultSetting = "Grundeinstellung" Deg = "gra" Deviation = "Varianz" DisplayValues = "Werte anzeigen" diff --git a/apps/shared.en.i18n b/apps/shared.en.i18n index 653ce19cc..d1a10ea3e 100644 --- a/apps/shared.en.i18n +++ b/apps/shared.en.i18n @@ -29,7 +29,6 @@ CountryWarning1 = "This setting defines the" CountryWarning2 = "mathematical conventions used." DataNotSuitable = "Data not suitable" DataTab = "Data" -DefaultSetting = "Basic settings" Deg = "deg" Deviation = "Variance" DisplayValues = "Display values" diff --git a/apps/shared.es.i18n b/apps/shared.es.i18n index 4d9db1574..985c8be44 100644 --- a/apps/shared.es.i18n +++ b/apps/shared.es.i18n @@ -29,7 +29,6 @@ CountryWarning1 = "Este ajuste define las convenciones" CountryWarning2 = "matemáticas utilizadas." DataNotSuitable = "Datos no adecuados" DataTab = "Datos" -DefaultSetting = "Ajustes básicos" Deg = "gra" Deviation = "Varianza" DisplayValues = "Visualizar los valores" diff --git a/apps/shared.fr.i18n b/apps/shared.fr.i18n index 9a04b810c..fc14d2565 100644 --- a/apps/shared.fr.i18n +++ b/apps/shared.fr.i18n @@ -29,7 +29,6 @@ CountryWarning1 = "Ce réglage permet de définir les" CountryWarning2 = "conventions mathématiques utilisées." DataNotSuitable = "Les données ne conviennent pas" DataTab = "Données" -DefaultSetting = "Réglages de base" Deg = "deg" Deviation = "Variance" DisplayValues = "Afficher les valeurs" diff --git a/apps/shared.it.i18n b/apps/shared.it.i18n index 0297dbbc7..1a91cae8f 100644 --- a/apps/shared.it.i18n +++ b/apps/shared.it.i18n @@ -29,7 +29,6 @@ CountryWarning1 = "Questa opzione permette di definire le" CountryWarning2 = "convenzioni matematiche utilizzate." DataNotSuitable = "I dati non sono adeguati" DataTab = "Dati" -DefaultSetting = "Impostazioni di base" Deg = "deg" Deviation = "Varianza" DisplayValues = "Mostra valori" diff --git a/apps/shared.nl.i18n b/apps/shared.nl.i18n index 30d3cfd78..272ae9807 100644 --- a/apps/shared.nl.i18n +++ b/apps/shared.nl.i18n @@ -29,7 +29,6 @@ CountryWarning1 = "Deze instelling definieert de" CountryWarning2 = "gebruikte wiskundige conventies." DataNotSuitable = "Gegevens niet geschikt" DataTab = "Gegevens" -DefaultSetting = "Standaardinstelling" Deg = "deg" Deviation = "Variantie" DisplayValues = "Waarden weergeven" diff --git a/apps/shared.pt.i18n b/apps/shared.pt.i18n index a4fc7603c..fc7470c24 100644 --- a/apps/shared.pt.i18n +++ b/apps/shared.pt.i18n @@ -29,7 +29,6 @@ CountryWarning1 = "Esta opção define as convenções" CountryWarning2 = "matemáticas utilizadas." DataNotSuitable = "Dados não adequados" DataTab = "Dados" -DefaultSetting = "Configurações básicas" Deg = "gra" Deviation = "Variância" DisplayValues = "Exibir os valores" diff --git a/apps/shared.universal.i18n b/apps/shared.universal.i18n index a328de9fe..9c77fe6b4 100644 --- a/apps/shared.universal.i18n +++ b/apps/shared.universal.i18n @@ -114,6 +114,7 @@ ConjCommandWithArg = "conj(z)" CoshCommandWithArg = "cosh(x)" CrossCommandWithArg = "cross(u,v)" D = "d" +DefaultSetting = "Auto" DeterminantCommandWithArg = "det(M)" DiffCommandWithArg = "diff(f(x),x,a)" DiffCommand = "diff(\x11,x,\x11)" diff --git a/apps/shared/interactive_curve_view_controller.cpp b/apps/shared/interactive_curve_view_controller.cpp index 29cb6068d..bb9abd1fe 100644 --- a/apps/shared/interactive_curve_view_controller.cpp +++ b/apps/shared/interactive_curve_view_controller.cpp @@ -15,6 +15,16 @@ InteractiveCurveViewController::InteractiveCurveViewController(Responder * paren m_rangeParameterController(this, inputEventHandlerDelegate, interactiveRange), m_zoomParameterController(this, interactiveRange, curveView), m_interactiveRange(interactiveRange), + m_autoButton(this, I18n::Message::DefaultSetting, Invocation([](void * context, void * sender) { + InteractiveCurveViewController * graphController = (InteractiveCurveViewController *) context; + graphController->autoButtonAction(); + return true; + }, this), KDFont::SmallFont), + m_normalizeButton(this, I18n::Message::Orthonormal, Invocation([](void * context, void * sender) { + InteractiveCurveViewController * graphController = (InteractiveCurveViewController *) context; + graphController->normalizeButtonAction(); + return true; + }, this), KDFont::SmallFont), m_rangeButton(this, I18n::Message::Axis, Invocation([](void * context, void * sender) { InteractiveCurveViewController * graphController = (InteractiveCurveViewController *) context; graphController->rangeParameterController()->setRange(graphController->interactiveRange()); @@ -64,14 +74,18 @@ const char * InteractiveCurveViewController::title() { return I18n::translate(I18n::Message::GraphTab); } +void InteractiveCurveViewController::setCurveViewAsMainView() { + header()->setSelectedButton(-1); + curveView()->selectMainView(true); + Container::activeApp()->setFirstResponder(this); + reloadBannerView(); + curveView()->reload(); +} + bool InteractiveCurveViewController::handleEvent(Ion::Events::Event event) { if (!curveView()->isMainViewSelected()) { if (event == Ion::Events::Down) { - header()->setSelectedButton(-1); - curveView()->selectMainView(true); - Container::activeApp()->setFirstResponder(this); - reloadBannerView(); - curveView()->reload(); + setCurveViewAsMainView(); return true; } if (event == Ion::Events::Up) { @@ -121,11 +135,11 @@ int InteractiveCurveViewController::numberOfButtons(ButtonRowController::Positio if (isEmpty()) { return 0; } - return 2; + return 4; } Button * InteractiveCurveViewController::buttonAtIndex(int index, ButtonRowController::Position position) const { - const Button * buttons[] = {&m_rangeButton, &m_zoomButton}; + const Button * buttons[] = {&m_autoButton, &m_normalizeButton, &m_rangeButton, &m_zoomButton}; return (Button *)buttons[index]; } @@ -275,4 +289,29 @@ float InteractiveCurveViewController::estimatedBannerHeight() const { return BannerView::HeightGivenNumberOfLines(estimatedBannerNumberOfLines()); } +bool InteractiveCurveViewController::autoButtonAction() { + if (m_interactiveRange->zoomAuto()) { + m_interactiveRange->setZoomAuto(false); + } else { + m_interactiveRange->setDefault(); + m_interactiveRange->setZoomAuto(true); + m_interactiveRange->checkForNormalizedRange(); + setCurveViewAsMainView(); + } + return m_interactiveRange->zoomAuto(); +} + +bool InteractiveCurveViewController::normalizeButtonAction() { + if (m_interactiveRange->zoomNormalize()) { + m_interactiveRange->setZoomNormalize(false); + } else { + m_interactiveRange->normalize(); + m_interactiveRange->setZoomAuto(false); + m_interactiveRange->setZoomNormalize(true); + setCurveViewAsMainView(); + } + return m_interactiveRange->zoomNormalize(); +} + + } diff --git a/apps/shared/interactive_curve_view_controller.h b/apps/shared/interactive_curve_view_controller.h index 4e8523c91..fff685f30 100644 --- a/apps/shared/interactive_curve_view_controller.h +++ b/apps/shared/interactive_curve_view_controller.h @@ -66,10 +66,19 @@ private: // InteractiveCurveViewRangeDelegate float addMargin(float x, float range, bool isVertical, bool isMin) override; + void setCurveViewAsMainView(); + + /* Those methods return the new status for the button, ie either + * m_interactiveRange->m_zoomAuto or m_zoomNormalize respectively. */ + bool autoButtonAction(); + bool normalizeButtonAction(); + uint32_t * m_rangeVersion; RangeParameterController m_rangeParameterController; ZoomParameterController m_zoomParameterController; InteractiveCurveViewRange * m_interactiveRange; + Button m_autoButton; + Button m_normalizeButton; Button m_rangeButton; Button m_zoomButton; }; diff --git a/apps/shared/interactive_curve_view_range.cpp b/apps/shared/interactive_curve_view_range.cpp index 3f9f1e6ab..f9ee20cc7 100644 --- a/apps/shared/interactive_curve_view_range.cpp +++ b/apps/shared/interactive_curve_view_range.cpp @@ -81,13 +81,13 @@ void InteractiveCurveViewRange::normalize() { float normalizedXYRatio = newXHalfRange/newYHalfRange; if (xyRatio < normalizedXYRatio) { float newXRange = normalizedXYRatio * yRange; - assert(newXRange > xRange); + assert(newXRange >= xRange); float delta = (newXRange - xRange) / 2.0f; m_xRange.setMin(xMin() - delta, k_lowerMaxFloat, k_upperMaxFloat); MemoizedCurveViewRange::protectedSetXMax(xMax()+delta, k_lowerMaxFloat, k_upperMaxFloat); } else if (xyRatio > normalizedXYRatio) { float newYRange = newYHalfRange/newXHalfRange * xRange; - assert(newYRange > yRange); + assert(newYRange >= yRange); float delta = (newYRange - yRange) / 2.0f; m_yRange.setMin(yMin() - delta, k_lowerMaxFloat, k_upperMaxFloat); MemoizedCurveViewRange::protectedSetYMax(yMax()+delta, k_lowerMaxFloat, k_upperMaxFloat);