mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/cartesian_function] When changing plot type, recompute unknowns
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "cartesian_function.h"
|
||||
#include "expression_model_store.h"
|
||||
#include "poincare_helpers.h"
|
||||
#include <apps/constant.h>
|
||||
#include <poincare/derivative.h>
|
||||
#include <poincare/integral.h>
|
||||
#include <poincare/matrix.h>
|
||||
@@ -123,15 +124,29 @@ void CartesianFunction::setPlotType(PlotType newPlotType) {
|
||||
if (newPlotType == currentPlotType) {
|
||||
return;
|
||||
}
|
||||
/* Reset memoized layout. */
|
||||
Expression e = expressionClone();
|
||||
|
||||
recordData()->setPlotType(newPlotType);
|
||||
|
||||
// Recompute the layouts
|
||||
m_model.tidy();
|
||||
|
||||
// Recompute the definition domain
|
||||
double tMin = newPlotType == PlotType::Cartesian ? -INFINITY : 0.0;
|
||||
double tMax = newPlotType == PlotType::Cartesian ? INFINITY : 2.0*M_PI;
|
||||
setTMin(tMin);
|
||||
setTMax(tMax);
|
||||
recordData()->setPlotType(newPlotType);
|
||||
|
||||
/* Recompute the unknowns. For instance, if the function was f(x) = xθ, it is
|
||||
* stored as f(?) = ?θ. When switching to polar type, it should be stored as
|
||||
* f(?) = ?? */
|
||||
constexpr int previousTextContentMaxSize = Constant::MaxSerializedExpressionSize;
|
||||
char previousTextContent[previousTextContentMaxSize];
|
||||
m_model.text(this, previousTextContent, previousTextContentMaxSize, symbol());
|
||||
setContent(previousTextContent);
|
||||
|
||||
// Handle parametric function switch
|
||||
if (currentPlotType == PlotType::Parametric) {
|
||||
Expression e = expressionClone();
|
||||
// Change [x(t) y(t)] to y(t)
|
||||
if (!e.isUninitialized()
|
||||
&& e.type() == ExpressionNode::Type::Matrix
|
||||
@@ -146,6 +161,7 @@ void CartesianFunction::setPlotType(PlotType newPlotType) {
|
||||
}
|
||||
return;
|
||||
} else if (newPlotType == PlotType::Parametric) {
|
||||
Expression e = expressionClone();
|
||||
// Change y(t) to [t y(t)]
|
||||
Matrix newExpr = Matrix::Builder();
|
||||
newExpr.addChildAtIndexInPlace(Symbol::Builder(UCodePointUnknownX), 0, 0);
|
||||
|
||||
@@ -18,8 +18,7 @@ private:
|
||||
|
||||
static constexpr CodePoint UCodePointNull = 0x0;
|
||||
|
||||
/* 0x1 and 0x2 represent soh and stx. They are not used, so we can use them for
|
||||
* another purpose */
|
||||
// 0x1 represents soh. It is not used, so we can use it for another purpose.
|
||||
static constexpr CodePoint UCodePointUnknownX = 0x1;
|
||||
|
||||
static constexpr CodePoint UCodePointTabulation = 0x9;
|
||||
|
||||
Reference in New Issue
Block a user