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

Floating vertical toolbar for inserting circuit elements. More...

#include <ElementsToolBar.h>

Inheritance diagram for ElementsToolBar:
Collaboration diagram for ElementsToolBar:

Public Member Functions

 ElementsToolBar (MainFrame *parent, bool vertical=true)
 
void EnableTools (bool enable)
 
wxToolBar * GetToolBar ()
 

Protected Member Functions

void InitToolBar (bool vertical=true)
 
void OnToolClicked (wxCommandEvent &event)
 
void OnClose (wxCloseEvent &event)
 

Private Attributes

MainFramem_mainFrame = nullptr
 
wxToolBar * m_toolBar = nullptr
 

Detailed Description

Floating vertical toolbar for inserting circuit elements.

Definition at line 13 of file ElementsToolBar.h.

Constructor & Destructor Documentation

◆ ElementsToolBar()

ElementsToolBar::ElementsToolBar ( MainFrame parent,
bool  vertical = true 
)

Definition at line 7 of file ElementsToolBar.cpp.

8 : wxFrame(parent, wxID_ANY, _("Power Elements"), wxDefaultPosition, wxDefaultSize,
9 wxCAPTION | wxCLOSE_BOX | wxFRAME_FLOAT_ON_PARENT | wxFRAME_TOOL_WINDOW | wxFRAME_NO_TASKBAR),
10 m_mainFrame(parent)
11{
12 InitToolBar(vertical);
13
14 Bind(wxEVT_CLOSE_WINDOW, &ElementsToolBar::OnClose, this);
15}

◆ ~ElementsToolBar()

ElementsToolBar::~ElementsToolBar ( )
virtual

Definition at line 17 of file ElementsToolBar.cpp.

18{
19}

Member Function Documentation

◆ EnableTools()

void ElementsToolBar::EnableTools ( bool  enable)

Definition at line 61 of file ElementsToolBar.cpp.

62{
63 if (!m_toolBar) return;
64 int ids[] = {
65 ID_ADDMENU_BUS, ID_ADDMENU_LINE, ID_ADDMENU_TRANSFORMER,
66 ID_ADDMENU_GENERATOR, ID_ADDMENU_INDMOTOR, ID_ADDMENU_SYNCCOMP,
67 ID_ADDMENU_LOAD, ID_ADDMENU_CAPACITOR, ID_ADDMENU_INDUCTOR,
68 ID_ADDMENU_HARMCURRENT, ID_ADDMENU_EMTELEMENT, ID_ADDMENU_TEXT
69 };
70 for (int id : ids) {
71 m_toolBar->EnableTool(id, enable);
72 }
73}

◆ GetToolBar()

wxToolBar * ElementsToolBar::GetToolBar ( )
inline

Definition at line 20 of file ElementsToolBar.h.

20{ return m_toolBar; }

◆ InitToolBar()

void ElementsToolBar::InitToolBar ( bool  vertical = true)
protected

Definition at line 21 of file ElementsToolBar.cpp.

22{
23 m_toolBar = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
24 (vertical ? wxTB_VERTICAL : wxTB_HORIZONTAL) | wxTB_FLAT | wxTB_NODIVIDER);
25 m_toolBar->SetToolBitmapSize(wxSize(32, 32));
26
27 wxString imgPath = Paths::GetDataPath() + "/images/elements/";
28
29 m_toolBar->AddTool(ID_ADDMENU_BUS, _("Bus"), wxBitmap(imgPath + "bus.png", wxBITMAP_TYPE_PNG), _("Add a bus at the circuit"));
30 m_toolBar->AddSeparator();
31
32 m_toolBar->AddTool(ID_ADDMENU_LINE, _("Line"), wxBitmap(imgPath + "line.png", wxBITMAP_TYPE_PNG), _("Add a power line at the circuit"));
33 m_toolBar->AddTool(ID_ADDMENU_TRANSFORMER, _("Transformer"), wxBitmap(imgPath + "transformer.png", wxBITMAP_TYPE_PNG), _("Add a transformer at the circuit"));
34
35
36 m_toolBar->AddTool(ID_ADDMENU_GENERATOR, _("Generator"), wxBitmap(imgPath + "generator.png", wxBITMAP_TYPE_PNG), _("Add a generator at the circuit"));
37 m_toolBar->AddTool(ID_ADDMENU_INDMOTOR, _("Induction motor"), wxBitmap(imgPath + "indmotor.png", wxBITMAP_TYPE_PNG), _("Add an induction motor at the circuit"));
38 m_toolBar->AddTool(ID_ADDMENU_SYNCCOMP, _("Synchronous compensator"), wxBitmap(imgPath + "synccomp.png", wxBITMAP_TYPE_PNG), _("Add a synchronous compensator at the circuit"));
39 m_toolBar->AddSeparator();
40
41 m_toolBar->AddTool(ID_ADDMENU_LOAD, _("Load"), wxBitmap(imgPath + "load.png", wxBITMAP_TYPE_PNG), _("Add a load at the circuit"));
42 m_toolBar->AddTool(ID_ADDMENU_CAPACITOR, _("Capacitor"), wxBitmap(imgPath + "capacitor.png", wxBITMAP_TYPE_PNG), _("Add a shunt capacitor at the circuit"));
43 m_toolBar->AddTool(ID_ADDMENU_INDUCTOR, _("Inductor"), wxBitmap(imgPath + "inductor.png", wxBITMAP_TYPE_PNG), _("Add a shunt inductor at the circuit"));
44 m_toolBar->AddSeparator();
45
46 m_toolBar->AddTool(ID_ADDMENU_HARMCURRENT, _("Harmonic current"), wxBitmap(imgPath + "harmcurrent.png", wxBITMAP_TYPE_PNG), _("Add a harmonic current source at the circuit"));
47 m_toolBar->AddTool(ID_ADDMENU_EMTELEMENT, _("EMT Element"), wxBitmap(imgPath + "emtelement.png", wxBITMAP_TYPE_PNG), _("Add an electromagnetic transient element"));
48 m_toolBar->AddSeparator();
49
50 m_toolBar->AddTool(ID_ADDMENU_TEXT, _("Label"), wxBitmap(imgPath + "text.png", wxBITMAP_TYPE_PNG), _("Add a linked element label"));
51
52 m_toolBar->Realize();
53
54 m_toolBar->Bind(wxEVT_TOOL, &ElementsToolBar::OnToolClicked, this);
55
56 wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
57 sizer->Add(m_toolBar, 1, wxEXPAND);
58 SetSizerAndFit(sizer);
59}

◆ OnClose()

void ElementsToolBar::OnClose ( wxCloseEvent &  event)
protected

Definition at line 82 of file ElementsToolBar.cpp.

83{
84 Hide();
85 if (m_mainFrame) {
86 m_mainFrame->OnElementsToolBarClosed();
87 }
88}

◆ OnToolClicked()

void ElementsToolBar::OnToolClicked ( wxCommandEvent &  event)
protected

Definition at line 75 of file ElementsToolBar.cpp.

76{
77 if (m_mainFrame) {
78 m_mainFrame->OnAddElementsClick(event);
79 }
80}

Member Data Documentation

◆ m_mainFrame

MainFrame* ElementsToolBar::m_mainFrame = nullptr
private

Definition at line 28 of file ElementsToolBar.h.

◆ m_toolBar

wxToolBar* ElementsToolBar::m_toolBar = nullptr
private

Definition at line 29 of file ElementsToolBar.h.


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