Blame view

build2/epsilon-master/apps/graph/values/function_parameter_controller.cpp 2.18 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  #include "function_parameter_controller.h"
  #include "values_controller.h"
  #include <assert.h>
  
  using namespace Shared;
  
  namespace Graph {
  
  FunctionParameterController::FunctionParameterController(ValuesController * valuesController) :
    ValuesFunctionParameterController('x'),
    m_displayDerivativeColumn(I18n::Message::DerivativeFunctionColumn),
    m_cartesianFunction(nullptr),
    m_valuesController(valuesController)
  {
  }
  
  void FunctionParameterController::setFunction(Function * function) {
    m_cartesianFunction = (CartesianFunction *)function;
    ValuesFunctionParameterController::setFunction(function);
  }
  
  bool FunctionParameterController::handleEvent(Ion::Events::Event event) {
    if (event == Ion::Events::OK || event == Ion::Events::EXE) {
      switch (selectedRow()) {
        case 0:
        {
          m_cartesianFunction->setDisplayDerivative(!m_cartesianFunction->displayDerivative());
          m_selectableTableView.reloadData();
          return true;
        }
  #if COPY_COLUMN
      case 1:
      /* TODO: implement function copy column */
        return true;
  #endif
        default:
          assert(false);
          return false;
      }
    }
    return false;
  }
  
  int FunctionParameterController::numberOfRows() {
    return k_totalNumberOfCell;
  };
  
  HighlightCell * FunctionParameterController::reusableCell(int index) {
    assert(index >= 0);
    assert(index < k_totalNumberOfCell);
  #if COPY_COLUMN
    HighlightCell * cells[] = {&m_displayDerivativeColumn, &m_copyColumn};
  #else
    HighlightCell * cells[] = {&m_displayDerivativeColumn};
  #endif
    return cells[index];
  }
  
  int FunctionParameterController::reusableCellCount() {
    return k_totalNumberOfCell;
  }
  
  void FunctionParameterController::viewWillAppear() {
    ValuesFunctionParameterController::viewWillAppear();
    if (m_cartesianFunction->displayDerivative()) {
      m_valuesController->selectCellAtLocation(m_valuesController->selectedColumn()+1, m_valuesController->selectedRow());
    }
  }
  
  void FunctionParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) {
    if (cell == &m_displayDerivativeColumn) {
      SwitchView * switchView = (SwitchView *)m_displayDerivativeColumn.accessoryView();
      switchView->setState(m_cartesianFunction->displayDerivative());
    }
  }
  
  }