mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/graph] ValuesController: change display of the parametric column -
display only one column for (x;y) values
This commit is contained in:
committed by
LeaNumworks
parent
6a983a5bdf
commit
bf23e0f8da
@@ -1,5 +1,6 @@
|
||||
#include "values_controller.h"
|
||||
#include <assert.h>
|
||||
#include "../../shared/poincare_helpers.h"
|
||||
#include "../../constant.h"
|
||||
#include "../app.h"
|
||||
|
||||
@@ -95,28 +96,11 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in
|
||||
bool isDerivative = false;
|
||||
Ion::Storage::Record record = recordAtColumn(i, &isDerivative);
|
||||
Shared::ExpiringPointer<ContinuousFunction> function = functionStore()->modelForRecord(record);
|
||||
if (function->plotType() == ContinuousFunction::PlotType::Parametric) {
|
||||
bool isX = false;
|
||||
if (i+1 < numberOfColumns() && typeAtLocation(i+1,j) == k_functionTitleCellType) {
|
||||
isX = recordAtColumn(i+1) == record;
|
||||
function = functionStore()->modelForRecord(record); // To pass Expiring pointer assertions
|
||||
}
|
||||
if (isX) {
|
||||
// This is the parametric function x column title
|
||||
function->name(bufferName, bufferNameSize);
|
||||
myFunctionCell->setHorizontalAlignment(1.0f);
|
||||
} else {
|
||||
// This is the parametric function y column title
|
||||
myFunctionCell->setHorizontalAlignment(0.0f);
|
||||
strlcpy(bufferName, "(t)", bufferNameSize);
|
||||
}
|
||||
myFunctionCell->setHorizontalAlignment(0.5f);
|
||||
if (isDerivative) {
|
||||
function->derivativeNameWithArgument(bufferName, bufferNameSize);
|
||||
} else {
|
||||
myFunctionCell->setHorizontalAlignment(0.5f);
|
||||
if (isDerivative) {
|
||||
function->derivativeNameWithArgument(bufferName, bufferNameSize);
|
||||
} else {
|
||||
function->nameWithArgument(bufferName, bufferNameSize);
|
||||
}
|
||||
function->nameWithArgument(bufferName, bufferNameSize);
|
||||
}
|
||||
myFunctionCell->setText(bufferName);
|
||||
myFunctionCell->setColor(function->color());
|
||||
@@ -175,8 +159,7 @@ int ValuesController::numberOfColumnsForRecord(Ion::Storage::Record record) cons
|
||||
ExpiringPointer<ContinuousFunction> f = functionStore()->modelForRecord(record);
|
||||
ContinuousFunction::PlotType plotType = f->plotType();
|
||||
return 1 +
|
||||
(plotType == ContinuousFunction::PlotType::Cartesian && f->displayDerivative()) +
|
||||
(plotType == ContinuousFunction::PlotType::Parametric);
|
||||
(plotType == ContinuousFunction::PlotType::Cartesian && f->displayDerivative());
|
||||
}
|
||||
|
||||
Shared::Interval * ValuesController::intervalAtColumn(int columnIndex) {
|
||||
@@ -228,23 +211,37 @@ ViewController * ValuesController::functionParameterController() {
|
||||
return &m_functionParameterController;
|
||||
}
|
||||
|
||||
double ValuesController::evaluationOfAbscissaAtColumn(double abscissa, int columnIndex) {
|
||||
void ValuesController::printEvaluationOfAbscissaAtColumn(double abscissa, int columnIndex, char * buffer, const int bufferSize) {
|
||||
bool isDerivative = false;
|
||||
double evaluationX = NAN;
|
||||
double evaluationY = NAN;
|
||||
Ion::Storage::Record record = recordAtColumn(columnIndex, &isDerivative);
|
||||
Shared::ExpiringPointer<ContinuousFunction> function = functionStore()->modelForRecord(record);
|
||||
Poincare::Context * context = textFieldDelegateApp()->localContext();
|
||||
bool isParametric = function->plotType() == ContinuousFunction::PlotType::Parametric;
|
||||
if (isDerivative) {
|
||||
return function->approximateDerivative(abscissa, context);
|
||||
evaluationY = function->approximateDerivative(abscissa, context);
|
||||
} else {
|
||||
Poincare::Coordinate2D<double> eval = function->evaluate2DAtParameter(abscissa, context);
|
||||
evaluationY = eval.x2();
|
||||
if (isParametric) {
|
||||
evaluationX = eval.x1();
|
||||
}
|
||||
}
|
||||
Poincare::Coordinate2D<double> eval = function->evaluate2DAtParameter(abscissa, context);
|
||||
if (function->plotType() != ContinuousFunction::PlotType::Parametric
|
||||
|| (columnIndex == numberOfColumns() - 1
|
||||
|| !((typeAtLocation(columnIndex+1, 0) == k_functionTitleCellType)
|
||||
&& recordAtColumn(columnIndex+1) == record)))
|
||||
{
|
||||
return eval.x2();
|
||||
int numberOfChar = 0;
|
||||
if (isParametric) {
|
||||
assert(numberOfChar < bufferSize-1);
|
||||
buffer[numberOfChar++] = '(';
|
||||
numberOfChar += PoincareHelpers::ConvertFloatToText<double>(evaluationX, buffer+numberOfChar, bufferSize-numberOfChar, Preferences::LargeNumberOfSignificantDigits);
|
||||
assert(numberOfChar < bufferSize-1);
|
||||
buffer[numberOfChar++] = ';';
|
||||
}
|
||||
numberOfChar += PoincareHelpers::ConvertFloatToText<double>(evaluationY, buffer+numberOfChar, bufferSize-numberOfChar, Preferences::LargeNumberOfSignificantDigits);
|
||||
if (isParametric) {
|
||||
assert(numberOfChar+1 < bufferSize-1);
|
||||
buffer[numberOfChar++] = ')';
|
||||
buffer[numberOfChar] = 0;
|
||||
}
|
||||
return eval.x1();
|
||||
}
|
||||
|
||||
void ValuesController::setStartEndMessages(Shared::IntervalParameterController * controller, int column) {
|
||||
|
||||
@@ -47,8 +47,8 @@ private:
|
||||
Shared::ContinuousFunction::PlotType plotTypeAtColumn(int * i) const;
|
||||
int maxNumberOfCells() override;
|
||||
int maxNumberOfFunctions() override;
|
||||
double evaluationOfAbscissaAtColumn(double abscissa, int columnIndex) override;
|
||||
Shared::Hideable * hideableCellFromType(HighlightCell * cell, int type);
|
||||
void printEvaluationOfAbscissaAtColumn(double abscissa, int columnIndex, char * buffer, const int bufferSize) override;
|
||||
ContinuousFunctionStore * functionStore() const override { return static_cast<ContinuousFunctionStore *>(Shared::ValuesController::functionStore()); }
|
||||
Shared::BufferFunctionTitleCell * functionTitleCells(int j) override;
|
||||
EvenOddBufferTextCell * floatCells(int j) override;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "values_controller.h"
|
||||
#include <assert.h>
|
||||
#include <cmath>
|
||||
#include "../../shared/poincare_helpers.h"
|
||||
#include "../app.h"
|
||||
|
||||
namespace Sequence {
|
||||
@@ -63,10 +64,10 @@ bool ValuesController::setDataAtLocation(double floatBody, int columnIndex, int
|
||||
return Shared::ValuesController::setDataAtLocation(std::round(floatBody), columnIndex, rowIndex);
|
||||
}
|
||||
|
||||
double ValuesController::evaluationOfAbscissaAtColumn(double abscissa, int columnIndex) {
|
||||
void ValuesController::printEvaluationOfAbscissaAtColumn(double abscissa, int columnIndex, char * buffer, const int bufferSize) {
|
||||
Shared::ExpiringPointer<Sequence> sequence = functionStore()->modelForRecord(recordAtColumn(columnIndex));
|
||||
Poincare::Coordinate2D<double> xy = sequence->evaluateXYAtParameter(abscissa, textFieldDelegateApp()->localContext());
|
||||
return xy.x2();
|
||||
Shared::PoincareHelpers::ConvertFloatToText<double>(xy.x2(), buffer, bufferSize, Poincare::Preferences::LargeNumberOfSignificantDigits);
|
||||
}
|
||||
|
||||
Shared::Interval * ValuesController::intervalAtColumn(int columnIndex) {
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
private:
|
||||
void setStartEndMessages(Shared::IntervalParameterController * controller, int column) override;
|
||||
bool setDataAtLocation(double floatBody, int columnIndex, int rowIndex) override;
|
||||
double evaluationOfAbscissaAtColumn(double abscissa, int columnIndex) override;
|
||||
void printEvaluationOfAbscissaAtColumn(double abscissa, int columnIndex, char * buffer, const int bufferSize) override;
|
||||
Shared::Interval * intervalAtColumn(int columnIndex) override;
|
||||
I18n::Message valuesParameterMessageAtColumn(int columnIndex) const override;
|
||||
int maxNumberOfCells() override { return k_maxNumberOfCells; }
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "values_controller.h"
|
||||
#include "function_app.h"
|
||||
#include "poincare_helpers.h"
|
||||
#include <poincare/preferences.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -125,14 +124,13 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in
|
||||
willDisplayCellAtLocationWithDisplayMode(cell, i, j, Preferences::sharedPreferences()->displayMode());
|
||||
// The cell is not a title cell and not editable
|
||||
if (typeAtLocation(i,j) == k_notEditableValueCellType) {
|
||||
constexpr int precision = Preferences::LargeNumberOfSignificantDigits;
|
||||
char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(precision)];
|
||||
char buffer[2*PrintFloat::bufferSizeForFloatsWithPrecision(Preferences::LargeNumberOfSignificantDigits)+3];//(??;??)
|
||||
// Special case: last row
|
||||
if (j == numberOfElementsInColumn(i) + 1) {
|
||||
buffer[0] = 0;
|
||||
} else {
|
||||
double x = intervalAtColumn(i)->element(j-1);
|
||||
PoincareHelpers::ConvertFloatToText<double>(evaluationOfAbscissaAtColumn(x, i), buffer, cellBufferSize(i), precision);
|
||||
printEvaluationOfAbscissaAtColumn(x, i, buffer, cellBufferSize(i));
|
||||
}
|
||||
static_cast<EvenOddBufferTextCell *>(cell)->setText(buffer);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ private:
|
||||
Responder * tabController() const override;
|
||||
bool cellAtLocationIsEditable(int columnIndex, int rowIndex) override;
|
||||
double dataAtLocation(int columnIndex, int rowIndex) override;
|
||||
virtual double evaluationOfAbscissaAtColumn(double abscissa, int columnIndex) = 0;
|
||||
virtual void printEvaluationOfAbscissaAtColumn(double abscissa, int columnIndex, char * buffer, const int bufferSize) = 0;
|
||||
virtual Interval * intervalAtColumn(int columnIndex) = 0;
|
||||
virtual I18n::Message valuesParameterMessageAtColumn(int columnIndex) const = 0;
|
||||
int maxNumberOfElements() const override {
|
||||
|
||||
Reference in New Issue
Block a user