Merge "[apps/graph/graph] Adjust default trigonometric range to angle unit preference"

This commit is contained in:
Émilie Feral
2017-02-14 15:45:22 +01:00
committed by Gerrit
3 changed files with 16 additions and 6 deletions

View File

@@ -1,4 +1,5 @@
#include "initialisation_parameter_controller.h"
#include "../../apps_container.h"
#include <assert.h>
#include <math.h>
@@ -27,9 +28,14 @@ void InitialisationParameterController::didBecomeFirstResponder() {
bool InitialisationParameterController::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::OK) {
RangeMethodPointer rangeMethods[k_totalNumberOfCells] = {&InteractiveCurveViewRange::setTrigonometric,
&InteractiveCurveViewRange::roundAbscissa, &InteractiveCurveViewRange::normalize, &InteractiveCurveViewRange::setDefault};
(m_graphRange->*rangeMethods[m_selectableTableView.selectedRow()])();
if (m_selectableTableView.selectedRow() == 0) {
AppsContainer * container = (AppsContainer *)app()->container();
m_graphRange->setTrigonometric(container->preferences()->angleUnit());
} else {
RangeMethodPointer rangeMethods[k_totalNumberOfCells-1] = {&InteractiveCurveViewRange::roundAbscissa,
&InteractiveCurveViewRange::normalize, &InteractiveCurveViewRange::setDefault};
(m_graphRange->*rangeMethods[m_selectableTableView.selectedRow()-1])();
}
StackViewController * stack = (StackViewController *)parentResponder();
stack->pop();
return true;

View File

@@ -97,10 +97,13 @@ void InteractiveCurveViewRange::normalize() {
m_yGridUnit = computeGridUnit(Axis::Y, m_yMin, m_yMax);
}
void InteractiveCurveViewRange::setTrigonometric() {
// TODO: if mode == degree, xmin = -600, xmax = 600
void InteractiveCurveViewRange::setTrigonometric(Expression::AngleUnit angleUnit) {
m_xMin = -10.5f;
m_xMax = 10.5f;
if (angleUnit == Expression::AngleUnit::Degree) {
m_xMin = -600;
m_xMax = 600;
}
m_xGridUnit = computeGridUnit(Axis::X, m_xMin, m_xMax);
m_yAuto = false;
m_yMin = -1.6f;

View File

@@ -2,6 +2,7 @@
#define APPS_INTERACTIVE_CURVE_VIEW_RANGE_H
#include <stdint.h>
#include <poincare.h>
#include "memoized_curve_view_range.h"
#include "curve_view_cursor.h"
#include "interactive_curve_view_range_delegate.h"
@@ -23,7 +24,7 @@ public:
void panWithVector(float x, float y);
void roundAbscissa();
void normalize();
void setTrigonometric();
void setTrigonometric(Expression::AngleUnit angleUnit);
virtual void setDefault();
void centerAxisAround(Axis axis, float position);
void panToMakePointVisible(float x, float y, float topMarginRatio, float rightMarginRatio, float bottomMarginRation, float leftMarginRation);