Files
Upsilon/apps/graph/function.cpp
Émilie Feral 1f7ba888c9 [apps/graph] add an attribute "activate" to functions
Change-Id: I1a1f548c540a6e31fe9ce1aeb742bf6a6292362c
2016-09-20 11:12:46 +02:00

59 lines
1.0 KiB
C++

#include "function.h"
Graph::Function::Function() :
m_text(nullptr),
m_expression(nullptr),
m_layout(nullptr)
{
}
Graph::Function::Function(const char * text, KDColor color) :
m_text(text), // FIXME: Copy !!
m_color(color),
m_name("f(x)"),
m_expression(nullptr),
m_layout(nullptr),
m_active(true)
{
}
Graph::Function::~Function() {
//FIXME: Free m_text!
if (m_layout != nullptr) {
delete m_layout;
}
if (m_expression != nullptr) {
delete m_expression;
}
}
const char * Graph::Function::text() {
return m_text;
}
const char * Graph::Function::name() {
return m_name;
}
Expression * Graph::Function::expression() {
if (m_expression == nullptr) {
m_expression = Expression::parse(m_text);
}
return m_expression;
}
ExpressionLayout * Graph::Function::layout() {
if (m_layout == nullptr) {
m_layout = expression()->createLayout();
}
return m_layout;
}
bool Graph::Function::isActive() {
return m_active;
}
void Graph::Function::setActive(bool active) {
m_active = active;
}