Power System Platform  2026w34a-beta
Loading...
Searching...
No Matches
MainFrame Class Reference

Main frame of the program. This class manage the ribbon menu and the notebook behavior. More...

#include <MainFrame.h>

Inheritance diagram for MainFrame:
Collaboration diagram for MainFrame:

Public Member Functions

 MainFrame ()
 Default constructor.
 
 MainFrame (wxWindow *parent, wxLocale *locale, PropertiesData *initProperties, wxString openPath="")
 Main frame contructor.
 
 ~MainFrame ()
 Default destructor.
 
int RunPSPTest ()
 
void OnAddElementsClick (wxCommandEvent &event)
 
void BuildElementsToolBar (ElementsToolbar style)
 
void OnElementsToolBarClosed ()
 
ElementsToolBar * GetElementsToolBar ()
 
- Public Member Functions inherited from MainFrameBase
wxRibbonBar * GetRibbonBar ()
 
wxAuiNotebook * GetAuiNotebook ()
 
wxStatusBar * GetStatusBar ()
 
 MainFrameBase (wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("PSP-UFU"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(800, 600), long style=wxCAPTION|wxRESIZE_BORDER|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxSYSTEM_MENU|wxCLOSE_BOX)
 

Protected Member Functions

virtual void OnGridClick (wxRibbonButtonBarEvent &event) override
 
virtual void OnAlignClick (wxRibbonButtonBarEvent &event) override
 
virtual void OnLabelMngrClick (wxRibbonButtonBarEvent &event)
 
virtual void OnSnapshotDropdown (wxRibbonButtonBarEvent &event)
 
virtual void OnProjectSettingsClick (wxRibbonButtonBarEvent &event)
 
virtual void OnNotebookPageChanged (wxAuiNotebookEvent &event)
 
virtual void OnHeatmapClick (wxRibbonButtonBarEvent &event)
 
virtual void OnClose (wxCloseEvent &event)
 
virtual void OnStabilityDropdown (wxRibbonButtonBarEvent &event)
 
virtual void OnFreqResponseClick (wxRibbonButtonBarEvent &event)
 
virtual void OnHarmDistortionsClick (wxRibbonButtonBarEvent &event)
 
virtual void OnGeneralSettingsClick (wxRibbonButtonBarEvent &event)
 
virtual void OnSimulationSettingsClick (wxRibbonButtonBarEvent &event)
 
virtual void OnRotClockClick (wxRibbonButtonBarEvent &event)
 
virtual void OnRotCounterClockClick (wxRibbonButtonBarEvent &event)
 
virtual void NotebookPageClosed (wxAuiNotebookEvent &event)
 
virtual void NotebookPageClosing (wxAuiNotebookEvent &event)
 
virtual void OnAboutClick (wxRibbonButtonBarEvent &event)
 
virtual void OnAddElementDropdown (wxRibbonButtonBarEvent &event)
 
virtual void OnChartsClick (wxRibbonButtonBarEvent &event)
 
virtual void OnCloseClick (wxRibbonButtonBarEvent &event)
 
virtual void OnCopyClick (wxRibbonButtonBarEvent &event)
 
virtual void OnDataReportClick (wxRibbonButtonBarEvent &event)
 
virtual void OnDeleteClick (wxRibbonButtonBarEvent &event)
 
virtual void OnDisableSolutionClick (wxRibbonButtonBarEvent &event)
 
virtual void OnDragClick (wxRibbonButtonBarEvent &event)
 
virtual void OnEnableSolutionClick (wxRibbonButtonBarEvent &event)
 
virtual void OnExitClick (wxRibbonButtonBarEvent &event)
 
virtual void OnFaultClick (wxRibbonButtonBarEvent &event)
 
virtual void OnFitClick (wxRibbonButtonBarEvent &event)
 
virtual void OnMoveClick (wxRibbonButtonBarEvent &event)
 
virtual void OnOpenClick (wxRibbonButtonBarEvent &event)
 
virtual void OnPSPGuideClick (wxRibbonButtonBarEvent &event)
 
virtual void OnPasteClick (wxRibbonButtonBarEvent &event)
 
virtual void OnPowerFlowClick (wxRibbonButtonBarEvent &event)
 
virtual void OnRedoClick (wxRibbonButtonBarEvent &event)
 
virtual void OnResetVoltagesClick (wxRibbonButtonBarEvent &event)
 
virtual void OnRunStabilityClick (wxRibbonButtonBarEvent &event)
 
virtual void OnSCPowerClick (wxRibbonButtonBarEvent &event)
 
virtual void OnSaveAsClick (wxRibbonButtonBarEvent &event)
 
virtual void OnSaveClick (wxRibbonButtonBarEvent &event)
 
virtual void OnSnapshotClick (wxRibbonButtonBarEvent &event)
 
virtual void OnUndoClick (wxRibbonButtonBarEvent &event)
 
virtual void OnNewClick (wxRibbonButtonBarEvent &event)
 
virtual void OnImportClick (wxRibbonButtonBarEvent &event)
 
void PositionElementsToolBar ()
 
void Init ()
 
void EnableCurrentProjectRibbon (bool enable=true)
 
void CreateDropdownMenus ()
 
void OnStabilityMenuClick (wxCommandEvent &event)
 
void OnSnapshotMenuClick (wxCommandEvent &event)
 

Protected Attributes

std::vector< Workspace * > m_workspaceList
 
int m_projectNumber = 1
 
wxRibbonMetroArtProvider * m_artMetro = nullptr
 
wxMenu * m_addElementsMenu = nullptr
 
wxMenu * m_stabilityMenu = nullptr
 
wxMenu * m_snapshotMenu = nullptr
 
wxLocale * m_locale = nullptr
 
PropertiesData * m_generalProperties = nullptr
 
ElementsToolBar * m_elementsToolBar = nullptr
 
bool m_elementsToolBarPositioned = false
 
- Protected Attributes inherited from MainFrameBase
wxRibbonBar * m_ribbonBar
 
wxRibbonPage * m_ribbonPageFile
 
wxRibbonPanel * m_ribbonPanelProjects
 
wxRibbonButtonBar * m_ribbonButtonBarProjects
 
wxRibbonPanel * m_ribbonPanelCProject
 
wxRibbonButtonBar * m_ribbonButtonBarCProject
 
wxRibbonPanel * m_ribbonPanelHelp
 
wxRibbonButtonBar * m_ribbonButtonBarHelp
 
wxRibbonPage * m_ribbonPageTools
 
wxRibbonPanel * m_ribbonPanelClipboard
 
wxRibbonButtonBar * m_ribbonButtonBarClipboard
 
wxRibbonPanel * m_ribbonPanelCircuit
 
wxRibbonButtonBar * m_ribbonButtonBarCircuit
 
wxRibbonPanel * m_ribbonPanelReports
 
wxRibbonButtonBar * m_ribbonButtonBarReports
 
wxRibbonPage * m_ribbonPageSimulation
 
wxRibbonPanel * m_ribbonPanelContinuous
 
wxRibbonButtonBar * m_ribbonButtonBarContinuous
 
wxRibbonPanel * m_ribbonPanelSimulations
 
wxRibbonButtonBar * m_ribbonButtonBarSimulations
 
wxAuiNotebook * m_auiNotebook
 
wxStatusBar * m_statusBar
 

Additional Inherited Members

- Public Types inherited from MainFrameBase
enum  {
  ID_RIBBON_SIMULSETTINGS = 10001 , ID_RIBBON_HARMDIST = 10002 , ID_RIBBON_POWERFLOW = 10003 , ID_RIBBON_FREQRESP = 10004 ,
  ID_RIBBON_DISABLESOL = 10005 , ID_RIBBON_ENABLESOL = 10006 , ID_RIBBON_SNAPSHOT = 10007 , ID_RIBBON_CHARTS = 10008 ,
  ID_RIBBON_PROJSETTINGS = 10009 , ID_RIBBON_LABELMNGR = 10010 , ID_RIBBON_GRID = 10011 , ID_RIBBON_ROTATECC = 10012 ,
  ID_RIBBON_FAULT = 10013 , ID_RIBBON_ROTATEC = 10014 , ID_RIBBON_DELETE = 10015 , ID_RIBBON_MOVE = 10016 ,
  ID_RIBBON_DRAG = 10017 , ID_RIBBON_ADDELEMENT = 10018 , ID_RIBBON_RUNSTAB = 10019 , ID_RIBBON_UNDO = 10020 ,
  ID_RIBBON_HEATMAP = 10021 , ID_RIBBON_ABOUT = 10022 , ID_RIBBON_GUIDE = 10023 , ID_RIBBON_FIT = 10024 ,
  ID_RIBBON_CLOSE = 10025 , ID_RIBBON_RESETVOLT = 10026 , ID_RIBBON_PASTE = 10027 , ID_RIBBON_SAVEAS = 10028 ,
  ID_RIBBON_SCPOWER = 10029 , ID_RIBBON_SAVE = 10030 , ID_RIBBON_EXIT = 10031 , ID_RIBBON_GENSETTINGS = 10032 ,
  ID_RIBBON_DATAREPORT = 10033 , ID_RIBBON_REDO = 10034 , ID_RIBBON_IMPORT = 10035 , ID_RIBBON_ALIGN = 10036 ,
  ID_RIBBON_COPY = 10037 , ID_RIBBON_OPEN = 10038 , ID_RIBBON_NEW = 10039
}
 

Detailed Description

Main frame of the program. This class manage the ribbon menu and the notebook behavior.

Author
Thales Lima Oliveira thale.nosp@m.s@uf.nosp@m.u.br
Date
19/09/2017

Definition at line 70 of file MainFrame.h.

Constructor & Destructor Documentation

◆ MainFrame() [1/2]

MainFrame::MainFrame ( )

Default constructor.

Definition at line 53 of file MainFrame.cpp.

53: MainFrameBase(nullptr) {}

◆ MainFrame() [2/2]

MainFrame::MainFrame ( wxWindow *  parent,
wxLocale *  locale,
PropertiesData *  initProperties,
wxString  openPath = "" 
)

Main frame contructor.

Parameters
parentParent window.
localeLocale settings.
initPropertiesInitial properties.

Definition at line 54 of file MainFrame.cpp.

55 : MainFrameBase(parent)
56{
57 m_locale = locale;
58 m_generalProperties = initProperties;
59
60 Init();
61
62 if (openPath != "") {
63 EnableCurrentProjectRibbon();
64 Workspace* newWorkspace = new Workspace(this, _("Open project"), this->GetStatusBar(), this->GetAuiNotebook());
65 //if (!m_sharedGLContext) m_sharedGLContext = newWorkspace->GetSharedGLContext();
66
67 FileHanding fileHandling(newWorkspace);
68 if (fileHandling.OpenProject(openPath)) {
69 newWorkspace->SetSavedPath(openPath);
70
71 m_workspaceList.push_back(newWorkspace);
72
73 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
74 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);
75
76 m_auiNotebook->AddPage(newWorkspace, newWorkspace->GetName(), true);
77 m_auiNotebook->Layout();
78 newWorkspace->Redraw();
79 newWorkspace->SetJustOpened(true);
80 newWorkspace->Fit();
81 m_projectNumber++;
82 }
83 }
84}
Save and opens the projects created on disk.
Definition FileHanding.h:43
This class manages the graphical and power elements. It is responsible for handling the user's intera...
Definition Workspace.h:105

◆ ~MainFrame()

MainFrame::~MainFrame ( )

Default destructor.

Definition at line 86 of file MainFrame.cpp.

87{
88 //if (!m_sharedGLContext && m_workspaceList.size() != 0) {
89 // m_sharedGLContext = m_workspaceList[0]->GetSharedGLContext();
90 //}
91 if (m_addElementsMenu) {
92 m_addElementsMenu->Disconnect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnAddElementsClick),
93 nullptr, this);
94 delete m_addElementsMenu;
95 }
96 if (m_stabilityMenu) {
97 m_stabilityMenu->Disconnect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnStabilityMenuClick),
98 nullptr, this);
99 delete m_stabilityMenu;
100 }
101 if (m_snapshotMenu) {
102 m_snapshotMenu->Disconnect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnSnapshotMenuClick),
103 nullptr, this);
104 delete m_snapshotMenu;
105 }
106
107 if (m_locale) delete m_locale;
108 if (m_generalProperties) delete m_generalProperties;
109}

Member Function Documentation

◆ BuildElementsToolBar()

void MainFrame::BuildElementsToolBar ( ElementsToolbar  style)

Definition at line 999 of file MainFrame.cpp.

1000{
1001 if (style != NONE) {
1002 delete m_elementsToolBar;
1003 //if (!m_elementsToolBarPositioned) {
1004 m_elementsToolBar = new ElementsToolBar(this, style == VERTICAL);
1005 PositionElementsToolBar();
1006 m_elementsToolBarPositioned = true;
1007 //}
1008 m_elementsToolBar->Show();
1009 m_elementsToolBar->Raise();
1010 }
1011 else {
1012 if (!m_elementsToolBar) return;
1013 m_elementsToolBar->Hide();
1014 }
1015}
Floating vertical toolbar for inserting circuit elements.

◆ CreateDropdownMenus()

void MainFrame::CreateDropdownMenus ( )
protected

Definition at line 215 of file MainFrame.cpp.

216{
217 m_addElementsMenu = new wxMenu();
218
219 struct ElementIcon {
220 int id;
221 wxString file;
222 };
223
224 const std::vector<ElementIcon> elementIcons = {
225 { ID_ADDMENU_BUS, "bus.png" },
226 { ID_ADDMENU_CAPACITOR, "capacitor.png" },
227 { ID_ADDMENU_EMTELEMENT, "emtelement.png" },
228 { ID_ADDMENU_GENERATOR, "generator.png" },
229 { ID_ADDMENU_HARMCURRENT, "harmcurrent.png" },
230 { ID_ADDMENU_INDMOTOR, "indmotor.png" },
231 { ID_ADDMENU_INDUCTOR, "inductor.png" },
232 { ID_ADDMENU_LINE, "line.png" },
233 { ID_ADDMENU_LOAD, "load.png" },
234 { ID_ADDMENU_SYNCCOMP, "synccomp.png" },
235 { ID_ADDMENU_TEXT, "text.png" },
236 { ID_ADDMENU_TRANSFORMER, "transformer.png" }
237 };
238
239 std::map<int, wxBitmap> elementBitmaps;
240
241 const int iconSize = FromDIP(16);
242
243 for (const auto& icon : elementIcons) {
244 wxImage image(Paths::GetDataPath() + "/images/elements/" + icon.file, wxBITMAP_TYPE_PNG);
245
246 if (image.IsOk()) {
247 image.Rescale(iconSize, iconSize, wxIMAGE_QUALITY_HIGH);
248 elementBitmaps[icon.id] = wxBitmap(image);
249 }
250 }
251
252 wxMenuItem* busElement =
253 new wxMenuItem(m_addElementsMenu, ID_ADDMENU_BUS, _("&Bus\tB"), _("Adds a bus at the circuit"));
254 busElement->SetBitmap(elementBitmaps.at(ID_ADDMENU_BUS));
255
256 wxMenuItem* lineElement =
257 new wxMenuItem(m_addElementsMenu, ID_ADDMENU_LINE, _("&Line\tL"), _("Adds a power line at the circuit"));
258 lineElement->SetBitmap(elementBitmaps.at(ID_ADDMENU_LINE));
259
260 wxMenuItem* transformerElement = new wxMenuItem(m_addElementsMenu, ID_ADDMENU_TRANSFORMER, _("&Transformer\tT"),
261 _("Adds a transformer at the circuit"));
262 transformerElement->SetBitmap(elementBitmaps.at(ID_ADDMENU_TRANSFORMER));
263
264 wxMenuItem* generatorElement = new wxMenuItem(m_addElementsMenu, ID_ADDMENU_GENERATOR, _("&Generator\tG"),
265 _("Adds a generator at the circuit"));
266 generatorElement->SetBitmap(elementBitmaps.at(ID_ADDMENU_GENERATOR));
267
268 wxMenuItem* indMotorElement = new wxMenuItem(m_addElementsMenu, ID_ADDMENU_INDMOTOR, _("&Induction motor\tI"),
269 _("Adds an induction motor at the circuit"));
270 indMotorElement->SetBitmap(elementBitmaps.at(ID_ADDMENU_INDMOTOR));
271
272 wxMenuItem* syncCompElement =
273 new wxMenuItem(m_addElementsMenu, ID_ADDMENU_SYNCCOMP, _("&Synchronous compensator \tK"),
274 _("Adds an induction motor at the circuit"));
275 syncCompElement->SetBitmap(elementBitmaps.at(ID_ADDMENU_SYNCCOMP));
276
277 wxMenuItem* loadElement =
278 new wxMenuItem(m_addElementsMenu, ID_ADDMENU_LOAD, _("&Load\tShift-L"), _("Adds a load at the circuit"));
279 loadElement->SetBitmap(elementBitmaps.at(ID_ADDMENU_LOAD));
280
281 wxMenuItem* capacitorElement = new wxMenuItem(m_addElementsMenu, ID_ADDMENU_CAPACITOR, _("&Capacitor\tShift-C"),
282 _("Adds a shunt capacitor at the circuit"));
283 capacitorElement->SetBitmap(elementBitmaps.at(ID_ADDMENU_CAPACITOR));
284
285 wxMenuItem* inductorElement = new wxMenuItem(m_addElementsMenu, ID_ADDMENU_INDUCTOR, _("&Inductor\tShift-I"),
286 _("Adds a shunt inductor at the circuit"));
287 inductorElement->SetBitmap(elementBitmaps.at(ID_ADDMENU_INDUCTOR));
288
289 wxMenuItem* harmCurrentElement =
290 new wxMenuItem(m_addElementsMenu, ID_ADDMENU_HARMCURRENT, _("&Harmonic current\tShift-H"),
291 _("Adds a harmonic current source at the circuit"));
292 harmCurrentElement->SetBitmap(elementBitmaps.at(ID_ADDMENU_HARMCURRENT));
293
294 wxMenuItem* emtElement =
295 new wxMenuItem(m_addElementsMenu, ID_ADDMENU_EMTELEMENT, _("&Electromagnetic Transient Element\tShift-E"), _("Adds an electromagnetic transient element that connects with ATP"));
296 emtElement->SetBitmap(elementBitmaps.at(ID_ADDMENU_EMTELEMENT));
297
298 wxMenuItem* textElement =
299 new wxMenuItem(m_addElementsMenu, ID_ADDMENU_TEXT, _("&Label\tA"), _("Adds a linked element label"));
300 textElement->SetBitmap(elementBitmaps.at(ID_ADDMENU_TEXT));
301
302
303 m_addElementsMenu->Append(busElement);
304 m_addElementsMenu->Append(lineElement);
305 m_addElementsMenu->Append(transformerElement);
306 m_addElementsMenu->Append(generatorElement);
307 m_addElementsMenu->Append(indMotorElement);
308 m_addElementsMenu->Append(syncCompElement);
309 m_addElementsMenu->Append(loadElement);
310 m_addElementsMenu->Append(capacitorElement);
311 m_addElementsMenu->Append(inductorElement);
312 m_addElementsMenu->Append(harmCurrentElement);
313 m_addElementsMenu->Append(emtElement);
314 m_addElementsMenu->Append(textElement);
315
316 m_addElementsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnAddElementsClick, this);
317
318 m_stabilityMenu = new wxMenu();
319
320 wxMenuItem* stabilityList = new wxMenuItem(m_stabilityMenu, ID_STABMENU_LIST, _("&Stability event list"),
321 _("Show the stability event list"));
322 m_stabilityMenu->Append(stabilityList);
323
324 m_stabilityMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnStabilityMenuClick, this);
325
326 m_snapshotMenu = new wxMenu();
327
328 wxMenuItem* snapshotList = new wxMenuItem(m_stabilityMenu, ID_SNAPSHOTMENU_LIST, _("&Export as SVG"),
329 _("Export the diagram as SVG file."));
330 m_snapshotMenu->Append(snapshotList);
331
332 m_snapshotMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnSnapshotMenuClick, this);
333}

◆ EnableCurrentProjectRibbon()

void MainFrame::EnableCurrentProjectRibbon ( bool  enable = true)
protected

Definition at line 176 of file MainFrame.cpp.

177{
178 if (m_elementsToolBar) {
179 m_elementsToolBar->EnableTools(enable);
180 }
181 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_ADDELEMENT, enable);
182 m_ribbonButtonBarReports->EnableButton(ID_RIBBON_CHARTS, enable);
183 m_ribbonButtonBarCProject->EnableButton(ID_RIBBON_CLOSE, enable);
184 m_ribbonButtonBarClipboard->EnableButton(ID_RIBBON_COPY, enable);
185 m_ribbonButtonBarReports->EnableButton(ID_RIBBON_DATAREPORT, enable);
186 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_DELETE, enable);
187 m_ribbonButtonBarContinuous->EnableButton(ID_RIBBON_DISABLESOL, enable);
188 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_DRAG, enable);
189 m_ribbonButtonBarContinuous->EnableButton(ID_RIBBON_ENABLESOL, enable);
190 m_ribbonButtonBarSimulations->EnableButton(ID_RIBBON_FAULT, enable);
191 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_FIT, enable);
192 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_MOVE, enable);
193 m_ribbonButtonBarClipboard->EnableButton(ID_RIBBON_PASTE, enable);
194 m_ribbonButtonBarSimulations->EnableButton(ID_RIBBON_POWERFLOW, enable);
195 m_ribbonButtonBarClipboard->EnableButton(ID_RIBBON_REDO, enable);
196 m_ribbonButtonBarContinuous->EnableButton(ID_RIBBON_RESETVOLT, enable);
197 m_ribbonButtonBarSimulations->EnableButton(ID_RIBBON_RUNSTAB, enable);
198 m_ribbonButtonBarCProject->EnableButton(ID_RIBBON_SAVE, enable);
199 m_ribbonButtonBarCProject->EnableButton(ID_RIBBON_SAVEAS, enable);
200 m_ribbonButtonBarSimulations->EnableButton(ID_RIBBON_SCPOWER, enable);
201 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_PROJSETTINGS, enable);
202 m_ribbonButtonBarReports->EnableButton(ID_RIBBON_HEATMAP, enable);
203 m_ribbonButtonBarReports->EnableButton(ID_RIBBON_SNAPSHOT, enable);
204 m_ribbonButtonBarSimulations->EnableButton(ID_RIBBON_SIMULSETTINGS, enable);
205 m_ribbonButtonBarClipboard->EnableButton(ID_RIBBON_UNDO, enable);
206 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_ROTATEC, enable);
207 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_ROTATECC, enable);
208 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_GRID, enable);
209 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_ALIGN, enable);
210 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_LABELMNGR, enable);
211 m_ribbonButtonBarSimulations->EnableButton(ID_RIBBON_HARMDIST, enable);
212 m_ribbonButtonBarSimulations->EnableButton(ID_RIBBON_FREQRESP, enable);
213}

◆ GetElementsToolBar()

ElementsToolBar * MainFrame::GetElementsToolBar ( )
inline

Definition at line 96 of file MainFrame.h.

96{ return m_elementsToolBar; }

◆ Init()

void MainFrame::Init ( )
protected

Definition at line 111 of file MainFrame.cpp.

112{
113 this->SetSize(800, 600);
114
115 m_generalProperties->SetGUIColourTheme();
116
117 CreateDropdownMenus();
118
119 EnableCurrentProjectRibbon(false);
120
121 if (wxSystemSettings::GetAppearance().IsDark())
122 {
123 auto* darkArt = m_ribbonBar->GetArtProvider();
124 wxColour stdBlue = wxColour(53, 132, 228);
125 wxColour darkBlue = wxColour(6, 68, 140);
126 wxColour stdGrey = wxColour(59, 59, 59);
127 wxColour darkGrey = wxColour(40, 40, 40);
128
129 darkArt->SetColor(wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR, stdGrey);
130 darkArt->SetColor(wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR, stdGrey);
131 darkArt->SetColor(wxRIBBON_ART_PAGE_BACKGROUND_COLOUR, stdGrey);
132 darkArt->SetColor(wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR, stdGrey);
133
134 darkArt->SetColor(wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR, darkGrey);
135 darkArt->SetColor(wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR, darkGrey);
136 darkArt->SetColor(wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR, darkGrey);
137 darkArt->SetColor(wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR, darkGrey);
138
139 darkArt->SetColor(wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR, stdBlue);
140 darkArt->SetColor(wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR, stdBlue);
141 darkArt->SetColor(wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR, stdBlue);
142 darkArt->SetColor(wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR, stdBlue);
143
144 darkArt->SetColor(wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR, stdBlue);
145 darkArt->SetColor(wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR, stdBlue);
146 darkArt->SetColor(wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR, stdBlue);
147 darkArt->SetColor(wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR, stdBlue);
148
149 darkArt->SetColor(wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR, darkBlue);
150 darkArt->SetColor(wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR, darkBlue);
151 darkArt->SetColor(wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR, darkBlue);
152 darkArt->SetColor(wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR, darkBlue);
153 m_ribbonBar->Realize();
154 }
155 else
156 {
157 m_artMetro = new wxRibbonMetroArtProvider();
158 m_ribbonBar->SetArtProvider(m_artMetro);
159 m_ribbonBar->Realize();
160 }
161
162 this->Layout();
163
164 if (!m_generalProperties) return;
165
166 //m_elementsToolBar = new ElementsToolBar(this, m_generalProperties->GetGeneralPropertiesData().elementsToolbar == VERTICAL);
167 //m_elementsToolBar->EnableTools(false);
168 if (m_generalProperties->GetGeneralPropertiesData().elementsToolbar != NONE) {
169 CallAfter([this]() {
170 BuildElementsToolBar(m_generalProperties->GetGeneralPropertiesData().elementsToolbar);
171 m_elementsToolBar->EnableTools(false);
172 });
173 }
174}

◆ NotebookPageClosed()

void MainFrame::NotebookPageClosed ( wxAuiNotebookEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 770 of file MainFrame.cpp.

771{
772 if (m_auiNotebook->GetPageCount() == 0) EnableCurrentProjectRibbon(false);
773 event.Skip();
774}

◆ NotebookPageClosing()

void MainFrame::NotebookPageClosing ( wxAuiNotebookEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 776 of file MainFrame.cpp.

777{
778 auto it = m_workspaceList.begin();
779 while (it != m_workspaceList.end()) {
780 if (*it == m_auiNotebook->GetCurrentPage()) {
781 //if ((*it)->GetSharedGLContext() == m_sharedGLContext) m_sharedGLContext = nullptr;
782 m_workspaceList.erase(it);
783 break;
784 }
785 ++it;
786 }
787 //if (!m_sharedGLContext && m_workspaceList.size() != 0) {
788 // m_sharedGLContext = m_workspaceList[0]->GetSharedGLContext();
789 //}
790 event.Skip();
791}

◆ OnAboutClick()

void MainFrame::OnAboutClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 357 of file MainFrame.cpp.

358{
359 AboutForm about(this);
360 about.ShowModal();
361}
Form to show some informations.
Definition AboutForm.h:33

◆ OnAddElementDropdown()

void MainFrame::OnAddElementDropdown ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 363 of file MainFrame.cpp.

363{ event.PopupMenu(m_addElementsMenu); }

◆ OnAddElementsClick()

void MainFrame::OnAddElementsClick ( wxCommandEvent &  event)

Definition at line 621 of file MainFrame.cpp.

622{
623 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
624
625 if (workspace) {
626 if (workspace->GetWorkspaceMode() != Workspace::WorkspaceMode::MODE_INSERT) {
627 auto elementList = workspace->GetElementSharedList();
628 auto textList = workspace->GetTextList();
629 wxString statusBarText = "";
630 bool newElement = false;
631 bool isText = false;
632
633 switch (event.GetId()) {
634 case ID_ADDMENU_BUS: {
635 auto newBus = std::make_shared<Bus>(wxPoint2DDouble(0, 0),
636 wxString::Format(_("Bus %d"), workspace->GetElementNumber(ID_BUS)));
637 workspace->IncrementElementNumber(ID_BUS);
638 elementList.push_back(newBus);
639 statusBarText = _("Insert Bus: Click to insert, ESC to cancel.");
640 newElement = true;
641 } break;
642 case ID_ADDMENU_LINE: {
643 auto newLine = std::make_shared<Line>(wxString::Format(_("Line %d"), workspace->GetElementNumber(ID_LINE)));
644 elementList.push_back(newLine);
645 workspace->IncrementElementNumber(ID_LINE);
646 statusBarText = _("Insert Line: Click on two buses, ESC to cancel.");
647 newElement = true;
648 } break;
649 case ID_ADDMENU_TRANSFORMER: {
650 auto newTransformer = std::make_shared <Transformer>(
651 wxString::Format(_("Transformer %d"), workspace->GetElementNumber(ID_TRANSFORMER)));
652 workspace->IncrementElementNumber(ID_TRANSFORMER);
653 elementList.push_back(newTransformer);
654 statusBarText = _("Insert Transformer: Click on two buses, ESC to cancel.");
655 newElement = true;
656 } break;
657 case ID_ADDMENU_GENERATOR: {
658 auto newGenerator = std::make_shared<SyncGenerator>(
659 wxString::Format(_("Generator %d"), workspace->GetElementNumber(ID_SYNCGENERATOR)));
660 workspace->IncrementElementNumber(ID_SYNCGENERATOR);
661 elementList.push_back(newGenerator);
662 statusBarText = _("Insert Generator: Click on a bus, ESC to cancel.");
663 newElement = true;
664 } break;
665 case ID_ADDMENU_LOAD: {
666 auto newLoad = std::make_shared<Load>(wxString::Format(_("Load %d"), workspace->GetElementNumber(ID_LOAD)));
667 workspace->IncrementElementNumber(ID_LOAD);
668 elementList.push_back(newLoad);
669 statusBarText = _("Insert Load: Click on a bus, ESC to cancel.");
670 newElement = true;
671 } break;
672 case ID_ADDMENU_CAPACITOR: {
673 auto newCapacitor = std::make_shared<Capacitor>(wxString::Format(_("Capacitor %d"), workspace->GetElementNumber(ID_CAPACITOR)));
674 workspace->IncrementElementNumber(ID_CAPACITOR);
675 elementList.push_back(newCapacitor);
676 statusBarText = _("Insert Capacitor: Click on a bus, ESC to cancel.");
677 newElement = true;
678 } break;
679 case ID_ADDMENU_INDUCTOR: {
680 auto newInductor = std::make_shared<Inductor>(wxString::Format(_("Inductor %d"), workspace->GetElementNumber(ID_INDUCTOR)));
681 workspace->IncrementElementNumber(ID_INDUCTOR);
682 elementList.push_back(newInductor);
683 statusBarText = _("Insert Inductor: Click on a bus, ESC to cancel.");
684 newElement = true;
685 } break;
686 case ID_ADDMENU_HARMCURRENT: {
687 auto newHarmCurrent = std::make_shared<HarmCurrent>(
688 wxString::Format(_("Harmonic Current %d"), workspace->GetElementNumber(ID_INDUCTOR)));
689 workspace->IncrementElementNumber(ID_HARMCURRENT);
690 elementList.push_back(newHarmCurrent);
691 statusBarText = _("Insert Harmonic Current Source: Click on a bus, ESC to cancel.");
692 newElement = true;
693 } break;
694 case ID_ADDMENU_INDMOTOR: {
695 auto newIndMotor = std::make_shared<IndMotor>(
696 wxString::Format(_("Induction motor %d"), workspace->GetElementNumber(ID_INDMOTOR)));
697 workspace->IncrementElementNumber(ID_INDMOTOR);
698 elementList.push_back(newIndMotor);
699 statusBarText = _("Insert Induction Motor: Click on a bus, ESC to cancel.");
700 newElement = true;
701 } break;
702 case ID_ADDMENU_SYNCCOMP: {
703 auto newSyncCondenser = std::make_shared<SyncMotor>(
704 wxString::Format(_("Synchronous condenser %d"), workspace->GetElementNumber(ID_SYNCMOTOR)));
705 workspace->IncrementElementNumber(ID_SYNCMOTOR);
706 elementList.push_back(newSyncCondenser);
707 statusBarText = _("Insert Synchronous Condenser: Click on a bus, ESC to cancel.");
708 newElement = true;
709 } break;
710 case ID_ADDMENU_EMTELEMENT: {
711 auto newEMTElement = std::make_shared<EMTElement>(wxString::Format(_("Electromagnetic Transient %d"), workspace->GetElementNumber(ID_EMTELEMENT)));
712 workspace->IncrementElementNumber(ID_EMTELEMENT);
713 elementList.push_back(newEMTElement);
714 statusBarText = _("Insert Electromagnetic Transient Element: Click on a bus, ESC to cancel.");
715 newElement = true;
716 } break;
717 case ID_ADDMENU_TEXT: {
718 //Text* newText = new Text();
719 auto newText = std::make_shared<Text>();
720 textList.push_back(newText);
721 statusBarText = _("Insert Label: Click to insert, ESC to cancel.");
722 newElement = true;
723 isText = true;
724 } break;
725 }
726 if (newElement) {
727 workspace->SetElementList(elementList);
728 workspace->SetTextList(textList);
729 if (!isText)
730 workspace->SetWorkspaceMode(Workspace::WorkspaceMode::MODE_INSERT);
731 else
732 workspace->SetWorkspaceMode(Workspace::WorkspaceMode::MODE_INSERT_TEXT);
733 workspace->SetStatusBarText(statusBarText);
734 workspace->Redraw();
735 }
736 }
737 }
738}

◆ OnAlignClick()

void MainFrame::OnAlignClick ( wxRibbonButtonBarEvent &  event)
overrideprotectedvirtual

Reimplemented from MainFrameBase.

Definition at line 938 of file MainFrame.cpp.

939{
940 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
941 if (workspace) {
942 workspace->AlignSelectedToGrid();
943 }
944}

◆ OnChartsClick()

void MainFrame::OnChartsClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 364 of file MainFrame.cpp.

365{
366 if (Workspace* workspace = dynamic_cast<Workspace*>(m_auiNotebook->GetCurrentPage())) {
367 std::vector<ElementPlotData> plotDataList;
368 auto elementList = workspace->GetElementList();
369 for (auto it = elementList.begin(), itEnd = elementList.end(); it != itEnd; ++it) {
370 if (PowerElement* powerElement = dynamic_cast<PowerElement*>(*it)) {
371 ElementPlotData plotData;
372 if (powerElement->GetPlotData(plotData)) plotDataList.push_back(plotData);
373 }
374 }
375 ChartView* cView = new ChartView(workspace, plotDataList, workspace->GetStabilityTimeVector(), m_generalProperties->GetGeneralPropertiesData().plotLib);
376 cView->Show();
377 }
378}
This class is responsible to manage the charts generated in the transient electromechanical studies.
Definition ChartView.h:49
Abstract class of power elements.

◆ OnClose()

void MainFrame::OnClose ( wxCloseEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 903 of file MainFrame.cpp.

904{
905 // Setup the workspace closing correctly
906
907 wxMessageDialog dialog(this,
908 _("Are you sure you want to close the program?\nAny unsaved changes will be lost."),
909 _("Closing PSP-UFU..."),
910 wxYES_NO | wxICON_EXCLAMATION);
911
912 if (dialog.ShowModal() == wxID_YES) {
913 if (!m_workspaceList.empty())
914 m_workspaceList[m_workspaceList.size() - 1]->Show();
915 event.Skip();
916 }
917 else event.Skip(false);
918}

◆ OnCloseClick()

void MainFrame::OnCloseClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 380 of file MainFrame.cpp.

381{
382 auto it = m_workspaceList.begin();
383 while (it != m_workspaceList.end()) {
384 if (*it == m_auiNotebook->GetCurrentPage()) {
385 //if ((*it)->GetSharedGLContext() == m_sharedGLContext) m_sharedGLContext = nullptr;
386 m_workspaceList.erase(it);
387 m_auiNotebook->DeletePage(m_auiNotebook->GetPageIndex(m_auiNotebook->GetCurrentPage()));
388 break;
389 }
390 ++it;
391 }
392 //if (!m_sharedGLContext && !m_workspaceList.empty()) {
393 // m_sharedGLContext = m_workspaceList[0]->GetSharedGLContext();
394 //}
395 if (m_workspaceList.empty()) {
396 EnableCurrentProjectRibbon(false);
397 }
398}

◆ OnCopyClick()

void MainFrame::OnCopyClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 399 of file MainFrame.cpp.

400{
401 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
402 if (workspace) { workspace->CopySelection(); }
403}

◆ OnDataReportClick()

void MainFrame::OnDataReportClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 405 of file MainFrame.cpp.

406{
407 if (Workspace* workspace = dynamic_cast<Workspace*>(m_auiNotebook->GetCurrentPage())) {
408 DataReport* dataReport = new DataReport(workspace, workspace);
409 dataReport->Show();
410 }
411}
Form that shows the results of power flow and fault calculations.
Definition DataReport.h:34

◆ OnDeleteClick()

void MainFrame::OnDeleteClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 412 of file MainFrame.cpp.

413{
414 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
415 if (workspace) { workspace->DeleteSelectedElements(); }
416}

◆ OnDisableSolutionClick()

void MainFrame::OnDisableSolutionClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 417 of file MainFrame.cpp.

418{
419 if (Workspace* workspace = dynamic_cast<Workspace*>(m_auiNotebook->GetCurrentPage())) {
420 workspace->SetContinuousCalculationActive(false);
421 }
422 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
423 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);
424}

◆ OnDragClick()

void MainFrame::OnDragClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 426 of file MainFrame.cpp.

427{
428 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
429 if (workspace) {
430 workspace->SetWorkspaceMode(Workspace::WorkspaceMode::MODE_DRAG);
431 }
432}

◆ OnElementsToolBarClosed()

void MainFrame::OnElementsToolBarClosed ( )

Definition at line 1017 of file MainFrame.cpp.

1018{
1019 if (m_generalProperties) {
1020 auto data = m_generalProperties->GetGeneralPropertiesData();
1021 data.elementsToolbar = NONE;
1022 m_generalProperties->SetGeneralPropertiesData(data);
1023 PropertiesData::SaveConfigFile(data);
1024 }
1025}

◆ OnEnableSolutionClick()

void MainFrame::OnEnableSolutionClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 434 of file MainFrame.cpp.

435{
436 if (Workspace* workspace = dynamic_cast<Workspace*>(m_auiNotebook->GetCurrentPage())) {
437 workspace->SetContinuousCalculationActive(true);
438 workspace->RunStaticStudies();
439 }
440 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, true);
441 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, false);
442}

◆ OnExitClick()

virtual void MainFrame::OnExitClick ( wxRibbonButtonBarEvent &  event)
inlineprotectedvirtual

Reimplemented from MainFrameBase.

Definition at line 126 of file MainFrame.h.

126{ this->Close(); };

◆ OnFaultClick()

void MainFrame::OnFaultClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 445 of file MainFrame.cpp.

446{
447 if (Workspace* workspace = dynamic_cast<Workspace*>(m_auiNotebook->GetCurrentPage())) { workspace->RunFault(); }
448}

◆ OnFitClick()

void MainFrame::OnFitClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 450 of file MainFrame.cpp.

451{
452 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
453 if (workspace) { workspace->Fit(); }
454}

◆ OnFreqResponseClick()

void MainFrame::OnFreqResponseClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 830 of file MainFrame.cpp.

831{
832 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
833 if (workspace) { workspace->RunFrequencyResponse(); }
834}

◆ OnGeneralSettingsClick()

void MainFrame::OnGeneralSettingsClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 805 of file MainFrame.cpp.

806{
807 GeneralPropertiesForm genPropForm(this, m_generalProperties);
808 genPropForm.SetInitialSize();
809 if (genPropForm.ShowModal() == wxID_OK) {
810 BuildElementsToolBar(m_generalProperties->GetGeneralPropertiesData().elementsToolbar);
811 }
812 for (auto& workspace : m_workspaceList) {
813 workspace->GetProperties()->SetGeneralPropertiesData(m_generalProperties->GetGeneralPropertiesData());
814 workspace->GetProperties()->SetGUIColourTheme();
815 workspace->SetColourTheme();
816 workspace->UpdateTextElements();
817 workspace->Redraw();
818 }
819}
Form to edit the software's general data.

◆ OnGridClick()

void MainFrame::OnGridClick ( wxRibbonButtonBarEvent &  event)
overrideprotectedvirtual

Reimplemented from MainFrameBase.

Definition at line 928 of file MainFrame.cpp.

929{
930 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
931 if (workspace) {
932 const bool enabled = workspace->IsGridEnabled();
933 m_ribbonButtonBarCircuit->ToggleButton(ID_RIBBON_GRID, !enabled);
934 workspace->EnableGrid(!enabled);
935 workspace->Redraw();
936 }
937}

◆ OnHarmDistortionsClick()

void MainFrame::OnHarmDistortionsClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 835 of file MainFrame.cpp.

836{
837 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
838 if (workspace) { workspace->RunHarmonicDistortion(); }
839}

◆ OnHeatmapClick()

void MainFrame::OnHeatmapClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 919 of file MainFrame.cpp.

920{
921 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
922 if (workspace) {
923 const bool enabled = workspace->IsHeatMapEnable();
924 m_ribbonButtonBarReports->ToggleButton(ID_RIBBON_HEATMAP, !enabled);
925 workspace->EnableHeatMap(!enabled);
926 }
927}

◆ OnImportClick()

void MainFrame::OnImportClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 740 of file MainFrame.cpp.

741{
742 // Create a new workspace to import
743 EnableCurrentProjectRibbon();
744
745 //Workspace* newWorkspace = new Workspace(this, wxString::Format(_("New project %d"), m_projectNumber), this->GetStatusBar(), this->GetAuiNotebook());
746 Workspace* newWorkspace = new Workspace(m_auiNotebook, wxString::Format(_("New project %d"), m_projectNumber), this->GetStatusBar(), this->GetAuiNotebook());
747 // Set general properties in new Workspace
748 newWorkspace->GetProperties()->SetGeneralPropertiesData(m_generalProperties->GetGeneralPropertiesData());
749 newWorkspace->SetColourTheme();
750
751 m_workspaceList.push_back(newWorkspace);
752
753 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
754 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);
755
756 m_auiNotebook->AddPage(newWorkspace, newWorkspace->GetName(), true);
757 newWorkspace->Redraw();
758 m_projectNumber++;
759
760
761 ImportForm importForm(this, newWorkspace);
762 if (importForm.ShowModal() == wxID_OK) {
763 m_auiNotebook->Layout();
764 newWorkspace->Redraw();
765 newWorkspace->SetJustOpened(true);
766 newWorkspace->Fit();
767 }
768}
Form to import other programs files to PSP.
Definition ImportForm.h:53

◆ OnLabelMngrClick()

void MainFrame::OnLabelMngrClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 969 of file MainFrame.cpp.

970{
971 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
972 if (workspace) {
973 LabelManager labelMngr(this, workspace);
974
975 if (labelMngr.ShowModal() == wxID_OK) {
976 workspace->UpdateTextElements();
977 workspace->Redraw();
978 }
979 }
980}

◆ OnMoveClick()

void MainFrame::OnMoveClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 456 of file MainFrame.cpp.

457{
458 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
459 if (workspace) {
460 auto elementList = workspace->GetAllElements();
461 // Calculate the average position of selected elements.
462 wxPoint2DDouble averagePos(0, 0);
463 int numSelElements = 0;
464 for (auto it = elementList.begin(), itEnd = elementList.end(); it != itEnd; ++it) {
465 Element* element = *it;
466 if (element->IsSelected()) {
467 averagePos += element->GetPosition();
468 numSelElements++;
469 }
470 }
471 averagePos = wxPoint2DDouble(averagePos.m_x / double(numSelElements), averagePos.m_y / double(numSelElements));
472 // Set the move position to the average of selected elements.
473 for (auto it = elementList.begin(), itEnd = elementList.end(); it != itEnd; ++it) {
474 Element* element = *it;
475 if (element->IsSelected()) { element->StartMove(averagePos); }
476 }
477 workspace->SetWorkspaceMode(Workspace::WorkspaceMode::MODE_MOVE_ELEMENT);
478 }
479}
Base class of all elements of the program. This class is responsible for manage graphical and his dat...
Definition Element.h:115
wxPoint2DDouble GetPosition() const
Get the element position.
Definition Element.h:189
virtual void StartMove(wxPoint2DDouble position)
Update the element attributes related to the movement.
Definition Element.cpp:335
bool IsSelected() const
Checks if the element is selected.
Definition Element.h:204

◆ OnNewClick()

void MainFrame::OnNewClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 335 of file MainFrame.cpp.

336{
337 EnableCurrentProjectRibbon();
338
339 Workspace* newWorkspace;
340 //newWorkspace = new Workspace(this, wxString::Format(_("New project %d"), m_projectNumber), this->GetStatusBar(), this->GetAuiNotebook());
341 newWorkspace = new Workspace(m_auiNotebook, wxString::Format(_("New project %d"), m_projectNumber), this->GetStatusBar(), this->GetAuiNotebook());
342 // Set general properties in new Workspace
343 newWorkspace->GetProperties()->SetGeneralPropertiesData(m_generalProperties->GetGeneralPropertiesData());
344 newWorkspace->SetColourTheme();
345
346 m_workspaceList.push_back(newWorkspace);
347
348 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
349 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);
350
351 m_auiNotebook->AddPage(newWorkspace, newWorkspace->GetName(), true);
352 newWorkspace->Redraw();
353 newWorkspace->SetJustOpened(true);
354 m_projectNumber++;
355}

◆ OnNotebookPageChanged()

void MainFrame::OnNotebookPageChanged ( wxAuiNotebookEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 945 of file MainFrame.cpp.

946{
947 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
948 if (workspace) {
949 m_ribbonButtonBarCircuit->ToggleButton(ID_RIBBON_GRID, workspace->IsGridEnabled());
950 m_ribbonButtonBarReports->ToggleButton(ID_RIBBON_HEATMAP, workspace->IsHeatMapEnable());
951 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, workspace->IsContinuousCalculationActive());
952 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, !workspace->IsContinuousCalculationActive());
953 }
954}

◆ OnOpenClick()

void MainFrame::OnOpenClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 481 of file MainFrame.cpp.

482{
483 wxFileDialog openFileDialog(this, _("Open PSP file"), "", "", "PSP files (*.psp)|*.psp",
484 wxFD_OPEN | wxFD_FILE_MUST_EXIST);
485 if (openFileDialog.ShowModal() == wxID_CANCEL) return;
486
487 wxFileName fileName(openFileDialog.GetPath());
488
489 EnableCurrentProjectRibbon();
490
491 //Workspace* newWorkspace = new Workspace(this, wxString::Format(_("New project %d"), m_projectNumber), this->GetStatusBar(), this->GetAuiNotebook());
492 Workspace* newWorkspace = new Workspace(m_auiNotebook, wxString::Format(_("New project %d"), m_projectNumber), this->GetStatusBar(), this->GetAuiNotebook());
493
494 // Set general properties in new workspace.
495 newWorkspace->GetProperties()->SetGeneralPropertiesData(m_generalProperties->GetGeneralPropertiesData());
496 newWorkspace->SetColourTheme();
497
498 FileHanding fileHandling(newWorkspace);
499 if (fileHandling.OpenProject(fileName)) {
500 newWorkspace->SetSavedPath(fileName);
501
502 m_workspaceList.push_back(newWorkspace);
503
504 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
505 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);
506
507 m_auiNotebook->AddPage(newWorkspace, newWorkspace->GetName(), true);
508 m_auiNotebook->Layout();
509 newWorkspace->Redraw();
510 newWorkspace->SetJustOpened(true);
511 newWorkspace->SaveCurrentState();
512 newWorkspace->Fit();
513 m_projectNumber++;
514 }
515 else {
516 wxMessageDialog msgDialog(this, _("It was not possible to open the selected file."), _("Error"),
517 wxOK | wxCENTRE | wxICON_ERROR);
518 msgDialog.ShowModal();
519 delete newWorkspace;
520 }
521}

◆ OnPasteClick()

void MainFrame::OnPasteClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 527 of file MainFrame.cpp.

528{
529 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
530 if (workspace) { workspace->Paste(); }
531}

◆ OnPowerFlowClick()

void MainFrame::OnPowerFlowClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 533 of file MainFrame.cpp.

534{
535 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
536 if (workspace) { workspace->RunPowerFlow(); }
537}

◆ OnProjectSettingsClick()

void MainFrame::OnProjectSettingsClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 955 of file MainFrame.cpp.

956{
957 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
958 if (workspace) {
959 ProjectPropertiesForm ppf(this, workspace);
960 ppf.ShowModal();
961 workspace->UpdateHeatMap();
962 workspace->Redraw();
963 }
964}

◆ OnPSPGuideClick()

void MainFrame::OnPSPGuideClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 523 of file MainFrame.cpp.

524{
525 wxLaunchDefaultBrowser("https://thales1330.github.io/PSP/docs/");
526}

◆ OnRedoClick()

void MainFrame::OnRedoClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 539 of file MainFrame.cpp.

540{
541 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
542 if (workspace) {
543 workspace->SetNextState();
544 }
545}

◆ OnResetVoltagesClick()

void MainFrame::OnResetVoltagesClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 546 of file MainFrame.cpp.

547{
548 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
549 if (workspace) { workspace->ResetAllVoltages(); }
550}

◆ OnRotClockClick()

void MainFrame::OnRotClockClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 793 of file MainFrame.cpp.

794{
795 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
796 if (workspace) { workspace->RotateSelectedElements(); }
797}

◆ OnRotCounterClockClick()

void MainFrame::OnRotCounterClockClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 799 of file MainFrame.cpp.

800{
801 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
802 if (workspace) { workspace->RotateSelectedElements(false); }
803}

◆ OnRunStabilityClick()

void MainFrame::OnRunStabilityClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 552 of file MainFrame.cpp.

553{
554 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
555 if (workspace) { workspace->RunStability(); }
556}

◆ OnSaveAsClick()

void MainFrame::OnSaveAsClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 564 of file MainFrame.cpp.

565{
566 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
567 if (workspace) {
568 FileHanding fileHandling(workspace);
569
570 wxFileDialog saveFileDialog(this, _("Save PSP file"), "", "", "PSP files (*.psp)|*.psp",
571 wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
572 if (saveFileDialog.ShowModal() == wxID_CANCEL) return;
573
574 fileHandling.SaveProject(saveFileDialog.GetPath());
575 wxFileName fileName(saveFileDialog.GetPath());
576 workspace->SetName(fileName.GetName());
577 m_auiNotebook->SetPageText(m_auiNotebook->GetPageIndex(workspace), workspace->GetName());
578 workspace->SetSavedPath(fileName);
579 }
580}

◆ OnSaveClick()

void MainFrame::OnSaveClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 582 of file MainFrame.cpp.

583{
584 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
585 if (workspace) {
586 FileHanding fileHandling(workspace);
587
588 if (workspace->GetSavedPath().IsOk()) {
589 fileHandling.SaveProject(workspace->GetSavedPath());
590 }
591 else {
592 wxFileDialog saveFileDialog(this, _("Save PSP file"), "", "", "PSP files (*.psp)|*.psp",
593 wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
594 if (saveFileDialog.ShowModal() == wxID_CANCEL) return;
595
596 fileHandling.SaveProject(saveFileDialog.GetPath());
597 wxFileName fileName(saveFileDialog.GetPath());
598 workspace->SetName(fileName.GetName());
599 m_auiNotebook->SetPageText(m_auiNotebook->GetPageIndex(workspace), workspace->GetName());
600 workspace->SetSavedPath(fileName);
601 }
602 }
603}

◆ OnSCPowerClick()

void MainFrame::OnSCPowerClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 558 of file MainFrame.cpp.

559{
560 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
561 if (workspace) { workspace->RunSCPower(); }
562}

◆ OnSimulationSettingsClick()

void MainFrame::OnSimulationSettingsClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 821 of file MainFrame.cpp.

822{
823 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
824 if (workspace) {
825 SimulationsSettingsForm simulSettingsForm(this, workspace->GetProperties(), m_locale);
826 simulSettingsForm.SetInitialSize();
827 simulSettingsForm.ShowModal();
828 }
829}
Form to edit the simulation data.

◆ OnSnapshotClick()

void MainFrame::OnSnapshotClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 605 of file MainFrame.cpp.

606{
607 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
608 if (workspace) {
609 workspace->CopyToClipboard();
610 }
611}

◆ OnSnapshotDropdown()

void MainFrame::OnSnapshotDropdown ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 965 of file MainFrame.cpp.

966{
967 event.PopupMenu(m_snapshotMenu);
968}

◆ OnSnapshotMenuClick()

void MainFrame::OnSnapshotMenuClick ( wxCommandEvent &  event)
protected

Definition at line 859 of file MainFrame.cpp.

860{
861 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
862
863 if (workspace) {
864 auto elementList = workspace->GetElementList();
865
866 switch (event.GetId()) {
867 case ID_SNAPSHOTMENU_LIST: {
868 // Save SVG file
869 wxFileDialog saveFileDialog(this, _("Save diagram as SVG"), "", "", "SVG files (*.svg)|*.svg",
870 wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
871 if (saveFileDialog.ShowModal() == wxID_CANCEL) return;
872 workspace->ExportAsSVG(saveFileDialog.GetPath());
873 } break;
874 }
875 }
876}

◆ OnStabilityDropdown()

void MainFrame::OnStabilityDropdown ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 841 of file MainFrame.cpp.

841{ event.PopupMenu(m_stabilityMenu); }

◆ OnStabilityMenuClick()

void MainFrame::OnStabilityMenuClick ( wxCommandEvent &  event)
protected

Definition at line 843 of file MainFrame.cpp.

844{
845 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
846
847 if (workspace) {
848 auto elementList = workspace->GetElementList();
849
850 switch (event.GetId()) {
851 case ID_STABMENU_LIST: {
852 StabilityEventList stabEventList(this, elementList);
853 stabEventList.ShowModal();
854 } break;
855 }
856 }
857}

◆ OnUndoClick()

void MainFrame::OnUndoClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 613 of file MainFrame.cpp.

614{
615 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
616 if (workspace) {
617 workspace->SetPreviousState();
618 }
619}

◆ PositionElementsToolBar()

void MainFrame::PositionElementsToolBar ( )
protected

Definition at line 982 of file MainFrame.cpp.

983{
984 if (!m_elementsToolBar) return;
985 //wxRect frameRect = GetScreenRect();
986 //wxSize tbSize = m_elementsToolBar->GetSize();
987 //if (tbSize.GetWidth() <= 0 || tbSize.GetHeight() <= 0) {
988 // tbSize = m_elementsToolBar->GetBestSize();
989 //}
990 //int x = frameRect.GetRight() - tbSize.GetWidth() - 25;
991 //int y = frameRect.GetTop() + 165;
992 //if (x < frameRect.GetLeft()) x = frameRect.GetLeft() + 10;
993 //if (y < frameRect.GetTop()) y = frameRect.GetTop() + 10;
994 //m_elementsToolBar->SetPosition(wxPoint(x, y));
995 wxPoint pos = GetPosition() + wxPoint(20, m_ribbonBar->GetSize().GetHeight() + 70);
996 m_elementsToolBar->Move(pos);
997}

◆ RunPSPTest()

int MainFrame::RunPSPTest ( )

Definition at line 878 of file MainFrame.cpp.

879{
880 wxMessageOutput::Get()->Printf("Main frame setup OK!\n");
881
882 // Emulate new project creation
883 EnableCurrentProjectRibbon();
884
885 Workspace* newWorkspace = new Workspace(this, wxString::Format(_("New project %d"), m_projectNumber),
886 this->GetStatusBar(), this->GetAuiNotebook());
887 //if (!m_sharedGLContext) {
888 // m_sharedGLContext = newWorkspace->GetSharedGLContext();
889 //}
890 m_workspaceList.push_back(newWorkspace);
891
892 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
893 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);
894
895 m_auiNotebook->AddPage(newWorkspace, newWorkspace->GetName(), true);
896 newWorkspace->Redraw();
897
898 wxMessageOutput::Get()->Printf("Project creation OK!\n");
899 wxMessageOutput::Get()->Printf("Test done!\n");
900
901 return 0;
902}

Member Data Documentation

◆ m_addElementsMenu

wxMenu* MainFrame::m_addElementsMenu = nullptr
protected

Definition at line 150 of file MainFrame.h.

◆ m_artMetro

wxRibbonMetroArtProvider* MainFrame::m_artMetro = nullptr
protected

Definition at line 149 of file MainFrame.h.

◆ m_elementsToolBar

ElementsToolBar* MainFrame::m_elementsToolBar = nullptr
protected

Definition at line 155 of file MainFrame.h.

◆ m_elementsToolBarPositioned

bool MainFrame::m_elementsToolBarPositioned = false
protected

Definition at line 156 of file MainFrame.h.

◆ m_generalProperties

PropertiesData* MainFrame::m_generalProperties = nullptr
protected

Definition at line 154 of file MainFrame.h.

◆ m_locale

wxLocale* MainFrame::m_locale = nullptr
protected

Definition at line 153 of file MainFrame.h.

◆ m_projectNumber

int MainFrame::m_projectNumber = 1
protected

Definition at line 147 of file MainFrame.h.

◆ m_snapshotMenu

wxMenu* MainFrame::m_snapshotMenu = nullptr
protected

Definition at line 152 of file MainFrame.h.

◆ m_stabilityMenu

wxMenu* MainFrame::m_stabilityMenu = nullptr
protected

Definition at line 151 of file MainFrame.h.

◆ m_workspaceList

std::vector<Workspace*> MainFrame::m_workspaceList
protected

Definition at line 146 of file MainFrame.h.


The documentation for this class was generated from the following files: