mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/regression] In graph, make selected dot persistent in snapshot
Change-Id: I0d1ca7bd45678861c946b2c1e6d580b9537089e2
This commit is contained in:
@@ -6,14 +6,14 @@ using namespace Shared;
|
||||
|
||||
namespace Regression {
|
||||
|
||||
GraphController::GraphController(Responder * parentResponder, ButtonRowController * header, Store * store, CurveViewCursor * cursor, uint32_t * modelVersion, uint32_t * rangeVersion) :
|
||||
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_bannerView(),
|
||||
m_view(store, m_cursor, &m_bannerView, &m_cursorView),
|
||||
m_store(store),
|
||||
m_initialisationParameterController(this, m_store),
|
||||
m_predictionParameterController(this, m_store, m_cursor, this),
|
||||
m_selectedDotIndex(-1)
|
||||
m_selectedDotIndex(selectedDotIndex)
|
||||
{
|
||||
m_store->setCursor(m_cursor);
|
||||
}
|
||||
@@ -37,7 +37,7 @@ I18n::Message GraphController::emptyMessage() {
|
||||
}
|
||||
|
||||
void GraphController::selectRegressionCurve() {
|
||||
m_selectedDotIndex = -1;
|
||||
*m_selectedDotIndex = -1;
|
||||
}
|
||||
|
||||
BannerView * GraphController::bannerView() {
|
||||
@@ -66,18 +66,18 @@ void GraphController::reloadBannerView() {
|
||||
int legendLength = strlen(legend);
|
||||
strlcpy(buffer, legend, legendLength+1);
|
||||
numberOfChar += legendLength;
|
||||
if (m_selectedDotIndex == m_store->numberOfPairs()) {
|
||||
if (*m_selectedDotIndex == m_store->numberOfPairs()) {
|
||||
legend = I18n::translate(I18n::Message::MeanDot);
|
||||
legendLength = strlen(legend);
|
||||
strlcpy(buffer+numberOfChar, legend, legendLength+1);
|
||||
numberOfChar += legendLength;
|
||||
} else if (m_selectedDotIndex < 0) {
|
||||
} else if (*m_selectedDotIndex < 0) {
|
||||
legend = I18n::translate(I18n::Message::Reg);
|
||||
legendLength = strlen(legend);
|
||||
strlcpy(buffer+numberOfChar, legend, legendLength+1);
|
||||
numberOfChar += legendLength;
|
||||
} else {
|
||||
numberOfChar += Complex::convertFloatToText(roundf((float)m_selectedDotIndex+1.0f), buffer+numberOfChar, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Expression::FloatDisplayMode::Decimal);
|
||||
numberOfChar += Complex::convertFloatToText(roundf((float)*m_selectedDotIndex+1.0f), buffer+numberOfChar, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Expression::FloatDisplayMode::Decimal);
|
||||
}
|
||||
legend = ") ";
|
||||
legendLength = strlen(legend);
|
||||
@@ -89,7 +89,7 @@ void GraphController::reloadBannerView() {
|
||||
legend = "x=";
|
||||
float x = m_cursor->x();
|
||||
// Display a specific legend if the mean dot is selected
|
||||
if (m_selectedDotIndex == m_store->numberOfPairs()) {
|
||||
if (*m_selectedDotIndex == m_store->numberOfPairs()) {
|
||||
constexpr static char legX[] = {Ion::Charset::XBar, '=', 0};
|
||||
legend = legX;
|
||||
x = m_store->meanOfColumn(0);
|
||||
@@ -107,7 +107,7 @@ void GraphController::reloadBannerView() {
|
||||
numberOfChar = 0;
|
||||
legend = "y=";
|
||||
float y = m_cursor->y();
|
||||
if (m_selectedDotIndex == m_store->numberOfPairs()) {
|
||||
if (*m_selectedDotIndex == m_store->numberOfPairs()) {
|
||||
constexpr static char legY[] = {Ion::Charset::YBar, '=', 0};
|
||||
legend = legY;
|
||||
y = m_store->meanOfColumn(1);
|
||||
@@ -184,20 +184,20 @@ void GraphController::initCursorParameters() {
|
||||
float y = m_store->yValueForXValue(x);
|
||||
m_cursor->moveTo(x, y);
|
||||
m_store->panToMakePointVisible(x, y, k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio);
|
||||
m_selectedDotIndex = -1;
|
||||
selectRegressionCurve();
|
||||
}
|
||||
|
||||
bool GraphController::moveCursorHorizontally(int direction) {
|
||||
if (m_selectedDotIndex >= 0) {
|
||||
int dotSelected = m_store->nextDot(direction, m_selectedDotIndex);
|
||||
if (*m_selectedDotIndex >= 0) {
|
||||
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_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_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;
|
||||
@@ -214,9 +214,9 @@ bool GraphController::moveCursorHorizontally(int direction) {
|
||||
|
||||
bool GraphController::moveCursorVertically(int direction) {
|
||||
float yRegressionCurve = m_store->yValueForXValue(m_cursor->x());
|
||||
if (m_selectedDotIndex >= 0) {
|
||||
if (*m_selectedDotIndex >= 0) {
|
||||
if ((yRegressionCurve - m_cursor->y() > 0) == (direction > 0)) {
|
||||
m_selectedDotIndex = -1;
|
||||
*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);
|
||||
return true;
|
||||
@@ -226,13 +226,13 @@ bool GraphController::moveCursorVertically(int direction) {
|
||||
} else {
|
||||
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_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_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;
|
||||
|
||||
Reference in New Issue
Block a user