1#include "ElementsToolBar.h"
2#include "../MainFrame.h"
3#include "../utils/Path.h"
7ElementsToolBar::ElementsToolBar(
MainFrame* parent,
bool vertical)
8 : wxFrame(parent, wxID_ANY, _(
"Power Elements"), wxDefaultPosition, wxDefaultSize,
9 wxCAPTION | wxCLOSE_BOX | wxFRAME_FLOAT_ON_PARENT | wxFRAME_TOOL_WINDOW | wxFRAME_NO_TASKBAR),
12 InitToolBar(vertical);
14 Bind(wxEVT_CLOSE_WINDOW, &ElementsToolBar::OnClose,
this);
17ElementsToolBar::~ElementsToolBar()
21void ElementsToolBar::InitToolBar(
bool vertical)
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));
27 wxString imgPath = Paths::GetDataPath() +
"/images/elements/";
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();
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"));
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();
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();
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();
50 m_toolBar->AddTool(ID_ADDMENU_TEXT, _(
"Label"), wxBitmap(imgPath +
"text.png", wxBITMAP_TYPE_PNG), _(
"Add a linked element label"));
54 m_toolBar->Bind(wxEVT_TOOL, &ElementsToolBar::OnToolClicked,
this);
56 wxBoxSizer* sizer =
new wxBoxSizer(wxVERTICAL);
57 sizer->Add(m_toolBar, 1, wxEXPAND);
58 SetSizerAndFit(sizer);
61void ElementsToolBar::EnableTools(
bool enable)
63 if (!m_toolBar)
return;
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
71 m_toolBar->EnableTool(
id, enable);
75void ElementsToolBar::OnToolClicked(wxCommandEvent& event)
78 m_mainFrame->OnAddElementsClick(event);
82void ElementsToolBar::OnClose(wxCloseEvent& event)
86 m_mainFrame->OnElementsToolBarClosed();
Main frame of the program. This class manage the ribbon menu and the notebook behavior.