[calculation] First version of the TrigonometryListController

This commit is contained in:
Émilie Feral
2019-12-06 15:55:29 +01:00
committed by Léa Saviot
parent 83a29a822b
commit 49d52f293e
9 changed files with 139 additions and 0 deletions

View File

@@ -13,6 +13,9 @@ app_calculation_src = $(addprefix apps/calculation/,\
additional_outputs/expression_with_equal_sign_view.cpp \
additional_outputs/illustrated_list_controller.cpp \
additional_outputs/scrollable_input_exact_approximate_expressions_cell.cpp \
additional_outputs/trigonometry_graph_cell.cpp \
additional_outputs/trigonometry_list_controller.cpp \
additional_outputs/trigonometry_model.cpp \
app.cpp \
edit_expression_controller.cpp \
expression_field.cpp \

View File

@@ -0,0 +1,19 @@
#include "trigonometry_graph_cell.h"
using namespace Shared;
using namespace Poincare;
namespace Calculation {
TrigonometryGraphView::TrigonometryGraphView(TrigonometryModel * model) :
CurveView(model),
m_angle(model)
{
}
void TrigonometryGraphView::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(rect, KDColorWhite);
// TODO
}
}

View File

@@ -0,0 +1,32 @@
#ifndef CALCULATION_ADDITIONAL_OUTPUTS_TRIGONOMETRY_GRAPH_CELL_H
#define CALCULATION_ADDITIONAL_OUTPUTS_TRIGONOMETRY_GRAPH_CELL_H
#include "../../shared/curve_view.h"
#include "trigonometry_model.h"
namespace Calculation {
class TrigonometryGraphView : public Shared::CurveView {
public:
TrigonometryGraphView(TrigonometryModel * model);
void drawRect(KDContext * ctx, KDRect rect) const override;
private:
char * label(Axis axis, int index) const override { return nullptr; }
TrigonometryModel * m_angle;
};
class TrigonometryGraphCell : public HighlightCell {
public:
TrigonometryGraphCell(TrigonometryModel * model) : m_view(model) {}
void setHighlighted(bool highlight) override { return; }
private:
int numberOfSubviews() const override { return 1; }
View * subviewAtIndex(int index) override { return &m_view; }
void layoutSubviews(bool force = false) override { m_view.setFrame(bounds(), force); }
TrigonometryGraphView m_view;
};
}
#endif

View File

@@ -0,0 +1,19 @@
#include "trigonometry_list_controller.h"
#include "../app.h"
using namespace Poincare;
namespace Calculation {
void TrigonometryListController::setExpression(Poincare::Expression e) {
IllustratedListController::setExpression(e.childAtIndex(0));
//TODO
//m_model.setAngle(std::complex<float>(1.2f,2.3f));
Poincare::Context * context = App::app()->localContext();
m_calculationStore.push("sin(θ)", context);
m_calculationStore.push("cos(θ)", context);
m_calculationStore.push("θ", context);
}
}

View File

@@ -0,0 +1,25 @@
#ifndef CALCULATION_ADDITIONAL_OUTPUTS_TRIGONOMETRY_LIST_CONTROLLER_H
#define CALCULATION_ADDITIONAL_OUTPUTS_TRIGONOMETRY_LIST_CONTROLLER_H
#include "trigonometry_graph_cell.h"
#include "trigonometry_model.h"
#include "illustrated_list_controller.h"
namespace Calculation {
class TrigonometryListController : public IllustratedListController {
public:
TrigonometryListController() :
IllustratedListController(nullptr),
m_graphCell(&m_model) {}
void setExpression(Poincare::Expression e) override;
private:
CodePoint expressionSymbol() const override { return UCodePointGreekSmallLetterTheta; }
HighlightCell * illustrationCell() override { return &m_graphCell; }
TrigonometryGraphCell m_graphCell;
TrigonometryModel m_model;
};
}
#endif

View File

@@ -0,0 +1,11 @@
#include "trigonometry_model.h"
namespace Calculation {
TrigonometryModel::TrigonometryModel() :
Shared::CurveViewRange(),
m_angle(NAN)
{
}
}

View File

@@ -0,0 +1,25 @@
#ifndef CALCULATION_ADDITIONAL_OUTPUTS_TRIGONOMETRY_MODEL_H
#define CALCULATION_ADDITIONAL_OUTPUTS_TRIGONOMETRY_MODEL_H
#include "../../shared/curve_view_range.h"
#include <complex>
namespace Calculation {
class TrigonometryModel : public Shared::CurveViewRange {
public:
TrigonometryModel();
// CurveViewRange
float xMin() const override { return -1.5f; }
float xMax() const override { return 1.5f; }
float yMin() const override { return -1.5f; }
float yMax() const override { return 1.5f; }
void setAngle(float f) { m_angle = f; }
private:
float m_angle;
};
}
#endif

View File

@@ -77,6 +77,9 @@ bool HistoryController::handleEvent(Ion::Events::Event event) {
if (additionalInfoType == Expression::AdditionalInformationType::Complex) {
m_complexController.setExpression(calculation->input());
Container::activeApp()->displayModalViewController(&m_complexController, 0.f, 0.f, Metric::CommonTopMargin, Metric::PopUpLeftMargin, 0, Metric::PopUpRightMargin);
} else if (additionalInfoType == Expression::AdditionalInformationType::Trigonometry) {
m_trigonometryController.setExpression(calculation->input());
Container::activeApp()->displayModalViewController(&m_trigonometryController, 0.f, 0.f, Metric::CommonTopMargin, Metric::PopUpLeftMargin, 0, Metric::PopUpRightMargin);
}
} else {
m_selectableTableView.deselectTable();

View File

@@ -6,6 +6,7 @@
#include "calculation_store.h"
#include "selectable_table_view.h"
#include "additional_outputs/complex_list_controller.h"
#include "additional_outputs/trigonometry_list_controller.h"
namespace Calculation {
@@ -38,6 +39,7 @@ private:
HistoryViewCell m_calculationHistory[k_maxNumberOfDisplayedRows];
CalculationStore * m_calculationStore;
ComplexListController m_complexController;
TrigonometryListController m_trigonometryController;
};
}