Numworks Epsilon  1.4.1
Graphing Calculator Operating System
values_controller.cpp
Go to the documentation of this file.
1 #include "values_controller.h"
2 #include <assert.h>
3 #include <cmath>
4 
5 using namespace Shared;
6 
7 namespace Sequence {
8 
9 ValuesController::ValuesController(Responder * parentResponder, SequenceStore * sequenceStore, Interval * interval, ButtonRowController * header) :
10  Shared::ValuesController(parentResponder, header, I18n::Message::NColumn, &m_intervalParameterController, interval),
11  m_sequenceTitleCells{},
12  m_floatCells{},
13  m_sequenceStore(sequenceStore),
14 #if COPY_COLUMN
15  m_sequenceParameterController('n'),
16 #endif
17  m_intervalParameterController(this, m_interval)
18 {
19 }
20 
23  // The cell is the abscissa title cell:
24  if (j == 0 && i == 0) {
25  EvenOddMessageTextCell * mytitleCell = (EvenOddMessageTextCell *)cell;
26  mytitleCell->setMessage(I18n::Message::N);
27  return;
28  }
29  // The cell is a function title cell:
30  if (j == 0 && i > 0) {
31  SequenceTitleCell * myCell = (SequenceTitleCell *)cell;
32  Sequence * sequence = m_sequenceStore->activeFunctionAtIndex(i-1);
33  myCell->setExpression(sequence->nameLayout());
34  myCell->setColor(sequence->color());
35  }
36 }
37 
39  if (m_sequenceStore->numberOfDefinedFunctions() == 0) {
40  return I18n::Message::NoSequence;
41  }
42  return I18n::Message::NoActivatedSequence;
43 }
44 
46  return &m_intervalParameterController;
47 }
48 
49 bool ValuesController::setDataAtLocation(double floatBody, int columnIndex, int rowIndex) {
50  if (floatBody < 0) {
51  return false;
52  }
53  return Shared::ValuesController::setDataAtLocation(std::round(floatBody), columnIndex, rowIndex);
54 }
55 
56 int ValuesController::maxNumberOfCells() {
57  return k_maxNumberOfCells;
58 }
59 
60 int ValuesController::maxNumberOfFunctions() {
61  return k_maxNumberOfSequences;
62 }
63 
64 SequenceTitleCell * ValuesController::functionTitleCells(int j) {
65  assert(j >= 0 && j < k_maxNumberOfSequences);
66  return m_sequenceTitleCells[j];
67 }
68 
69 EvenOddBufferTextCell * ValuesController::floatCells(int j) {
70  assert(j >= 0 && j < k_maxNumberOfCells);
71  return m_floatCells[j];
72 }
73 
74 SequenceStore * ValuesController::functionStore() const {
75  return m_sequenceStore;
76 }
77 
78 Shared::ValuesFunctionParameterController * ValuesController::functionParameterController() {
79 #if COPY_COLUMN
80  return &m_sequenceParameterController;
81 #else
82  return nullptr;
83 #endif
84 }
85 
86 View * ValuesController::loadView() {
87  for (int i = 0; i < k_maxNumberOfSequences; i++) {
88  m_sequenceTitleCells[i] = new SequenceTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator);
89  }
90  for (int i = 0; i < k_maxNumberOfCells; i++) {
91  m_floatCells[i] = new EvenOddBufferTextCell();
92  }
94 }
95 
96 void ValuesController::unloadView(View * view) {
97  for (int i = 0; i < k_maxNumberOfCells; i++) {
98  delete m_floatCells[i];
99  m_floatCells[i] = nullptr;
100  }
101  for (int i = 0; i < k_maxNumberOfSequences; i++) {
102  delete m_sequenceTitleCells[i];
103  m_sequenceTitleCells[i] = nullptr;
104  }
106 }
107 
108 }
void setExpression(Poincare::ExpressionLayout *expressionLayout)
Definition: i18n.h:6
#define assert(e)
Definition: assert.h:9
const Event sequence[]
virtual void willDisplayCellAtLocation(HighlightCell *cell, int i, int j) override
ValuesController(Responder *parentResponder, ButtonRowController *header, I18n::Message parameterTitle, IntervalParameterController *intervalParameterController, Interval *interval)
bool setDataAtLocation(double floatBody, int columnIndex, int rowIndex) override
Sequence * activeFunctionAtIndex(int i) override
I18n::Message emptyMessage() override
IntervalParameterController * intervalParameterController() override
#define round(x)
Definition: math.h:192
#define N
Definition: b_log__D.c:69
void setMessage(I18n::Message textContent, KDColor textColor=KDColorBlack)
Definition: app.cpp:7
Definition: view.h:23
void willDisplayCellAtLocation(HighlightCell *cell, int i, int j) override
void unloadView(View *view) override
void setColor(KDColor color) override