mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
[apps] Graph: add a submenu calculation parameter controller in the
curve parameter controller
This commit is contained in:
committed by
EmilieNumworks
parent
ef8f5e07c2
commit
6d7d957c8f
@@ -7,6 +7,7 @@ app_objs += $(addprefix apps/graph/,\
|
||||
cartesian_function_store.o\
|
||||
function_title_cell.o\
|
||||
graph/banner_view.o\
|
||||
graph/calculation_parameter_controller.o\
|
||||
graph/curve_parameter_controller.o\
|
||||
graph/graph_controller.o\
|
||||
graph/graph_view.o\
|
||||
|
||||
66
apps/graph/graph/calculation_parameter_controller.cpp
Normal file
66
apps/graph/graph/calculation_parameter_controller.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "calculation_parameter_controller.h"
|
||||
#include <assert.h>
|
||||
#include <cmath>
|
||||
|
||||
using namespace Shared;
|
||||
|
||||
namespace Graph {
|
||||
|
||||
CalculationParameterController::CalculationParameterController(Responder * parentResponder) :
|
||||
ViewController(parentResponder),
|
||||
m_selectableTableView(this, this, 0, 1, Metric::CommonTopMargin, Metric::CommonRightMargin,
|
||||
Metric::CommonBottomMargin, Metric::CommonLeftMargin, this),
|
||||
m_function(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
const char * CalculationParameterController::title() {
|
||||
return I18n::translate(I18n::Message::Compute);
|
||||
}
|
||||
|
||||
View * CalculationParameterController::view() {
|
||||
return &m_selectableTableView;
|
||||
}
|
||||
|
||||
void CalculationParameterController::didBecomeFirstResponder() {
|
||||
m_selectableTableView.selectCellAtLocation(0, 0);
|
||||
app()->setFirstResponder(&m_selectableTableView);
|
||||
}
|
||||
|
||||
bool CalculationParameterController::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int CalculationParameterController::numberOfRows() {
|
||||
return k_totalNumberOfCells;
|
||||
};
|
||||
|
||||
|
||||
HighlightCell * CalculationParameterController::reusableCell(int index) {
|
||||
assert(index >= 0);
|
||||
assert(index < k_totalNumberOfCells);
|
||||
return &m_cells[index];
|
||||
}
|
||||
|
||||
int CalculationParameterController::reusableCellCount() {
|
||||
return k_totalNumberOfCells;
|
||||
}
|
||||
|
||||
KDCoordinate CalculationParameterController::cellHeight() {
|
||||
return Metric::ParameterCellHeight;
|
||||
}
|
||||
|
||||
void CalculationParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||
MessageTableCell * myCell = (MessageTableCell *)cell;
|
||||
I18n::Message titles[k_totalNumberOfCells] = {I18n::Message::Intersection, I18n::Message::Maximum, I18n::Message::Minimum, I18n::Message::Zeros, I18n::Message::Tangent, I18n::Message::Integral};
|
||||
myCell->setMessage(titles[index]);
|
||||
}
|
||||
|
||||
void CalculationParameterController::setFunction(Function * function) {
|
||||
m_function = function;
|
||||
}
|
||||
|
||||
}
|
||||
33
apps/graph/graph/calculation_parameter_controller.h
Normal file
33
apps/graph/graph/calculation_parameter_controller.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef GRAPH_CALCULATION_PARAMETER_CONTROLLER_H
|
||||
#define GRAPH_CALCULATION_PARAMETER_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "../../shared/function.h"
|
||||
#include "../../i18n.h"
|
||||
|
||||
namespace Graph {
|
||||
|
||||
class CalculationParameterController : public ViewController, public SimpleListViewDataSource, public SelectableTableViewDataSource {
|
||||
public:
|
||||
CalculationParameterController(Responder * parentResponder);
|
||||
View * view() override;
|
||||
const char * title() override;
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
void didBecomeFirstResponder() override;
|
||||
int numberOfRows() override;
|
||||
KDCoordinate cellHeight() override;
|
||||
HighlightCell * reusableCell(int index) override;
|
||||
int reusableCellCount() override;
|
||||
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||
void setFunction(Shared::Function * function);
|
||||
private:
|
||||
constexpr static int k_totalNumberOfCells = 6;
|
||||
MessageTableCell m_cells[k_totalNumberOfCells];
|
||||
SelectableTableView m_selectableTableView;
|
||||
Shared::Function * m_function;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,9 @@ CurveParameterController::CurveParameterController(InteractiveCurveViewRange * g
|
||||
FunctionCurveParameterController(graphRange, cursor),
|
||||
m_goToParameterController(this, graphRange, cursor, I18n::Message::X),
|
||||
m_bannerView(bannerView),
|
||||
#if FUNCTION_CALCULATE_MENU
|
||||
m_calculationCell(I18n::Message::Compute),
|
||||
#endif
|
||||
m_derivativeCell(I18n::Message::DerivateNumber)
|
||||
m_derivativeCell(I18n::Message::DerivateNumber),
|
||||
m_calculationParameterController(this)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,19 +34,16 @@ bool CurveParameterController::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE || (event == Ion::Events::Right && selectedRow() == 0)) {
|
||||
#endif
|
||||
switch (selectedRow()) {
|
||||
#if FUNCTION_CALCULATE_MENU
|
||||
case 0:
|
||||
{
|
||||
m_calculationParameterController.setFunction(m_function);
|
||||
StackViewController * stack = (StackViewController *)parentResponder();
|
||||
stack->push(&m_calculationParameterController);
|
||||
return true;
|
||||
}
|
||||
case 1:
|
||||
#else
|
||||
case 0:
|
||||
#endif
|
||||
return handleGotoSelection();
|
||||
#if FUNCTION_CALCULATE_MENU
|
||||
case 2:
|
||||
#else
|
||||
case 1:
|
||||
#endif
|
||||
{
|
||||
m_bannerView->setDisplayDerivative(!m_bannerView->displayDerivative());
|
||||
m_selectableTableView.reloadData();
|
||||
@@ -67,11 +63,7 @@ int CurveParameterController::numberOfRows() {
|
||||
HighlightCell * CurveParameterController::reusableCell(int index) {
|
||||
assert(index >= 0);
|
||||
assert(index < k_totalNumberOfCells);
|
||||
#if FUNCTION_CALCULATE_MENU
|
||||
HighlightCell * cells[] = {&m_calculationCell, &m_goToCell, &m_derivativeCell};
|
||||
#else
|
||||
HighlightCell * cells[] = {&m_goToCell, &m_derivativeCell};
|
||||
#endif
|
||||
return cells[index];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define GRAPH_GRAPH_CURVE_PARAMETER_CONTROLLER_H
|
||||
|
||||
#include "../../shared/function_curve_parameter_controller.h"
|
||||
#include "calculation_parameter_controller.h"
|
||||
#include "banner_view.h"
|
||||
|
||||
namespace Graph {
|
||||
@@ -19,13 +20,10 @@ private:
|
||||
Shared::FunctionGoToParameterController * goToParameterController() override;
|
||||
Shared::FunctionGoToParameterController m_goToParameterController;
|
||||
BannerView * m_bannerView;
|
||||
#if FUNCTION_CALCULATE_MENU
|
||||
constexpr static int k_totalNumberOfCells = 3;
|
||||
MessageTableCellWithChevron m_calculationCell;
|
||||
#else
|
||||
constexpr static int k_totalNumberOfCells = 2;
|
||||
#endif
|
||||
MessageTableCellWithSwitch m_derivativeCell;
|
||||
CalculationParameterController m_calculationParameterController;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ protected:
|
||||
bool handleGotoSelection();
|
||||
MessageTableCellWithChevron m_goToCell;
|
||||
SelectableTableView m_selectableTableView;
|
||||
Function * m_function;
|
||||
private:
|
||||
virtual FunctionGoToParameterController * goToParameterController() = 0;
|
||||
Function * m_function;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user