Rename Shared::CartesianFunction to Shared::ContinuousFunction

This commit is contained in:
Ruben Dashyan
2019-09-09 15:55:56 +02:00
committed by LeaNumworks
parent be019cd5cf
commit df2897925b
30 changed files with 170 additions and 162 deletions

View File

@@ -33,7 +33,7 @@ App * App::Snapshot::unpack(Container * container) {
void App::Snapshot::reset() {
Shared::FunctionApp::Snapshot::reset();
for (int i = 0; i < Shared::CartesianFunction::k_numberOfPlotTypes; i++) {
for (int i = 0; i < Shared::ContinuousFunction::k_numberOfPlotTypes; i++) {
m_interval[i].reset();
}
}

View File

@@ -27,14 +27,14 @@ public:
Descriptor * descriptor() override;
ContinuousFunctionStore * functionStore() override { return &m_functionStore; }
Shared::InteractiveCurveViewRange * graphRange() { return &m_graphRange; }
Shared::Interval * intervalForType(Shared::CartesianFunction::PlotType plotType) {
Shared::Interval * intervalForType(Shared::ContinuousFunction::PlotType plotType) {
return m_interval + static_cast<size_t>(plotType);
}
private:
void tidy() override;
ContinuousFunctionStore m_functionStore;
Shared::InteractiveCurveViewRange m_graphRange;
Shared::Interval m_interval[Shared::CartesianFunction::k_numberOfPlotTypes];
Shared::Interval m_interval[Shared::ContinuousFunction::k_numberOfPlotTypes];
};
static App * app() {
return static_cast<App *>(Container::activeApp());
@@ -46,7 +46,7 @@ public:
CodePoint XNT() override;
NestedMenuController * variableBoxForInputEventHandler(InputEventHandler * textInput) override;
ContinuousFunctionStore * functionStore() override { return snapshot()->functionStore(); }
Shared::Interval * intervalForType(Shared::CartesianFunction::PlotType plotType) {
Shared::Interval * intervalForType(Shared::ContinuousFunction::PlotType plotType) {
return snapshot()->intervalForType(plotType);
}
ValuesController * valuesController() override {

View File

@@ -9,22 +9,22 @@ using namespace Shared;
namespace Graph {
int ContinuousFunctionStore::numberOfActiveFunctionsOfType(CartesianFunction::PlotType plotType) const {
int ContinuousFunctionStore::numberOfActiveFunctionsOfType(ContinuousFunction::PlotType plotType) const {
int count = 0;
for (int i = 0; i < numberOfActiveFunctions(); i++) {
Ion::Storage::Record record = activeRecordAtIndex(i);
ExpiringPointer<CartesianFunction> function = modelForRecord(record);
ExpiringPointer<ContinuousFunction> function = modelForRecord(record);
count += (plotType == function->plotType());
}
return count;
}
Ion::Storage::Record ContinuousFunctionStore::activeRecordOfTypeAtIndex(CartesianFunction::PlotType plotType, int index) const {
Ion::Storage::Record ContinuousFunctionStore::activeRecordOfTypeAtIndex(ContinuousFunction::PlotType plotType, int index) const {
int count = 0;
Ion::Storage::Record record;
for (int i = 0; i < numberOfActiveFunctions(); i++) {
record = activeRecordAtIndex(i);
ExpiringPointer<CartesianFunction> function = modelForRecord(record);
ExpiringPointer<ContinuousFunction> function = modelForRecord(record);
if (plotType == function->plotType()) {
if (count == index) {
break;
@@ -37,13 +37,13 @@ Ion::Storage::Record ContinuousFunctionStore::activeRecordOfTypeAtIndex(Cartesia
Ion::Storage::Record::ErrorStatus ContinuousFunctionStore::addEmptyModel() {
Ion::Storage::Record::ErrorStatus error;
CartesianFunction newModel = CartesianFunction::NewModel(&error);
ContinuousFunction newModel = ContinuousFunction::NewModel(&error);
return error;
}
ExpressionModelHandle * ContinuousFunctionStore::setMemoizedModelAtIndex(int cacheIndex, Ion::Storage::Record record) const {
assert(cacheIndex >= 0 && cacheIndex < maxNumberOfMemoizedModels());
m_functions[cacheIndex] = CartesianFunction(record);
m_functions[cacheIndex] = ContinuousFunction(record);
return &m_functions[cacheIndex];
}

View File

@@ -10,15 +10,15 @@ namespace Graph {
class ContinuousFunctionStore : public Shared::FunctionStore {
public:
Shared::ExpiringPointer<Shared::CartesianFunction> modelForRecord(Ion::Storage::Record record) const { return Shared::ExpiringPointer<Shared::CartesianFunction>(static_cast<Shared::CartesianFunction *>(privateModelForRecord(record))); }
int numberOfActiveFunctionsOfType(Shared::CartesianFunction::PlotType plotType) const;
Ion::Storage::Record activeRecordOfTypeAtIndex(Shared::CartesianFunction::PlotType plotType, int index) const;
Shared::ExpiringPointer<Shared::ContinuousFunction> modelForRecord(Ion::Storage::Record record) const { return Shared::ExpiringPointer<Shared::ContinuousFunction>(static_cast<Shared::ContinuousFunction *>(privateModelForRecord(record))); }
int numberOfActiveFunctionsOfType(Shared::ContinuousFunction::PlotType plotType) const;
Ion::Storage::Record activeRecordOfTypeAtIndex(Shared::ContinuousFunction::PlotType plotType, int index) const;
private:
Ion::Storage::Record::ErrorStatus addEmptyModel() override;
const char * modelExtension() const override { return Ion::Storage::funcExtension; }
Shared::ExpressionModelHandle * setMemoizedModelAtIndex(int cacheIndex, Ion::Storage::Record record) const override;
Shared::ExpressionModelHandle * memoizedModelAtIndex(int cacheIndex) const override;
mutable Shared::CartesianFunction m_functions[k_maxNumberOfMemoizedModels];
mutable Shared::ContinuousFunction m_functions[k_maxNumberOfMemoizedModels];
};
}

View File

@@ -27,7 +27,7 @@ void CalculationGraphController::viewWillAppear() {
m_graphView->setBannerView(&m_defaultBannerView);
} else {
m_isActive = true;
assert(App::app()->functionStore()->modelForRecord(m_record)->plotType() == Shared::CartesianFunction::PlotType::Cartesian);
assert(App::app()->functionStore()->modelForRecord(m_record)->plotType() == Shared::ContinuousFunction::PlotType::Cartesian);
m_cursor->moveTo(pointOfInterest.x1(), pointOfInterest.x1(), pointOfInterest.x2());
m_graphRange->panToMakePointVisible(m_cursor->x(), m_cursor->y(), cursorTopMarginRatio(), k_cursorRightMarginRatio, cursorBottomMarginRatio(), k_cursorLeftMarginRatio);
m_bannerView->setNumberOfSubviews(Shared::XYBannerView::k_numberOfSubviews);
@@ -75,7 +75,7 @@ bool CalculationGraphController::moveCursorHorizontally(int direction) {
if (std::isnan(newPointOfInterest.x1())) {
return false;
}
assert(App::app()->functionStore()->modelForRecord(m_record)->plotType() == Shared::CartesianFunction::PlotType::Cartesian);
assert(App::app()->functionStore()->modelForRecord(m_record)->plotType() == Shared::ContinuousFunction::PlotType::Cartesian);
m_cursor->moveTo(newPointOfInterest.x1(), newPointOfInterest.x1(), newPointOfInterest.x2());
return true;
}

View File

@@ -118,7 +118,7 @@ void CalculationParameterController::setRecord(Ion::Storage::Record record) {
bool CalculationParameterController::shouldDisplayIntersection() const {
ContinuousFunctionStore * store = App::app()->functionStore();
int numberOfCartesianFunctions = store->numberOfActiveFunctionsOfType(Shared::CartesianFunction::PlotType::Cartesian);
int numberOfCartesianFunctions = store->numberOfActiveFunctionsOfType(Shared::ContinuousFunction::PlotType::Cartesian);
// Intersection row is displayed when all functions are cartesian and there are least two of them
// TODO: compute intersections between polar/parametric/cartesian functions?
return numberOfCartesianFunctions > 1 && numberOfCartesianFunctions == store->numberOfActiveFunctions();

View File

@@ -81,8 +81,8 @@ void CurveParameterController::viewWillAppear() {
}
bool CurveParameterController::shouldDisplayCalculationAndDerivative() const {
Shared::ExpiringPointer<CartesianFunction> f = App::app()->functionStore()->modelForRecord(m_record);
return f->plotType() == CartesianFunction::PlotType::Cartesian;
Shared::ExpiringPointer<ContinuousFunction> f = App::app()->functionStore()->modelForRecord(m_record);
return f->plotType() == ContinuousFunction::PlotType::Cartesian;
}
int CurveParameterController::cellIndex(int visibleCellIndex) const {

View File

@@ -34,7 +34,7 @@ void GraphController::viewWillAppear() {
selectFunctionWithCursor(indexFunctionSelectedByCursor());
}
void GraphController::interestingFunctionRange(ExpiringPointer<CartesianFunction> f, float tMin, float tMax, float step, float * xm, float * xM, float * ym, float * yM) const {
void GraphController::interestingFunctionRange(ExpiringPointer<ContinuousFunction> f, float tMin, float tMax, float step, float * xm, float * xM, float * ym, float * yM) const {
Poincare::Context * context = textFieldDelegateApp()->localContext();
const int balancedBound = std::floor((tMax-tMin)/2/step);
for (int j = -balancedBound; j <= balancedBound ; j++) {
@@ -60,8 +60,8 @@ void GraphController::interestingRanges(float * xm, float * xM, float * ym, floa
if (displaysNonCartesianFunctions()) {
const int functionsCount = functionStore()->numberOfActiveFunctions();
for (int i = 0; i < functionsCount; i++) {
ExpiringPointer<CartesianFunction> f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
if (f->plotType() == CartesianFunction::PlotType::Cartesian) {
ExpiringPointer<ContinuousFunction> f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
if (f->plotType() == ContinuousFunction::PlotType::Cartesian) {
continue;
}
/* Scan x-range from the middle to the extrema in order to get balanced
@@ -86,8 +86,8 @@ void GraphController::interestingRanges(float * xm, float * xM, float * ym, floa
* missed. */
const float step = const_cast<GraphController *>(this)->curveView()->pixelWidth() / 2;
for (int i = 0; i < functionStore()->numberOfActiveFunctions(); i++) {
ExpiringPointer<CartesianFunction> f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
if (f->plotType() != CartesianFunction::PlotType::Cartesian) {
ExpiringPointer<ContinuousFunction> f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
if (f->plotType() != ContinuousFunction::PlotType::Cartesian) {
continue;
}
/* Scan x-range from the middle to the extrema in order to get balanced
@@ -114,7 +114,7 @@ float GraphController::interestingXHalfRange() const {
Poincare::Context * context = textFieldDelegateApp()->localContext();
ContinuousFunctionStore * store = functionStore();
for (int i = 0; i < store->numberOfActiveFunctions(); i++) {
ExpiringPointer<CartesianFunction> f = store->modelForRecord(store->activeRecordAtIndex(i));
ExpiringPointer<ContinuousFunction> f = store->modelForRecord(store->activeRecordAtIndex(i));
float fRange = f->expressionReduced(context).characteristicXRange(context, Poincare::Preferences::sharedPreferences()->angleUnit());
if (!std::isnan(fRange)) {
characteristicRange = maxFloat(fRange, characteristicRange);
@@ -125,14 +125,14 @@ float GraphController::interestingXHalfRange() const {
void GraphController::selectFunctionWithCursor(int functionIndex) {
FunctionGraphController::selectFunctionWithCursor(functionIndex);
ExpiringPointer<CartesianFunction> f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(functionIndex));
ExpiringPointer<ContinuousFunction> f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(functionIndex));
m_cursorView.setColor(f->color());
}
void GraphController::reloadBannerView() {
Ion::Storage::Record record = functionStore()->activeRecordAtIndex(indexFunctionSelectedByCursor());
bool displayDerivative = m_displayDerivativeInBanner &&
functionStore()->modelForRecord(record)->plotType() == CartesianFunction::PlotType::Cartesian;
functionStore()->modelForRecord(record)->plotType() == ContinuousFunction::PlotType::Cartesian;
m_bannerView.setNumberOfSubviews(Shared::XYBannerView::k_numberOfSubviews + displayDerivative);
FunctionGraphController::reloadBannerView();
if (!displayDerivative) {
@@ -148,7 +148,7 @@ bool GraphController::moveCursorHorizontally(int direction) {
int GraphController::closestCurveIndexVertically(bool goingUp, int currentSelectedCurve, Poincare::Context * context) const {
int nbOfActiveFunctions = functionStore()-> numberOfActiveFunctions();
if (functionStore()->numberOfActiveFunctionsOfType(CartesianFunction::PlotType::Cartesian) == nbOfActiveFunctions) {
if (functionStore()->numberOfActiveFunctionsOfType(ContinuousFunction::PlotType::Cartesian) == nbOfActiveFunctions) {
return FunctionGraphController::closestCurveIndexVertically(goingUp, currentSelectedCurve, context);
}
int nextActiveFunctionIndex = currentSelectedCurve + (goingUp ? -1 : 1);
@@ -156,8 +156,8 @@ int GraphController::closestCurveIndexVertically(bool goingUp, int currentSelect
}
double GraphController::defaultCursorT(Ion::Storage::Record record) {
ExpiringPointer<CartesianFunction> function = functionStore()->modelForRecord(record);
if (function->plotType() == CartesianFunction::PlotType::Cartesian) {
ExpiringPointer<ContinuousFunction> function = functionStore()->modelForRecord(record);
if (function->plotType() == ContinuousFunction::PlotType::Cartesian) {
return FunctionGraphController::defaultCursorT(record);
}
return function->tMin();
@@ -165,8 +165,8 @@ double GraphController::defaultCursorT(Ion::Storage::Record record) {
bool GraphController::displaysNonCartesianFunctions() const {
ContinuousFunctionStore * store = functionStore();
return store->numberOfActiveFunctionsOfType(CartesianFunction::PlotType::Polar) > 0
|| store->numberOfActiveFunctionsOfType(CartesianFunction::PlotType::Parametric) > 0;
return store->numberOfActiveFunctionsOfType(ContinuousFunction::PlotType::Polar) > 0
|| store->numberOfActiveFunctionsOfType(ContinuousFunction::PlotType::Parametric) > 0;
}
bool GraphController::shouldSetDefaultOnModelChange() const {

View File

@@ -36,7 +36,7 @@ private:
ContinuousFunctionStore * functionStore() const override { return static_cast<ContinuousFunctionStore *>(Shared::FunctionGraphController::functionStore()); }
bool displaysNonCartesianFunctions() const;
bool defautRangeIsNormalized() const override { return displaysNonCartesianFunctions(); }
void interestingFunctionRange(Shared::ExpiringPointer<Shared::CartesianFunction> f, float tMin, float tMax, float step, float * xm, float * xM, float * ym, float * yM) const;
void interestingFunctionRange(Shared::ExpiringPointer<Shared::ContinuousFunction> f, float tMin, float tMax, float step, float * xm, float * xM, float * ym, float * yM) const;
bool shouldSetDefaultOnModelChange() const override;
Shared::RoundCursorView m_cursorView;

View File

@@ -10,17 +10,17 @@ using namespace Poincare;
namespace Graph {
bool GraphControllerHelper::privateMoveCursorHorizontally(Shared::CurveViewCursor * cursor, int direction, Shared::InteractiveCurveViewRange * range, int numberOfStepsInGradUnit, Ion::Storage::Record record) {
ExpiringPointer<CartesianFunction> function = App::app()->functionStore()->modelForRecord(record);
ExpiringPointer<ContinuousFunction> function = App::app()->functionStore()->modelForRecord(record);
double tCursorPosition = cursor->t();
double t = tCursorPosition;
double tMin = function->tMin();
double tMax = function->tMax();
double dir = (direction > 0 ? 1.0 : -1.0);
CartesianFunction::PlotType type = function->plotType();
if (type == CartesianFunction::PlotType::Cartesian) {
ContinuousFunction::PlotType type = function->plotType();
if (type == ContinuousFunction::PlotType::Cartesian) {
t+= dir * range->xGridUnit()/numberOfStepsInGradUnit;
} else {
assert(type == CartesianFunction::PlotType::Polar || type == CartesianFunction::PlotType::Parametric);
assert(type == ContinuousFunction::PlotType::Polar || type == ContinuousFunction::PlotType::Parametric);
t += dir * (tMax-tMin)/k_definitionDomainDivisor;
}
Coordinate2D<double> xy = function->evaluateXYAtParameter(t, App::app()->localContext());
@@ -29,7 +29,7 @@ bool GraphControllerHelper::privateMoveCursorHorizontally(Shared::CurveViewCurso
}
void GraphControllerHelper::reloadDerivativeInBannerViewForCursorOnFunction(Shared::CurveViewCursor * cursor, Ion::Storage::Record record) {
ExpiringPointer<CartesianFunction> function = App::app()->functionStore()->modelForRecord(record);
ExpiringPointer<ContinuousFunction> function = App::app()->functionStore()->modelForRecord(record);
constexpr size_t bufferSize = FunctionBannerDelegate::k_maxNumberOfCharacters+PrintFloat::bufferSizeForFloatsWithPrecision(Preferences::LargeNumberOfSignificantDigits);
char buffer[bufferSize];
const char * space = " ";

View File

@@ -26,8 +26,8 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
ContinuousFunctionStore * functionStore = App::app()->functionStore();
for (int i = 0; i < functionStore->numberOfActiveFunctions(); i++) {
Ion::Storage::Record record = functionStore->activeRecordAtIndex(i);
ExpiringPointer<CartesianFunction> f = functionStore->modelForRecord(record);;
Shared::CartesianFunction::PlotType type = f->plotType();
ExpiringPointer<ContinuousFunction> f = functionStore->modelForRecord(record);;
Shared::ContinuousFunction::PlotType type = f->plotType();
float tmin = f->tMin();
float tmax = f->tMax();
/* The step is a fraction of tmax-tmin. We will evaluate the function at
@@ -44,9 +44,9 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
float tstep = (tmax-tmin)/10.0938275501223f;
// Cartesian
if (type == Shared::CartesianFunction::PlotType::Cartesian) {
if (type == Shared::ContinuousFunction::PlotType::Cartesian) {
drawCartesianCurve(ctx, rect, tmin, tmax, [](float t, void * model, void * context) {
CartesianFunction * f = (CartesianFunction *)model;
ContinuousFunction * f = (ContinuousFunction *)model;
Poincare::Context * c = (Poincare::Context *)context;
return f->evaluateXYAtParameter(t, c);
}, f.operator->(), context(), f->color(), record == m_selectedRecord, m_highlightedStart, m_highlightedEnd);
@@ -64,9 +64,9 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
}
// Polar
if (type == Shared::CartesianFunction::PlotType::Polar) {
if (type == Shared::ContinuousFunction::PlotType::Polar) {
drawCurve(ctx, rect, tmin, tmax, tstep, [](float t, void * model, void * context) {
CartesianFunction * f = (CartesianFunction *)model;
ContinuousFunction * f = (ContinuousFunction *)model;
Poincare::Context * c = (Poincare::Context *)context;
return f->evaluateXYAtParameter(t, c);
}, f.operator->(), context(), false, f->color());
@@ -74,9 +74,9 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
}
// Parametric
assert(type == Shared::CartesianFunction::PlotType::Parametric);
assert(type == Shared::ContinuousFunction::PlotType::Parametric);
drawCurve(ctx, rect, tmin, tmax, tstep, [](float t, void * model, void * context) {
CartesianFunction * f = (CartesianFunction *)model;
ContinuousFunction * f = (ContinuousFunction *)model;
Poincare::Context * c = (Poincare::Context *)context;
return f->evaluateXYAtParameter(t, c);
}, f.operator->(), context(), false, f->color());

View File

@@ -24,12 +24,12 @@ void IntersectionGraphController::reloadBannerView() {
const char * space = " ";
const char * legend = "=";
// 'f(x)=g(x)=', keep 2 chars for '='
ExpiringPointer<CartesianFunction> f = functionStore()->modelForRecord(m_record);
ExpiringPointer<ContinuousFunction> f = functionStore()->modelForRecord(m_record);
int numberOfChar = f->nameWithArgument(buffer, bufferSize-2);
assert(numberOfChar <= bufferSize);
numberOfChar += strlcpy(buffer+numberOfChar, legend, bufferSize-numberOfChar);
// keep 1 char for '=';
ExpiringPointer<CartesianFunction> g = functionStore()->modelForRecord(m_intersectedRecord);
ExpiringPointer<ContinuousFunction> g = functionStore()->modelForRecord(m_intersectedRecord);
numberOfChar += g->nameWithArgument(buffer+numberOfChar, bufferSize-numberOfChar-1);
assert(numberOfChar <= bufferSize);
numberOfChar += strlcpy(buffer+numberOfChar, legend, bufferSize-numberOfChar);
@@ -46,7 +46,7 @@ Poincare::Coordinate2D<double> IntersectionGraphController::computeNewPointOfInt
for (int i = 0; i < functionStore()->numberOfActiveFunctions(); i++) {
Ion::Storage::Record record = functionStore()->activeRecordAtIndex(i);
if (record != m_record) {
CartesianFunction f = *(functionStore()->modelForRecord(record));
ContinuousFunction f = *(functionStore()->modelForRecord(record));
Poincare::Coordinate2D<double> intersection = functionStore()->modelForRecord(m_record)->nextIntersectionFrom(start, step, max, context, f.expressionReduced(context), f.tMin(), f.tMax());
if ((std::isnan(result.x1()) || std::fabs(intersection.x1()-start) < std::fabs(result.x1()-start)) && !std::isnan(intersection.x1())) {
m_intersectedRecord = record;

View File

@@ -46,8 +46,8 @@ bool TangentGraphController::textFieldDidFinishEditing(TextField * textField, co
if (myApp->hasUndefinedValue(text, floatBody)) {
return false;
}
ExpiringPointer<CartesianFunction> function = App::app()->functionStore()->modelForRecord(m_record);
assert(function->plotType() == Shared::CartesianFunction::PlotType::Cartesian);
ExpiringPointer<ContinuousFunction> function = App::app()->functionStore()->modelForRecord(m_record);
assert(function->plotType() == Shared::ContinuousFunction::PlotType::Cartesian);
double y = function->evaluate2DAtParameter(floatBody, myApp->localContext()).x2();
m_cursor->moveTo(floatBody, floatBody, y);
interactiveCurveViewRange()->panToMakePointVisible(m_cursor->x(), m_cursor->y(), cursorTopMarginRatio(), k_cursorRightMarginRatio, cursorBottomMarginRatio(), k_cursorLeftMarginRatio);
@@ -74,7 +74,7 @@ void TangentGraphController::reloadBannerView() {
constexpr int precision = Preferences::MediumNumberOfSignificantDigits;
const char * legend = "a=";
int legendLength = strlcpy(buffer, legend, bufferSize);
ExpiringPointer<CartesianFunction> function = App::app()->functionStore()->modelForRecord(m_record);
ExpiringPointer<ContinuousFunction> function = App::app()->functionStore()->modelForRecord(m_record);
double y = function->approximateDerivative(m_cursor->x(), context);
PoincareHelpers::ConvertFloatToText<double>(y, buffer + legendLength, PrintFloat::bufferSizeForFloatsWithPrecision(precision), precision);
m_bannerView->aView()->setText(buffer);
@@ -82,7 +82,7 @@ void TangentGraphController::reloadBannerView() {
legend = "b=";
legendLength = strlcpy(buffer, legend, bufferSize);
Shared::TextFieldDelegateApp * myApp = textFieldDelegateApp();
assert(function->plotType() == Shared::CartesianFunction::PlotType::Cartesian);
assert(function->plotType() == Shared::ContinuousFunction::PlotType::Cartesian);
y = -y*m_cursor->x()+function->evaluate2DAtParameter(m_cursor->x(), myApp->localContext()).x2();
PoincareHelpers::ConvertFloatToText<double>(y, buffer + legendLength, PrintFloat::bufferSizeForFloatsWithPrecision(precision), precision);
m_bannerView->bView()->setText(buffer);

View File

@@ -31,15 +31,15 @@ void DomainParameterController::willDisplayCellForIndex(HighlightCell * cell, in
return;
}
MessageTableCellWithEditableText * myCell = (MessageTableCellWithEditableText *)cell;
Shared::CartesianFunction::PlotType plotType = function()->plotType();
Shared::ContinuousFunction::PlotType plotType = function()->plotType();
switch (plotType) {
case Shared::CartesianFunction::PlotType::Cartesian:
case Shared::ContinuousFunction::PlotType::Cartesian:
{
I18n::Message labels[k_totalNumberOfCell] = {I18n::Message::XMin, I18n::Message::XMax};
myCell->setMessage(labels[index]);
break;
}
case Shared::CartesianFunction::PlotType::Parametric:
case Shared::ContinuousFunction::PlotType::Parametric:
{
I18n::Message labels[k_totalNumberOfCell] = {I18n::Message::TMin, I18n::Message::TMax};
myCell->setMessage(labels[index]);
@@ -47,7 +47,7 @@ void DomainParameterController::willDisplayCellForIndex(HighlightCell * cell, in
}
default:
{
assert(plotType == Shared::CartesianFunction::PlotType::Polar);
assert(plotType == Shared::ContinuousFunction::PlotType::Polar);
I18n::Message labels[k_totalNumberOfCell] = {I18n::Message::ThetaMin, I18n::Message::ThetaMax};
myCell->setMessage(labels[index]);
break;
@@ -89,15 +89,15 @@ void DomainParameterController::buttonAction() {
stack->pop();
}
Shared::ExpiringPointer<Shared::CartesianFunction> DomainParameterController::function() const {
Shared::ExpiringPointer<Shared::ContinuousFunction> DomainParameterController::function() const {
assert(!m_record.isNull());
App * myApp = App::app();
return myApp->functionStore()->modelForRecord(m_record);
}
FloatParameterController<float>::InfinityTolerance DomainParameterController::infinityAllowanceForRow(int row) const {
Shared::CartesianFunction::PlotType plotType = function()->plotType();
if (plotType == Shared::CartesianFunction::PlotType::Cartesian) {
Shared::ContinuousFunction::PlotType plotType = function()->plotType();
if (plotType == Shared::ContinuousFunction::PlotType::Cartesian) {
return row == 0 ? FloatParameterController<float>::InfinityTolerance::MinusInfinity : FloatParameterController<float>::InfinityTolerance::PlusInfinity;
}
return FloatParameterController<float>::InfinityTolerance::None;

View File

@@ -30,7 +30,7 @@ private:
float parameterAtIndex(int index) override;
void buttonAction() override;
InfinityTolerance infinityAllowanceForRow(int row) const override;
Shared::ExpiringPointer<Shared::CartesianFunction> function() const;
Shared::ExpiringPointer<Shared::ContinuousFunction> function() const;
MessageTableCellWithEditableText m_domainCells[k_totalNumberOfCell];
Ion::Storage::Record m_record;
};

View File

@@ -54,7 +54,7 @@ bool ListController::textFieldDidFinishEditing(TextField * textField, const char
char baseName[maxBaseNameSize];
if (textLength <= argumentLength) {
// The user entered an empty name. Use a default function name.
CartesianFunction::DefaultName(baseName, maxBaseNameSize);
ContinuousFunction::DefaultName(baseName, maxBaseNameSize);
/* We don't need to update the textfield edited text here because we are
* sure that the default name is compliant. It will thus lead to the end of
* edition and its content will be reloaded by willDisplayTitleCellAtIndex. */
@@ -118,7 +118,7 @@ bool ListController::textFieldDidAbortEditing(TextField * textField) {
// Put the name column back to normal size
computeTitlesColumnWidth();
selectableTableView()->reloadData();
ExpiringPointer<CartesianFunction> function = modelStore()->modelForRecord(modelStore()->recordAtIndex(selectedRow()));
ExpiringPointer<ContinuousFunction> function = modelStore()->modelForRecord(modelStore()->recordAtIndex(selectedRow()));
setFunctionNameInTextField(function, textField);
m_selectableTableView.selectedCell()->setHighlighted(true);
Container::activeApp()->setFirstResponder(&m_selectableTableView);
@@ -165,7 +165,7 @@ void ListController::willDisplayTitleCellAtIndex(HighlightCell * cell, int j) {
titleCell->setBaseline(baseline(j));
if (!titleCell->isEditing()) {
// Set name and color if the name is not being edited
ExpiringPointer<CartesianFunction> function = modelStore()->modelForRecord(modelStore()->recordAtIndex(j));
ExpiringPointer<ContinuousFunction> function = modelStore()->modelForRecord(modelStore()->recordAtIndex(j));
setFunctionNameInTextField(function, titleCell->textField());
KDColor functionNameColor = function->isActive() ? function->color() : Palette::GreyDark;
titleCell->setColor(functionNameColor);
@@ -177,12 +177,12 @@ void ListController::willDisplayExpressionCellAtIndex(HighlightCell * cell, int
assert(j >= 0 && j < modelStore()->numberOfModels());
Shared::FunctionListController::willDisplayExpressionCellAtIndex(cell, j);
FunctionExpressionCell * myCell = (FunctionExpressionCell *)cell;
ExpiringPointer<CartesianFunction> f = modelStore()->modelForRecord(modelStore()->recordAtIndex(j));
ExpiringPointer<ContinuousFunction> f = modelStore()->modelForRecord(modelStore()->recordAtIndex(j));
KDColor textColor = f->isActive() ? KDColorBlack : Palette::GreyDark;
myCell->setTextColor(textColor);
}
void ListController::setFunctionNameInTextField(ExpiringPointer<CartesianFunction> function, TextField * textField) {
void ListController::setFunctionNameInTextField(ExpiringPointer<ContinuousFunction> function, TextField * textField) {
assert(textField != nullptr);
char bufferName[BufferTextView::k_maxNumberOfChar];
function->nameWithArgument(bufferName, BufferTextView::k_maxNumberOfChar);

View File

@@ -29,7 +29,7 @@ private:
HighlightCell * expressionCells(int index) override;
void willDisplayTitleCellAtIndex(HighlightCell * cell, int j) override;
void willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) override;
void setFunctionNameInTextField(Shared::ExpiringPointer<Shared::CartesianFunction> function, TextField * textField);
void setFunctionNameInTextField(Shared::ExpiringPointer<Shared::ContinuousFunction> function, TextField * textField);
ContinuousFunctionStore * modelStore() override;
TextFieldFunctionTitleCell m_functionTitleCells[k_maxNumberOfDisplayableRows];
Shared::FunctionExpressionCell m_expressionCells[k_maxNumberOfDisplayableRows];

View File

@@ -54,7 +54,7 @@ void ListParameterController::willDisplayCellForIndex(HighlightCell * cell, int
if ((cell == &m_typeCell || cell == &m_functionDomain) && !m_record.isNull()) {
App * myApp = App::app();
assert(!m_record.isNull());
Shared::ExpiringPointer<Shared::CartesianFunction> function = myApp->functionStore()->modelForRecord(m_record);
Shared::ExpiringPointer<Shared::ContinuousFunction> function = myApp->functionStore()->modelForRecord(m_record);
if (cell == &m_typeCell) {
m_typeCell.setMessage(I18n::Message::CurveType);
int row = static_cast<int>(function->plotType());

View File

@@ -20,10 +20,10 @@ void TypeParameterController::didBecomeFirstResponder() {
bool TypeParameterController::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
assert(!m_record.isNull());
Shared::CartesianFunction::PlotType plotType = static_cast<Shared::CartesianFunction::PlotType>(selectedRow());
Shared::ContinuousFunction::PlotType plotType = static_cast<Shared::ContinuousFunction::PlotType>(selectedRow());
App * myApp = App::app();
assert(!m_record.isNull());
Shared::ExpiringPointer<Shared::CartesianFunction> function = myApp->functionStore()->modelForRecord(m_record);
Shared::ExpiringPointer<Shared::ContinuousFunction> function = myApp->functionStore()->modelForRecord(m_record);
function->setPlotType(plotType, Poincare::Preferences::sharedPreferences()->angleUnit());
StackViewController * stack = stackController();
stack->pop();
@@ -44,7 +44,7 @@ const char * TypeParameterController::title() {
void TypeParameterController::viewWillAppear() {
App * myApp = App::app();
assert(!m_record.isNull());
Shared::ExpiringPointer<Shared::CartesianFunction> function = myApp->functionStore()->modelForRecord(m_record);
Shared::ExpiringPointer<Shared::ContinuousFunction> function = myApp->functionStore()->modelForRecord(m_record);
int row = static_cast<int>(function->plotType());
selectCellAtLocation(0, row);
m_selectableTableView.reloadData();

View File

@@ -69,7 +69,7 @@ void FunctionParameterController::willDisplayCellForIndex(HighlightCell * cell,
}
}
ExpiringPointer<CartesianFunction> FunctionParameterController::function() {
ExpiringPointer<ContinuousFunction> FunctionParameterController::function() {
return App::app()->functionStore()->modelForRecord(m_record);
}

View File

@@ -19,7 +19,7 @@ public:
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
void viewWillAppear() override;
private:
Shared::ExpiringPointer<Shared::CartesianFunction> function();
Shared::ExpiringPointer<Shared::ContinuousFunction> function();
#if COPY_COLUMN
constexpr static int k_totalNumberOfCell = 2;
#else

View File

@@ -34,7 +34,7 @@ bool IntervalParameterSelectorController::handleEvent(Ion::Events::Event event)
if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) {
StackViewController * stack = (StackViewController *)parentResponder();
Shared::IntervalParameterController * controller = App::app()->valuesController()->intervalParameterController();
Shared::CartesianFunction::PlotType plotType = plotTypeAtRow(selectedRow());
Shared::ContinuousFunction::PlotType plotType = plotTypeAtRow(selectedRow());
controller->setTitle(messageForType(plotType));
setStartEndMessages(controller, plotType);
controller->setInterval(App::app()->intervalForType(plotType));
@@ -47,9 +47,9 @@ bool IntervalParameterSelectorController::handleEvent(Ion::Events::Event event)
int IntervalParameterSelectorController::numberOfRows() const {
int rowCount = 0;
int plotTypeIndex = 0;
Shared::CartesianFunction::PlotType plotType;
while (plotTypeIndex < Shared::CartesianFunction::k_numberOfPlotTypes) {
plotType = static_cast<Shared::CartesianFunction::PlotType>(plotTypeIndex);
Shared::ContinuousFunction::PlotType plotType;
while (plotTypeIndex < Shared::ContinuousFunction::k_numberOfPlotTypes) {
plotType = static_cast<Shared::ContinuousFunction::PlotType>(plotTypeIndex);
bool plotTypeIsShown = App::app()->functionStore()->numberOfActiveFunctionsOfType(plotType) > 0;
rowCount += plotTypeIsShown;
plotTypeIndex++;
@@ -63,21 +63,21 @@ HighlightCell * IntervalParameterSelectorController::reusableCell(int index) {
}
int IntervalParameterSelectorController::reusableCellCount() const {
return Shared::CartesianFunction::k_numberOfPlotTypes;
return Shared::ContinuousFunction::k_numberOfPlotTypes;
}
void IntervalParameterSelectorController::willDisplayCellForIndex(HighlightCell * cell, int index) {
assert(0 <= index && index < numberOfRows());
Shared::CartesianFunction::PlotType plotType = plotTypeAtRow(index);
Shared::ContinuousFunction::PlotType plotType = plotTypeAtRow(index);
static_cast<MessageTableCellWithChevron *>(cell)->setMessage(messageForType(plotType));
}
Shared::CartesianFunction::PlotType IntervalParameterSelectorController::plotTypeAtRow(int j) const {
Shared::ContinuousFunction::PlotType IntervalParameterSelectorController::plotTypeAtRow(int j) const {
int rowCount = 0;
int plotTypeIndex = 0;
Shared::CartesianFunction::PlotType plotType;
while (plotTypeIndex < Shared::CartesianFunction::k_numberOfPlotTypes) {
plotType = static_cast<Shared::CartesianFunction::PlotType>(plotTypeIndex);
Shared::ContinuousFunction::PlotType plotType;
while (plotTypeIndex < Shared::ContinuousFunction::k_numberOfPlotTypes) {
plotType = static_cast<Shared::ContinuousFunction::PlotType>(plotTypeIndex);
bool plotTypeIsShown = App::app()->functionStore()->numberOfActiveFunctionsOfType(plotType) > 0;
if (plotTypeIsShown && rowCount == j) {
break;
@@ -89,8 +89,8 @@ Shared::CartesianFunction::PlotType IntervalParameterSelectorController::plotTyp
return plotType;
}
I18n::Message IntervalParameterSelectorController::messageForType(Shared::CartesianFunction::PlotType plotType) {
constexpr I18n::Message message[Shared::CartesianFunction::k_numberOfPlotTypes] = {
I18n::Message IntervalParameterSelectorController::messageForType(Shared::ContinuousFunction::PlotType plotType) {
constexpr I18n::Message message[Shared::ContinuousFunction::k_numberOfPlotTypes] = {
I18n::Message::IntervalX,
I18n::Message::IntervalTheta,
I18n::Message::IntervalT
@@ -98,13 +98,13 @@ I18n::Message IntervalParameterSelectorController::messageForType(Shared::Cartes
return message[static_cast<size_t>(plotType)];
}
void IntervalParameterSelectorController::setStartEndMessages(Shared::IntervalParameterController * controller, Shared::CartesianFunction::PlotType plotType) {
if (plotType == Shared::CartesianFunction::PlotType::Cartesian) {
void IntervalParameterSelectorController::setStartEndMessages(Shared::IntervalParameterController * controller, Shared::ContinuousFunction::PlotType plotType) {
if (plotType == Shared::ContinuousFunction::PlotType::Cartesian) {
controller->setStartEndMessages(I18n::Message::XStart, I18n::Message::XEnd);
} else if (plotType == Shared::CartesianFunction::PlotType::Polar) {
} else if (plotType == Shared::ContinuousFunction::PlotType::Polar) {
controller->setStartEndMessages(I18n::Message::ThetaStart, I18n::Message::ThetaEnd);
} else {
assert(plotType == Shared::CartesianFunction::PlotType::Parametric);
assert(plotType == Shared::ContinuousFunction::PlotType::Parametric);
controller->setStartEndMessages(I18n::Message::TStart, I18n::Message::TEnd);
}
}

View File

@@ -20,11 +20,11 @@ public:
int reusableCellCount() const override;
HighlightCell * reusableCell(int index) override;
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
void setStartEndMessages(Shared::IntervalParameterController * controller, Shared::CartesianFunction::PlotType plotType);
void setStartEndMessages(Shared::IntervalParameterController * controller, Shared::ContinuousFunction::PlotType plotType);
private:
Shared::CartesianFunction::PlotType plotTypeAtRow(int j) const;
I18n::Message messageForType(Shared::CartesianFunction::PlotType plotType);
MessageTableCellWithChevron m_intervalParameterCell[Shared::CartesianFunction::k_numberOfPlotTypes];
Shared::ContinuousFunction::PlotType plotTypeAtRow(int j) const;
I18n::Message messageForType(Shared::ContinuousFunction::PlotType plotType);
MessageTableCellWithChevron m_intervalParameterCell[Shared::ContinuousFunction::k_numberOfPlotTypes];
SelectableTableView m_selectableTableView;
};

View File

@@ -95,8 +95,8 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in
char bufferName[bufferNameSize];
bool isDerivative = false;
Ion::Storage::Record record = recordAtColumn(i, &isDerivative);
Shared::ExpiringPointer<CartesianFunction> function = functionStore()->modelForRecord(record);
if (function->plotType() == CartesianFunction::PlotType::Parametric) {
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;
@@ -153,14 +153,14 @@ Ion::Storage::Record ValuesController::recordAtColumn(int i) {
Ion::Storage::Record ValuesController::recordAtColumn(int i, bool * isDerivative) {
assert(typeAtLocation(i, 0) == k_functionTitleCellType);
CartesianFunction::PlotType plotType = plotTypeAtColumn(&i);
ContinuousFunction::PlotType plotType = plotTypeAtColumn(&i);
int index = 1;
for (int k = 0; k < functionStore()->numberOfActiveFunctionsOfType(plotType); k++) {
Ion::Storage::Record record = functionStore()->activeRecordOfTypeAtIndex(plotType, k);
const int numberOfColumnsForCurrentRecord = numberOfColumnsForRecord(record);
if (index <= i && i < index + numberOfColumnsForCurrentRecord) {
ExpiringPointer<CartesianFunction> f = functionStore()->modelForRecord(record);
*isDerivative = i != index && f->plotType() == CartesianFunction::PlotType::Cartesian;
ExpiringPointer<ContinuousFunction> f = functionStore()->modelForRecord(record);
*isDerivative = i != index && f->plotType() == ContinuousFunction::PlotType::Cartesian;
return record;
}
index += numberOfColumnsForCurrentRecord;
@@ -170,11 +170,11 @@ Ion::Storage::Record ValuesController::recordAtColumn(int i, bool * isDerivative
}
int ValuesController::numberOfColumnsForRecord(Ion::Storage::Record record) const {
ExpiringPointer<CartesianFunction> f = functionStore()->modelForRecord(record);
CartesianFunction::PlotType plotType = f->plotType();
ExpiringPointer<ContinuousFunction> f = functionStore()->modelForRecord(record);
ContinuousFunction::PlotType plotType = f->plotType();
return 1 +
(plotType == CartesianFunction::PlotType::Cartesian && f->displayDerivative()) +
(plotType == CartesianFunction::PlotType::Parametric);
(plotType == ContinuousFunction::PlotType::Cartesian && f->displayDerivative()) +
(plotType == ContinuousFunction::PlotType::Parametric);
}
Shared::Interval * ValuesController::intervalAtColumn(int columnIndex) {
@@ -182,16 +182,16 @@ Shared::Interval * ValuesController::intervalAtColumn(int columnIndex) {
}
I18n::Message ValuesController::valuesParameterMessageAtColumn(int columnIndex) const {
return CartesianFunction::ParameterMessageForPlotType(plotTypeAtColumn(&columnIndex));
return ContinuousFunction::ParameterMessageForPlotType(plotTypeAtColumn(&columnIndex));
}
CartesianFunction::PlotType ValuesController::plotTypeAtColumn(int * i) const {
ContinuousFunction::PlotType ValuesController::plotTypeAtColumn(int * i) const {
int plotTypeIndex = 0;
while (plotTypeIndex < CartesianFunction::k_numberOfPlotTypes && *i >= m_numberOfColumnsForType[plotTypeIndex]) {
while (plotTypeIndex < ContinuousFunction::k_numberOfPlotTypes && *i >= m_numberOfColumnsForType[plotTypeIndex]) {
*i -= m_numberOfColumnsForType[plotTypeIndex++];
}
assert(plotTypeIndex < CartesianFunction::k_numberOfPlotTypes);
return static_cast<CartesianFunction::PlotType>(plotTypeIndex);
assert(plotTypeIndex < ContinuousFunction::k_numberOfPlotTypes);
return static_cast<ContinuousFunction::PlotType>(plotTypeIndex);
}
int ValuesController::maxNumberOfCells() {
@@ -215,7 +215,7 @@ EvenOddBufferTextCell * ValuesController::floatCells(int j) {
ViewController * ValuesController::functionParameterController() {
bool isDerivative = false;
Ion::Storage::Record record = recordAtColumn(selectedColumn(), &isDerivative);
if (functionStore()->modelForRecord(record)->plotType() != CartesianFunction::PlotType::Cartesian) {
if (functionStore()->modelForRecord(record)->plotType() != ContinuousFunction::PlotType::Cartesian) {
return nullptr;
}
if (isDerivative) {
@@ -229,13 +229,13 @@ ViewController * ValuesController::functionParameterController() {
double ValuesController::evaluationOfAbscissaAtColumn(double abscissa, int columnIndex) {
bool isDerivative = false;
Ion::Storage::Record record = recordAtColumn(columnIndex, &isDerivative);
Shared::ExpiringPointer<CartesianFunction> function = functionStore()->modelForRecord(record);
Shared::ExpiringPointer<ContinuousFunction> function = functionStore()->modelForRecord(record);
Poincare::Context * context = textFieldDelegateApp()->localContext();
if (isDerivative) {
return function->approximateDerivative(abscissa, context);
}
Poincare::Coordinate2D<double> eval = function->evaluate2DAtParameter(abscissa, context);
if (function->plotType() != CartesianFunction::PlotType::Parametric
if (function->plotType() != ContinuousFunction::PlotType::Parametric
|| (columnIndex == numberOfColumns() - 1
|| !((typeAtLocation(columnIndex+1, 0) == k_functionTitleCellType)
&& recordAtColumn(columnIndex+1) == record)))
@@ -251,17 +251,17 @@ void ValuesController::setStartEndMessages(Shared::IntervalParameterController *
}
void ValuesController::updateNumberOfColumns() const {
for (int plotTypeIndex = 0; plotTypeIndex < CartesianFunction::k_numberOfPlotTypes; plotTypeIndex++) {
for (int plotTypeIndex = 0; plotTypeIndex < ContinuousFunction::k_numberOfPlotTypes; plotTypeIndex++) {
m_numberOfColumnsForType[plotTypeIndex] = 0;
}
for (int i = 0; i < functionStore()->numberOfActiveFunctions(); i++) {
Ion::Storage::Record record = functionStore()->activeRecordAtIndex(i);
ExpiringPointer<CartesianFunction> f = functionStore()->modelForRecord(record);
ExpiringPointer<ContinuousFunction> f = functionStore()->modelForRecord(record);
int plotTypeIndex = static_cast<int>(f->plotType());
m_numberOfColumnsForType[plotTypeIndex] += numberOfColumnsForRecord(record);
}
m_numberOfColumns = 0;
for (int plotTypeIndex = 0; plotTypeIndex < CartesianFunction::k_numberOfPlotTypes; plotTypeIndex++) {
for (int plotTypeIndex = 0; plotTypeIndex < ContinuousFunction::k_numberOfPlotTypes; plotTypeIndex++) {
m_numberOfColumnsForType[plotTypeIndex] += (m_numberOfColumnsForType[plotTypeIndex] > 0);
m_numberOfColumns += m_numberOfColumnsForType[plotTypeIndex];
}

View File

@@ -32,7 +32,7 @@ public:
void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection = false) override;
private:
constexpr static int k_maxNumberOfFunctions = 5;
constexpr static int k_maxNumberOfAbscissaCells = Shared::CartesianFunction::k_numberOfPlotTypes * k_maxNumberOfRows;
constexpr static int k_maxNumberOfAbscissaCells = Shared::ContinuousFunction::k_numberOfPlotTypes * k_maxNumberOfRows;
constexpr static int k_maxNumberOfCells = k_maxNumberOfFunctions * k_maxNumberOfRows;
void setStartEndMessages(Shared::IntervalParameterController * controller, int column) override;
@@ -42,7 +42,7 @@ private:
int numberOfColumnsForRecord(Ion::Storage::Record record) const;
Shared::Interval * intervalAtColumn(int columnIndex) override;
I18n::Message valuesParameterMessageAtColumn(int columnIndex) const override;
Shared::CartesianFunction::PlotType plotTypeAtColumn(int * i) const;
Shared::ContinuousFunction::PlotType plotTypeAtColumn(int * i) const;
int maxNumberOfCells() override;
int maxNumberOfFunctions() override;
double evaluationOfAbscissaAtColumn(double abscissa, int columnIndex) override;
@@ -51,14 +51,14 @@ private:
EvenOddBufferTextCell * floatCells(int j) override;
int abscissaCellsCount() const override { return k_maxNumberOfAbscissaCells; }
EvenOddEditableTextCell * abscissaCells(int j) override { assert (j >= 0 && j < k_maxNumberOfAbscissaCells); return &m_abscissaCells[j]; }
int abscissaTitleCellsCount() const override { return Shared::CartesianFunction::k_numberOfPlotTypes; }
int abscissaTitleCellsCount() const override { return Shared::ContinuousFunction::k_numberOfPlotTypes; }
EvenOddMessageTextCell * abscissaTitleCells(int j) override { assert (j >= 0 && j < abscissaTitleCellsCount()); return &m_abscissaTitleCells[j]; }
ViewController * functionParameterController() override;
mutable int m_numberOfColumnsForType[Shared::CartesianFunction::k_numberOfPlotTypes];
mutable int m_numberOfColumnsForType[Shared::ContinuousFunction::k_numberOfPlotTypes];
Shared::BufferFunctionTitleCell m_functionTitleCells[k_maxNumberOfFunctions];
Shared::HideableEvenOddBufferTextCell m_floatCells[k_maxNumberOfCells];
AbscissaTitleCell m_abscissaTitleCells[Shared::CartesianFunction::k_numberOfPlotTypes];
AbscissaTitleCell m_abscissaTitleCells[Shared::ContinuousFunction::k_numberOfPlotTypes];
Shared::StoreCell m_abscissaCells[k_maxNumberOfAbscissaCells];
FunctionParameterController m_functionParameterController;
Shared::IntervalParameterController m_intervalParameterController;

View File

@@ -22,7 +22,7 @@ namespace Shared {
static inline double maxDouble(double x, double y) { return x > y ? x : y; }
static inline double minDouble(double x, double y) { return x < y ? x : y; }
void CartesianFunction::DefaultName(char buffer[], size_t bufferSize) {
void ContinuousFunction::DefaultName(char buffer[], size_t bufferSize) {
constexpr int k_maxNumberOfDefaultLetterNames = 4;
static constexpr const char k_defaultLetterNames[k_maxNumberOfDefaultLetterNames] = {
'f', 'g', 'h', 'p'
@@ -53,7 +53,7 @@ void CartesianFunction::DefaultName(char buffer[], size_t bufferSize) {
assert(currentNumberLength >= 0 && currentNumberLength < availableBufferSize);
}
CartesianFunction CartesianFunction::NewModel(Ion::Storage::Record::ErrorStatus * error, const char * baseName) {
ContinuousFunction ContinuousFunction::NewModel(Ion::Storage::Record::ErrorStatus * error, const char * baseName) {
static int s_colorIndex = 0;
// Create the record
char nameBuffer[SymbolAbstract::k_maxNameSize];
@@ -67,14 +67,14 @@ CartesianFunction CartesianFunction::NewModel(Ion::Storage::Record::ErrorStatus
// Return if error
if (*error != Ion::Storage::Record::ErrorStatus::None) {
return CartesianFunction();
return ContinuousFunction();
}
// Return the CartesianFunction withthe new record
return CartesianFunction(Ion::Storage::sharedStorage()->recordBaseNamedWithExtension(baseName, Ion::Storage::funcExtension));
// Return the ContinuousFunction withthe new record
return ContinuousFunction(Ion::Storage::sharedStorage()->recordBaseNamedWithExtension(baseName, Ion::Storage::funcExtension));
}
int CartesianFunction::derivativeNameWithArgument(char * buffer, size_t bufferSize) {
int ContinuousFunction::derivativeNameWithArgument(char * buffer, size_t bufferSize) {
// Fill buffer with f(x). Keep size for derivative sign.
int derivativeSize = UTF8Decoder::CharSizeOfCodePoint('\'');
int numberOfChars = nameWithArgument(buffer, bufferSize - derivativeSize);
@@ -88,7 +88,7 @@ int CartesianFunction::derivativeNameWithArgument(char * buffer, size_t bufferSi
return numberOfChars + derivativeSize;
}
Poincare::Expression CartesianFunction::expressionReduced(Poincare::Context * context) const {
Poincare::Expression ContinuousFunction::expressionReduced(Poincare::Context * context) const {
Poincare::Expression result = ExpressionModelHandle::expressionReduced(context);
if (plotType() == PlotType::Parametric && (
result.type() != Poincare::ExpressionNode::Type::Matrix ||
@@ -100,11 +100,11 @@ Poincare::Expression CartesianFunction::expressionReduced(Poincare::Context * co
return result;
}
I18n::Message CartesianFunction::parameterMessageName() const {
I18n::Message ContinuousFunction::parameterMessageName() const {
return ParameterMessageForPlotType(plotType());
}
CodePoint CartesianFunction::symbol() const {
CodePoint ContinuousFunction::symbol() const {
switch (plotType()) {
case PlotType::Cartesian:
return 'x';
@@ -116,11 +116,11 @@ CodePoint CartesianFunction::symbol() const {
}
}
CartesianFunction::PlotType CartesianFunction::plotType() const {
ContinuousFunction::PlotType ContinuousFunction::plotType() const {
return recordData()->plotType();
}
void CartesianFunction::setPlotType(PlotType newPlotType, Poincare::Preferences::AngleUnit angleUnit) {
void ContinuousFunction::setPlotType(PlotType newPlotType, Poincare::Preferences::AngleUnit angleUnit) {
PlotType currentPlotType = plotType();
if (newPlotType == currentPlotType) {
return;
@@ -174,7 +174,7 @@ void CartesianFunction::setPlotType(PlotType newPlotType, Poincare::Preferences:
}
}
I18n::Message CartesianFunction::ParameterMessageForPlotType(PlotType plotType) {
I18n::Message ContinuousFunction::ParameterMessageForPlotType(PlotType plotType) {
if (plotType == PlotType::Cartesian) {
return I18n::Message::X;
}
@@ -186,7 +186,7 @@ I18n::Message CartesianFunction::ParameterMessageForPlotType(PlotType plotType)
}
template <typename T>
Poincare::Coordinate2D<T> CartesianFunction::privateEvaluateXYAtParameter(T t, Poincare::Context * context) const {
Poincare::Coordinate2D<T> ContinuousFunction::privateEvaluateXYAtParameter(T t, Poincare::Context * context) const {
Coordinate2D<T> x1x2 = templatedApproximateAtParameter(t, context);
PlotType type = plotType();
if (type == PlotType::Cartesian || type == PlotType::Parametric) {
@@ -206,15 +206,15 @@ Poincare::Coordinate2D<T> CartesianFunction::privateEvaluateXYAtParameter(T t, P
return Coordinate2D<T>(x1x2.x2() * std::cos(angle), x1x2.x2() * std::sin(angle));
}
bool CartesianFunction::displayDerivative() const {
bool ContinuousFunction::displayDerivative() const {
return recordData()->displayDerivative();
}
void CartesianFunction::setDisplayDerivative(bool display) {
void ContinuousFunction::setDisplayDerivative(bool display) {
return recordData()->setDisplayDerivative(display);
}
int CartesianFunction::printValue(double cursorT, double cursorX, double cursorY, char * buffer, int bufferSize, int precision, Poincare::Context * context) {
int ContinuousFunction::printValue(double cursorT, double cursorX, double cursorY, char * buffer, int bufferSize, int precision, Poincare::Context * context) {
PlotType type = plotType();
if (type == PlotType::Cartesian) {
return Function::printValue(cursorT, cursorX, cursorY, buffer, bufferSize, precision, context);
@@ -232,7 +232,7 @@ int CartesianFunction::printValue(double cursorT, double cursorX, double cursorY
return result;
}
double CartesianFunction::approximateDerivative(double x, Poincare::Context * context) const {
double ContinuousFunction::approximateDerivative(double x, Poincare::Context * context) const {
assert(plotType() == PlotType::Cartesian);
if (x < tMin() || x > tMax()) {
return NAN;
@@ -244,38 +244,38 @@ double CartesianFunction::approximateDerivative(double x, Poincare::Context * co
return PoincareHelpers::ApproximateToScalar<double>(derivative, context);
}
float CartesianFunction::tMin() const {
float ContinuousFunction::tMin() const {
return recordData()->tMin();
}
float CartesianFunction::tMax() const {
float ContinuousFunction::tMax() const {
return recordData()->tMax();
}
void CartesianFunction::setTMin(float tMin) {
void ContinuousFunction::setTMin(float tMin) {
recordData()->setTMin(tMin);
}
void CartesianFunction::setTMax(float tMax) {
void ContinuousFunction::setTMax(float tMax) {
recordData()->setTMax(tMax);
}
void * CartesianFunction::Model::expressionAddress(const Ion::Storage::Record * record) const {
void * ContinuousFunction::Model::expressionAddress(const Ion::Storage::Record * record) const {
return (char *)record->value().buffer+sizeof(RecordDataBuffer);
}
size_t CartesianFunction::Model::expressionSize(const Ion::Storage::Record * record) const {
size_t ContinuousFunction::Model::expressionSize(const Ion::Storage::Record * record) const {
return record->value().size-sizeof(RecordDataBuffer);
}
CartesianFunction::RecordDataBuffer * CartesianFunction::recordData() const {
ContinuousFunction::RecordDataBuffer * ContinuousFunction::recordData() const {
assert(!isNull());
Ion::Storage::Record::Data d = value();
return reinterpret_cast<RecordDataBuffer *>(const_cast<void *>(d.buffer));
}
template<typename T>
Coordinate2D<T> CartesianFunction::templatedApproximateAtParameter(T t, Poincare::Context * context) const {
Coordinate2D<T> ContinuousFunction::templatedApproximateAtParameter(T t, Poincare::Context * context) const {
if (isCircularlyDefined(context) || t < tMin() || t > tMax()) {
return Coordinate2D<T>(plotType() == PlotType::Cartesian ? t : NAN, NAN);
}
@@ -296,19 +296,19 @@ Coordinate2D<T> CartesianFunction::templatedApproximateAtParameter(T t, Poincare
PoincareHelpers::ApproximateWithValueForSymbol(e.childAtIndex(1), unknown, t, context));
}
Coordinate2D<double> CartesianFunction::nextMinimumFrom(double start, double step, double max, Context * context) const {
Coordinate2D<double> ContinuousFunction::nextMinimumFrom(double start, double step, double max, Context * context) const {
return nextPointOfInterestFrom(start, step, max, context, [](Expression e, char * symbol, double start, double step, double max, Context * context) { return PoincareHelpers::NextMinimum(e, symbol, start, step, max, context); });
}
Coordinate2D<double> CartesianFunction::nextMaximumFrom(double start, double step, double max, Context * context) const {
Coordinate2D<double> ContinuousFunction::nextMaximumFrom(double start, double step, double max, Context * context) const {
return nextPointOfInterestFrom(start, step, max, context, [](Expression e, char * symbol, double start, double step, double max, Context * context) { return PoincareHelpers::NextMaximum(e, symbol, start, step, max, context); });
}
Coordinate2D<double> CartesianFunction::nextRootFrom(double start, double step, double max, Context * context) const {
Coordinate2D<double> ContinuousFunction::nextRootFrom(double start, double step, double max, Context * context) const {
return nextPointOfInterestFrom(start, step, max, context, [](Expression e, char * symbol, double start, double step, double max, Context * context) { return Coordinate2D<double>(PoincareHelpers::NextRoot(e, symbol, start, step, max, context), 0.0); });
}
Coordinate2D<double> CartesianFunction::nextIntersectionFrom(double start, double step, double max, Poincare::Context * context, Poincare::Expression e, double eDomainMin, double eDomainMax) const {
Coordinate2D<double> ContinuousFunction::nextIntersectionFrom(double start, double step, double max, Poincare::Context * context, Poincare::Expression e, double eDomainMin, double eDomainMax) const {
assert(plotType() == PlotType::Cartesian);
constexpr int bufferSize = CodePoint::MaxCodePointCharLength + 1;
char unknownX[bufferSize];
@@ -325,7 +325,7 @@ Coordinate2D<double> CartesianFunction::nextIntersectionFrom(double start, doubl
return PoincareHelpers::NextIntersection(expressionReduced(context), unknownX, start, step, max, context, e);
}
Coordinate2D<double> CartesianFunction::nextPointOfInterestFrom(double start, double step, double max, Context * context, ComputePointOfInterest compute) const {
Coordinate2D<double> ContinuousFunction::nextPointOfInterestFrom(double start, double step, double max, Context * context, ComputePointOfInterest compute) const {
assert(plotType() == PlotType::Cartesian);
constexpr int bufferSize = CodePoint::MaxCodePointCharLength + 1;
char unknownX[bufferSize];
@@ -340,7 +340,7 @@ Coordinate2D<double> CartesianFunction::nextPointOfInterestFrom(double start, do
return compute(expressionReduced(context), unknownX, start, step, max, context);
}
Poincare::Expression CartesianFunction::sumBetweenBounds(double start, double end, Poincare::Context * context) const {
Poincare::Expression ContinuousFunction::sumBetweenBounds(double start, double end, Poincare::Context * context) const {
assert(plotType() == PlotType::Cartesian);
start = maxDouble(start, tMin());
end = minDouble(end, tMax());
@@ -350,7 +350,7 @@ Poincare::Expression CartesianFunction::sumBetweenBounds(double start, double en
* the derivative table. */
}
template Coordinate2D<float> CartesianFunction::templatedApproximateAtParameter<float>(float, Poincare::Context *) const;
template Coordinate2D<double> CartesianFunction::templatedApproximateAtParameter<double>(double, Poincare::Context *) const;
template Coordinate2D<float> ContinuousFunction::templatedApproximateAtParameter<float>(float, Poincare::Context *) const;
template Coordinate2D<double> ContinuousFunction::templatedApproximateAtParameter<double>(double, Poincare::Context *) const;
}

View File

@@ -1,6 +1,14 @@
#ifndef SHARED_CARTESIAN_FUNCTION_H
#define SHARED_CARTESIAN_FUNCTION_H
/* Although the considered functions are not generally continuous
* mathematically speaking, the present class is named ContinuousFunction to
* mark the difference with the Sequence class.
*
* We could not simply name it Function, since such a class already exists:
* it is the base class of ContinuousFunction and Sequence.
*/
#include "global_context.h"
#include "function.h"
#include "range_1D.h"
@@ -9,11 +17,11 @@
namespace Shared {
class CartesianFunction : public Function {
class ContinuousFunction : public Function {
public:
static void DefaultName(char buffer[], size_t bufferSize);
static CartesianFunction NewModel(Ion::Storage::Record::ErrorStatus * error, const char * baseName = nullptr);
CartesianFunction(Ion::Storage::Record record = Record()) :
static ContinuousFunction NewModel(Ion::Storage::Record::ErrorStatus * error, const char * baseName = nullptr);
ContinuousFunction(Ion::Storage::Record record = Record()) :
Function(record)
{}
I18n::Message parameterMessageName() const override;
@@ -71,7 +79,7 @@ private:
Poincare::Coordinate2D<double> nextPointOfInterestFrom(double start, double step, double max, Poincare::Context * context, ComputePointOfInterest compute) const;
template <typename T> Poincare::Coordinate2D<T> privateEvaluateXYAtParameter(T t, Poincare::Context * context) const;
/* RecordDataBuffer is the layout of the data buffer of Record
* representing a CartesianFunction. See comment on
* representing a ContinuousFunction. See comment on
* Shared::Function::RecordDataBuffer about packing. */
class __attribute__((packed)) RecordDataBuffer : public Function::RecordDataBuffer {
public:

View File

@@ -32,7 +32,7 @@ Poincare::Expression GlobalContext::ExpressionFromFunctionRecord(Ion::Storage::R
}
/* An function record value has metadata before the expression. To get the
* expression, use the function record handle. */
CartesianFunction f = CartesianFunction(record);
ContinuousFunction f = ContinuousFunction(record);
return f.expressionClone();
}
@@ -42,7 +42,7 @@ const Layout GlobalContext::LayoutForRecord(Ion::Storage::Record record) {
return PoincareHelpers::CreateLayout(ExpressionFromSymbolRecord(record));
} else {
assert(Ion::Storage::FullNameHasExtension(record.fullName(), Ion::Storage::funcExtension, strlen(Ion::Storage::funcExtension)));
return CartesianFunction(record).layout();
return ContinuousFunction(record).layout();
}
}
@@ -113,13 +113,13 @@ Ion::Storage::Record::ErrorStatus GlobalContext::SetExpressionForFunction(const
if (!Ion::Storage::FullNameHasExtension(previousRecord.fullName(), Ion::Storage::funcExtension, strlen(Ion::Storage::funcExtension))) {
// The previous record was not a function. Destroy it and create the new record.
previousRecord.destroy();
CartesianFunction newModel = CartesianFunction::NewModel(&error, symbol.name());
ContinuousFunction newModel = ContinuousFunction::NewModel(&error, symbol.name());
if (error != Ion::Storage::Record::ErrorStatus::None) {
return error;
}
recordToSet = newModel;
}
error = CartesianFunction(recordToSet).setExpressionContent(expressionToStore);
error = ContinuousFunction(recordToSet).setExpressionContent(expressionToStore);
return error;
}

View File

@@ -106,7 +106,7 @@ void VariableBoxController::willDisplayCellForIndex(HighlightCell * cell, int in
symbolLength = SymbolAbstract::TruncateExtension(symbolName, record.fullName(), SymbolAbstract::k_maxNameSize);
} else {
assert(m_currentPage == Page::Function);
CartesianFunction f(record);
ContinuousFunction f(record);
symbolLength = f.nameWithArgument(
symbolName,
Shared::Function::k_maxNameWithArgumentSize

View File

@@ -5,7 +5,7 @@
#include <stdio.h>
namespace Shared {
class CartesianFunction;
class ContinuousFunction;
}
namespace Poincare {
@@ -25,7 +25,7 @@ namespace Poincare {
class TreeHandle {
template<class T>
friend class ArrayBuilder;
friend class ::Shared::CartesianFunction;
friend class ::Shared::ContinuousFunction;
friend class TreeNode;
friend class TreePool;
public: