Numworks Epsilon  1.4.1
Graphing Calculator Operating System
function_go_to_parameter_controller.cpp
Go to the documentation of this file.
3 #include <assert.h>
4 #include <cmath>
5 
6 namespace Shared {
7 
9  GoToParameterController(parentResponder, graphRange, cursor, symbol),
10  m_function(nullptr)
11 {
12 }
13 
15  return I18n::translate(I18n::Message::Goto);
16 }
17 
18 double FunctionGoToParameterController::parameterAtIndex(int index) {
19  assert(index == 0);
20  return m_cursor->x();
21 }
22 
23 bool FunctionGoToParameterController::setParameterAtIndex(int parameterIndex, double f) {
24  assert(parameterIndex == 0);
26  float y = m_function->evaluateAtAbscissa(f, myApp->localContext());
28  app()->displayWarning(I18n::Message::ForbiddenValue);
29  return false;
30  }
31  if (std::isnan(y) || std::isinf(y)) {
32  app()->displayWarning(I18n::Message::ValueNotReachedByFunction);
33  return false;
34  }
35  m_cursor->moveTo(f, y);
38  return true;
39 }
40 
42  m_function = function;
43 }
44 
45 }
#define assert(e)
Definition: assert.h:9
#define isinf(x)
Definition: math.h:44
#define fabs(x)
Definition: math.h:178
virtual Poincare::Context * localContext()
enum Message uint16_t enum Language uint16_t const char * translate(Message m, Language l=(Language) 0)
Definition: i18n.cpp:5
void displayWarning(I18n::Message warningMessage)
Definition: app.cpp:97
static constexpr double k_maxDisplayableFloat
InteractiveCurveViewRange * m_graphRange
void moveTo(double x, double y)
#define isnan(x)
Definition: math.h:43
virtual float evaluateAtAbscissa(float x, Poincare::Context *context) const
Definition: function.h:30
void centerAxisAround(Axis axis, float position)
App * app()
Definition: responder.cpp:77
FunctionGoToParameterController(Responder *parentResponder, InteractiveCurveViewRange *graphRange, CurveViewCursor *cursor, I18n::Message symbol)
bool setParameterAtIndex(int parameterIndex, double f) override