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:
@@ -21,6 +21,7 @@ const Image * App::Descriptor::icon() {
|
||||
App::Snapshot::Snapshot() :
|
||||
m_store(),
|
||||
m_cursor(),
|
||||
m_graphSelectedDotIndex(-1),
|
||||
m_modelVersion(0),
|
||||
m_rangeVersion(0)
|
||||
{
|
||||
@@ -51,6 +52,10 @@ CurveViewCursor * App::Snapshot::cursor() {
|
||||
return &m_cursor;
|
||||
}
|
||||
|
||||
int * App::Snapshot::graphSelectedDotIndex() {
|
||||
return &m_graphSelectedDotIndex;
|
||||
}
|
||||
|
||||
uint32_t * App::Snapshot::modelVersion() {
|
||||
return &m_modelVersion;
|
||||
}
|
||||
@@ -64,7 +69,7 @@ App::App(Container * container, Snapshot * snapshot) :
|
||||
m_calculationController(&m_calculationAlternateEmptyViewController, &m_calculationHeader, snapshot->store()),
|
||||
m_calculationAlternateEmptyViewController(&m_calculationHeader, &m_calculationController, &m_calculationController),
|
||||
m_calculationHeader(&m_tabViewController, &m_calculationAlternateEmptyViewController, &m_calculationController),
|
||||
m_graphController(&m_graphAlternateEmptyViewController, &m_graphHeader, snapshot->store(), snapshot->cursor(), snapshot->modelVersion(), snapshot->rangeVersion()),
|
||||
m_graphController(&m_graphAlternateEmptyViewController, &m_graphHeader, snapshot->store(), snapshot->cursor(), snapshot->modelVersion(), snapshot->rangeVersion(), snapshot->graphSelectedDotIndex()),
|
||||
m_graphAlternateEmptyViewController(&m_graphHeader, &m_graphController, &m_graphController),
|
||||
m_graphHeader(&m_graphStackViewController, &m_graphAlternateEmptyViewController, &m_graphController),
|
||||
m_graphStackViewController(&m_tabViewController, &m_graphHeader),
|
||||
|
||||
@@ -26,11 +26,13 @@ public:
|
||||
Descriptor * descriptor() override;
|
||||
Store * store();
|
||||
Shared::CurveViewCursor * cursor();
|
||||
int * graphSelectedDotIndex();
|
||||
uint32_t * modelVersion();
|
||||
uint32_t * rangeVersion();
|
||||
private:
|
||||
Store m_store;
|
||||
Shared::CurveViewCursor m_cursor;
|
||||
int m_graphSelectedDotIndex;
|
||||
uint32_t m_modelVersion;
|
||||
uint32_t m_rangeVersion;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Regression {
|
||||
class GraphController : public Shared::InteractiveCurveViewController {
|
||||
|
||||
public:
|
||||
GraphController(Responder * parentResponder, ButtonRowController * header, Store * store, Shared::CurveViewCursor * cursor, uint32_t * modelVersion, uint32_t * rangeVersion);
|
||||
GraphController(Responder * parentResponder, ButtonRowController * header, Store * store, Shared::CurveViewCursor * cursor, uint32_t * modelVersion, uint32_t * rangeVersion, int * selectedDotIndex);
|
||||
ViewController * initialisationParameterController() override;
|
||||
bool isEmpty() const override;
|
||||
I18n::Message emptyMessage() override;
|
||||
@@ -46,7 +46,7 @@ private:
|
||||
PredictionParameterController m_predictionParameterController;
|
||||
/* 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_selectedDotIndex;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user