mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/reg] Init the graph selected series at cursor initialization
This commit is contained in:
@@ -17,7 +17,7 @@ GraphController::GraphController(Responder * parentResponder, ButtonRowControlle
|
||||
m_initialisationParameterController(this, m_store),
|
||||
m_predictionParameterController(this, m_store, m_cursor, this),
|
||||
m_selectedDotIndex(selectedDotIndex),
|
||||
m_selectedSeries(0) // TODO -1
|
||||
m_selectedSeries(-1)
|
||||
{
|
||||
m_store->setCursor(m_cursor);
|
||||
}
|
||||
@@ -191,7 +191,7 @@ void GraphController::initRangeParameters() {
|
||||
}
|
||||
|
||||
void GraphController::initCursorParameters() {
|
||||
assert(m_selectedSeries >= 0);
|
||||
m_selectedSeries = m_store->indexOfKthNonEmptySeries(0);
|
||||
double x = m_store->meanOfColumn(m_selectedSeries, 0);
|
||||
double y = m_store->meanOfColumn(m_selectedSeries, 1);
|
||||
m_cursor->moveTo(x, y);
|
||||
|
||||
@@ -137,7 +137,7 @@ void Store::setDefault() {
|
||||
}
|
||||
|
||||
bool Store::isEmpty() const {
|
||||
for (int i = 0; i < k_numberOfSeries; i ++) {
|
||||
for (int i = 0; i < k_numberOfSeries; i++) {
|
||||
if (!seriesIsEmpty(i)) {
|
||||
return false;
|
||||
}
|
||||
@@ -145,10 +145,37 @@ bool Store::isEmpty() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
int Store::numberOfNonEmptySeries() const {
|
||||
// TODO Share with stats in FLoatPairStore
|
||||
int nonEmptySeriesCount = 0;
|
||||
for (int i = 0; i< k_numberOfSeries; i++) {
|
||||
if (!seriesIsEmpty(i)) {
|
||||
nonEmptySeriesCount++;
|
||||
}
|
||||
}
|
||||
return nonEmptySeriesCount;
|
||||
}
|
||||
|
||||
bool Store::seriesIsEmpty(int series) const {
|
||||
return numberOfPairsOfSeries(series) < 2;
|
||||
}
|
||||
|
||||
int Store::indexOfKthNonEmptySeries(int k) const {
|
||||
// TODO put in FloatPairStore (it is also in stats/store)
|
||||
assert(k >= 0 && k < numberOfNonEmptySeries());
|
||||
int nonEmptySeriesCount = 0;
|
||||
for (int i = 0; i < k_numberOfSeries; i++) {
|
||||
if (!seriesIsEmpty(i)) {
|
||||
if (nonEmptySeriesCount == k) {
|
||||
return i;
|
||||
}
|
||||
nonEmptySeriesCount++;
|
||||
}
|
||||
}
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Calculations */
|
||||
|
||||
double Store::doubleCastedNumberOfPairsOfSeries(int series) const {
|
||||
|
||||
@@ -23,7 +23,9 @@ public:
|
||||
|
||||
// Series
|
||||
bool isEmpty() const;
|
||||
int numberOfNonEmptySeries() const;
|
||||
bool seriesIsEmpty(int series) const;
|
||||
int indexOfKthNonEmptySeries(int k) const;
|
||||
|
||||
// Calculation
|
||||
double doubleCastedNumberOfPairsOfSeries(int series) const;
|
||||
|
||||
Reference in New Issue
Block a user