From c8206d51f29ebf8bbabaf2fff1f7df8992a3c58d Mon Sep 17 00:00:00 2001 From: Ruben Dashyan Date: Thu, 5 Sep 2019 11:17:43 +0200 Subject: [PATCH] [apps/shared/cartesian_function] Add static ParameterMessageForPlotType method --- apps/shared/cartesian_function.cpp | 21 ++++++++++++--------- apps/shared/cartesian_function.h | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/apps/shared/cartesian_function.cpp b/apps/shared/cartesian_function.cpp index 1196cdf29..70ec010d5 100644 --- a/apps/shared/cartesian_function.cpp +++ b/apps/shared/cartesian_function.cpp @@ -95,15 +95,7 @@ Poincare::Expression CartesianFunction::expressionReduced(Poincare::Context * co } I18n::Message CartesianFunction::parameterMessageName() const { - PlotType type = plotType(); - if (type == PlotType::Cartesian) { - return I18n::Message::X; - } - if (type == PlotType::Polar) { - return I18n::Message::Theta; - } - assert(plotType() == PlotType::Parametric); - return I18n::Message::T; + return ParameterMessageForPlotType(plotType()); } CodePoint CartesianFunction::symbol() const { @@ -161,6 +153,17 @@ void CartesianFunction::setPlotType(PlotType newPlotType) { } } +I18n::Message CartesianFunction::ParameterMessageForPlotType(PlotType plotType) { + if (plotType == PlotType::Cartesian) { + return I18n::Message::X; + } + if (plotType == PlotType::Polar) { + return I18n::Message::Theta; + } + assert(plotType == PlotType::Parametric); + return I18n::Message::T; +} + template Poincare::Coordinate2D CartesianFunction::privateEvaluateXYAtParameter(T t, Poincare::Context * context) const { Coordinate2D x1x2 = templatedApproximateAtParameter(t, context); diff --git a/apps/shared/cartesian_function.h b/apps/shared/cartesian_function.h index 786b1c9fc..d0b9e5b8a 100644 --- a/apps/shared/cartesian_function.h +++ b/apps/shared/cartesian_function.h @@ -27,6 +27,7 @@ public: }; PlotType plotType() const; void setPlotType(PlotType plotType); + static I18n::Message ParameterMessageForPlotType(PlotType plotType); // Evaluation Poincare::Coordinate2D evaluate2DAtParameter(double t, Poincare::Context * context) const {