Files
Upsilon/apps/regression/graph_controller.h
Gabriel Ozouf 190568ea84 [interactive_curve_view_controller] Fix Cursor
Restore the permanence of the cursor between accesses to the graph
window.
The cursor used to be reset when the models had been modified. As there
is no longer a system in place to track these modifications, we manually
check if there is a curve beneath the cursor before reseting it.

Change-Id: I6f71fc17744b5bf1ee552c82126bb4a08b823629
2020-11-04 15:58:19 +01:00

71 lines
2.6 KiB
C++

#ifndef REGRESSION_GRAPH_CONTROLLER_H
#define REGRESSION_GRAPH_CONTROLLER_H
#include "banner_view.h"
#include "store.h"
#include "graph_options_controller.h"
#include "graph_view.h"
#include "../shared/interactive_curve_view_controller.h"
#include "../shared/curve_view_cursor.h"
#include "../shared/cursor_view.h"
#include "../shared/round_cursor_view.h"
namespace Regression {
class GraphController : public Shared::InteractiveCurveViewController {
public:
GraphController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, Store * store, Shared::CurveViewCursor * cursor, uint32_t * rangeVersion, int * selectedDotIndex, int * selectedSeriesIndex);
bool isEmpty() const override;
I18n::Message emptyMessage() override;
void viewWillAppear() override;
void selectRegressionCurve() { *m_selectedDotIndex = -1; }
int selectedSeriesIndex() const { return *m_selectedSeriesIndex; }
// moveCursorHorizontally and Vertically are public to be used in tests
bool moveCursorHorizontally(int direction, int scrollSpeed = 1) override;
bool moveCursorVertically(int direction) override;
private:
constexpr static int k_maxLegendLength = 16;
constexpr static int k_maxNumberOfCharacters = 50;
Poincare::Context * globalContext();
// SimpleInteractiveCurveViewController
void reloadBannerView() override;
Shared::InteractiveCurveViewRange * interactiveCurveViewRange() override;
Shared::CurveView * curveView() override;
bool handleEnter() override;
// InteractiveCurveViewController
void initCursorParameters() override;
bool isCursorHanging() override;
uint32_t rangeVersion() override;
int selectedCurveIndex() const override { return *m_selectedSeriesIndex; }
bool closestCurveIndexIsSuitable(int newIndex, int currentIndex) const override;
Poincare::Coordinate2D<double> xyValues(int curveIndex, double x, Poincare::Context * context) const override;
double yValue(int curveIndex, double x, Poincare::Context * context) const;
bool suitableYValue(double y) const override;
int numberOfCurves() const override;
int estimatedBannerNumberOfLines() const override;
void setRoundCrossCursorView();
Shared::CursorView m_crossCursorView;
Shared::RoundCursorView m_roundCursorView;
BannerView m_bannerView;
GraphView m_view;
Store * m_store;
GraphOptionsController m_graphOptionsController;
/* The selectedDotIndex is -1 when no dot is selected, m_numberOfPairs when
* the mean dot is selected and the dot index otherwise */
int * m_selectedDotIndex;
int * m_selectedSeriesIndex;
Model::Type m_modelType[Store::k_numberOfSeries];
};
}
#endif