Blame view

build6/epsilon-master/apps/calculation/calculation.h 2.11 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
  #ifndef CALCULATION_CALCULATION_H
  #define CALCULATION_CALCULATION_H
  
  #include <escher.h>
  #include <poincare.h>
  
  namespace Calculation {
  
  class CalculationStore;
  
  class Calculation {
  public:
    enum class EqualSign : uint8_t {
      Unknown,
      Approximation,
      Equal
    };
    Calculation();
    ~Calculation(); // Delete expression and layout, if needed
    Calculation& operator=(const Calculation& other);
    Calculation(const Calculation& other) = delete;
    Calculation(Calculation&& other) = delete;
    Calculation& operator=(Calculation&& other) = delete;
    /* c.reset() is the equivalent of c = Calculation() without copy assingment. */
    void reset();
    void setContent(const char * c, Poincare::Context * context, Poincare::Expression * ansExpression);
    KDCoordinate height(Poincare::Context * context);
    const char * inputText();
    const char * exactOutputText();
    const char * approximateOutputText();
    Poincare::Expression * input();
    Poincare::ExpressionLayout * createInputLayout();
    Poincare::Expression * approximateOutput(Poincare::Context * context);
    Poincare::Expression * exactOutput(Poincare::Context * context);
    Poincare::ExpressionLayout * createExactOutputLayout(Poincare::Context * context);
    Poincare::ExpressionLayout * createApproximateOutputLayout(Poincare::Context * context);
    bool isEmpty();
    void tidy();
    bool shouldOnlyDisplayApproximateOutput(Poincare::Context * context);
    EqualSign exactAndApproximateDisplayedOutputsAreEqual(Poincare::Context * context);
    constexpr static int k_printedExpressionSize = 2*::TextField::maxBufferSize();
  private:
    /* Buffers holding text expressions have to be longer than the text written
     * by user (of maximum length TextField::maxBufferSize()) because when we
     * print an expression we add omitted signs (multiplications, parenthesis...) */
    char m_inputText[k_printedExpressionSize];
    char m_exactOutputText[k_printedExpressionSize];
    char m_approximateOutputText[k_printedExpressionSize];
    Poincare::Expression * m_input;
    Poincare::Expression * m_exactOutput;
    Poincare::Expression * m_approximateOutput;
    KDCoordinate m_height;
    EqualSign m_equalSign;
  };
  
  }
  
  #endif