mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps] Graph: create the integral graph controller and add it to the
calculation menu
This commit is contained in:
committed by
EmilieNumworks
parent
c9be0f18bc
commit
e5032b8c30
@@ -12,6 +12,7 @@ app_objs += $(addprefix apps/graph/,\
|
||||
graph/graph_controller.o\
|
||||
graph/graph_controller_helper.o\
|
||||
graph/graph_view.o\
|
||||
graph/integral_graph_controller.o\
|
||||
graph/tangent_graph_controller.o\
|
||||
list/list_controller.o\
|
||||
values/derivative_parameter_controller.o\
|
||||
|
||||
@@ -12,7 +12,8 @@ CalculationParameterController::CalculationParameterController(Responder * paren
|
||||
m_selectableTableView(this, this, 0, 1, Metric::CommonTopMargin, Metric::CommonRightMargin,
|
||||
Metric::CommonBottomMargin, Metric::CommonLeftMargin, this),
|
||||
m_function(nullptr),
|
||||
m_tangentGraphController(nullptr, graphView, bannerView, range, cursor)
|
||||
m_tangentGraphController(nullptr, graphView, bannerView, range, cursor),
|
||||
m_integralGraphController(nullptr, graphView, range, cursor)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -31,19 +32,33 @@ void CalculationParameterController::didBecomeFirstResponder() {
|
||||
|
||||
bool CalculationParameterController::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||
ViewController * controller = nullptr;
|
||||
switch(selectedRow()) {
|
||||
case 4:
|
||||
{
|
||||
m_tangentGraphController.setFunction(m_function);
|
||||
StackViewController * stack = (StackViewController *)parentResponder();
|
||||
stack->pop();
|
||||
stack->pop();
|
||||
stack->push(&m_tangentGraphController);
|
||||
return true;
|
||||
}
|
||||
controller = &m_tangentGraphController;
|
||||
break;
|
||||
case 5:
|
||||
m_integralGraphController.setFunction(m_function);
|
||||
controller = &m_integralGraphController;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
// This is temporary (until the end of development of calculation menu)
|
||||
if (controller == nullptr) {
|
||||
return false;
|
||||
}
|
||||
StackViewController * stack = static_cast<StackViewController *>(parentResponder());
|
||||
stack->pop();
|
||||
stack->pop();
|
||||
stack->push(controller);
|
||||
return true;
|
||||
}
|
||||
if (event == Ion::Events::Left) {
|
||||
StackViewController * stack = static_cast<StackViewController *>(parentResponder());
|
||||
stack->pop();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <escher.h>
|
||||
#include "../cartesian_function.h"
|
||||
#include "tangent_graph_controller.h"
|
||||
#include "integral_graph_controller.h"
|
||||
#include "graph_view.h"
|
||||
#include "banner_view.h"
|
||||
#include "../../i18n.h"
|
||||
@@ -29,6 +30,7 @@ private:
|
||||
SelectableTableView m_selectableTableView;
|
||||
CartesianFunction * m_function;
|
||||
TangentGraphController m_tangentGraphController;
|
||||
IntegralGraphController m_integralGraphController;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
38
apps/graph/graph/integral_graph_controller.cpp
Normal file
38
apps/graph/graph/integral_graph_controller.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "integral_graph_controller.h"
|
||||
#include "../../shared/text_field_delegate.h"
|
||||
#include "../app.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace Shared;
|
||||
using namespace Poincare;
|
||||
|
||||
namespace Graph {
|
||||
|
||||
IntegralGraphController::IntegralGraphController(Responder * parentResponder, GraphView * graphView, InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor) :
|
||||
SumGraphController(parentResponder, graphView, graphRange, cursor, Ion::Charset::Integral)
|
||||
{
|
||||
}
|
||||
|
||||
const char * IntegralGraphController::title() {
|
||||
return I18n::translate(I18n::Message::Integral);
|
||||
}
|
||||
|
||||
I18n::Message IntegralGraphController::legendMessageAtStep(Step step) {
|
||||
switch(step) {
|
||||
case Step::FirstParameter:
|
||||
return I18n::Message::SelectLowerBound;
|
||||
case Step::SecondParameter:
|
||||
return I18n::Message::SelectUpperBound;
|
||||
default:
|
||||
return I18n::Message::Default;
|
||||
}
|
||||
}
|
||||
|
||||
double IntegralGraphController::cursorNextStep(double x, int direction) {
|
||||
return (direction > 0 ? x + m_graphRange->xGridUnit()/k_numberOfCursorStepsInGradUnit : x - m_graphRange->xGridUnit()/k_numberOfCursorStepsInGradUnit);
|
||||
}
|
||||
|
||||
}
|
||||
21
apps/graph/graph/integral_graph_controller.h
Normal file
21
apps/graph/graph/integral_graph_controller.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef GRAPH_INTEGRAL_GRAPH_CONTROLLER_H
|
||||
#define GRAPH_INTEGRAL_GRAPH_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "graph_view.h"
|
||||
#include "../../shared/sum_graph_controller.h"
|
||||
|
||||
namespace Graph {
|
||||
|
||||
class IntegralGraphController : public Shared::SumGraphController {
|
||||
public:
|
||||
IntegralGraphController(Responder * parentResponder, GraphView * graphView, Shared::InteractiveCurveViewRange * graphRange, Shared::CurveViewCursor * cursor);
|
||||
const char * title() override;
|
||||
private:
|
||||
I18n::Message legendMessageAtStep(Step step) override;
|
||||
double cursorNextStep(double position, int direction) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -19,9 +19,9 @@ SumGraphController::SumGraphController(Responder * parentResponder, FunctionGrap
|
||||
m_startSum(NAN),
|
||||
m_endSum(NAN),
|
||||
m_function(nullptr),
|
||||
m_graphRange(range),
|
||||
m_graphView(graphView),
|
||||
m_legendView(this, sumSymbol),
|
||||
m_graphRange(range),
|
||||
m_cursorView()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ protected:
|
||||
double m_startSum;
|
||||
double m_endSum;
|
||||
Function * m_function;
|
||||
InteractiveCurveViewRange * m_graphRange;
|
||||
private:
|
||||
constexpr static float k_cursorTopMarginRatio = 0.07f; // (cursorHeight/2)/graphViewHeight
|
||||
constexpr static float k_cursorRightMarginRatio = 0.04f; // (cursorWidth/2)/graphViewWidth
|
||||
@@ -79,7 +80,6 @@ private:
|
||||
};
|
||||
FunctionGraphView * m_graphView;
|
||||
LegendView m_legendView;
|
||||
InteractiveCurveViewRange * m_graphRange;
|
||||
VerticalCursorView m_cursorView;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user