From ee1cdea8374b9512e8a55c921576e09ab2989e72 Mon Sep 17 00:00:00 2001 From: Ruben Dashyan Date: Wed, 24 Jul 2019 18:02:07 +0200 Subject: [PATCH] [apps/shared/cartesian_function] Function symbol depends on its plot type --- apps/shared/cartesian_function.cpp | 14 ++++++++++++++ apps/shared/cartesian_function.h | 2 +- ion/include/ion/unicode/code_point.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/shared/cartesian_function.cpp b/apps/shared/cartesian_function.cpp index 5909796d1..fd3c275a8 100644 --- a/apps/shared/cartesian_function.cpp +++ b/apps/shared/cartesian_function.cpp @@ -78,11 +78,25 @@ int CartesianFunction::derivativeNameWithArgument(char * buffer, size_t bufferSi return numberOfChars + derivativeSize; } +CodePoint CartesianFunction::symbol() const { + switch (plotType()) { + case PlotType::Cartesian: + return 'x'; + case PlotType::Polar: + return UCodePointGreekSmallLetterTheta; + default: + assert(plotType() == PlotType::Parametric); + return 't'; + } +} + CartesianFunction::PlotType CartesianFunction::plotType() const { return recordData()->plotType(); } void CartesianFunction::setPlotType(PlotType plotType) { + /* Reset memoized layout. */ + m_model.tidy(); return recordData()->setPlotType(plotType); } diff --git a/apps/shared/cartesian_function.h b/apps/shared/cartesian_function.h index 671921a24..a7aaf85c1 100644 --- a/apps/shared/cartesian_function.h +++ b/apps/shared/cartesian_function.h @@ -14,7 +14,7 @@ public: CartesianFunction(Ion::Storage::Record record = Record()) : Function(record) {} - CodePoint symbol() const override { return 'x'; } + CodePoint symbol() const override; enum class PlotType { Cartesian = 0, diff --git a/ion/include/ion/unicode/code_point.h b/ion/include/ion/unicode/code_point.h index b60b800e8..329aca844 100644 --- a/ion/include/ion/unicode/code_point.h +++ b/ion/include/ion/unicode/code_point.h @@ -32,6 +32,7 @@ static constexpr CodePoint UCodePointRightSystemParenthesis = 0x13; // Used fo static constexpr CodePoint UCodePointMiddleDot = 0xb7; // · static constexpr CodePoint UCodePointMultiplicationSign = 0xd7; // × +static constexpr CodePoint UCodePointGreekSmallLetterTheta = 0x3b8; // θ static constexpr CodePoint UCodePointGreekSmallLetterPi = 0x3c0; // π static constexpr CodePoint UCodePointLatinLetterSmallCapitalE = 0x1d07; // ᴇ static constexpr CodePoint UCodePointScriptSmallE = 0x212f; // ℯ