[apps/shared] Specifiy the meaning of a defined sequence in sequence/

Change-Id: I082a7f9f9785c12dfedcee070badb4eded66ab89
This commit is contained in:
Émilie Feral
2017-02-21 17:58:28 +01:00
parent 7f4323ad40
commit 5b78ad893d
5 changed files with 21 additions and 4 deletions

View File

@@ -161,4 +161,15 @@ Poincare::ExpressionLayout * Sequence::secondInitialConditionName() {
return m_secondInitialConditionName;
}
bool Sequence::isDefined() {
switch (m_type) {
case Type::Explicite:
return layout() != nullptr;
case Type::SingleRecurrence:
return layout() != nullptr && m_firstInitialConditionLayout != nullptr;
default:
return layout() != nullptr && m_firstInitialConditionLayout != nullptr && m_secondInitialConditionLayout != nullptr;
}
}
}

View File

@@ -29,6 +29,7 @@ public:
Poincare::ExpressionLayout * definitionName();
Poincare::ExpressionLayout * firstInitialConditionName();
Poincare::ExpressionLayout * secondInitialConditionName();
bool isDefined() override;
private:
Type m_type;
char m_firstInitialConditionText[Shared::Function::k_bodyLength];

View File

@@ -62,6 +62,10 @@ Poincare::ExpressionLayout * Function::layout() {
return m_layout;
}
bool Function::isDefined() {
return m_layout != nullptr;
}
bool Function::isActive() {
return m_active;
}

View File

@@ -15,6 +15,7 @@ public:
KDColor color() const { return m_color; }
Poincare::Expression * expression();
Poincare::ExpressionLayout * layout();
virtual bool isDefined();
bool isActive();
void setActive(bool active);
void setContent(const char * c);

View File

@@ -12,7 +12,7 @@ Function * FunctionStore::activeFunctionAtIndex(int i) {
assert(i>=0 && i<m_numberOfFunctions);
int index = 0;
for (int k = 0; k < m_numberOfFunctions; k++) {
if (functionAtIndex(k)->isActive() && functionAtIndex(k)->layout() != nullptr) {
if (functionAtIndex(k)->isActive() && functionAtIndex(k)->isDefined()) {
if (i == index) {
return functionAtIndex(k);
}
@@ -27,7 +27,7 @@ Function * FunctionStore::definedFunctionAtIndex(int i) {
assert(i>=0 && i<m_numberOfFunctions);
int index = 0;
for (int k = 0; k < m_numberOfFunctions; k++) {
if (functionAtIndex(k)->layout() != nullptr) {
if (functionAtIndex(k)->isDefined()) {
if (i == index) {
return functionAtIndex(k);
}
@@ -45,7 +45,7 @@ int FunctionStore::numberOfFunctions() {
int FunctionStore::numberOfActiveFunctions() {
int result = 0;
for (int i = 0; i < m_numberOfFunctions; i++) {
if (functionAtIndex(i)->layout() != nullptr && functionAtIndex(i)->isActive()) {
if (functionAtIndex(i)->isDefined() && functionAtIndex(i)->isActive()) {
result++;
}
}
@@ -55,7 +55,7 @@ int FunctionStore::numberOfActiveFunctions() {
int FunctionStore::numberOfDefinedFunctions() {
int result = 0;
for (int i = 0; i < m_numberOfFunctions; i++) {
if (functionAtIndex(i)->layout() != nullptr) {
if (functionAtIndex(i)->isDefined()) {
result++;
}
}