Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
TransferFunction.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 TRANSFERFUNCTION_H
19#define TRANSFERFUNCTION_H
20
21#include "ControlElement.h"
22
23#include <wx/dcscreen.h>
24//#include "OpenGLText.h"
25#include "../GCText.h"
26
28
37{
38 public:
39 struct SpaceState {
40 std::vector<std::vector<double> > A;
41 std::vector<double> B;
42 std::vector<double> C;
43 double D;
44 };
45
46 TransferFunction(int id);
48
49 //virtual void Draw(wxPoint2DDouble translation, double scale) const;
50 virtual void DrawDC(wxPoint2DDouble translation, double scale, wxGraphicsContext* gc) const;
51 virtual bool Contains(wxPoint2DDouble position) const { return m_rect.Contains(position); }
52 virtual bool Intersects(wxRect2DDouble rect) const { return m_rect.Intersects(rect); }
53 virtual bool ShowForm(wxWindow* parent, Element* element);
54 virtual void Rotate(bool clockwise = true);
55
56 virtual std::vector<double> GetNumerator() const { return m_numerator; }
57 virtual std::vector<double> GetDenominator() const { return m_denominator; }
58 virtual void SetNumerator(std::vector<double> numerator) { m_numerator = numerator; }
59 virtual void SetDenominator(std::vector<double> denominator) { m_denominator = denominator; }
60 virtual void UpdateTFText();
61 virtual bool UpdateText();
62 virtual SpaceState GetSpaceState() { return m_ss; }
68 virtual void CalculateSpaceState(int maxIteration = 100, double error = 1e-3);
78 virtual bool Solve(double* input, double timeStep);
79 virtual void GetTFString(wxString& numerator, wxString& denominator);
80
81 virtual rapidxml::xml_node<>* SaveElement(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* elementListNode);
82 virtual bool OpenElement(rapidxml::xml_node<>* elementNode);
83
84 virtual Element* GetCopy();
85
86 protected:
87 virtual void SetText(wxString numerator, wxString denominator);
88 virtual wxString GetSuperscriptNumber(int number);
89
90 wchar_t m_supNumber[10];
91
92 //OpenGLText* m_glTextNum = nullptr;
93 //OpenGLText* m_glTextDen = nullptr;
94 GCText* m_gcTextNum = nullptr;
95 GCText* m_gcTextDen = nullptr;
96 int m_fontSize = 10;
97
98 std::vector<double> m_numerator;
99 std::vector<double> m_denominator;
100 SpaceState m_ss;
101
102 std::vector<double> m_x;
103 std::vector<double> m_dx;
104 double m_error = 1e-3;
105 int m_maxIteration = 100;
106};
107
108#endif // TRANSFERFUNCTION_H
Base class of a control element. Provide general methods to other control classes.
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
Form to edit the transfer function control data.
Calculates the time response by a frequency domain transfer function.
virtual void DrawDC(wxPoint2DDouble translation, double scale, wxGraphicsContext *gc) const
Draw the element using GDI+.
virtual Element * GetCopy()
Get a the element copy.
virtual bool UpdateText()
Update the OpenGL text in the element (if present).
virtual void CalculateSpaceState(int maxIteration=100, double error=1e-3)
Convert the transfer function to space state on controllable canonical form (CCF).
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 bool Solve(double *input, double timeStep)
Calculates the time response by the space state form of transfer function.
virtual bool ShowForm(wxWindow *parent, Element *element)
Show element data form.