Numworks Epsilon  1.4.1
Graphing Calculator Operating System
calculation_parameter_controller.cpp
Go to the documentation of this file.
2 #include "graph_controller.h"
3 #include <assert.h>
4 #include <cmath>
5 
6 using namespace Shared;
7 
8 namespace Graph {
9 
10 CalculationParameterController::CalculationParameterController(Responder * parentResponder, GraphView * graphView, BannerView * bannerView, InteractiveCurveViewRange * range, CurveViewCursor * cursor, CartesianFunctionStore * functionStore) :
11  ViewController(parentResponder),
12  m_selectableTableView(this),
13  m_function(nullptr),
14  m_tangentGraphController(nullptr, graphView, bannerView, range, cursor),
15  m_integralGraphController(nullptr, graphView, range, cursor),
16  m_minimumGraphController(nullptr, graphView, bannerView, range, cursor),
17  m_maximumGraphController(nullptr, graphView, bannerView, range, cursor),
18  m_rootGraphController(nullptr, graphView, bannerView, range, cursor),
19  m_intersectionGraphController(nullptr, graphView, bannerView, range, cursor, functionStore)
20 {
21 }
22 
24  return I18n::translate(I18n::Message::Compute);
25 }
26 
28  return &m_selectableTableView;
29 }
30 
32  m_selectableTableView.selectCellAtLocation(0, 0);
33  app()->setFirstResponder(&m_selectableTableView);
34 }
35 
37  if (event == Ion::Events::OK || event == Ion::Events::EXE) {
38  ViewController * controller = nullptr;
39  switch(selectedRow()) {
40  case 0:
41  m_intersectionGraphController.setFunction(m_function);
42  controller = &m_intersectionGraphController;
43  break;
44  case 1:
45  m_maximumGraphController.setFunction(m_function);
46  controller = &m_maximumGraphController;
47  break;
48  case 2:
49  m_minimumGraphController.setFunction(m_function);
50  controller = &m_minimumGraphController;
51  break;
52  case 3:
53  m_rootGraphController.setFunction(m_function);
54  controller = &m_rootGraphController;
55  break;
56  case 4:
57  m_tangentGraphController.setFunction(m_function);
58  controller = &m_tangentGraphController;
59  break;
60  case 5:
61  m_integralGraphController.setFunction(m_function);
62  controller = &m_integralGraphController;
63  break;
64  default:
65  return false;
66  }
67  StackViewController * stack = static_cast<StackViewController *>(parentResponder());
68  stack->pop();
69  stack->pop();
70  stack->push(controller);
71  return true;
72  }
73  if (event == Ion::Events::Left) {
74  StackViewController * stack = static_cast<StackViewController *>(parentResponder());
75  stack->pop();
76  return true;
77  }
78  return false;
79 }
80 
82  return k_totalNumberOfCells;
83 };
84 
85 
87  assert(index >= 0);
88  assert(index < k_totalNumberOfCells);
89  return &m_cells[index];
90 }
91 
93  return k_totalNumberOfCells;
94 }
95 
98 }
99 
101  MessageTableCell * myCell = (MessageTableCell *)cell;
102  I18n::Message titles[k_totalNumberOfCells] = {I18n::Message::Intersection, I18n::Message::Maximum, I18n::Message::Minimum, I18n::Message::Zeros, I18n::Message::Tangent, I18n::Message::Integral};
103  myCell->setMessage(titles[index]);
104 }
105 
107  m_function = function;
108 }
109 
110 }
void setFunction(CartesianFunction *function)
constexpr Event Tangent
Definition: events.h:87
#define assert(e)
Definition: assert.h:9
constexpr Event EXE
Definition: events.h:114
int16_t KDCoordinate
Definition: coordinate.h:6
void push(ViewController *vc, KDColor textColor=Palette::SubTab, KDColor backgroundColor=KDColorWhite, KDColor separatorColor=Palette::GreyBright)
Responder * parentResponder() const
Definition: responder.cpp:12
bool selectCellAtLocation(int i, int j, bool setFirstResponder=true)
void setFunction(CartesianFunction *function)
Definition: app.cpp:9
HighlightCell * reusableCell(int index) override
enum Message uint16_t enum Language uint16_t const char * translate(Message m, Language l=(Language) 0)
Definition: i18n.cpp:5
bool handleEvent(Ion::Events::Event event) override
constexpr Event Left
Definition: events.h:61
void setMessage(I18n::Message message)
static constexpr KDCoordinate ParameterCellHeight
Definition: metric.h:15
void setFirstResponder(Responder *responder)
Definition: app.cpp:62
Definition: view.h:23
void setFunction(Function *function)
App * app()
Definition: responder.cpp:77
constexpr Event OK
Definition: events.h:65
void willDisplayCellForIndex(HighlightCell *cell, int index) override