Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
MathExpression.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017 Thales Lima Oliveira <thales@ufu.br>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#ifndef MATHEXPRESSION_H
19#define MATHEXPRESSION_H
20
21#include "ControlElement.h"
22#include "MathExprParser.h"
23//#include "OpenGLText.h"
24#include "../GCText.h"
25
26class ConnectionLine;
27
29
38{
39 public:
40 MathExpression(int id);
42
43 //virtual void Draw(wxPoint2DDouble translation, double scale) const;
44 virtual void DrawDC(wxPoint2DDouble translation, double scale, wxGraphicsContext* gc) const;
45 virtual bool Contains(wxPoint2DDouble position) const { return m_rect.Contains(position); }
46 virtual bool Intersects(wxRect2DDouble rect) const { return m_rect.Intersects(rect); }
47 virtual bool ShowForm(wxWindow* parent, Element* element);
48 virtual void Rotate(bool clockwise = true);
49
50 virtual bool Solve(double* input, double timeStep);
51 virtual bool Initialize();
52 virtual wxString GetMathExpression() { return m_mathExpression; }
53 virtual void SetMathExpression(wxString mathExpression) { m_mathExpression = mathExpression; }
54 virtual std::vector<wxString> GetVariables() { return m_variablesVector; }
55 virtual void SetVariables(std::vector<wxString> variablesVector);
56 virtual MathExprParser GetParser() { return m_fparser; }
57
58 virtual void UpdatePoints();
59 void AddInNode();
60 void RemoveInNode();
61 virtual bool UpdateText();
62
63 virtual rapidxml::xml_node<>* SaveElement(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* elementListNode);
64 virtual bool OpenElement(rapidxml::xml_node<>* elementNode);
65
66 virtual Element* GetCopy();
67
68 protected:
69 void CalculateBlockSize(double numInNodes);
70
71 MathExprParser m_fparser;
72 wxString m_mathExpression = "sqrt(x^2 + y^2)";
73 wxString m_variables = "time,step,x,y";
74 std::vector<wxString> m_variablesVector;
75 double* m_inputValues = nullptr;
76 std::vector<GCText*> m_gcTextInputVector;
77 GCText m_symbol;
78 wxSize m_symbolSize;
79 int m_maxSringSize = 0;
80 double m_minimumSize = 36.0;
81};
82
83#endif // MATHEXPRESSION_H
Base class of a control element. Provide general methods to other control classes.
Connection between two control elements or other connection line and an element.
Base class of all elements of the program. This class is responsible for manage graphical and his dat...
Definition Element.h:112
Class to draw text on Graphics Context using wxWidgets.
Definition GCText.h:32
A generic math expression block that can perform math and conditional operations with the inputs.
virtual bool ShowForm(wxWindow *parent, Element *element)
Show element data form.
virtual Element * GetCopy()
Get a the element copy.
virtual bool UpdateText()
Update the OpenGL text in the element (if present).
virtual bool Intersects(wxRect2DDouble rect) const
Check if the element's rect intersects other rect.
virtual bool Contains(wxPoint2DDouble position) const
Checks if the element contains a position.
virtual void Rotate(bool clockwise=true)
Rotate the element.
virtual void DrawDC(wxPoint2DDouble translation, double scale, wxGraphicsContext *gc) const
Draw the element using GDI+.