[poincare] Improve integral layout

Change-Id: Ie9f10058d856741838f8e34ba30fc6934909581b
This commit is contained in:
Émilie Feral
2017-01-13 17:40:01 +01:00
parent 863200445b
commit 3283a063cb
2 changed files with 12 additions and 0 deletions

View File

@@ -11,6 +11,7 @@ public:
Type type() const override;
Expression * cloneWithDifferentOperands(Expression ** newOperands,
int numberOfOperands, bool cloneOperands = true) const override;
ExpressionLayout * createLayout() const override;
private:
float functionValueAtAbscissa(float x, XContext xcontext) const;
};

View File

@@ -5,7 +5,11 @@
extern "C" {
#include <assert.h>
#include <math.h>
#include <stdlib.h>
}
#include "layout/horizontal_layout.h"
#include "layout/string_layout.h"
#include "layout/integral_layout.h"
Integral::Integral() :
Function("int")
@@ -52,6 +56,13 @@ float Integral::approximate(Context& context) const {
return result;
}
ExpressionLayout * Integral::createLayout() const {
ExpressionLayout ** childrenLayouts = (ExpressionLayout **)malloc(2*sizeof(ExpressionLayout *));
childrenLayouts[0] = m_args[0]->createLayout();
childrenLayouts[1] = new StringLayout("dx", 2);
return new IntegralLayout(m_args[1]->createLayout(), m_args[2]->createLayout(), new HorizontalLayout(childrenLayouts, 2));
}
float Integral::functionValueAtAbscissa(float x, XContext xContext) const {
Float e = Float(x);
Symbol xSymbol = Symbol('x');