Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
Text.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 TEXT_H
19#define TEXT_H
20
21//#include <GL/glew.h>
22
23//#ifdef _MSC_VER
24 //#include <windows.h>
25//#endif
26//#include <GL/gl.h>
27#include <wx/dcmemory.h>
28
29#include "GraphicalElement.h"
31#include "GCText.h"
32
33class TextForm;
34
35class Bus;
36class Line;
37class Transformer;
38class SyncGenerator;
39class IndMotor;
40class SyncMotor;
41class Load;
42class Inductor;
43class Capacitor;
44class HarmCurrent;
45
46enum DataType {
47 DATA_NAME,
48 DATA_VOLTAGE,
49 DATA_ANGLE,
50 DATA_SC_CURRENT,
51 DATA_SC_VOLTAGE,
52 DATA_SC_POWER,
53 DATA_ACTIVE_POWER,
54 DATA_REACTIVE_POWER,
55 DATA_PF_ACTIVE,
56 DATA_PF_REACTIVE,
57 DATA_PF_LOSSES,
58 DATA_PF_CURRENT,
59 DATA_PQ_THD
60};
61
69class Text : public GraphicalElement
70{
71public:
72 Text();
73 Text(wxPoint2DDouble position, wxString fontName = wxT("Arial"), int fontSize = 10);
74 ~Text();
75
76 virtual Element* GetCopy();
77 virtual bool AddParent(Element* parent, wxPoint2DDouble position) { return true; };
78 virtual bool Contains(wxPoint2DDouble position) const;
79 //virtual void Draw(wxPoint2DDouble translation, double scale);
80 virtual void DrawDC(wxPoint2DDouble translation, double scale, wxGraphicsContext* gc);
81 virtual void DrawDC(wxPoint2DDouble translation, double scale, wxDC& dc);
82 virtual bool Intersects(wxRect2DDouble rect) const;
83 virtual void Rotate(bool clockwise = true);
84 virtual bool ShowForm(wxWindow* parent, std::vector<Element*> elementList);
85 virtual void UpdateText(double systemPowerBase);
86 virtual wxString GetText() const { return m_text; }
87 virtual void SetText(wxString text);
88 virtual void SetFontName(wxString fontName) { m_fontName = fontName; }
89 virtual void SetFontSize(int fontSize) { m_fontSize = fontSize; }
90 virtual void SetAltSelectionColour(bool useAltSelectionColour = true) { m_useAltSelectionColour = useAltSelectionColour; }
91 virtual void SetAllowRotation(bool allowRotation = true) { m_allowRotation = allowRotation; }
92 //virtual bool IsGLTextOK();
93
94 void SetDataType(const DataType& dataType) { m_dataType = dataType; }
95 void SetDirection(int direction) { m_direction = direction; }
96 void SetElement(Element* element) { m_element = element; }
97 void SetElementNumber(int elementNumber) { m_elementNumber = elementNumber; }
98 void SetElementTypeText(const ElementType elementType) { m_elementTypeText = elementType; }
99 void SetUnit(const ElectricalUnit unit) { m_unit = unit; }
100 void SetDecimalPlaces(int decimalPlaces) { m_decimalPlaces = decimalPlaces; }
101 const DataType GetDataType() const { return m_dataType; }
102 int GetDirection() const { return m_direction; }
103 Element* GetElement() { return m_element; }
104 int GetElementNumber() const { return m_elementNumber; }
105 const ElementType GetElementTypeText() const { return m_elementTypeText; }
106 const ElectricalUnit GetUnit() const { return m_unit; }
107 int GetDecimalPlaces() const { return m_decimalPlaces; }
108
109 virtual rapidxml::xml_node<>* SaveElement(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* elementListNode);
110 virtual bool OpenElement(rapidxml::xml_node<>* elementNode);
111
112protected:
113 wxString m_text = _("Label");
114 wxString m_fontName = wxT("Arial");
115 int m_fontSize = 10;
116 int m_numberOfLines = 0;
117 bool m_isMultlineText = false;
118 bool m_useAltSelectionColour = false;
119 bool m_allowRotation = true;
120 bool m_updateTextRectangle = true;
121
122 std::vector<GCText*> m_gcTextList;
123
124 Element* m_element = nullptr;
125 ElementType m_elementTypeText = TYPE_NONE;
126 int m_elementNumber;
127 DataType m_dataType;
128 ElectricalUnit m_unit;
129 int m_direction = 0;
130 int m_decimalPlaces = 2;
131};
132
133#endif // TEXT_H
ElectricalUnit
Electrical units.
Node for power elements. All others power elements are connected through this.
Definition Bus.h:86
Shunt capactior power element.
Definition Capacitor.h:39
Base class of all elements of the program. This class is responsible for manage graphical and his dat...
Definition Element.h:112
Abstract class for graphical elements shown with power elements in workspace.
Shunt Harmonic Corrent Source.
Definition HarmCurrent.h:24
Induction motor power element.
Definition IndMotor.h:119
Inductor shunt power element.
Definition Inductor.h:39
Power line element.
Definition Line.h:64
Loas shunt power element.
Definition Load.h:74
Synchronous generator power element.
Synchronous motor (synchronous compensator) power element.
Definition SyncMotor.h:135
Form to edit the text graphical data.
Definition TextForm.h:33
Element that shows power element informations in workspace.
Definition Text.h:70
virtual Element * GetCopy()
Get a the element copy.
Definition Text.cpp:1146
virtual bool AddParent(Element *parent, wxPoint2DDouble position)
Add a parent to the element. This method must be used on power elements that connect to a bus,...
Definition Text.h:77
virtual bool Contains(wxPoint2DDouble position) const
Checks if the element contains a position.
Definition Text.cpp:62
virtual bool Intersects(wxRect2DDouble rect) const
Check if the element's rect intersects other rect.
Definition Text.cpp:242
virtual void Rotate(bool clockwise=true)
Rotate the element.
Definition Text.cpp:254
Two-winding transformer power element.
Definition Transformer.h:84