summaryrefslogtreecommitdiffstats
path: root/Project/MathExpression.cpp
diff options
context:
space:
mode:
authorThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-12-31 17:59:10 -0200
committerThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-12-31 17:59:10 -0200
commitdbe0b112622f8e91fa3e44a6b6e1aa7e230d3ded (patch)
tree51c89fc8155dcc447743dc89a1ab5ce36acc72cf /Project/MathExpression.cpp
parentff52be4e9705d443a4fde091525806322c2dc032 (diff)
downloadPSP.git-dbe0b112622f8e91fa3e44a6b6e1aa7e230d3ded.tar.gz
PSP.git-dbe0b112622f8e91fa3e44a6b6e1aa7e230d3ded.tar.xz
PSP.git-dbe0b112622f8e91fa3e44a6b6e1aa7e230d3ded.zip
Math Expression implemented
Diffstat (limited to 'Project/MathExpression.cpp')
-rw-r--r--Project/MathExpression.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/Project/MathExpression.cpp b/Project/MathExpression.cpp
index 920d168..f8be598 100644
--- a/Project/MathExpression.cpp
+++ b/Project/MathExpression.cpp
@@ -152,12 +152,17 @@ void MathExpression::Rotate(bool clockwise)
}
}
-bool MathExpression::Solve(double input, double timeStep, double currentTime)
+bool MathExpression::Solve(double* input, double timeStep)
{
+ if(!input) {
+ m_output = 0.0;
+ return true;
+ }
// Get the input vector from connection lines (can't use default (one) input argument)
- m_inputValues[0] = currentTime;
+ m_inputValues[0] = input[1]; // Current time
m_inputValues[1] = timeStep;
- int i = 2;
+ m_inputValues[2] = input[2]; // Switch status
+ int i = 3;
for(auto itN = m_nodeList.begin(), itNEnd = m_nodeList.end(); itN != itNEnd; ++itN) {
Node* node = *itN;
if(node->GetNodeType() != Node::NODE_OUT) {
@@ -306,7 +311,7 @@ void MathExpression::SetVariables(std::vector<wxString> variablesVector)
bool MathExpression::Initialize()
{
- m_variables = "time,step,";
+ m_variables = "time,step,switch,";
for(auto it = m_variablesVector.begin(), itEnd = m_variablesVector.end(); it != itEnd; ++it)
m_variables += *(it) + ",";
m_variables.RemoveLast();
@@ -319,7 +324,7 @@ bool MathExpression::Initialize()
wxLocale oldLocale(currentLang); // Return to current language.
if(m_inputValues) delete m_inputValues;
- m_inputValues = new double[m_variablesVector.size() + 2]; // Custom variables + time + step
+ m_inputValues = new double[m_variablesVector.size() + 3]; // Custom variables + time + step + switch
// Optimize only once to gain performance.
m_fparser.Optimize();