mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-22 07:10:40 +01:00
[apps] Regression: alternate between round and cross cursor views
This commit is contained in:
committed by
EmilieNumworks
parent
9cd50d8d9a
commit
e6a33772fe
@@ -9,8 +9,10 @@ namespace Regression {
|
||||
|
||||
GraphController::GraphController(Responder * parentResponder, ButtonRowController * header, Store * store, CurveViewCursor * cursor, uint32_t * modelVersion, uint32_t * rangeVersion, int * selectedDotIndex) :
|
||||
InteractiveCurveViewController(parentResponder, header, store, &m_view, cursor, modelVersion, rangeVersion),
|
||||
m_crossCursorView(),
|
||||
m_roundCursorView(Palette::YellowDark),
|
||||
m_bannerView(),
|
||||
m_view(store, m_cursor, &m_bannerView, &m_cursorView),
|
||||
m_view(store, m_cursor, &m_bannerView, &m_crossCursorView),
|
||||
m_store(store),
|
||||
m_initialisationParameterController(this, m_store),
|
||||
m_predictionParameterController(this, m_store, m_cursor, this),
|
||||
@@ -37,8 +39,14 @@ I18n::Message GraphController::emptyMessage() {
|
||||
return I18n::Message::NoEnoughDataForRegression;
|
||||
}
|
||||
|
||||
void GraphController::viewWillAppear() {
|
||||
InteractiveCurveViewController::viewWillAppear();
|
||||
m_view.setCursorView(*m_selectedDotIndex >= 0 ? static_cast<View *>(&m_crossCursorView): static_cast<View *>(&m_roundCursorView));
|
||||
}
|
||||
|
||||
void GraphController::selectRegressionCurve() {
|
||||
*m_selectedDotIndex = -1;
|
||||
m_view.setCursorView(&m_roundCursorView);
|
||||
}
|
||||
|
||||
CurveView * GraphController::curveView() {
|
||||
@@ -177,11 +185,11 @@ void GraphController::initRangeParameters() {
|
||||
}
|
||||
|
||||
void GraphController::initCursorParameters() {
|
||||
double x = (m_store->xMin() + m_store->xMax())/2.0;
|
||||
double y = m_store->yValueForXValue(x);
|
||||
double x = m_store->meanOfColumn(0);
|
||||
double y = m_store->meanOfColumn(1);
|
||||
m_cursor->moveTo(x, y);
|
||||
m_store->panToMakePointVisible(x, y, k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio);
|
||||
selectRegressionCurve();
|
||||
*m_selectedDotIndex = m_store->numberOfPairs();
|
||||
}
|
||||
|
||||
bool GraphController::moveCursorHorizontally(int direction) {
|
||||
@@ -213,7 +221,7 @@ bool GraphController::moveCursorVertically(int direction) {
|
||||
double yRegressionCurve = m_store->yValueForXValue(m_cursor->x());
|
||||
if (*m_selectedDotIndex >= 0) {
|
||||
if ((yRegressionCurve - m_cursor->y() > 0) == (direction > 0)) {
|
||||
*m_selectedDotIndex = -1;
|
||||
selectRegressionCurve();
|
||||
m_cursor->moveTo(m_cursor->x(), yRegressionCurve);
|
||||
m_store->panToMakePointVisible(m_cursor->x(), m_cursor->y(), k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio);
|
||||
return true;
|
||||
@@ -222,18 +230,19 @@ bool GraphController::moveCursorVertically(int direction) {
|
||||
}
|
||||
} else {
|
||||
int dotSelected = m_store->closestVerticalDot(direction, m_cursor->x());
|
||||
if (dotSelected >= 0 && dotSelected < m_store->numberOfPairs()) {
|
||||
if (dotSelected >= 0 && dotSelected <= m_store->numberOfPairs()) {
|
||||
m_view.setCursorView(&m_crossCursorView);
|
||||
if (dotSelected == m_store->numberOfPairs()) {
|
||||
*m_selectedDotIndex = dotSelected;
|
||||
m_cursor->moveTo(m_store->meanOfColumn(0), m_store->meanOfColumn(1));
|
||||
m_store->panToMakePointVisible(m_cursor->x(), m_cursor->y(), k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio);
|
||||
return true;
|
||||
}
|
||||
*m_selectedDotIndex = dotSelected;
|
||||
m_cursor->moveTo(m_store->get(0, *m_selectedDotIndex), m_store->get(1, *m_selectedDotIndex));
|
||||
m_store->panToMakePointVisible(m_cursor->x(), m_cursor->y(), k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio);
|
||||
return true;
|
||||
}
|
||||
if (dotSelected == m_store->numberOfPairs()) {
|
||||
*m_selectedDotIndex = dotSelected;
|
||||
m_cursor->moveTo(m_store->meanOfColumn(0), m_store->meanOfColumn(1));
|
||||
m_store->panToMakePointVisible(m_cursor->x(), m_cursor->y(), k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user