mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/regression] When predicting regression, select the line instead of
dots Change-Id: Ia86c06fa64af8aec68ea9b53ba8534e58be1b64b
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "go_to_parameter_controller.h"
|
||||
#include "graph_controller.h"
|
||||
#include "../apps_container.h"
|
||||
#include <assert.h>
|
||||
#include <float.h>
|
||||
@@ -8,10 +9,11 @@ using namespace Poincare;
|
||||
|
||||
namespace Regression {
|
||||
|
||||
GoToParameterController::GoToParameterController(Responder * parentResponder, Store * store, CurveViewCursor * cursor) :
|
||||
GoToParameterController::GoToParameterController(Responder * parentResponder, Store * store, CurveViewCursor * cursor, GraphController * graphController) :
|
||||
Shared::GoToParameterController(parentResponder, store, cursor, I18n::Message::X),
|
||||
m_store(store),
|
||||
m_xPrediction(true)
|
||||
m_xPrediction(true),
|
||||
m_graphController(graphController)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -50,12 +52,14 @@ bool GoToParameterController::setParameterAtIndex(int parameterIndex, float f) {
|
||||
}
|
||||
if (isnan(x)) {
|
||||
if (m_store->slope() < FLT_EPSILON && f == m_store->yIntercept()) {
|
||||
m_graphController->selectRegressionCurve();
|
||||
m_cursor->moveTo(m_cursor->x(), f);
|
||||
return true;
|
||||
}
|
||||
app()->displayWarning(I18n::Message::ValueNotReachedByRegression);
|
||||
return false;
|
||||
}
|
||||
m_graphController->selectRegressionCurve();
|
||||
if (m_xPrediction) {
|
||||
m_cursor->moveTo(f, x);
|
||||
} else {
|
||||
|
||||
@@ -7,9 +7,11 @@
|
||||
|
||||
namespace Regression {
|
||||
|
||||
class GraphController;
|
||||
|
||||
class GoToParameterController : public Shared::GoToParameterController {
|
||||
public:
|
||||
GoToParameterController(Responder * parentResponder, Store * store, Shared::CurveViewCursor * cursor);
|
||||
GoToParameterController(Responder * parentResponder, Store * store, Shared::CurveViewCursor * cursor, GraphController * graphController);
|
||||
void setXPrediction(bool xPrediction);
|
||||
const char * title() override;
|
||||
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||
@@ -18,6 +20,7 @@ private:
|
||||
bool setParameterAtIndex(int parameterIndex, float f) override;
|
||||
Store * m_store;
|
||||
bool m_xPrediction;
|
||||
GraphController * m_graphController;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ GraphController::GraphController(Responder * parentResponder, ButtonRowControlle
|
||||
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, this),
|
||||
m_selectedDotIndex(-1)
|
||||
{
|
||||
m_store->setCursor(m_cursor);
|
||||
@@ -36,6 +36,10 @@ I18n::Message GraphController::emptyMessage() {
|
||||
return I18n::Message::NoEnoughDataForRegression;
|
||||
}
|
||||
|
||||
void GraphController::selectRegressionCurve() {
|
||||
m_selectedDotIndex = -1;
|
||||
}
|
||||
|
||||
BannerView * GraphController::bannerView() {
|
||||
return &m_bannerView;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
ViewController * initialisationParameterController() override;
|
||||
bool isEmpty() const override;
|
||||
I18n::Message emptyMessage() override;
|
||||
void selectRegressionCurve();
|
||||
private:
|
||||
constexpr static float k_cursorTopMarginRatio = 0.07f; // (cursorHeight/2)/graphViewHeight
|
||||
constexpr static float k_cursorRightMarginRatio = 0.04f; // (cursorWidth/2)/graphViewWidth
|
||||
|
||||
@@ -5,11 +5,11 @@ using namespace Shared;
|
||||
|
||||
namespace Regression {
|
||||
|
||||
PredictionParameterController::PredictionParameterController(Responder * parentResponder, Store * store, CurveViewCursor * cursor) :
|
||||
PredictionParameterController::PredictionParameterController(Responder * parentResponder, Store * store, CurveViewCursor * cursor, GraphController * graphController) :
|
||||
ViewController(parentResponder),
|
||||
m_selectableTableView(this, this, 0, 1, Metric::CommonTopMargin, Metric::CommonRightMargin,
|
||||
Metric::CommonBottomMargin, Metric::CommonLeftMargin, this),
|
||||
m_goToParameterController(this, store, cursor)
|
||||
m_goToParameterController(this, store, cursor, graphController)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
|
||||
namespace Regression {
|
||||
|
||||
class GraphController;
|
||||
|
||||
class PredictionParameterController : public ViewController, public SimpleListViewDataSource, public SelectableTableViewDataSource {
|
||||
public:
|
||||
PredictionParameterController(Responder * parentResponder, Store * store, Shared::CurveViewCursor * cursor);
|
||||
PredictionParameterController(Responder * parentResponder, Store * store, Shared::CurveViewCursor * cursor, GraphController * graphController);
|
||||
View * view() override;
|
||||
const char * title() override;
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
|
||||
Reference in New Issue
Block a user