Power System Platform  2026w23a-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 ()
 
- 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 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 Init ()
 
void EnableCurrentProjectRibbon (bool enable=true)
 
void CreateDropdownMenus ()
 
void OnAddElementsClick (wxCommandEvent &event)
 
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
 
PropertiesDatam_generalProperties = nullptr
 
- 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_ROTATECC = 10011 , ID_RIBBON_FAULT = 10012 ,
  ID_RIBBON_ROTATEC = 10013 , ID_RIBBON_DELETE = 10014 , ID_RIBBON_MOVE = 10015 , ID_RIBBON_DRAG = 10016 ,
  ID_RIBBON_ADDELEMENT = 10017 , ID_RIBBON_RUNSTAB = 10018 , ID_RIBBON_UNDO = 10019 , ID_RIBBON_HEATMAP = 10020 ,
  ID_RIBBON_ABOUT = 10021 , ID_RIBBON_GUIDE = 10022 , ID_RIBBON_FIT = 10023 , ID_RIBBON_CLOSE = 10024 ,
  ID_RIBBON_RESETVOLT = 10025 , ID_RIBBON_PASTE = 10026 , ID_RIBBON_SAVEAS = 10027 , ID_RIBBON_SCPOWER = 10028 ,
  ID_RIBBON_SAVE = 10029 , ID_RIBBON_EXIT = 10030 , ID_RIBBON_GENSETTINGS = 10031 , ID_RIBBON_DATAREPORT = 10032 ,
  ID_RIBBON_REDO = 10033 , ID_RIBBON_IMPORT = 10034 , ID_RIBBON_COPY = 10035 , ID_RIBBON_OPEN = 10036 ,
  ID_RIBBON_NEW = 10037
}
 

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 68 of file MainFrame.h.

Constructor & Destructor Documentation

◆ MainFrame() [1/2]

MainFrame::MainFrame ( )

Default constructor.

Definition at line 51 of file MainFrame.cpp.

51: 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 52 of file MainFrame.cpp.

53 : MainFrameBase(parent)
54{
55 m_locale = locale;
56 m_generalProperties = initProperties;
57
58 Init();
59
60 if (openPath != "") {
61 EnableCurrentProjectRibbon();
62 Workspace* newWorkspace = new Workspace(this, _("Open project"), this->GetStatusBar(), this->GetAuiNotebook());
63 //if (!m_sharedGLContext) m_sharedGLContext = newWorkspace->GetSharedGLContext();
64
65 FileHanding fileHandling(newWorkspace);
66 if (fileHandling.OpenProject(openPath)) {
67 newWorkspace->SetSavedPath(openPath);
68
69 m_workspaceList.push_back(newWorkspace);
70
71 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
72 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);
73
74 m_auiNotebook->AddPage(newWorkspace, newWorkspace->GetName(), true);
75 m_auiNotebook->Layout();
76 newWorkspace->Redraw();
77 newWorkspace->SetJustOpened(true);
78 newWorkspace->Fit();
79 m_projectNumber++;
80 }
81 }
82}
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 84 of file MainFrame.cpp.

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

Member Function Documentation

◆ CreateDropdownMenus()

void MainFrame::CreateDropdownMenus ( )
protected

Definition at line 202 of file MainFrame.cpp.

203{
204 m_addElementsMenu = new wxMenu();
205
206 wxMenuItem* busElement =
207 new wxMenuItem(m_addElementsMenu, ID_ADDMENU_BUS, _("&Bus\tB"), _("Adds a bus at the circuit"));
208 // busElement->SetBitmap(wxArtProvider::GetBitmap(wxART_WARNING));
209 wxMenuItem* lineElement =
210 new wxMenuItem(m_addElementsMenu, ID_ADDMENU_LINE, _("&Line\tL"), _("Adds a power line at the circuit"));
211 wxMenuItem* transformerElement = new wxMenuItem(m_addElementsMenu, ID_ADDMENU_TRANSFORMER, _("&Transformer\tT"),
212 _("Adds a transformer at the circuit"));
213 wxMenuItem* generatorElement = new wxMenuItem(m_addElementsMenu, ID_ADDMENU_GENERATOR, _("&Generator\tG"),
214 _("Adds a generator at the circuit"));
215 wxMenuItem* indMotorElement = new wxMenuItem(m_addElementsMenu, ID_ADDMENU_INDMOTOR, _("&Induction motor\tI"),
216 _("Adds an induction motor at the circuit"));
217 wxMenuItem* syncCompElement =
218 new wxMenuItem(m_addElementsMenu, ID_ADDMENU_SYNCCOMP, _("&Synchronous compensator \tK"),
219 _("Adds an induction motor at the circuit"));
220 wxMenuItem* loadElement =
221 new wxMenuItem(m_addElementsMenu, ID_ADDMENU_LOAD, _("&Load\tShift-L"), _("Adds a load at the circuit"));
222 wxMenuItem* capacitorElement = new wxMenuItem(m_addElementsMenu, ID_ADDMENU_CAPACITOR, _("&Capacitor\tShift-C"),
223 _("Adds a shunt capacitor at the circuit"));
224 wxMenuItem* inductorElement = new wxMenuItem(m_addElementsMenu, ID_ADDMENU_INDUCTOR, _("&Inductor\tShift-I"),
225 _("Adds a shunt inductor at the circuit"));
226 wxMenuItem* harmCurrentElement =
227 new wxMenuItem(m_addElementsMenu, ID_ADDMENU_HARMCURRENT, _("&Harmonic current\tShift-H"),
228 _("Adds a harmonic current source at the circuit"));
229 wxMenuItem* emtElement =
230 new wxMenuItem(m_addElementsMenu, ID_ADDMENU_EMTELEMENT, _("&Electromagnetic Transient Element\tShift-E"), _("Adds an electromagnetic transient element that connects with ATP"));
231 wxMenuItem* textElement =
232 new wxMenuItem(m_addElementsMenu, ID_ADDMENU_TEXT, _("&Label\tA"), _("Adds a linked element label"));
233
234
235 m_addElementsMenu->Append(busElement);
236 m_addElementsMenu->Append(lineElement);
237 m_addElementsMenu->Append(transformerElement);
238 m_addElementsMenu->Append(generatorElement);
239 m_addElementsMenu->Append(indMotorElement);
240 m_addElementsMenu->Append(syncCompElement);
241 m_addElementsMenu->Append(loadElement);
242 m_addElementsMenu->Append(capacitorElement);
243 m_addElementsMenu->Append(inductorElement);
244 m_addElementsMenu->Append(harmCurrentElement);
245 m_addElementsMenu->Append(emtElement);
246 m_addElementsMenu->Append(textElement);
247
248 m_addElementsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnAddElementsClick, this);
249
250 m_stabilityMenu = new wxMenu();
251
252 wxMenuItem* stabilityList = new wxMenuItem(m_stabilityMenu, ID_STABMENU_LIST, _("&Stability event list"),
253 _("Show the stability event list"));
254 m_stabilityMenu->Append(stabilityList);
255
256 m_stabilityMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnStabilityMenuClick, this);
257
258 m_snapshotMenu = new wxMenu();
259
260 wxMenuItem* snapshotList = new wxMenuItem(m_stabilityMenu, ID_SNAPSHOTMENU_LIST, _("&Export as SVG"),
261 _("Export the diagram as SVG file."));
262 m_snapshotMenu->Append(snapshotList);
263
264 m_snapshotMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnSnapshotMenuClick, this);
265}

◆ EnableCurrentProjectRibbon()

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

Definition at line 163 of file MainFrame.cpp.

164{
165 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_ADDELEMENT, enable);
166 m_ribbonButtonBarReports->EnableButton(ID_RIBBON_CHARTS, enable);
167 m_ribbonButtonBarCProject->EnableButton(ID_RIBBON_CLOSE, enable);
168 m_ribbonButtonBarClipboard->EnableButton(ID_RIBBON_COPY, enable);
169 m_ribbonButtonBarReports->EnableButton(ID_RIBBON_DATAREPORT, enable);
170 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_DELETE, enable);
171 m_ribbonButtonBarContinuous->EnableButton(ID_RIBBON_DISABLESOL, enable);
172 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_DRAG, enable);
173 m_ribbonButtonBarContinuous->EnableButton(ID_RIBBON_ENABLESOL, enable);
174 m_ribbonButtonBarSimulations->EnableButton(ID_RIBBON_FAULT, enable);
175 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_FIT, enable);
176 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_MOVE, enable);
177 m_ribbonButtonBarClipboard->EnableButton(ID_RIBBON_PASTE, enable);
178 m_ribbonButtonBarSimulations->EnableButton(ID_RIBBON_POWERFLOW, enable);
179 m_ribbonButtonBarClipboard->EnableButton(ID_RIBBON_REDO, enable);
180 m_ribbonButtonBarContinuous->EnableButton(ID_RIBBON_RESETVOLT, enable);
181 m_ribbonButtonBarSimulations->EnableButton(ID_RIBBON_RUNSTAB, enable);
182 m_ribbonButtonBarCProject->EnableButton(ID_RIBBON_SAVE, enable);
183 m_ribbonButtonBarCProject->EnableButton(ID_RIBBON_SAVEAS, enable);
184 m_ribbonButtonBarSimulations->EnableButton(ID_RIBBON_SCPOWER, enable);
185 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_PROJSETTINGS, enable);
186 m_ribbonButtonBarReports->EnableButton(ID_RIBBON_HEATMAP, enable);
187 m_ribbonButtonBarReports->EnableButton(ID_RIBBON_SNAPSHOT, enable);
188 m_ribbonButtonBarSimulations->EnableButton(ID_RIBBON_SIMULSETTINGS, enable);
189 m_ribbonButtonBarClipboard->EnableButton(ID_RIBBON_UNDO, enable);
190 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_ROTATEC, enable);
191 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_ROTATECC, enable);
192 m_ribbonButtonBarCircuit->EnableButton(ID_RIBBON_LABELMNGR, enable);
193 m_ribbonButtonBarSimulations->EnableButton(ID_RIBBON_HARMDIST, enable);
194 m_ribbonButtonBarSimulations->EnableButton(ID_RIBBON_FREQRESP, enable);
195
196 //if (m_generalProperties->GetGeneralPropertiesData().useOpenGL)
197 // m_ribbonButtonBarReports->EnableButton(ID_RIBBON_HEATMAP, enable);
198 //else
199 // m_ribbonButtonBarReports->EnableButton(ID_RIBBON_HEATMAP, false);
200}

◆ Init()

void MainFrame::Init ( )
protected

Definition at line 109 of file MainFrame.cpp.

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

◆ NotebookPageClosed()

void MainFrame::NotebookPageClosed ( wxAuiNotebookEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 702 of file MainFrame.cpp.

703{
704 if (m_auiNotebook->GetPageCount() == 0) EnableCurrentProjectRibbon(false);
705 event.Skip();
706}

◆ NotebookPageClosing()

void MainFrame::NotebookPageClosing ( wxAuiNotebookEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 708 of file MainFrame.cpp.

709{
710 auto it = m_workspaceList.begin();
711 while (it != m_workspaceList.end()) {
712 if (*it == m_auiNotebook->GetCurrentPage()) {
713 //if ((*it)->GetSharedGLContext() == m_sharedGLContext) m_sharedGLContext = nullptr;
714 m_workspaceList.erase(it);
715 break;
716 }
717 ++it;
718 }
719 //if (!m_sharedGLContext && m_workspaceList.size() != 0) {
720 // m_sharedGLContext = m_workspaceList[0]->GetSharedGLContext();
721 //}
722 event.Skip();
723}

◆ OnAboutClick()

void MainFrame::OnAboutClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 289 of file MainFrame.cpp.

290{
291 AboutForm about(this);
292 about.ShowModal();
293}
Form to show some informations.
Definition AboutForm.h:33

◆ OnAddElementDropdown()

void MainFrame::OnAddElementDropdown ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 295 of file MainFrame.cpp.

295{ event.PopupMenu(m_addElementsMenu); }

◆ OnAddElementsClick()

void MainFrame::OnAddElementsClick ( wxCommandEvent &  event)
protected

Definition at line 553 of file MainFrame.cpp.

554{
555 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
556
557 if (workspace) {
558 if (workspace->GetWorkspaceMode() != Workspace::WorkspaceMode::MODE_INSERT) {
559 auto elementList = workspace->GetElementSharedList();
560 auto textList = workspace->GetTextList();
561 wxString statusBarText = "";
562 bool newElement = false;
563 bool isText = false;
564
565 switch (event.GetId()) {
566 case ID_ADDMENU_BUS: {
567 auto newBus = std::make_shared<Bus>(wxPoint2DDouble(0, 0),
568 wxString::Format(_("Bus %d"), workspace->GetElementNumber(ID_BUS)));
569 workspace->IncrementElementNumber(ID_BUS);
570 elementList.push_back(newBus);
571 statusBarText = _("Insert Bus: Click to insert, ESC to cancel.");
572 newElement = true;
573 } break;
574 case ID_ADDMENU_LINE: {
575 auto newLine = std::make_shared<Line>(wxString::Format(_("Line %d"), workspace->GetElementNumber(ID_LINE)));
576 elementList.push_back(newLine);
577 workspace->IncrementElementNumber(ID_LINE);
578 statusBarText = _("Insert Line: Click on two buses, ESC to cancel.");
579 newElement = true;
580 } break;
581 case ID_ADDMENU_TRANSFORMER: {
582 auto newTransformer = std::make_shared <Transformer>(
583 wxString::Format(_("Transformer %d"), workspace->GetElementNumber(ID_TRANSFORMER)));
584 workspace->IncrementElementNumber(ID_TRANSFORMER);
585 elementList.push_back(newTransformer);
586 statusBarText = _("Insert Transformer: Click on two buses, ESC to cancel.");
587 newElement = true;
588 } break;
589 case ID_ADDMENU_GENERATOR: {
590 auto newGenerator = std::make_shared<SyncGenerator>(
591 wxString::Format(_("Generator %d"), workspace->GetElementNumber(ID_SYNCGENERATOR)));
592 workspace->IncrementElementNumber(ID_SYNCGENERATOR);
593 elementList.push_back(newGenerator);
594 statusBarText = _("Insert Generator: Click on a bus, ESC to cancel.");
595 newElement = true;
596 } break;
597 case ID_ADDMENU_LOAD: {
598 auto newLoad = std::make_shared<Load>(wxString::Format(_("Load %d"), workspace->GetElementNumber(ID_LOAD)));
599 workspace->IncrementElementNumber(ID_LOAD);
600 elementList.push_back(newLoad);
601 statusBarText = _("Insert Load: Click on a bus, ESC to cancel.");
602 newElement = true;
603 } break;
604 case ID_ADDMENU_CAPACITOR: {
605 auto newCapacitor = std::make_shared<Capacitor>(wxString::Format(_("Capacitor %d"), workspace->GetElementNumber(ID_CAPACITOR)));
606 workspace->IncrementElementNumber(ID_CAPACITOR);
607 elementList.push_back(newCapacitor);
608 statusBarText = _("Insert Capacitor: Click on a bus, ESC to cancel.");
609 newElement = true;
610 } break;
611 case ID_ADDMENU_INDUCTOR: {
612 auto newInductor = std::make_shared<Inductor>(wxString::Format(_("Inductor %d"), workspace->GetElementNumber(ID_INDUCTOR)));
613 workspace->IncrementElementNumber(ID_INDUCTOR);
614 elementList.push_back(newInductor);
615 statusBarText = _("Insert Inductor: Click on a bus, ESC to cancel.");
616 newElement = true;
617 } break;
618 case ID_ADDMENU_HARMCURRENT: {
619 auto newHarmCurrent = std::make_shared<HarmCurrent>(
620 wxString::Format(_("Harmonic Current %d"), workspace->GetElementNumber(ID_INDUCTOR)));
621 workspace->IncrementElementNumber(ID_HARMCURRENT);
622 elementList.push_back(newHarmCurrent);
623 statusBarText = _("Insert Harmonic Current Source: Click on a bus, ESC to cancel.");
624 newElement = true;
625 } break;
626 case ID_ADDMENU_INDMOTOR: {
627 auto newIndMotor = std::make_shared<IndMotor>(
628 wxString::Format(_("Induction motor %d"), workspace->GetElementNumber(ID_INDMOTOR)));
629 workspace->IncrementElementNumber(ID_INDMOTOR);
630 elementList.push_back(newIndMotor);
631 statusBarText = _("Insert Induction Motor: Click on a bus, ESC to cancel.");
632 newElement = true;
633 } break;
634 case ID_ADDMENU_SYNCCOMP: {
635 auto newSyncCondenser = std::make_shared<SyncMotor>(
636 wxString::Format(_("Synchronous condenser %d"), workspace->GetElementNumber(ID_SYNCMOTOR)));
637 workspace->IncrementElementNumber(ID_SYNCMOTOR);
638 elementList.push_back(newSyncCondenser);
639 statusBarText = _("Insert Synchronous Condenser: Click on a bus, ESC to cancel.");
640 newElement = true;
641 } break;
642 case ID_ADDMENU_EMTELEMENT: {
643 auto newEMTElement = std::make_shared<EMTElement>(wxString::Format(_("Electromagnetic Transient %d"), workspace->GetElementNumber(ID_EMTELEMENT)));
644 workspace->IncrementElementNumber(ID_EMTELEMENT);
645 elementList.push_back(newEMTElement);
646 statusBarText = _("Insert Electromagnetic Transient Element: Click on a bus, ESC to cancel.");
647 newElement = true;
648 } break;
649 case ID_ADDMENU_TEXT: {
650 //Text* newText = new Text();
651 auto newText = std::make_shared<Text>();
652 textList.push_back(newText);
653 statusBarText = _("Insert Label: Click to insert, ESC to cancel.");
654 newElement = true;
655 isText = true;
656 } break;
657 }
658 if (newElement) {
659 workspace->SetElementList(elementList);
660 workspace->SetTextList(textList);
661 if (!isText)
662 workspace->SetWorkspaceMode(Workspace::WorkspaceMode::MODE_INSERT);
663 else
664 workspace->SetWorkspaceMode(Workspace::WorkspaceMode::MODE_INSERT_TEXT);
665 workspace->SetStatusBarText(statusBarText);
666 workspace->Redraw();
667 }
668 }
669 }
670}

◆ OnChartsClick()

void MainFrame::OnChartsClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 296 of file MainFrame.cpp.

297{
298 if (Workspace* workspace = dynamic_cast<Workspace*>(m_auiNotebook->GetCurrentPage())) {
299 std::vector<ElementPlotData> plotDataList;
300 auto elementList = workspace->GetElementList();
301 for (auto it = elementList.begin(), itEnd = elementList.end(); it != itEnd; ++it) {
302 if (PowerElement* powerElement = dynamic_cast<PowerElement*>(*it)) {
303 ElementPlotData plotData;
304 if (powerElement->GetPlotData(plotData)) plotDataList.push_back(plotData);
305 }
306 }
307 ChartView* cView = new ChartView(workspace, plotDataList, workspace->GetStabilityTimeVector(), m_generalProperties->GetGeneralPropertiesData().plotLib);
308 cView->Show();
309 }
310}
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 833 of file MainFrame.cpp.

834{
835 // Setup the workspace closing correctly
836
837 wxMessageDialog dialog(this,
838 _("Are you sure you want to close the program?\nAny unsaved changes will be lost."),
839 _("Closing PSP-UFU..."),
840 wxYES_NO | wxICON_EXCLAMATION);
841
842 if (dialog.ShowModal() == wxID_YES) {
843 if (!m_workspaceList.empty())
844 m_workspaceList[m_workspaceList.size() - 1]->Show();
845 event.Skip();
846 }
847 else event.Skip(false);
848}

◆ OnCloseClick()

void MainFrame::OnCloseClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 312 of file MainFrame.cpp.

313{
314 auto it = m_workspaceList.begin();
315 while (it != m_workspaceList.end()) {
316 if (*it == m_auiNotebook->GetCurrentPage()) {
317 //if ((*it)->GetSharedGLContext() == m_sharedGLContext) m_sharedGLContext = nullptr;
318 m_workspaceList.erase(it);
319 m_auiNotebook->DeletePage(m_auiNotebook->GetPageIndex(m_auiNotebook->GetCurrentPage()));
320 break;
321 }
322 ++it;
323 }
324 //if (!m_sharedGLContext && !m_workspaceList.empty()) {
325 // m_sharedGLContext = m_workspaceList[0]->GetSharedGLContext();
326 //}
327 if (m_workspaceList.empty()) {
328 EnableCurrentProjectRibbon(false);
329 }
330}

◆ OnCopyClick()

void MainFrame::OnCopyClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 331 of file MainFrame.cpp.

332{
333 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
334 if (workspace) { workspace->CopySelection(); }
335}

◆ OnDataReportClick()

void MainFrame::OnDataReportClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 337 of file MainFrame.cpp.

338{
339 if (Workspace* workspace = dynamic_cast<Workspace*>(m_auiNotebook->GetCurrentPage())) {
340 DataReport* dataReport = new DataReport(workspace, workspace);
341 dataReport->Show();
342 }
343}
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 344 of file MainFrame.cpp.

345{
346 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
347 if (workspace) { workspace->DeleteSelectedElements(); }
348}

◆ OnDisableSolutionClick()

void MainFrame::OnDisableSolutionClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 349 of file MainFrame.cpp.

350{
351 if (Workspace* workspace = dynamic_cast<Workspace*>(m_auiNotebook->GetCurrentPage())) {
352 workspace->SetContinuousCalculationActive(false);
353 }
354 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
355 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);
356}

◆ OnDragClick()

void MainFrame::OnDragClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 358 of file MainFrame.cpp.

359{
360 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
361 if (workspace) {
362 workspace->SetWorkspaceMode(Workspace::WorkspaceMode::MODE_DRAG);
363 }
364}

◆ OnEnableSolutionClick()

void MainFrame::OnEnableSolutionClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 366 of file MainFrame.cpp.

367{
368 if (Workspace* workspace = dynamic_cast<Workspace*>(m_auiNotebook->GetCurrentPage())) {
369 workspace->SetContinuousCalculationActive(true);
370 workspace->RunStaticStudies();
371 }
372 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, true);
373 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, false);
374}

◆ OnExitClick()

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

Reimplemented from MainFrameBase.

Definition at line 117 of file MainFrame.h.

117{ this->Close(); };

◆ OnFaultClick()

void MainFrame::OnFaultClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 377 of file MainFrame.cpp.

378{
379 if (Workspace* workspace = dynamic_cast<Workspace*>(m_auiNotebook->GetCurrentPage())) { workspace->RunFault(); }
380}

◆ OnFitClick()

void MainFrame::OnFitClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 382 of file MainFrame.cpp.

383{
384 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
385 if (workspace) { workspace->Fit(); }
386}

◆ OnFreqResponseClick()

void MainFrame::OnFreqResponseClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 760 of file MainFrame.cpp.

761{
762 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
763 if (workspace) { workspace->RunFrequencyResponse(); }
764}

◆ OnGeneralSettingsClick()

void MainFrame::OnGeneralSettingsClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 737 of file MainFrame.cpp.

738{
739 GeneralPropertiesForm genPropForm(this, m_generalProperties);
740 genPropForm.SetInitialSize();
741 genPropForm.ShowModal();
742 for (auto& workspace : m_workspaceList) {
743 workspace->GetProperties()->SetGeneralPropertiesData(m_generalProperties->GetGeneralPropertiesData());
744 workspace->GetProperties()->SetGUIColourTheme();
745 workspace->SetColourTheme();
746 workspace->UpdateTextElements();
747 workspace->Redraw();
748 }
749}
Form to edit the software's general data.

◆ OnHarmDistortionsClick()

void MainFrame::OnHarmDistortionsClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 765 of file MainFrame.cpp.

766{
767 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
768 if (workspace) { workspace->RunHarmonicDistortion(); }
769}

◆ OnHeatmapClick()

void MainFrame::OnHeatmapClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 849 of file MainFrame.cpp.

850{
851 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
852 if (workspace) {
853 const bool enabled = workspace->IsHeatMapEnable();
854 m_ribbonButtonBarReports->ToggleButton(ID_RIBBON_HEATMAP, !enabled);
855 workspace->EnableHeatMap(!enabled);
856 }
857}

◆ OnImportClick()

void MainFrame::OnImportClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 672 of file MainFrame.cpp.

673{
674 // Create a new workspace to import
675 EnableCurrentProjectRibbon();
676
677 //Workspace* newWorkspace = new Workspace(this, wxString::Format(_("New project %d"), m_projectNumber), this->GetStatusBar(), this->GetAuiNotebook());
678 Workspace* newWorkspace = new Workspace(m_auiNotebook, wxString::Format(_("New project %d"), m_projectNumber), this->GetStatusBar(), this->GetAuiNotebook());
679 // Set general properties in new Workspace
680 newWorkspace->GetProperties()->SetGeneralPropertiesData(m_generalProperties->GetGeneralPropertiesData());
681 newWorkspace->SetColourTheme();
682
683 m_workspaceList.push_back(newWorkspace);
684
685 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
686 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);
687
688 m_auiNotebook->AddPage(newWorkspace, newWorkspace->GetName(), true);
689 newWorkspace->Redraw();
690 m_projectNumber++;
691
692
693 ImportForm importForm(this, newWorkspace);
694 if (importForm.ShowModal() == wxID_OK) {
695 m_auiNotebook->Layout();
696 newWorkspace->Redraw();
697 newWorkspace->SetJustOpened(true);
698 newWorkspace->Fit();
699 }
700}
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 881 of file MainFrame.cpp.

882{
883 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
884 if (workspace) {
885 LabelManager labelMngr(this, workspace);
886
887 if (labelMngr.ShowModal() == wxID_OK) {
888 workspace->UpdateTextElements();
889 workspace->Redraw();
890 }
891 }
892}

◆ OnMoveClick()

void MainFrame::OnMoveClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 388 of file MainFrame.cpp.

389{
390 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
391 if (workspace) {
392 auto elementList = workspace->GetAllElements();
393 // Calculate the average position of selected elements.
394 wxPoint2DDouble averagePos(0, 0);
395 int numSelElements = 0;
396 for (auto it = elementList.begin(), itEnd = elementList.end(); it != itEnd; ++it) {
397 Element* element = *it;
398 if (element->IsSelected()) {
399 averagePos += element->GetPosition();
400 numSelElements++;
401 }
402 }
403 averagePos = wxPoint2DDouble(averagePos.m_x / double(numSelElements), averagePos.m_y / double(numSelElements));
404 // Set the move position to the average of selected elements.
405 for (auto it = elementList.begin(), itEnd = elementList.end(); it != itEnd; ++it) {
406 Element* element = *it;
407 if (element->IsSelected()) { element->StartMove(averagePos); }
408 }
409 workspace->SetWorkspaceMode(Workspace::WorkspaceMode::MODE_MOVE_ELEMENT);
410 }
411}
Base class of all elements of the program. This class is responsible for manage graphical and his dat...
Definition Element.h:114
wxPoint2DDouble GetPosition() const
Get the element position.
Definition Element.h:188
virtual void StartMove(wxPoint2DDouble position)
Update the element attributes related to the movement.
Definition Element.cpp:265
bool IsSelected() const
Checks if the element is selected.
Definition Element.h:203

◆ OnNewClick()

void MainFrame::OnNewClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 267 of file MainFrame.cpp.

268{
269 EnableCurrentProjectRibbon();
270
271 Workspace* newWorkspace;
272 //newWorkspace = new Workspace(this, wxString::Format(_("New project %d"), m_projectNumber), this->GetStatusBar(), this->GetAuiNotebook());
273 newWorkspace = new Workspace(m_auiNotebook, wxString::Format(_("New project %d"), m_projectNumber), this->GetStatusBar(), this->GetAuiNotebook());
274 // Set general properties in new Workspace
275 newWorkspace->GetProperties()->SetGeneralPropertiesData(m_generalProperties->GetGeneralPropertiesData());
276 newWorkspace->SetColourTheme();
277
278 m_workspaceList.push_back(newWorkspace);
279
280 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
281 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);
282
283 m_auiNotebook->AddPage(newWorkspace, newWorkspace->GetName(), true);
284 newWorkspace->Redraw();
285 newWorkspace->SetJustOpened(true);
286 m_projectNumber++;
287}

◆ OnNotebookPageChanged()

void MainFrame::OnNotebookPageChanged ( wxAuiNotebookEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 858 of file MainFrame.cpp.

859{
860 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
861 if (workspace) {
862 m_ribbonButtonBarReports->ToggleButton(ID_RIBBON_HEATMAP, workspace->IsHeatMapEnable());
863 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, workspace->IsContinuousCalculationActive());
864 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, !workspace->IsContinuousCalculationActive());
865 }
866}

◆ OnOpenClick()

void MainFrame::OnOpenClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 413 of file MainFrame.cpp.

414{
415 wxFileDialog openFileDialog(this, _("Open PSP file"), "", "", "PSP files (*.psp)|*.psp",
416 wxFD_OPEN | wxFD_FILE_MUST_EXIST);
417 if (openFileDialog.ShowModal() == wxID_CANCEL) return;
418
419 wxFileName fileName(openFileDialog.GetPath());
420
421 EnableCurrentProjectRibbon();
422
423 //Workspace* newWorkspace = new Workspace(this, wxString::Format(_("New project %d"), m_projectNumber), this->GetStatusBar(), this->GetAuiNotebook());
424 Workspace* newWorkspace = new Workspace(m_auiNotebook, wxString::Format(_("New project %d"), m_projectNumber), this->GetStatusBar(), this->GetAuiNotebook());
425
426 // Set general properties in new workspace.
427 newWorkspace->GetProperties()->SetGeneralPropertiesData(m_generalProperties->GetGeneralPropertiesData());
428 newWorkspace->SetColourTheme();
429
430 FileHanding fileHandling(newWorkspace);
431 if (fileHandling.OpenProject(fileName)) {
432 newWorkspace->SetSavedPath(fileName);
433
434 m_workspaceList.push_back(newWorkspace);
435
436 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
437 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);
438
439 m_auiNotebook->AddPage(newWorkspace, newWorkspace->GetName(), true);
440 m_auiNotebook->Layout();
441 newWorkspace->Redraw();
442 newWorkspace->SetJustOpened(true);
443 newWorkspace->SaveCurrentState();
444 newWorkspace->Fit();
445 m_projectNumber++;
446 }
447 else {
448 wxMessageDialog msgDialog(this, _("It was not possible to open the selected file."), _("Error"),
449 wxOK | wxCENTRE | wxICON_ERROR);
450 msgDialog.ShowModal();
451 delete newWorkspace;
452 }
453}

◆ OnPasteClick()

void MainFrame::OnPasteClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 459 of file MainFrame.cpp.

460{
461 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
462 if (workspace) { workspace->Paste(); }
463}

◆ OnPowerFlowClick()

void MainFrame::OnPowerFlowClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 465 of file MainFrame.cpp.

466{
467 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
468 if (workspace) { workspace->RunPowerFlow(); }
469}

◆ OnProjectSettingsClick()

void MainFrame::OnProjectSettingsClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 867 of file MainFrame.cpp.

868{
869 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
870 if (workspace) {
871 ProjectPropertiesForm ppf(this, workspace);
872 ppf.ShowModal();
873 workspace->UpdateHeatMap();
874 workspace->Redraw();
875 }
876}

◆ OnPSPGuideClick()

void MainFrame::OnPSPGuideClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 455 of file MainFrame.cpp.

456{
457 wxLaunchDefaultBrowser("https://thales1330.github.io/PSP/docs/");
458}

◆ OnRedoClick()

void MainFrame::OnRedoClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 471 of file MainFrame.cpp.

472{
473 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
474 if (workspace) {
475 workspace->SetNextState();
476 }
477}

◆ OnResetVoltagesClick()

void MainFrame::OnResetVoltagesClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 478 of file MainFrame.cpp.

479{
480 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
481 if (workspace) { workspace->ResetAllVoltages(); }
482}

◆ OnRotClockClick()

void MainFrame::OnRotClockClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 725 of file MainFrame.cpp.

726{
727 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
728 if (workspace) { workspace->RotateSelectedElements(); }
729}

◆ OnRotCounterClockClick()

void MainFrame::OnRotCounterClockClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 731 of file MainFrame.cpp.

732{
733 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
734 if (workspace) { workspace->RotateSelectedElements(false); }
735}

◆ OnRunStabilityClick()

void MainFrame::OnRunStabilityClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 484 of file MainFrame.cpp.

485{
486 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
487 if (workspace) { workspace->RunStability(); }
488}

◆ OnSaveAsClick()

void MainFrame::OnSaveAsClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 496 of file MainFrame.cpp.

497{
498 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
499 if (workspace) {
500 FileHanding fileHandling(workspace);
501
502 wxFileDialog saveFileDialog(this, _("Save PSP file"), "", "", "PSP files (*.psp)|*.psp",
503 wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
504 if (saveFileDialog.ShowModal() == wxID_CANCEL) return;
505
506 fileHandling.SaveProject(saveFileDialog.GetPath());
507 wxFileName fileName(saveFileDialog.GetPath());
508 workspace->SetName(fileName.GetName());
509 m_auiNotebook->SetPageText(m_auiNotebook->GetPageIndex(workspace), workspace->GetName());
510 workspace->SetSavedPath(fileName);
511 }
512}

◆ OnSaveClick()

void MainFrame::OnSaveClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 514 of file MainFrame.cpp.

515{
516 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
517 if (workspace) {
518 FileHanding fileHandling(workspace);
519
520 if (workspace->GetSavedPath().IsOk()) {
521 fileHandling.SaveProject(workspace->GetSavedPath());
522 }
523 else {
524 wxFileDialog saveFileDialog(this, _("Save PSP file"), "", "", "PSP files (*.psp)|*.psp",
525 wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
526 if (saveFileDialog.ShowModal() == wxID_CANCEL) return;
527
528 fileHandling.SaveProject(saveFileDialog.GetPath());
529 wxFileName fileName(saveFileDialog.GetPath());
530 workspace->SetName(fileName.GetName());
531 m_auiNotebook->SetPageText(m_auiNotebook->GetPageIndex(workspace), workspace->GetName());
532 workspace->SetSavedPath(fileName);
533 }
534 }
535}

◆ OnSCPowerClick()

void MainFrame::OnSCPowerClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 490 of file MainFrame.cpp.

491{
492 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
493 if (workspace) { workspace->RunSCPower(); }
494}

◆ OnSimulationSettingsClick()

void MainFrame::OnSimulationSettingsClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 751 of file MainFrame.cpp.

752{
753 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
754 if (workspace) {
755 SimulationsSettingsForm simulSettingsForm(this, workspace->GetProperties(), m_locale);
756 simulSettingsForm.SetInitialSize();
757 simulSettingsForm.ShowModal();
758 }
759}
Form to edit the simulation data.

◆ OnSnapshotClick()

void MainFrame::OnSnapshotClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 537 of file MainFrame.cpp.

538{
539 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
540 if (workspace) {
541 workspace->CopyToClipboard();
542 }
543}

◆ OnSnapshotDropdown()

void MainFrame::OnSnapshotDropdown ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 877 of file MainFrame.cpp.

878{
879 event.PopupMenu(m_snapshotMenu);
880}

◆ OnSnapshotMenuClick()

void MainFrame::OnSnapshotMenuClick ( wxCommandEvent &  event)
protected

Definition at line 789 of file MainFrame.cpp.

790{
791 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
792
793 if (workspace) {
794 auto elementList = workspace->GetElementList();
795
796 switch (event.GetId()) {
797 case ID_SNAPSHOTMENU_LIST: {
798 // Save SVG file
799 wxFileDialog saveFileDialog(this, _("Save diagram as SVG"), "", "", "SVG files (*.svg)|*.svg",
800 wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
801 if (saveFileDialog.ShowModal() == wxID_CANCEL) return;
802 workspace->ExportAsSVG(saveFileDialog.GetPath());
803 } break;
804 }
805 }
806}

◆ OnStabilityDropdown()

void MainFrame::OnStabilityDropdown ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 771 of file MainFrame.cpp.

771{ event.PopupMenu(m_stabilityMenu); }

◆ OnStabilityMenuClick()

void MainFrame::OnStabilityMenuClick ( wxCommandEvent &  event)
protected

Definition at line 773 of file MainFrame.cpp.

774{
775 Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
776
777 if (workspace) {
778 auto elementList = workspace->GetElementList();
779
780 switch (event.GetId()) {
781 case ID_STABMENU_LIST: {
782 StabilityEventList stabEventList(this, elementList);
783 stabEventList.ShowModal();
784 } break;
785 }
786 }
787}

◆ OnUndoClick()

void MainFrame::OnUndoClick ( wxRibbonButtonBarEvent &  event)
protectedvirtual

Reimplemented from MainFrameBase.

Definition at line 545 of file MainFrame.cpp.

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

◆ RunPSPTest()

int MainFrame::RunPSPTest ( )

Definition at line 808 of file MainFrame.cpp.

809{
810 wxMessageOutput::Get()->Printf("Main frame setup OK!\n");
811
812 // Emulate new project creation
813 EnableCurrentProjectRibbon();
814
815 Workspace* newWorkspace = new Workspace(this, wxString::Format(_("New project %d"), m_projectNumber),
816 this->GetStatusBar(), this->GetAuiNotebook());
817 //if (!m_sharedGLContext) {
818 // m_sharedGLContext = newWorkspace->GetSharedGLContext();
819 //}
820 m_workspaceList.push_back(newWorkspace);
821
822 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
823 m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);
824
825 m_auiNotebook->AddPage(newWorkspace, newWorkspace->GetName(), true);
826 newWorkspace->Redraw();
827
828 wxMessageOutput::Get()->Printf("Project creation OK!\n");
829 wxMessageOutput::Get()->Printf("Test done!\n");
830
831 return 0;
832}

Member Data Documentation

◆ m_addElementsMenu

wxMenu* MainFrame::m_addElementsMenu = nullptr
protected

Definition at line 141 of file MainFrame.h.

◆ m_artMetro

wxRibbonMetroArtProvider* MainFrame::m_artMetro = nullptr
protected

Definition at line 140 of file MainFrame.h.

◆ m_generalProperties

PropertiesData* MainFrame::m_generalProperties = nullptr
protected

Definition at line 145 of file MainFrame.h.

◆ m_locale

wxLocale* MainFrame::m_locale = nullptr
protected

Definition at line 144 of file MainFrame.h.

◆ m_projectNumber

int MainFrame::m_projectNumber = 1
protected

Definition at line 138 of file MainFrame.h.

◆ m_snapshotMenu

wxMenu* MainFrame::m_snapshotMenu = nullptr
protected

Definition at line 143 of file MainFrame.h.

◆ m_stabilityMenu

wxMenu* MainFrame::m_stabilityMenu = nullptr
protected

Definition at line 142 of file MainFrame.h.

◆ m_workspaceList

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

Definition at line 137 of file MainFrame.h.


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