Power System Platform  2026w34a-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 DATA_TRANSFORMER_TAP
61};
62
70class Text : public GraphicalElement
71{
72public:
73 Text();
74 Text(wxPoint2DDouble position, wxString fontName = wxT("Arial"), int fontSize = 10);
75 ~Text();
76
77 virtual Element* GetCopy();
78 virtual bool AddParent(Element* parent, wxPoint2DDouble position, bool isOpening = false) { return true; };
79 virtual bool Contains(wxPoint2DDouble position) const;
80 //virtual void Draw(wxPoint2DDouble translation, double scale);
81 virtual void DrawDC(GUIColour* guiColour, wxPoint2DDouble translation, double scale, wxGraphicsContext* gc);
82 virtual void DrawDC(GUIColour* guiColour, wxPoint2DDouble translation, double scale, wxDC& dc);
83 virtual bool Intersects(wxRect2DDouble rect) const;
84 virtual void Rotate(bool clockwise = true);
85 virtual bool ShowForm(wxWindow* parent, std::vector<Element*> elementList, wxWindow* workspace);
86 virtual void UpdateText(double systemPowerBase);
87 virtual wxString GetText() const { return m_text; }
88 virtual void SetText(wxString text);
89 virtual void SetFontName(wxString fontName) { m_fontName = fontName; m_updateTextRectangle = true; }
90 virtual void SetFontSize(int fontSize) { m_fontSize = fontSize; m_updateTextRectangle = true; }
91 virtual void SetAltSelectionColour(bool useAltSelectionColour = true) { m_useAltSelectionColour = useAltSelectionColour; }
92 virtual void SetAllowRotation(bool allowRotation = true) { m_allowRotation = allowRotation; }
93 //virtual bool IsGLTextOK();
94
95 void SetDataType(const DataType& dataType) { m_dataType = dataType; }
96 void SetDirection(int direction) { m_direction = direction; }
97 void SetElement(Element* element) { m_element = element; }
98 void SetElementNumber(int elementNumber) { m_elementNumber = elementNumber; }
99 void SetElementTypeText(const ElementType elementType) { m_elementTypeText = elementType; }
100 void SetUnit(const ElectricalUnit unit) { m_unit = unit; }
101 void SetDecimalPlaces(int decimalPlaces) { m_decimalPlaces = decimalPlaces; }
102 const DataType GetDataType() const { return m_dataType; }
103 int GetDirection() const { return m_direction; }
104 Element* GetElement() { return m_element; }
105 int GetElementNumber() const { return m_elementNumber; }
106 const ElementType GetElementTypeText() const { return m_elementTypeText; }
107 const ElectricalUnit GetUnit() const { return m_unit; }
108 int GetDecimalPlaces() const { return m_decimalPlaces; }
109
110 virtual rapidxml::xml_node<>* SaveElement(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* elementListNode);
111 virtual bool OpenElement(rapidxml::xml_node<>* elementNode);
112
113protected:
114 wxString m_text = _("Label");
115 wxString m_fontName = wxT("Arial");
116 int m_fontSize = 10;
117 int m_numberOfLines = 0;
118 bool m_isMultlineText = false;
119 bool m_useAltSelectionColour = false;
120 bool m_allowRotation = true;
121 bool m_updateTextRectangle = true;
122
123 std::vector<GCText*> m_gcTextList;
124
125 Element* m_element = nullptr;
126 ElementType m_elementTypeText = TYPE_NONE;
127 int m_elementNumber;
128 DataType m_dataType;
129 ElectricalUnit m_unit;
130 int m_direction = 0;
131 int m_decimalPlaces = 2;
132};
133
134#endif // TEXT_H
Node for power elements. All others power elements are connected through this.
Definition Bus.h:87
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:115
Abstract class for graphical elements shown with graphical 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:71
virtual Element * GetCopy()
Get a the element copy.
Definition Text.cpp:1173
virtual bool Contains(wxPoint2DDouble position) const
Checks if the element contains a position.
Definition Text.cpp:69
virtual bool AddParent(Element *parent, wxPoint2DDouble position, bool isOpening=false)
Add a parent to the element. This method must be used on power elements that connect to a bus,...
Definition Text.h:78
virtual bool Intersects(wxRect2DDouble rect) const
Check if the element's rect intersects other rect.
Definition Text.cpp:252
virtual void Rotate(bool clockwise=true)
Rotate the element.
Definition Text.cpp:266
Two-winding transformer power element with OLTC support.
Definition Transformer.h:96