mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-25 08:41:01 +01:00
[apps/sequence][apps/regression][apps/graph] Move ranges and cursor in
snapshot Change-Id: I3e5a163ae4b3a6860969ef12d939513cffed7710
This commit is contained in:
@@ -6,16 +6,16 @@ using namespace Shared;
|
||||
|
||||
namespace Regression {
|
||||
|
||||
GraphController::GraphController(Responder * parentResponder, ButtonRowController * header, Store * store) :
|
||||
InteractiveCurveViewController(parentResponder, header, store, &m_view),
|
||||
GraphController::GraphController(Responder * parentResponder, ButtonRowController * header, Store * store, CurveViewCursor * cursor) :
|
||||
InteractiveCurveViewController(parentResponder, header, store, &m_view, cursor),
|
||||
m_bannerView(),
|
||||
m_view(store, &m_cursor, &m_bannerView, &m_cursorView),
|
||||
m_view(store, m_cursor, &m_bannerView, &m_cursorView),
|
||||
m_store(store),
|
||||
m_initialisationParameterController(this, m_store),
|
||||
m_predictionParameterController(this, m_store, &m_cursor),
|
||||
m_predictionParameterController(this, m_store, m_cursor),
|
||||
m_selectedDotIndex(-1)
|
||||
{
|
||||
m_store->setCursor(&m_cursor);
|
||||
m_store->setCursor(m_cursor);
|
||||
}
|
||||
|
||||
ViewController * GraphController::initialisationParameterController() {
|
||||
@@ -84,7 +84,7 @@ void GraphController::reloadBannerView() {
|
||||
|
||||
numberOfChar = 0;
|
||||
legend = " x=";
|
||||
float x = m_cursor.x();
|
||||
float x = m_cursor->x();
|
||||
// Display a specific legend if the mean dot is selected
|
||||
if (m_selectedDotIndex == m_store->numberOfPairs()) {
|
||||
constexpr static char legX[] = {Ion::Charset::XBar, ' ', '=', ' ', 0};
|
||||
@@ -103,7 +103,7 @@ void GraphController::reloadBannerView() {
|
||||
|
||||
numberOfChar = 0;
|
||||
legend = " y=";
|
||||
float y = m_cursor.y();
|
||||
float y = m_cursor->y();
|
||||
if (m_selectedDotIndex == m_store->numberOfPairs()) {
|
||||
constexpr static char legY[] = {Ion::Charset::YBar, ' ', '=', ' ', 0};
|
||||
legend = legY;
|
||||
@@ -127,7 +127,7 @@ void GraphController::initRangeParameters() {
|
||||
void GraphController::initCursorParameters() {
|
||||
float x = (m_store->xMin() + m_store->xMax())/2.0f;
|
||||
float y = m_store->yValueForXValue(x);
|
||||
m_cursor.moveTo(x, y);
|
||||
m_cursor->moveTo(x, y);
|
||||
m_store->panToMakePointVisible(x, y, k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio);
|
||||
m_selectedDotIndex = -1;
|
||||
}
|
||||
@@ -137,49 +137,49 @@ bool GraphController::moveCursorHorizontally(int direction) {
|
||||
int dotSelected = m_store->nextDot(direction, m_selectedDotIndex);
|
||||
if (dotSelected >= 0 && dotSelected < m_store->numberOfPairs()) {
|
||||
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);
|
||||
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);
|
||||
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;
|
||||
}
|
||||
float x = direction > 0 ? m_cursor.x() + m_store->xGridUnit()/k_numberOfCursorStepsInGradUnit :
|
||||
m_cursor.x() - m_store->xGridUnit()/k_numberOfCursorStepsInGradUnit;
|
||||
float x = direction > 0 ? m_cursor->x() + m_store->xGridUnit()/k_numberOfCursorStepsInGradUnit :
|
||||
m_cursor->x() - m_store->xGridUnit()/k_numberOfCursorStepsInGradUnit;
|
||||
float y = m_store->yValueForXValue(x);
|
||||
m_cursor.moveTo(x, y);
|
||||
m_cursor->moveTo(x, y);
|
||||
m_store->panToMakePointVisible(x, y, k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GraphController::moveCursorVertically(int direction) {
|
||||
float yRegressionCurve = m_store->yValueForXValue(m_cursor.x());
|
||||
float yRegressionCurve = m_store->yValueForXValue(m_cursor->x());
|
||||
if (m_selectedDotIndex >= 0) {
|
||||
if ((yRegressionCurve - m_cursor.y() > 0) == (direction > 0)) {
|
||||
if ((yRegressionCurve - m_cursor->y() > 0) == (direction > 0)) {
|
||||
m_selectedDotIndex = -1;
|
||||
m_cursor.moveTo(m_cursor.x(), yRegressionCurve);
|
||||
m_store->panToMakePointVisible(m_cursor.x(), m_cursor.y(), k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio);
|
||||
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;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
int dotSelected = m_store->closestVerticalDot(direction, m_cursor.x());
|
||||
int dotSelected = m_store->closestVerticalDot(direction, m_cursor->x());
|
||||
if (dotSelected >= 0 && dotSelected < m_store->numberOfPairs()) {
|
||||
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);
|
||||
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);
|
||||
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