[apps/graph] Implement move cursor vertically on graph with

parametric/polar curves
This commit is contained in:
Émilie Feral
2019-08-30 17:12:27 +02:00
parent d5730e2702
commit 0f43a04225
5 changed files with 13 additions and 4 deletions

View File

@@ -66,4 +66,13 @@ bool GraphController::moveCursorHorizontally(int direction) {
return privateMoveCursorHorizontally(m_cursor, direction, m_graphRange, k_numberOfCursorStepsInGradUnit, record);
}
int GraphController::closestCurveIndexVertically(bool goingUp, int currentSelectedCurve, Poincare::Context * context) const {
int nbOfActiveFunctions = functionStore()-> numberOfActiveFunctions();
if (functionStore()->numberOfActiveFunctionsOfType(CartesianFunction::PlotType::Cartesian) == nbOfActiveFunctions) {
return FunctionGraphController::closestCurveIndexVertically(goingUp, currentSelectedCurve, context);
}
int nextActiveFunctionIndex = currentSelectedCurve + (goingUp ? 1 : -1);
return nextActiveFunctionIndex >= nbOfActiveFunctions ? -1 : nextActiveFunctionIndex;
}
}

View File

@@ -27,7 +27,7 @@ private:
BannerView * bannerView() override { return &m_bannerView; }
void reloadBannerView() override;
bool moveCursorHorizontally(int direction) override;
bool moveCursorVertically(int direction) override { return false; } // TODO Emilie
int closestCurveIndexVertically(bool goingUp, int currentSelectedCurve, Poincare::Context * context) const override;
Shared::InteractiveCurveViewRange * interactiveCurveViewRange() override { return m_graphRange; }
GraphView * functionGraphView() override { return &m_view; }
CurveParameterController * curveParameterController() override { return &m_curveParameterController; }

View File

@@ -286,7 +286,7 @@ bool GraphController::moveCursorVertically(int direction) {
// Find the closest regression
int selectedRegressionIndex = *m_selectedDotIndex == -1 ? *m_selectedSeriesIndex : -1;
int closestRegressionSeries = InteractiveCurveViewController::closestCurveIndexVertically(direction > 0, selectedRegressionIndex, context);
int closestRegressionSeries = closestCurveIndexVertically(direction > 0, selectedRegressionIndex, context);
// Find the closest dot
int closestDotSeries = -1;

View File

@@ -150,7 +150,7 @@ void FunctionGraphController::initCursorParameters() {
bool FunctionGraphController::moveCursorVertically(int direction) {
int currentActiveFunctionIndex = indexFunctionSelectedByCursor();
Poincare::Context * context = textFieldDelegateApp()->localContext();
int nextActiveFunctionIndex = InteractiveCurveViewController::closestCurveIndexVertically(direction > 0, currentActiveFunctionIndex, context);
int nextActiveFunctionIndex = closestCurveIndexVertically(direction > 0, currentActiveFunctionIndex, context);
if (nextActiveFunctionIndex < 0) {
return false;
}

View File

@@ -42,7 +42,7 @@ protected:
bool isCursorVisible();
// Closest vertical curve helper
int closestCurveIndexVertically(bool goingUp, int currentSelectedCurve, Poincare::Context * context) const;
virtual int closestCurveIndexVertically(bool goingUp, int currentSelectedCurve, Poincare::Context * context) const;
virtual bool closestCurveIndexIsSuitable(int newIndex, int currentIndex) const = 0;
virtual int selectedCurveIndex() const = 0;
virtual Poincare::Coordinate2D<double> xyValues(int curveIndex, double t, Poincare::Context * context) const = 0;