mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[poincare] Start removing ExpressionLayout
This commit is contained in:
@@ -66,21 +66,18 @@ void Calculation::setContent(const char * c, Context * context, Expression * ans
|
||||
|
||||
KDCoordinate Calculation::height(Context * context) {
|
||||
if (m_height < 0) {
|
||||
ExpressionLayout * inputLayout = createInputLayout();
|
||||
KDCoordinate inputHeight = inputLayout->size().height();
|
||||
delete inputLayout;
|
||||
Poincare::ExpressionLayout * approximateLayout = createApproximateOutputLayout(context);
|
||||
KDCoordinate approximateOutputHeight = approximateLayout->size().height();
|
||||
LayoutRef inputLayout = createInputLayout();
|
||||
KDCoordinate inputHeight = inputLayout.layoutSize().height();
|
||||
LayoutRef approximateLayout = createApproximateOutputLayout(context);
|
||||
KDCoordinate approximateOutputHeight = approximateLayout.layoutSize().height();
|
||||
if (shouldOnlyDisplayApproximateOutput(context)) {
|
||||
m_height = inputHeight+approximateOutputHeight;
|
||||
} else {
|
||||
Poincare::ExpressionLayout * exactLayout = createExactOutputLayout(context);
|
||||
KDCoordinate exactOutputHeight = exactLayout->size().height();
|
||||
KDCoordinate outputHeight = max(exactLayout->baseline(), approximateLayout->baseline()) + max(exactOutputHeight-exactLayout->baseline(), approximateOutputHeight-approximateLayout->baseline());
|
||||
delete exactLayout;
|
||||
LayoutRef exactLayout = createExactOutputLayout(context);
|
||||
KDCoordinate exactOutputHeight = exactLayout.layoutSize().height();
|
||||
KDCoordinate outputHeight = max(exactLayout.baseline(), approximateLayout.baseline()) + max(exactOutputHeight-exactLayout.baseline(), approximateOutputHeight-approximateLayout.baseline());
|
||||
m_height = inputHeight + outputHeight;
|
||||
}
|
||||
delete approximateLayout;
|
||||
}
|
||||
return m_height;
|
||||
}
|
||||
@@ -104,11 +101,11 @@ Expression * Calculation::input() {
|
||||
return m_input;
|
||||
}
|
||||
|
||||
ExpressionLayout * Calculation::createInputLayout() {
|
||||
LayoutRef Calculation::createInputLayout() {
|
||||
if (input() != nullptr) {
|
||||
return input()->createLayout(PrintFloat::Mode::Decimal, Expression::ComplexFormat::Cartesian);
|
||||
}
|
||||
return nullptr;
|
||||
return LayoutRef(nullptr);
|
||||
}
|
||||
|
||||
bool Calculation::isEmpty() {
|
||||
@@ -156,11 +153,11 @@ Expression * Calculation::exactOutput(Context * context) {
|
||||
return m_exactOutput;
|
||||
}
|
||||
|
||||
ExpressionLayout * Calculation::createExactOutputLayout(Context * context) {
|
||||
LayoutRef Calculation::createExactOutputLayout(Context * context) {
|
||||
if (exactOutput(context) != nullptr) {
|
||||
return exactOutput(context)->createLayout();
|
||||
}
|
||||
return nullptr;
|
||||
return LayoutRef(nullptr);
|
||||
}
|
||||
|
||||
Expression * Calculation::approximateOutput(Context * context) {
|
||||
@@ -178,11 +175,11 @@ Expression * Calculation::approximateOutput(Context * context) {
|
||||
return m_approximateOutput;
|
||||
}
|
||||
|
||||
ExpressionLayout * Calculation::createApproximateOutputLayout(Context * context) {
|
||||
LayoutRef Calculation::createApproximateOutputLayout(Context * context) {
|
||||
if (approximateOutput(context) != nullptr) {
|
||||
return approximateOutput(context)->createLayout();
|
||||
}
|
||||
return nullptr;
|
||||
return LayoutRef(nullptr);
|
||||
}
|
||||
|
||||
bool Calculation::shouldOnlyDisplayApproximateOutput(Context * context) {
|
||||
|
||||
@@ -29,11 +29,11 @@ public:
|
||||
const char * exactOutputText();
|
||||
const char * approximateOutputText();
|
||||
Poincare::Expression * input();
|
||||
Poincare::ExpressionLayout * createInputLayout();
|
||||
Poincare::LayoutRef createInputLayout();
|
||||
Poincare::Expression * approximateOutput(Poincare::Context * context);
|
||||
Poincare::Expression * exactOutput(Poincare::Context * context);
|
||||
Poincare::ExpressionLayout * createExactOutputLayout(Poincare::Context * context);
|
||||
Poincare::ExpressionLayout * createApproximateOutputLayout(Poincare::Context * context);
|
||||
Poincare::LayoutRef createExactOutputLayout(Poincare::Context * context);
|
||||
Poincare::LayoutRef createApproximateOutputLayout(Poincare::Context * context);
|
||||
bool isEmpty();
|
||||
void tidy();
|
||||
bool shouldOnlyDisplayApproximateOutput(Poincare::Context * context);
|
||||
|
||||
@@ -18,25 +18,10 @@ HistoryViewCell::HistoryViewCell(Responder * parentResponder) :
|
||||
{
|
||||
}
|
||||
|
||||
HistoryViewCell::~HistoryViewCell() {
|
||||
if (m_inputLayout != nullptr) {
|
||||
delete m_inputLayout;
|
||||
m_inputLayout = nullptr;
|
||||
}
|
||||
if (m_exactOutputLayout != nullptr) {
|
||||
delete m_exactOutputLayout;
|
||||
m_exactOutputLayout = nullptr;
|
||||
}
|
||||
if (m_approximateOutputLayout != nullptr) {
|
||||
delete m_approximateOutputLayout;
|
||||
m_approximateOutputLayout = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Shared::ScrollableExactApproximateExpressionsView * HistoryViewCell::outputView() {
|
||||
return &m_scrollableOutputView;
|
||||
|
||||
}
|
||||
|
||||
void HistoryViewCell::setEven(bool even) {
|
||||
EvenOddCell::setEven(even);
|
||||
m_inputView.setBackgroundColor(backgroundColor());
|
||||
@@ -57,11 +42,11 @@ void HistoryViewCell::setHighlighted(bool highlight) {
|
||||
reloadScroll();
|
||||
}
|
||||
|
||||
Poincare::ExpressionLayout * HistoryViewCell::expressionLayout() const {
|
||||
Poincare::LayoutRef HistoryViewCell::layoutRef() const {
|
||||
if (m_selectedSubviewType == SubviewType::Input) {
|
||||
return m_inputLayout;
|
||||
} else {
|
||||
return m_scrollableOutputView.expressionLayout();
|
||||
return m_scrollableOutputView.layoutRef();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,27 +94,20 @@ void HistoryViewCell::layoutSubviews() {
|
||||
}
|
||||
|
||||
void HistoryViewCell::setCalculation(Calculation * calculation) {
|
||||
if (m_inputLayout) {
|
||||
delete m_inputLayout;
|
||||
}
|
||||
m_inputLayout = calculation->createInputLayout();
|
||||
m_inputView.setExpressionLayout(m_inputLayout);
|
||||
m_inputView.setLayoutRef(m_inputLayout);
|
||||
App * calculationApp = (App *)app();
|
||||
/* Both output expressions have to be updated at the same time. Otherwise,
|
||||
* when updating one layout, if the second one still points to a deleted
|
||||
* layout, calling to layoutSubviews() would fail. */
|
||||
if (m_exactOutputLayout) {
|
||||
delete m_exactOutputLayout;
|
||||
m_exactOutputLayout = nullptr;
|
||||
if (m_exactOutputLayout.isDefined()) {
|
||||
m_exactOutputLayout = Poincare::LayoutRef(nullptr);
|
||||
}
|
||||
if (!calculation->shouldOnlyDisplayApproximateOutput(calculationApp->localContext())) {
|
||||
m_exactOutputLayout = calculation->createExactOutputLayout(calculationApp->localContext());
|
||||
}
|
||||
if (m_approximateOutputLayout) {
|
||||
delete m_approximateOutputLayout;
|
||||
}
|
||||
m_approximateOutputLayout = calculation->createApproximateOutputLayout(calculationApp->localContext());
|
||||
Poincare::ExpressionLayout * outputExpressions[2] = {m_approximateOutputLayout, m_exactOutputLayout};
|
||||
Poincare::LayoutRef outputExpressions[2] = {m_approximateOutputLayout, m_exactOutputLayout};
|
||||
m_scrollableOutputView.setExpressions(outputExpressions);
|
||||
I18n::Message equalMessage = calculation->exactAndApproximateDisplayedOutputsAreEqual(calculationApp->localContext()) == Calculation::EqualSign::Equal ? I18n::Message::Equal : I18n::Message::AlmostEqual;
|
||||
m_scrollableOutputView.setEqualMessage(equalMessage);
|
||||
|
||||
@@ -15,7 +15,6 @@ public:
|
||||
Output
|
||||
};
|
||||
HistoryViewCell(Responder * parentResponder);
|
||||
~HistoryViewCell();
|
||||
void reloadCell() override;
|
||||
void reloadScroll();
|
||||
void setEven(bool even) override;
|
||||
@@ -23,7 +22,7 @@ public:
|
||||
Responder * responder() override {
|
||||
return this;
|
||||
}
|
||||
Poincare::ExpressionLayout * expressionLayout() const override;
|
||||
Poincare::LayoutRef layoutRef() const override;
|
||||
KDColor backgroundColor() const override;
|
||||
void setCalculation(Calculation * calculation);
|
||||
int numberOfSubviews() const override;
|
||||
@@ -37,9 +36,9 @@ public:
|
||||
Shared::ScrollableExactApproximateExpressionsView * outputView();
|
||||
private:
|
||||
constexpr static KDCoordinate k_resultWidth = 80;
|
||||
Poincare::ExpressionLayout * m_inputLayout;
|
||||
Poincare::ExpressionLayout * m_exactOutputLayout;
|
||||
Poincare::ExpressionLayout * m_approximateOutputLayout;
|
||||
Poincare::LayoutRef m_inputLayout;
|
||||
Poincare::LayoutRef m_exactOutputLayout;
|
||||
Poincare::LayoutRef m_approximateOutputLayout;
|
||||
ScrollableExpressionView m_inputView;
|
||||
Shared::ScrollableExactApproximateExpressionsView m_scrollableOutputView;
|
||||
SubviewType m_selectedSubviewType;
|
||||
|
||||
@@ -10,8 +10,8 @@ ScrollableExpressionView::ScrollableExpressionView(Responder * parentResponder)
|
||||
{
|
||||
}
|
||||
|
||||
void ScrollableExpressionView::setExpressionLayout(ExpressionLayout * expressionLayout) {
|
||||
m_expressionView.setExpressionLayout(expressionLayout);
|
||||
void ScrollableExpressionView::setLayoutRef(LayoutRef layoutRef) {
|
||||
m_expressionView.setLayoutRef(layoutRef);
|
||||
layoutSubviews();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Calculation {
|
||||
class ScrollableExpressionView : public ScrollableView, public ScrollViewDataSource {
|
||||
public:
|
||||
ScrollableExpressionView(Responder * parentResponder);
|
||||
void setExpressionLayout(Poincare::ExpressionLayout * expressionLayout);
|
||||
void setLayoutRef(Poincare::LayoutRef layoutRef);
|
||||
void setBackgroundColor(KDColor backgroundColor) override;
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
private:
|
||||
|
||||
@@ -10,16 +10,15 @@ namespace Shared {
|
||||
ExpressionModel::ExpressionModel() :
|
||||
m_text{0},
|
||||
m_expression(nullptr),
|
||||
m_layout(nullptr)
|
||||
m_layoutRef(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
ExpressionModel::~ExpressionModel() {
|
||||
/* We cannot call tidy here because tidy is a virtual function and does not
|
||||
* do the same thing for all children class. */
|
||||
if (m_layout != nullptr) {
|
||||
delete m_layout;
|
||||
m_layout = nullptr;
|
||||
if (m_layoutRef.isDefined()) {
|
||||
m_layoutRef = LayoutRef(nullptr);
|
||||
}
|
||||
if (m_expression != nullptr) {
|
||||
delete m_expression;
|
||||
@@ -44,15 +43,15 @@ Poincare::Expression * ExpressionModel::expression(Poincare::Context * context)
|
||||
return m_expression;
|
||||
}
|
||||
|
||||
Poincare::ExpressionLayout * ExpressionModel::layout() {
|
||||
if (m_layout == nullptr) {
|
||||
LayoutRef ExpressionModel::layoutRef() {
|
||||
if (!m_layoutRef.isDefined()) {
|
||||
Expression * nonSimplifiedExpression = Expression::parse(m_text);
|
||||
if (nonSimplifiedExpression != nullptr) {
|
||||
m_layout = nonSimplifiedExpression->createLayout(PrintFloat::Mode::Decimal);
|
||||
m_layoutRef = nonSimplifiedExpression->createLayout(PrintFloat::Mode::Decimal);
|
||||
delete nonSimplifiedExpression;
|
||||
}
|
||||
}
|
||||
return m_layout;
|
||||
return m_layoutRef;
|
||||
}
|
||||
|
||||
bool ExpressionModel::isDefined() {
|
||||
@@ -68,9 +67,8 @@ void ExpressionModel::setContent(const char * c) {
|
||||
/* We cannot call tidy here because tidy is a virtual function and does not
|
||||
* do the same thing for all children class. And here we want to delete only
|
||||
* the m_layout and m_expression. */
|
||||
if (m_layout != nullptr) {
|
||||
delete m_layout;
|
||||
m_layout = nullptr;
|
||||
if (m_layoutRef.isDefined()) {
|
||||
m_layoutRef = LayoutRef(nullptr);
|
||||
}
|
||||
if (m_expression != nullptr) {
|
||||
delete m_expression;
|
||||
@@ -79,9 +77,8 @@ void ExpressionModel::setContent(const char * c) {
|
||||
}
|
||||
|
||||
void ExpressionModel::tidy() {
|
||||
if (m_layout != nullptr) {
|
||||
delete m_layout;
|
||||
m_layout = nullptr;
|
||||
if (m_layoutRef.isDefined()) {
|
||||
m_layoutRef = LayoutRef(nullptr);
|
||||
}
|
||||
if (m_expression != nullptr) {
|
||||
delete m_expression;
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
ExpressionModel(ExpressionModel&& other) = delete;
|
||||
const char * text() const;
|
||||
Poincare::Expression * expression(Poincare::Context * context) const;
|
||||
Poincare::ExpressionLayout * layout();
|
||||
Poincare::LayoutRef layoutRef();
|
||||
/* Here, isDefined is the exact contrary of isEmpty. However, for Sequence
|
||||
* inheriting from ExpressionModel, isEmpty and isDefined have not exactly
|
||||
* opposite meaning. For instance, u(n+1)=u(n) & u(0) = ... is not empty and
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
static_assert((k_dataLengthInBytes & 0x3) == 0, "The expression model data size is not a multiple of 4 bytes (cannot compute crc)"); // Assert that dataLengthInBytes is a multiple of 4
|
||||
char m_text[k_expressionBufferSize];
|
||||
mutable Poincare::Expression * m_expression;
|
||||
mutable Poincare::ExpressionLayout * m_layout;
|
||||
mutable Poincare::LayoutRef m_layoutRef;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -23,17 +23,18 @@ KDCoordinate ExpressionModelListController::expressionRowHeight(int j) {
|
||||
return Metric::StoreRowHeight;
|
||||
}
|
||||
ExpressionModel * m = modelStore()->modelAtIndex(j);
|
||||
if (m->layout() == nullptr) {
|
||||
if (!m->layoutRef().isDefined()) {
|
||||
return Metric::StoreRowHeight;
|
||||
}
|
||||
KDCoordinate modelSize = m->layout()->size().height();
|
||||
KDCoordinate modelSize = m->layoutRef().layoutSize().height();
|
||||
return modelSize + Metric::StoreRowHeight - KDText::charSize().height();
|
||||
}
|
||||
|
||||
void ExpressionModelListController::willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) {
|
||||
EvenOddExpressionCell * myCell = (EvenOddExpressionCell *)cell;
|
||||
ExpressionModel * m = modelStore()->modelAtIndex(j);
|
||||
myCell->setExpressionLayout(m->layout());
|
||||
myCell->setExpressionLayout(nullptr); //TODO
|
||||
//myCell->setExpressionLayout(m->layout());
|
||||
}
|
||||
|
||||
/* Responder */
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace Shared {
|
||||
class ScrollableExactApproximateExpressionsCell : public ::EvenOddCell, public Responder {
|
||||
public:
|
||||
ScrollableExactApproximateExpressionsCell(Responder * parentResponder = nullptr);
|
||||
void setExpressions(Poincare::ExpressionLayout ** expressionsLayout) {
|
||||
return m_view.setExpressions(expressionsLayout);
|
||||
void setExpressions(Poincare::LayoutRef * layoutRefs) {
|
||||
return m_view.setExpressions(layoutRefs); // TODO rename setLayouts
|
||||
}
|
||||
void setEqualMessage(I18n::Message equalSignMessage) {
|
||||
return m_view.setEqualMessage(equalSignMessage);
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
Responder * responder() override {
|
||||
return this;
|
||||
}
|
||||
Poincare::ExpressionLayout * expressionLayout() const override { return m_view.expressionLayout(); }
|
||||
Poincare::LayoutRef layoutRef() const override { return m_view.layoutRef(); }
|
||||
void didBecomeFirstResponder() override;
|
||||
constexpr static KDCoordinate k_margin = 5;
|
||||
private:
|
||||
|
||||
@@ -49,8 +49,8 @@ KDSize ScrollableExactApproximateExpressionsView::ContentCell::minimalSizeForOpt
|
||||
return approximateExpressionSize;
|
||||
}
|
||||
KDSize exactExpressionSize = m_exactExpressionView.minimalSizeForOptimalDisplay();
|
||||
KDCoordinate exactBaseline = m_exactExpressionView.expressionLayout()->baseline();
|
||||
KDCoordinate approximateBaseline = m_approximateExpressionView.expressionLayout()->baseline();
|
||||
KDCoordinate exactBaseline = m_exactExpressionView.layoutRef().baseline();
|
||||
KDCoordinate approximateBaseline = m_approximateExpressionView.layoutRef().baseline();
|
||||
KDCoordinate height = max(exactBaseline, approximateBaseline) + max(exactExpressionSize.height()-exactBaseline, approximateExpressionSize.height()-approximateBaseline);
|
||||
KDSize approximateSignSize = m_approximateSign.minimalSizeForOptimalDisplay();
|
||||
return KDSize(exactExpressionSize.width()+approximateSignSize.width()+approximateExpressionSize.width()+2*k_digitHorizontalMargin, height);
|
||||
@@ -61,16 +61,16 @@ void ScrollableExactApproximateExpressionsView::ContentCell::setSelectedSubviewT
|
||||
setHighlighted(isHighlighted());
|
||||
}
|
||||
|
||||
Poincare::ExpressionLayout * ScrollableExactApproximateExpressionsView::ContentCell::expressionLayout() const {
|
||||
Poincare::LayoutRef ScrollableExactApproximateExpressionsView::ContentCell::layoutRef() const {
|
||||
if (m_selectedSubviewType == SubviewType::ExactOutput) {
|
||||
return m_exactExpressionView.expressionLayout();
|
||||
return m_exactExpressionView.layoutRef();
|
||||
} else {
|
||||
return m_approximateExpressionView.expressionLayout();
|
||||
return m_approximateExpressionView.layoutRef();
|
||||
}
|
||||
}
|
||||
|
||||
int ScrollableExactApproximateExpressionsView::ContentCell::numberOfSubviews() const {
|
||||
if (m_exactExpressionView.expressionLayout() != nullptr) {
|
||||
if (m_exactExpressionView.layoutRef().isDefined()) {
|
||||
return 3;
|
||||
}
|
||||
return 1;
|
||||
@@ -88,8 +88,8 @@ void ScrollableExactApproximateExpressionsView::ContentCell::layoutSubviews() {
|
||||
m_approximateExpressionView.setFrame(KDRect(0, 0, approximateExpressionSize.width(), height));
|
||||
return;
|
||||
}
|
||||
KDCoordinate exactBaseline = m_exactExpressionView.expressionLayout()->baseline();
|
||||
KDCoordinate approximateBaseline = m_approximateExpressionView.expressionLayout()->baseline();
|
||||
KDCoordinate exactBaseline = m_exactExpressionView.layoutRef().baseline();
|
||||
KDCoordinate approximateBaseline = m_approximateExpressionView.layoutRef().baseline();
|
||||
KDCoordinate baseline = max(exactBaseline, approximateBaseline);
|
||||
KDSize exactExpressionSize = m_exactExpressionView.minimalSizeForOptimalDisplay();
|
||||
KDSize approximateSignSize = m_approximateSign.minimalSizeForOptimalDisplay();
|
||||
@@ -103,9 +103,10 @@ ScrollableExactApproximateExpressionsView::ScrollableExactApproximateExpressions
|
||||
m_contentCell()
|
||||
{
|
||||
}
|
||||
void ScrollableExactApproximateExpressionsView::setExpressions(ExpressionLayout ** expressionsLayout) {
|
||||
m_contentCell.approximateExpressionView()->setExpressionLayout(expressionsLayout[0]);
|
||||
m_contentCell.exactExpressionView()->setExpressionLayout(expressionsLayout[1]);
|
||||
|
||||
void ScrollableExactApproximateExpressionsView::setExpressions(Poincare::LayoutRef * layoutRefs) {
|
||||
m_contentCell.approximateExpressionView()->setLayoutRef(layoutRefs[0]);
|
||||
m_contentCell.exactExpressionView()->setLayoutRef(layoutRefs[1]);
|
||||
m_contentCell.layoutSubviews();
|
||||
}
|
||||
|
||||
@@ -114,7 +115,7 @@ void ScrollableExactApproximateExpressionsView::setEqualMessage(I18n::Message eq
|
||||
}
|
||||
|
||||
void ScrollableExactApproximateExpressionsView::didBecomeFirstResponder() {
|
||||
if (m_contentCell.exactExpressionView()->expressionLayout() == nullptr) {
|
||||
if (!m_contentCell.exactExpressionView()->layoutRef().isDefined()) {
|
||||
setSelectedSubviewType(SubviewType::ApproximativeOutput);
|
||||
} else {
|
||||
setSelectedSubviewType(SubviewType::ExactOutput);
|
||||
@@ -122,7 +123,7 @@ void ScrollableExactApproximateExpressionsView::didBecomeFirstResponder() {
|
||||
}
|
||||
|
||||
bool ScrollableExactApproximateExpressionsView::handleEvent(Ion::Events::Event event) {
|
||||
if (m_contentCell.exactExpressionView()->expressionLayout() == nullptr) {
|
||||
if (!m_contentCell.exactExpressionView()->layoutRef().isDefined()) {
|
||||
return ScrollableView::handleEvent(event);
|
||||
}
|
||||
bool rightExpressionIsVisible = minimalSizeForOptimalDisplay().width() - m_contentCell.approximateExpressionView()->minimalSizeForOptimalDisplay().width() - m_manualScrollingOffset.x() < bounds().width()
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
::EvenOddCell * evenOddCell() {
|
||||
return &m_contentCell;
|
||||
}
|
||||
void setExpressions(Poincare::ExpressionLayout ** expressionsLayout);
|
||||
void setExpressions(Poincare::LayoutRef * layoutRefs);
|
||||
void setEqualMessage(I18n::Message equalSignMessage);
|
||||
SubviewType selectedSubviewType() {
|
||||
return m_contentCell.selectedSubviewType();
|
||||
@@ -26,8 +26,8 @@ public:
|
||||
void didBecomeFirstResponder() override;
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
Poincare::ExpressionLayout * expressionLayout() const {
|
||||
return m_contentCell.expressionLayout();
|
||||
Poincare::LayoutRef layoutRef() const {
|
||||
return m_contentCell.layoutRef();
|
||||
}
|
||||
private:
|
||||
class ContentCell : public ::EvenOddCell {
|
||||
@@ -52,7 +52,7 @@ private:
|
||||
void setSelectedSubviewType(SubviewType subviewType);
|
||||
void layoutSubviews() override;
|
||||
int numberOfSubviews() const override;
|
||||
Poincare::ExpressionLayout * expressionLayout() const override;
|
||||
Poincare::LayoutRef layoutRef() const override;
|
||||
private:
|
||||
View * subviewAtIndex(int index) override;
|
||||
constexpr static KDCoordinate k_digitHorizontalMargin = 10;
|
||||
|
||||
@@ -202,7 +202,7 @@ bool SumGraphController::handleEnter() {
|
||||
|
||||
SumGraphController::LegendView::LegendView(SumGraphController * controller, char sumSymbol) :
|
||||
m_sum(0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle),
|
||||
m_sumLayout(nullptr),
|
||||
m_sumLayoutRef(nullptr),
|
||||
m_legend(KDText::FontSize::Small, I18n::Message::Default, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle),
|
||||
m_editableZone(controller, m_draftText, m_draftText, TextField::maxBufferSize(), controller, false, KDText::FontSize::Small, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle),
|
||||
m_sumSymbol(sumSymbol)
|
||||
@@ -210,13 +210,6 @@ SumGraphController::LegendView::LegendView(SumGraphController * controller, char
|
||||
m_draftText[0] = 0;
|
||||
}
|
||||
|
||||
SumGraphController::LegendView::~LegendView() {
|
||||
if (m_sumLayout != nullptr) {
|
||||
delete m_sumLayout;
|
||||
m_sumLayout = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void SumGraphController::LegendView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->fillRect(bounds(), Palette::GreyMiddle);
|
||||
}
|
||||
@@ -238,28 +231,26 @@ void SumGraphController::LegendView::setEditableZone(double d) {
|
||||
|
||||
void SumGraphController::LegendView::setSumSymbol(Step step, double start, double end, double result, ExpressionLayout * functionLayout) {
|
||||
assert(step == Step::Result || functionLayout == nullptr);
|
||||
if (m_sumLayout) {
|
||||
delete m_sumLayout;
|
||||
m_sumLayout = nullptr;
|
||||
}
|
||||
const char sigma[] = {' ', m_sumSymbol};
|
||||
if (step == Step::FirstParameter) {
|
||||
m_sumLayout = LayoutEngine::createStringLayout(sigma, sizeof(sigma));
|
||||
m_sumLayoutRef = LayoutEngine::createStringLayout(sigma, sizeof(sigma));
|
||||
} else if (step == Step::SecondParameter) {
|
||||
char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits)];
|
||||
PrintFloat::convertFloatToText<double>(start, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits, PrintFloat::Mode::Decimal);
|
||||
m_sumLayout = new CondensedSumLayout(
|
||||
m_sumLayoutRef = LayoutEngine::createStringLayout(sigma, sizeof(sigma));/* TODO new CondensedSumLayout(
|
||||
LayoutEngine::createStringLayout(sigma, sizeof(sigma)),
|
||||
LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small),
|
||||
new EmptyLayout(EmptyLayout::Color::Yellow, false, KDText::FontSize::Small, false),
|
||||
false);
|
||||
false); */
|
||||
} else {
|
||||
m_sumLayoutRef = LayoutEngine::createStringLayout(sigma, sizeof(sigma));
|
||||
/* TODO
|
||||
char buffer[2+PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
|
||||
PrintFloat::convertFloatToText<double>(start, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, PrintFloat::Mode::Decimal);
|
||||
ExpressionLayout * start = LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small);
|
||||
ExpressionLayout * start = LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small);
|
||||
PrintFloat::convertFloatToText<double>(end, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, PrintFloat::Mode::Decimal);
|
||||
ExpressionLayout * end = LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small);
|
||||
m_sumLayout = new CondensedSumLayout(
|
||||
ExpressionLayout * end = LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small);
|
||||
m_sumLayoutRef = new CondensedSumLayout(
|
||||
LayoutEngine::createStringLayout(sigma, sizeof(sigma)),
|
||||
start,
|
||||
end,
|
||||
@@ -269,10 +260,10 @@ void SumGraphController::LegendView::setSumSymbol(Step step, double start, doubl
|
||||
PrintFloat::convertFloatToText<double>(result, buffer+2, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
childrenLayouts[2] = LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small);
|
||||
childrenLayouts[1] = functionLayout;
|
||||
childrenLayouts[0] = m_sumLayout;
|
||||
m_sumLayout = new HorizontalLayout(childrenLayouts, 3, false);
|
||||
childrenLayouts[0] = m_sumLayoutRef;
|
||||
m_sumLayoutRef = new HorizontalLayout(childrenLayouts, 3, false);*/
|
||||
}
|
||||
m_sum.setExpressionLayout(m_sumLayout);
|
||||
m_sum.setLayoutRef(m_sumLayoutRef);
|
||||
if (step == Step::Result) {
|
||||
m_sum.setAlignment(0.5f, 0.5f);
|
||||
} else {
|
||||
|
||||
@@ -49,7 +49,6 @@ private:
|
||||
class LegendView : public View {
|
||||
public:
|
||||
LegendView(SumGraphController * controller, char sumSymbol);
|
||||
~LegendView();
|
||||
LegendView(const LegendView& other) = delete;
|
||||
LegendView(LegendView&& other) = delete;
|
||||
LegendView& operator=(const LegendView& other) = delete;
|
||||
@@ -71,7 +70,7 @@ private:
|
||||
void layoutSubviews() override;
|
||||
void layoutSubviews(Step step);
|
||||
ExpressionView m_sum;
|
||||
Poincare::ExpressionLayout * m_sumLayout;
|
||||
Poincare::LayoutRef m_sumLayoutRef;
|
||||
MessageTextView m_legend;
|
||||
TextField m_editableZone;
|
||||
char m_draftText[TextField::maxBufferSize()];
|
||||
|
||||
@@ -148,16 +148,16 @@ void VariableBoxController::ContentViewController::willDisplayCellForIndex(Highl
|
||||
if (evaluation) {
|
||||
/* TODO: implement list contexts */
|
||||
// TODO: handle matrix and scalar!
|
||||
ExpressionLayout * layout = expressionLayoutForIndex(index);
|
||||
LayoutRef layoutR = layoutRefForIndex(index);
|
||||
const Matrix * matrixEvaluation = static_cast<const Matrix *>(evaluation);
|
||||
myCell->setExpressionLayout(layout);
|
||||
myCell->setLayoutRef(layoutR);
|
||||
char buffer[2*PrintFloat::bufferSizeForFloatsWithPrecision(2)+1];
|
||||
int numberOfChars = PrintFloat::convertFloatToText<float>(matrixEvaluation->numberOfRows(), buffer, PrintFloat::bufferSizeForFloatsWithPrecision(2), 2, PrintFloat::Mode::Decimal);
|
||||
buffer[numberOfChars++] = 'x';
|
||||
PrintFloat::convertFloatToText<float>(matrixEvaluation->numberOfColumns(), buffer+numberOfChars, PrintFloat::bufferSizeForFloatsWithPrecision(2), 2, PrintFloat::Mode::Decimal);
|
||||
myCell->setSubtitle(buffer);
|
||||
} else {
|
||||
myCell->setExpressionLayout(nullptr);
|
||||
myCell->setLayoutRef(LayoutRef(nullptr));
|
||||
myCell->setSubtitle(I18n::translate(I18n::Message::Empty));
|
||||
}
|
||||
}
|
||||
@@ -166,9 +166,9 @@ KDCoordinate VariableBoxController::ContentViewController::rowHeight(int index)
|
||||
if (m_currentPage == Page::RootMenu || m_currentPage == Page::Scalar) {
|
||||
return Metric::ToolboxRowHeight;
|
||||
}
|
||||
ExpressionLayout * expressionLayout = expressionLayoutForIndex(index);
|
||||
if (expressionLayout) {
|
||||
return expressionLayout->size().height()+k_leafMargin;
|
||||
LayoutRef layoutR = layoutRefForIndex(index);
|
||||
if (layoutR.isDefined()) {
|
||||
return layoutR.layoutSize().height()+k_leafMargin;
|
||||
}
|
||||
return Metric::ToolboxRowHeight;
|
||||
}
|
||||
@@ -252,10 +252,10 @@ const Expression * VariableBoxController::ContentViewController::expressionForIn
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ExpressionLayout * VariableBoxController::ContentViewController::expressionLayoutForIndex(int index) {
|
||||
LayoutRef VariableBoxController::ContentViewController::layoutRefForIndex(int index) {
|
||||
if (m_currentPage == Page::Matrix) {
|
||||
const Symbol symbol = Symbol::matrixSymbol('0'+(char)index);
|
||||
return m_context->expressionLayoutForSymbol(&symbol);
|
||||
return m_context->layoutRefForSymbol(&symbol);
|
||||
}
|
||||
#if LIST_VARIABLES
|
||||
if (m_currentPage == Page::List) {
|
||||
|
||||
@@ -53,7 +53,7 @@ private:
|
||||
void putLabelAtIndexInBuffer(int index, char * buffer);
|
||||
I18n::Message nodeLabelAtIndex(int index);
|
||||
const Poincare::Expression * expressionForIndex(int index);
|
||||
Poincare::ExpressionLayout * expressionLayoutForIndex(int index);
|
||||
Poincare::LayoutRef layoutRefForIndex(int index);
|
||||
Poincare::GlobalContext * m_context;
|
||||
Responder * m_sender;
|
||||
int m_firstSelectedRow;
|
||||
|
||||
@@ -76,8 +76,8 @@ void VariableBoxLeafCell::setSubtitle(const char * text) {
|
||||
layoutSubviews();
|
||||
}
|
||||
|
||||
void VariableBoxLeafCell::setExpressionLayout(ExpressionLayout * expressionLayout) {
|
||||
m_expressionView.setExpressionLayout(expressionLayout);
|
||||
void VariableBoxLeafCell::setLayoutRef(LayoutRef layoutRef) {
|
||||
m_expressionView.setLayoutRef(layoutRef);
|
||||
}
|
||||
|
||||
void VariableBoxLeafCell::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
void reloadCell() override;
|
||||
void setLabel(const char * text);
|
||||
void setSubtitle(const char * text);
|
||||
void setExpressionLayout(Poincare::ExpressionLayout * expressionLayout);
|
||||
void setLayoutRef(Poincare::LayoutRef layoutRef);
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
const char * text() const override {
|
||||
return m_labelView.text();
|
||||
|
||||
@@ -8,7 +8,7 @@ class Clipboard {
|
||||
public:
|
||||
static Clipboard * sharedClipboard();
|
||||
void store(const char * storedText);
|
||||
void store(Poincare::ExpressionLayout * layout);
|
||||
void store(Poincare::LayoutRef layoutR);
|
||||
const char * storedText();
|
||||
void reset();
|
||||
private:
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
void setAlignment(float horizontalAlignment, float verticalAlignment);
|
||||
void setLeftMargin(KDCoordinate margin);
|
||||
void setRightMargin(KDCoordinate margin);
|
||||
Poincare::ExpressionLayout * expressionLayout() const override { return m_expressionView.expressionLayout(); }
|
||||
Poincare::LayoutRef layoutRef() const override { return m_expressionView.layoutRef(); }
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
protected:
|
||||
int numberOfSubviews() const override;
|
||||
|
||||
@@ -10,7 +10,7 @@ public:
|
||||
View * labelView() const override;
|
||||
void setHighlighted(bool highlight) override;
|
||||
void setExpressionLayout(Poincare::ExpressionLayout * expressionLayout);
|
||||
Poincare::ExpressionLayout * expressionLayout() const override { return m_labelExpressionView.expressionLayout(); }
|
||||
Poincare::LayoutRef layoutRef() const override { return m_labelExpressionView.layoutRef(); }
|
||||
private:
|
||||
ExpressionView m_labelExpressionView;
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <escher/view.h>
|
||||
#include <escher/responder.h>
|
||||
#include <poincare.h>
|
||||
#include <poincare/layout_reference.h>
|
||||
|
||||
class HighlightCell : public View {
|
||||
public:
|
||||
@@ -17,8 +18,8 @@ public:
|
||||
virtual const char * text() const {
|
||||
return nullptr;
|
||||
}
|
||||
virtual Poincare::ExpressionLayout * expressionLayout() const {
|
||||
return nullptr;
|
||||
virtual Poincare::LayoutRef layoutRef() const {
|
||||
return Poincare::LayoutRef(nullptr);
|
||||
}
|
||||
protected:
|
||||
bool m_highlighted;
|
||||
|
||||
@@ -10,8 +10,8 @@ void Clipboard::store(const char * storedText) {
|
||||
strlcpy(m_textBuffer, storedText, TextField::maxBufferSize());
|
||||
}
|
||||
|
||||
void Clipboard::store(Poincare::ExpressionLayout * layout) {
|
||||
layout->writeTextInBuffer(m_textBuffer, TextField::maxBufferSize(), Poincare::Preferences::sharedPreferences()->numberOfSignificantDigits());
|
||||
void Clipboard::store(Poincare::LayoutRef layoutR) {
|
||||
layoutR.writeTextInBuffer(m_textBuffer, TextField::maxBufferSize(), Poincare::Preferences::sharedPreferences()->numberOfSignificantDigits());
|
||||
}
|
||||
|
||||
const char * Clipboard::storedText() {
|
||||
|
||||
@@ -93,7 +93,8 @@ bool LayoutField::handleEventWithText(const char * text, bool indentation, bool
|
||||
} else if (resultLayoutRef.isHorizontal()) {
|
||||
/* If the layout is horizontal, pick the first open parenthesis. For now,
|
||||
* all horizontal layouts in MathToolbox have parentheses. */
|
||||
for (LayoutRef l : resultLayoutRef.directChildren()) {
|
||||
for (int i = 0; i < resultLayoutRef.numberOfChildren(); i++) {
|
||||
LayoutRef l = resultLayoutRef.childAtIndex(i);
|
||||
if (l.isLeftParenthesis()) {
|
||||
pointedLayoutRef = l;
|
||||
break;
|
||||
|
||||
@@ -128,9 +128,9 @@ bool SelectableTableView::handleEvent(Ion::Events::Event event) {
|
||||
Clipboard::sharedClipboard()->store(text);
|
||||
return true;
|
||||
}
|
||||
Poincare::ExpressionLayout * layout = cell->expressionLayout();
|
||||
if (layout) {
|
||||
Clipboard::sharedClipboard()->store(layout);
|
||||
Poincare::LayoutRef layoutR = cell->layoutRef();
|
||||
if (layoutR.isDefined()) {
|
||||
Clipboard::sharedClipboard()->store(layoutR);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
private:
|
||||
Expression * setSign(Sign s, Context & context, AngleUnit angleUnit) override;
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "abs");
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createInfixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
private:
|
||||
constexpr static int k_maxNValue = 300;
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "binomial");
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define POINCARE_CHAR_LAYOUT_NODE_H
|
||||
|
||||
#include <poincare/layout_cursor.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_node.h>
|
||||
#include <poincare/layout_reference.h>
|
||||
|
||||
@@ -19,9 +18,7 @@ public:
|
||||
void setFontSize(KDText::FontSize fontSize) { m_fontSize = fontSize; }
|
||||
|
||||
// LayoutNode
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writeOneCharInBuffer(buffer, bufferSize, m_char);
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
private:
|
||||
Complex(T a, T b);
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat) const override;
|
||||
/* Simplification */
|
||||
static Expression * CreateDecimal(T f);
|
||||
Expression * shallowReduce(Context & context, AngleUnit angleUnit) override;
|
||||
@@ -54,8 +54,8 @@ private:
|
||||
/* convertComplexToText and convertFloatToTextPrivate return the string length
|
||||
* of the buffer (does not count the 0 last char)*/
|
||||
int convertComplexToText(char * buffer, int bufferSize, int numberOfSignificantDigits, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, char multiplicationSign) const;
|
||||
ExpressionLayout * createPolarLayout(PrintFloat::Mode floatDisplayMode) const;
|
||||
ExpressionLayout * createCartesianLayout(PrintFloat::Mode floatDisplayMode) const;
|
||||
//ExpressionLayout * createPolarLayout(PrintFloat::Mode floatDisplayMode) const;
|
||||
//ExpressionLayout * createCartesianLayout(PrintFloat::Mode floatDisplayMode) const;
|
||||
T m_a;
|
||||
T m_b;
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
int polynomialDegree(char symbolName) const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "conj");
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/trigonometry.h>
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -19,8 +20,9 @@ public:
|
||||
template<typename T> static Complex<T> computeOnComplex(const Complex<T> c, AngleUnit angleUnit = AngleUnit::Radian);
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -31,7 +31,7 @@ private:
|
||||
int simplificationOrderSameType(const Expression * e, bool canBeInterrupted) const override;
|
||||
/* Layout */
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
/* Simplification */
|
||||
Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
|
||||
Expression * shallowBeautify(Context& context, AngleUnit angleUnit) override;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/variable_context.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -15,8 +16,9 @@ public:
|
||||
int polynomialDegree(char symbolName) const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "/");
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
/* Evaluation */
|
||||
Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<float>(context, angleUnit); }
|
||||
Expression * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<double>(context, angleUnit); }
|
||||
|
||||
@@ -19,7 +19,7 @@ private:
|
||||
/* Simplification */
|
||||
Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "=");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_EXPRESSION_H
|
||||
#define POINCARE_EXPRESSION_H
|
||||
|
||||
#include <poincare/expression_layout.h>
|
||||
#include <poincare/layout_reference.h>
|
||||
#include <poincare/print_float.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
@@ -249,7 +249,7 @@ public:
|
||||
bool isEqualToItsApproximationLayout(Expression * approximation, int bufferSize, int numberOfSignificantDigits, Context & context);
|
||||
|
||||
/* Layout Engine */
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode = PrintFloat::Mode::Default, ComplexFormat complexFormat = ComplexFormat::Default) const; // Returned object must be deleted
|
||||
LayoutRef createLayout(PrintFloat::Mode floatDisplayMode = PrintFloat::Mode::Default, ComplexFormat complexFormat = ComplexFormat::Default) const;
|
||||
virtual int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const = 0;
|
||||
|
||||
/* Simplification */
|
||||
@@ -315,7 +315,7 @@ private:
|
||||
//TODO: What should be the implementation for complex?
|
||||
virtual int simplificationOrderSameType(const Expression * e, bool canBeInterrupted) const { return 0; }
|
||||
/* Layout Engine */
|
||||
virtual ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const = 0;
|
||||
virtual LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const = 0;
|
||||
/* Simplification */
|
||||
Expression * deepBeautify(Context & context, AngleUnit angleUnit);
|
||||
Expression * deepReduce(Context & context, AngleUnit angleUnit);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <poincare/rational.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <cmath>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -17,8 +18,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -15,7 +15,7 @@ private:
|
||||
constexpr static int k_maxOperandValue = 100;
|
||||
/* Layout */
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
/* Simplication */
|
||||
Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,9 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "floor"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
/* The expression recorded in global context is already a expression.
|
||||
* Otherwise, we would need the context and the angle unit to evaluate it */
|
||||
const Expression * expressionForSymbol(const Symbol * symbol) override;
|
||||
ExpressionLayout * expressionLayoutForSymbol(const Symbol * symbol);
|
||||
LayoutRef layoutRefForSymbol(const Symbol * symbol);
|
||||
void setExpressionForSymbolName(const Expression * expression, const Symbol * symbol, Context & context) override;
|
||||
static constexpr uint16_t k_maxNumberOfScalarExpressions = 26;
|
||||
static constexpr uint16_t k_maxNumberOfListExpressions = 10;
|
||||
@@ -33,7 +33,7 @@ private:
|
||||
Complex<double> * m_expressions[k_maxNumberOfScalarExpressions];
|
||||
Matrix * m_matrixExpressions[k_maxNumberOfMatrixExpressions];
|
||||
/* Matrix layout memoization */
|
||||
ExpressionLayout * m_matrixLayout[k_maxNumberOfMatrixExpressions];
|
||||
LayoutRef m_matrixLayouts[k_maxNumberOfMatrixExpressions];
|
||||
Complex<double> m_pi;
|
||||
Complex<double> m_e;
|
||||
Complex<double> m_i;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -15,8 +16,9 @@ public:
|
||||
template<typename T> static Complex<T> computeOnComplex(const Complex<T> c, AngleUnit angleUnit);
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -15,11 +16,12 @@ public:
|
||||
template<typename T> static Complex<T> computeOnComplex(const Complex<T> c, AngleUnit angleUnit);
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "sinh"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -15,8 +16,9 @@ public:
|
||||
template<typename T> static Complex<T> computeOnComplex(const Complex<T> c, AngleUnit angleUnit);
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
namespace Poincare {
|
||||
|
||||
class ExpressionLayout;
|
||||
|
||||
/*class LayoutNode;
|
||||
class LayoutReference<LayoutNode>;
|
||||
*/
|
||||
/* All algorithm should be improved with:
|
||||
* Modern Computer Arithmetic, Richard P. Brent and Paul Zimmermann */
|
||||
|
||||
@@ -52,7 +54,7 @@ public:
|
||||
|
||||
// Layout
|
||||
int writeTextInBuffer(char * buffer, int bufferSize) const;
|
||||
ExpressionLayout * createLayout() const;
|
||||
//LayoutReference<LayoutNode> createLayout() const;
|
||||
|
||||
// Approximation
|
||||
template<typename T> T approximate() const;
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
int polynomialDegree(char symbolName) const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "int");
|
||||
}
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
#define POINCARE_LAYOUT_ENGINE_H
|
||||
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/tree_reference.h>
|
||||
#include <poincare/layout_reference.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
class LayoutEngine {
|
||||
|
||||
public:
|
||||
/* Expression to ExpressionLayout */
|
||||
static ExpressionLayout * createInfixLayout(const Expression * expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char * operatorName);
|
||||
static ExpressionLayout * createPrefixLayout(const Expression * expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char * operatorName);
|
||||
/* Expression to LayoutRef */
|
||||
static LayoutRef createInfixLayout(const Expression * expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char * operatorName);
|
||||
static LayoutRef createPrefixLayout(const Expression * expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char * operatorName);
|
||||
|
||||
/* Create special layouts */
|
||||
static ExpressionLayout * createParenthesedLayout(ExpressionLayout * layout, bool cloneLayout);
|
||||
static ExpressionLayout * createStringLayout(const char * buffer, int bufferSize, KDText::FontSize fontSize = KDText::FontSize::Large);
|
||||
static LayoutRef createParenthesedLayout(LayoutRef layout, bool cloneLayout);
|
||||
static LayoutRef createStringLayout(const char * buffer, int bufferSize, KDText::FontSize fontSize = KDText::FontSize::Large);
|
||||
static ExpressionLayout * createLogLayout(ExpressionLayout * argument, ExpressionLayout * index);
|
||||
|
||||
/* Expression to Text */
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
virtual bool hasText() const { return false; } //TODO
|
||||
virtual char XNTChar() const { return 'x'; }
|
||||
virtual bool isHorizontal() const { return false; }
|
||||
virtual bool isLeftParenthesis() const { return false; }
|
||||
|
||||
// Rendering
|
||||
void draw(KDContext * ctx, KDPoint p, KDColor expressionColor = KDColorBlack, KDColor backgroundColor = KDColorWhite);
|
||||
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
}
|
||||
|
||||
bool isHorizontal() const { return this->typedNode()->isHorizontal(); }
|
||||
bool isLeftParenthesis() const { return this->typedNode()->isLeftParenthesis(); }
|
||||
bool hasText() { return this->typedNode()->hasText(); }
|
||||
char XNTChar() const { return this->typedNode()->XNTChar(); }
|
||||
KDSize layoutSize() { return this->typedNode()->layoutSize(); }
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "log");
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
/* rowCanonize turns a matrix in its reduced row echelon form. */
|
||||
void rowCanonize(Context & context, AngleUnit angleUnit, Multiplication * m = nullptr);
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
/* Evaluation */
|
||||
Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<float>(context, angleUnit); }
|
||||
Expression * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<double>(context, angleUnit); }
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Evaluation */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
Expression * setSign(Sign s, Context & context, AngleUnit angleUnit) override;
|
||||
/* Layout */
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
/* Simplification */
|
||||
Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "root");
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
/* Simplification */
|
||||
Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
int polynomialDegree(char symbolName) const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "");
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -15,8 +16,9 @@ public:
|
||||
private:
|
||||
constexpr static int k_maxNValue = 100;
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/rational.h>
|
||||
#include <poincare/multiplication.h>
|
||||
#include <poincare/char_layout_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -30,7 +31,7 @@ private:
|
||||
/* Property */
|
||||
Expression * setSign(Sign s, Context & context, AngleUnit angleUnit) override;
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/char_layout_node.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +16,9 @@ public:
|
||||
int polynomialDegree(char symbolName) const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/char_layout_node.h>
|
||||
#include <poincare/char_layout_node.h> //TODO remove
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -13,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/char_layout_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -17,8 +18,9 @@ public:
|
||||
private:
|
||||
Expression * setSign(Sign s, Context & context, AngleUnit angleUnit) override;
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
/*return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());*/
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
static int NaturalOrder(const Rational & i, const Rational & j);
|
||||
private:
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<float>(context, angleUnit); }
|
||||
Expression * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<double>(context, angleUnit); }
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/char_layout_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/char_layout_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,8 +15,9 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Poincare {
|
||||
class Sequence : public StaticHierarchy<3> {
|
||||
using StaticHierarchy<3>::StaticHierarchy;
|
||||
private:
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ public:
|
||||
Expression * clone() const override { return nullptr; }
|
||||
int polynomialDegree(char symbolName) const override { return -1; }
|
||||
Type type() const override { return Expression::Type::SimplificationRoot; }
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return nullptr;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutRef(nullptr); //TODO
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return 0; }
|
||||
Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/trigonometry.h>
|
||||
#include <poincare/char_layout_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -18,8 +19,9 @@ public:
|
||||
template<typename T> static Complex<T> computeOnComplex(const Complex<T> c, AngleUnit angleUnit = AngleUnit::Radian);
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
/* Simplification */
|
||||
Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
|
||||
|
||||
@@ -18,7 +18,7 @@ private:
|
||||
/* Simplification */
|
||||
Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
/* Evalutation */
|
||||
Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<float>(context, angleUnit); }
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/char_layout_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -17,8 +18,9 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createInfixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
// return LayoutEngine::createInfixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
/* Comparison */
|
||||
int simplificationOrderSameType(const Expression * e, bool canBeInterrupted) const override;
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
/* Evaluation */
|
||||
Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<float>(context, angleUnit); }
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
|
||||
#include <poincare/char_layout_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -16,8 +16,9 @@ public:
|
||||
float characteristicXRange(Context & context, AngleUnit angleUnit = AngleUnit::Default) const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
//return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
return CharLayoutRef('a'); //TODO
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -65,6 +65,7 @@ public:
|
||||
int nodeRetainCount() const { return node()->retainCount(); }
|
||||
void incrementNumberOfChildren(int increment = 1) { return node()->incrementNumberOfChildren(increment); }
|
||||
void decrementNumberOfChildren(int decrement = 1) { return node()->decrementNumberOfChildren(decrement); }
|
||||
int numberOfDescendants(bool includeSelf) const { return node()->numberOfDescendants(includeSelf);}
|
||||
|
||||
// Serialization
|
||||
bool needsParenthesisWithParent(TreeReference<TreeNode> parentRef) { return node()->needsParenthesisWithParent(parentRef.node()); }
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
int polynomialDegree(char symbolName) const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
/* Evaluation */
|
||||
Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<float>(context, angleUnit); }
|
||||
Expression * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<double>(context, angleUnit); }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <poincare/absolute_value.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/simplification_engine.h>
|
||||
#include "layout/absolute_value_layout.h"
|
||||
#include <poincare/char_layout_node.h>
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
@@ -24,10 +24,10 @@ Expression * AbsoluteValue::setSign(Sign s, Context & context, AngleUnit angleUn
|
||||
return this;
|
||||
}
|
||||
|
||||
ExpressionLayout * AbsoluteValue::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
LayoutRef AbsoluteValue::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
assert(floatDisplayMode != PrintFloat::Mode::Default);
|
||||
assert(complexFormat != ComplexFormat::Default);
|
||||
return new AbsoluteValueLayout(operand(0)->createLayout(floatDisplayMode, complexFormat), false);
|
||||
return CharLayoutRef('a'); //TODO
|
||||
}
|
||||
|
||||
Expression * AbsoluteValue::shallowReduce(Context& context, AngleUnit angleUnit) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/rational.h>
|
||||
#include "layout/binomial_coefficient_layout.h"
|
||||
#include <poincare/char_layout_node.h>
|
||||
|
||||
extern "C" {
|
||||
#include <stdlib.h>
|
||||
@@ -72,14 +73,15 @@ Expression * BinomialCoefficient::shallowReduce(Context& context, AngleUnit angl
|
||||
return replaceWith(new Rational(result), true);
|
||||
}
|
||||
|
||||
ExpressionLayout * BinomialCoefficient::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
assert(floatDisplayMode != PrintFloat::Mode::Default);
|
||||
LayoutRef BinomialCoefficient::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
/*assert(floatDisplayMode != PrintFloat::Mode::Default);
|
||||
assert(complexFormat != ComplexFormat::Default);
|
||||
return new BinomialCoefficientLayout(
|
||||
operand(0)->createLayout(floatDisplayMode, complexFormat),
|
||||
operand(1)->createLayout(floatDisplayMode, complexFormat),
|
||||
false);
|
||||
}
|
||||
*/}
|
||||
|
||||
template<typename T>
|
||||
Expression * BinomialCoefficient::templatedApproximate(Context& context, AngleUnit angleUnit) const {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
#include <poincare/char_layout_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -59,10 +60,11 @@ Complex<T> Ceiling::computeOnComplex(const Complex<T> c, AngleUnit angleUnit) {
|
||||
return Complex<T>::Float(std::ceil(c.a()));
|
||||
}
|
||||
|
||||
ExpressionLayout * Ceiling::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
assert(floatDisplayMode != PrintFloat::Mode::Default);
|
||||
LayoutRef Ceiling::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
/*assert(floatDisplayMode != PrintFloat::Mode::Default);
|
||||
assert(complexFormat != ComplexFormat::Default);
|
||||
return new CeilingLayout(m_operands[0]->createLayout(floatDisplayMode, complexFormat), false);
|
||||
}
|
||||
*/}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
#include <poincare/char_layout_node.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
// LayoutNode
|
||||
int CharLayoutNode::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const {
|
||||
return LayoutEngine::writeOneCharInBuffer(buffer, bufferSize, m_char);
|
||||
}
|
||||
|
||||
void CharLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
if (cursor->position() == LayoutCursor::Position::Right) {
|
||||
cursor->setPosition(LayoutCursor::Position::Left);
|
||||
|
||||
@@ -20,6 +20,8 @@ extern "C" {
|
||||
#include <string.h>
|
||||
}
|
||||
|
||||
#include <poincare/char_layout_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
template<typename T>
|
||||
@@ -213,13 +215,14 @@ Complex<T>::Complex(T a, T b) :
|
||||
}
|
||||
|
||||
template <class T>
|
||||
ExpressionLayout * Complex<T>::privateCreateLayout(PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat) const {
|
||||
assert(floatDisplayMode != PrintFloat::Mode::Default);
|
||||
LayoutRef Complex<T>::privateCreateLayout(PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat) const {
|
||||
return CharLayoutRef('a'); //TODO
|
||||
/* assert(floatDisplayMode != PrintFloat::Mode::Default);
|
||||
if (complexFormat == Expression::ComplexFormat::Polar) {
|
||||
return createPolarLayout(floatDisplayMode);
|
||||
}
|
||||
return createCartesianLayout(floatDisplayMode);
|
||||
}
|
||||
*/}
|
||||
|
||||
template <class T>
|
||||
Expression * Complex<T>::CreateDecimal(T f) {
|
||||
@@ -306,7 +309,7 @@ int Complex<T>::convertComplexToText(char * buffer, int bufferSize, int numberOf
|
||||
return numberOfChars;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
/*template <class T>
|
||||
ExpressionLayout * Complex<T>::createPolarLayout(PrintFloat::Mode floatDisplayMode) const {
|
||||
char bufferBase[PrintFloat::k_maxFloatBufferLength+2];
|
||||
int numberOfCharInBase = 0;
|
||||
@@ -349,7 +352,7 @@ ExpressionLayout * Complex<T>::createCartesianLayout(PrintFloat::Mode floatDispl
|
||||
char buffer[PrintFloat::k_maxComplexBufferLength];
|
||||
int numberOfChars = convertComplexToText(buffer, PrintFloat::k_maxComplexBufferLength, Preferences::sharedPreferences()->numberOfSignificantDigits(), floatDisplayMode, Expression::ComplexFormat::Cartesian, Ion::Charset::MiddleDot);
|
||||
return LayoutEngine::createStringLayout(buffer, numberOfChars);
|
||||
}
|
||||
}*/
|
||||
|
||||
template class Complex<float>;
|
||||
template class Complex<double>;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user