diff --git a/apps/calculation/Makefile b/apps/calculation/Makefile index 922c1eb0b..34fa268ab 100644 --- a/apps/calculation/Makefile +++ b/apps/calculation/Makefile @@ -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 \ diff --git a/apps/calculation/additional_outputs/trigonometry_graph_cell.cpp b/apps/calculation/additional_outputs/trigonometry_graph_cell.cpp new file mode 100644 index 000000000..5e3348f6c --- /dev/null +++ b/apps/calculation/additional_outputs/trigonometry_graph_cell.cpp @@ -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 +} + +} diff --git a/apps/calculation/additional_outputs/trigonometry_graph_cell.h b/apps/calculation/additional_outputs/trigonometry_graph_cell.h new file mode 100644 index 000000000..4c5d2c8a1 --- /dev/null +++ b/apps/calculation/additional_outputs/trigonometry_graph_cell.h @@ -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 + diff --git a/apps/calculation/additional_outputs/trigonometry_list_controller.cpp b/apps/calculation/additional_outputs/trigonometry_list_controller.cpp new file mode 100644 index 000000000..6d67decec --- /dev/null +++ b/apps/calculation/additional_outputs/trigonometry_list_controller.cpp @@ -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(1.2f,2.3f)); + + Poincare::Context * context = App::app()->localContext(); + m_calculationStore.push("sin(θ)", context); + m_calculationStore.push("cos(θ)", context); + m_calculationStore.push("θ", context); +} + +} diff --git a/apps/calculation/additional_outputs/trigonometry_list_controller.h b/apps/calculation/additional_outputs/trigonometry_list_controller.h new file mode 100644 index 000000000..d2c2b4392 --- /dev/null +++ b/apps/calculation/additional_outputs/trigonometry_list_controller.h @@ -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 diff --git a/apps/calculation/additional_outputs/trigonometry_model.cpp b/apps/calculation/additional_outputs/trigonometry_model.cpp new file mode 100644 index 000000000..ef7c708c3 --- /dev/null +++ b/apps/calculation/additional_outputs/trigonometry_model.cpp @@ -0,0 +1,11 @@ +#include "trigonometry_model.h" + +namespace Calculation { + +TrigonometryModel::TrigonometryModel() : + Shared::CurveViewRange(), + m_angle(NAN) +{ +} + +} diff --git a/apps/calculation/additional_outputs/trigonometry_model.h b/apps/calculation/additional_outputs/trigonometry_model.h new file mode 100644 index 000000000..54255a2b9 --- /dev/null +++ b/apps/calculation/additional_outputs/trigonometry_model.h @@ -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 + +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 diff --git a/apps/calculation/history_controller.cpp b/apps/calculation/history_controller.cpp index 8d14ac4cf..3c4d40ef3 100644 --- a/apps/calculation/history_controller.cpp +++ b/apps/calculation/history_controller.cpp @@ -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(); diff --git a/apps/calculation/history_controller.h b/apps/calculation/history_controller.h index 2d490d45e..2c8bd630d 100644 --- a/apps/calculation/history_controller.h +++ b/apps/calculation/history_controller.h @@ -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; }; }