Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
ControlEditor.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 CONTROLEDITOR_H
19#define CONTROLEDITOR_H
20
21
22#include "ControlEditorBase.h"
23
24#include <wx/wrapsizer.h>
25#include <wx/dcclient.h>
26#include <wx/dcscreen.h>
27#include <wx/graphics.h>
28#include <wx/progdlg.h>
29
30#ifdef _MSC_VER
31 //#include <windows.h>
32#endif
33
34#include "../elements/controlElement/IOControl.h"
35#include "ControlSystemTest.h"
36
37class FileHanding;
38class Camera;
39class Element;
40class ControlElement;
42class ConnectionLine;
43class Sum;
44class Multiplier;
45class Limiter;
46class RateLimiter;
47class Exponential;
48class Constant;
49class Gain;
50class MathOperation;
51class Divider;
52class MathExpression;
53
56
57class ChartView;
59
60enum class ControlElementButtonID : int {
61 ID_IO = 0,
62 ID_TF,
63 ID_SUM,
64 ID_CONST,
65 ID_LIMITER,
66 ID_GAIN,
67 ID_MULT,
68 ID_EXP,
69 ID_RATELIM,
70 ID_MATH_DIV,
71 ID_MATH_EXPR
72};
73
81class ControlElementButton : public wxWindow
82{
83public:
84 ControlElementButton(wxWindow* parent, wxString label, wxImage image, wxWindowID id = wxID_ANY);
86
87protected:
88 virtual void OnPaint(wxPaintEvent& event);
89 virtual void OnMouseEnter(wxMouseEvent& event);
90 virtual void OnMouseLeave(wxMouseEvent& event);
91 virtual void OnLeftClickDown(wxMouseEvent& event);
92 virtual void OnLeftClickUp(wxMouseEvent& event);
93
94 wxString m_label;
95 wxFont m_font;
96 wxPoint m_labelPosition;
97
98 wxImage m_image;
99 wxSize m_imageSize;
100 wxPoint m_imagePosition;
101
102 int m_borderSize = 2;
103 bool m_mouseAbove = false;
104 bool m_selected = false;
105
106 wxSize m_buttonSize;
107};
108
109class ControlEditor : public ControlEditorBase
110{
111public:
112 enum class ControlEditorMode : int {
113 MODE_EDIT = 0,
114 MODE_MOVE_ELEMENT,
115 MODE_MOVE_LINE,
116 MODE_DRAG,
117 MODE_DRAG_INSERT,
118 MODE_INSERT,
119 MODE_INSERT_LINE,
120 MODE_SELECTION_RECT,
121 MODE_PASTE,
122 MODE_DRAG_PASTE
123 };
124 ControlEditor(wxWindow* parent) : ControlEditorBase(parent) {}
125 ControlEditor(wxWindow* parent,
126 int ioflags = IOControl::IN_TERMINAL_VOLTAGE | IOControl::IN_VELOCITY | IOControl::OUT_FIELD_VOLTAGE |
127 IOControl::OUT_MEC_POWER);
128 virtual ~ControlEditor();
129
130 virtual void AddElement(ControlElementButtonID id);
131 //virtual void Redraw() { m_glCanvas->Refresh(); }
132 virtual void Redraw() { m_cePanel->Refresh(); }
133 virtual void SetJustOpened(bool justOpened) { m_justOpened = justOpened; }
134 virtual void RotateSelectedElements(bool clockwise);
135 virtual void DeleteSelectedElements();
136 virtual void CheckConnections();
137 virtual std::vector< std::shared_ptr<ConnectionLine> > GetConnectionLineList() const { return m_connectionList; }
138 virtual std::vector< std::shared_ptr<ControlElement> > GetControlElementList() const { return m_elementList; }
139 virtual void SetElementsList(const std::vector< std::shared_ptr<ControlElement> >& elementList) { m_elementList = elementList; }
140 virtual void SetConnectionsList(const std::vector< std::shared_ptr<ConnectionLine> >& connectionList) { m_connectionList = connectionList; }
141 virtual void SetControlContainer(ControlElementContainer* ctrlContainer) { m_ctrlContainer = ctrlContainer; }
142 virtual void SetPlotLib(int plotLib) { m_plotLib = plotLib; }
143
144 virtual void OnClose(wxCloseEvent& event);
145 virtual void OnTestClick(wxCommandEvent& event);
146 virtual void OnButtonOKClick(wxCommandEvent& event) { Close(); }
147 virtual void OnImportClick(wxCommandEvent& event);
148 virtual void OnExportClick(wxCommandEvent& event);
149 virtual void OnKeyDown(wxKeyEvent& event);
150 virtual void OnIdle(wxIdleEvent& event);
151 virtual void OnScroll(wxMouseEvent& event);
152 virtual void OnDoubleClick(wxMouseEvent& event);
153 virtual void OnLeftClickDown(wxMouseEvent& event);
154 virtual void OnLeftClickUp(wxMouseEvent& event);
155 virtual void OnMiddleDown(wxMouseEvent& event);
156 virtual void OnMiddleUp(wxMouseEvent& event);
157 virtual void OnMouseMotion(wxMouseEvent& event);
158 virtual void OnPaint(wxPaintEvent& event);
159 virtual void LeftClickDown(wxMouseEvent& event);
160
161 virtual void BuildColourList();
162 virtual wxColour GetNextColour();
163
164 void BuildControlElementPanel();
165
166protected:
167 //void SetViewport();
168 int GetNextID();
169
170 std::vector< std::shared_ptr<ConnectionLine> >::iterator DeleteLineFromList(std::vector< std::shared_ptr<ConnectionLine> >::iterator& it);
171
172 //wxGLContext* m_glContext = nullptr;
173 Camera* m_camera = nullptr;
174
175 ControlEditorMode m_mode = ControlEditorMode::MODE_EDIT;
176
177 wxRect2DDouble m_selectionRect;
178 wxPoint2DDouble m_startSelRect;
179
180 //std::vector<ControlElement*> m_elementList;
181 std::vector< std::shared_ptr<ControlElement> > m_elementList;
182 //std::vector<ConnectionLine*> m_connectionList;
183 std::vector< std::shared_ptr<ConnectionLine> > m_connectionList;
184
185 ControlElementContainer* m_ctrlContainer = nullptr;
186
187 bool m_justOpened = false;
188 int m_ioFlags = 0;
189
190 int m_inputType = 0;
191 double m_startTime = 1.0;
192 double m_slope = 1.0;
193 double m_timeStep = 1e-4;
194 double m_simTime = 10.0;
195 int m_plotLib = 0;
196
197 std::vector<wxColour> m_colourList;
198 std::vector<wxColour>::iterator m_itColourList;
199};
200#endif // CONTROLEDITOR_H
Class responsible for the correct visualization of the elements on screen.
Definition Camera.h:31
This class is responsible to manage the charts generated in the transient electromechanical studies.
Definition ChartView.h:49
Connection between two control elements or other connection line and an element.
A control element that provides a constant value.
Definition Constant.h:37
This class is responsible to handle the user interaction with control elements.
Class that can contain all control elements. Can identify (using RTTI) the elements from a generic li...
Solves in the time the control system. Can solve the control system directly from a ControlEditor or ...
Control element that divides two inputs.
Definition Divider.h:33
Class to store the elements in the clipboard.
Base class of all elements of the program. This class is responsible for manage graphical and his dat...
Definition Element.h:112
Generates an output following an exponential function.
Definition Exponential.h:33
Save and opens the projects created on disk.
Definition FileHanding.h:43
Provide an output multiplying the input by a constant.
Definition Gain.h:37
Limits the input value by superior and inferior values.
Definition Limiter.h:33
A generic math expression block that can perform math and conditional operations with the inputs.
Abstract class that define the general behavior of math operation control block.
Multiplies two inputs.
Definition Multiplier.h:33
Limits the rising and/or falling rate.
Definition RateLimiter.h:33
Sum the all inputs (can choose the input signal).
Definition Sum.h:34
Calculates the time response by a frequency domain transfer function.