[apps/graph/graph] Define PreimageParameterController class

This commit is contained in:
Ruben Dashyan
2019-04-02 11:41:52 +02:00
committed by Émilie Feral
parent e0774cba4b
commit 23fd28b3b4
3 changed files with 85 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ app_src += $(addprefix apps/graph/,\
graph/graph_controller_helper.cpp \
graph/graph_view.cpp \
graph/preimage_graph_controller.cpp\
graph/preimage_parameter_controller.cpp\
graph/integral_graph_controller.cpp \
graph/intersection_graph_controller.cpp \
graph/root_graph_controller.cpp \

View File

@@ -0,0 +1,53 @@
#include "preimage_parameter_controller.h"
#include "../app.h"
#include <assert.h>
namespace Graph {
PreimageParameterController::PreimageParameterController(
Responder * parentResponder,
InputEventHandlerDelegate * inputEventHandlerDelegate,
Shared::InteractiveCurveViewRange * graphRange,
Shared::CurveViewCursor * cursor,
PreimageGraphController * preimageGraphController
) :
Shared::GoToParameterController(
parentResponder,
inputEventHandlerDelegate,
graphRange,
cursor,
I18n::Message::Y
),
m_preimageGraphController(preimageGraphController)
{
}
const char * PreimageParameterController::title() {
return I18n::translate(I18n::Message::Preimage);
}
void PreimageParameterController::viewWillAppear() {
m_preimageGraphController->setImage(m_cursor->y());
Shared::GoToParameterController::viewWillAppear();
}
void PreimageParameterController::buttonAction() {
m_preimageGraphController->setRecord(m_record);
StackViewController * stack = static_cast<StackViewController *>(parentResponder());
stack->pop();
stack->pop();
stack->pop();
stack->push(m_preimageGraphController);
}
double PreimageParameterController::parameterAtIndex(int index) {
assert(index == 0);
return m_preimageGraphController->image();
}
bool PreimageParameterController::setParameterAtIndex(int parameterIndex, double f) {
assert(parameterIndex == 0);
m_preimageGraphController->setImage(f);
return true;
}
}

View File

@@ -0,0 +1,31 @@
#ifndef GRAPH_PREIMAGE_PARAMETER_CONTROLLER
#define GRAPH_PREIMAGE_PARAMETER_CONTROLLER
#include "../../shared/go_to_parameter_controller.h"
#include "preimage_graph_controller.h"
namespace Graph {
class PreimageParameterController : public Shared::GoToParameterController {
public:
PreimageParameterController(
Responder * parentResponder,
InputEventHandlerDelegate * inputEventHandlerDelegate,
Shared::InteractiveCurveViewRange * graphRange,
Shared::CurveViewCursor * cursor,
PreimageGraphController * preimageGraphController
);
const char * title() override;
void setRecord(Ion::Storage::Record record) { m_record = record; }
void viewWillAppear() override;
private:
void buttonAction() override;
double parameterAtIndex(int index) override;
bool setParameterAtIndex(int parameterIndex, double f) override;
Ion::Storage::Record m_record;
PreimageGraphController * m_preimageGraphController;
};
}
#endif