KiCad PCB EDA Suite
Loading...
Searching...
No Matches
toolbars_simulator_frame.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4* Copyright (C) 2023 CERN
5* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <sim/simulator_frame.h>
22#include <tool/action_menu.h>
23#include <tool/action_toolbar.h>
24#include <tool/common_control.h>
25#include <tool/tool_manager.h>
26#include <tools/ee_actions.h>
27#include <widgets/wx_menubar.h>
28
29
31{
32 if( m_toolBar )
33 {
36 }
37 else
38 {
39 EDA_BASE_FRAME* parent = dynamic_cast<EDA_BASE_FRAME*>( this );
40
41 wxCHECK( parent, /* void */ );
42
43 m_toolBar = new ACTION_TOOLBAR( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
44 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
45 }
46
49
53
57
62
66
70
71 // after adding the buttons to the toolbar, must call Realize() to reflect the changes
73
74 m_toolBar->Refresh();
75}
76
77
79{
81 EDA_BASE_FRAME* base_frame = dynamic_cast<EDA_BASE_FRAME*>( this );
82
83 // base_frame == nullptr should not happen, but it makes Coverity happy
84 wxCHECK( base_frame, /* void */ );
85
86 // wxWidgets handles the OSX Application menu behind the scenes, but that means
87 // we always have to start from scratch with a new wxMenuBar.
88 wxMenuBar* oldMenuBar = base_frame->GetMenuBar();
89 WX_MENUBAR* menuBar = new WX_MENUBAR();
90
91 //-- File menu -----------------------------------------------------------
92 //
93 ACTION_MENU* fileMenu = new ACTION_MENU( false, tool );
94
96
97 fileMenu->AppendSeparator();
98 fileMenu->Add( EE_ACTIONS::openWorkbook );
99 fileMenu->Add( EE_ACTIONS::saveWorkbook );
100 fileMenu->Add( EE_ACTIONS::saveWorkbookAs );
101
102 fileMenu->AppendSeparator();
103 fileMenu->Add( EE_ACTIONS::exportPlotAsPNG );
104 fileMenu->Add( EE_ACTIONS::exportPlotAsCSV );
105
106 fileMenu->AppendSeparator();
107 fileMenu->AddClose( _( "Simulator" ) );
108
109
110 //-- View menu -----------------------------------------------------------
111 //
112 ACTION_MENU* viewMenu = new ACTION_MENU( false, tool );
113
114 viewMenu->Add( ACTIONS::zoomUndo );
115 viewMenu->Add( ACTIONS::zoomRedo );
116
117 viewMenu->AppendSeparator();
118 viewMenu->Add( ACTIONS::zoomInCenter );
119 viewMenu->Add( ACTIONS::zoomOutCenter );
120 viewMenu->Add( ACTIONS::zoomFitScreen );
121
122 viewMenu->AppendSeparator();
127
128
129 //-- Simulation menu -----------------------------------------------------------
130 //
131 ACTION_MENU* simulationMenu = new ACTION_MENU( false, tool );
132
133 simulationMenu->Add( EE_ACTIONS::newAnalysisTab );
134 simulationMenu->Add( EE_ACTIONS::simAnalysisProperties );
135 simulationMenu->Add( EE_ACTIONS::runSimulation );
136
137 simulationMenu->AppendSeparator();
138 simulationMenu->Add( EE_ACTIONS::simProbe );
139 simulationMenu->Add( EE_ACTIONS::simTune );
140
141 simulationMenu->AppendSeparator();
142 simulationMenu->Add( EE_ACTIONS::editUserDefinedSignals );
143 simulationMenu->Add( EE_ACTIONS::showNetlist );
144
145
146 //-- Preferences menu -----------------------------------------------
147 //
148 ACTION_MENU* prefsMenu = new ACTION_MENU( false, tool );
149
150 //prefsMenu->Add( ACTIONS::configurePaths );
151 //prefsMenu->Add( EE_ACTIONS::showSimLibTable );
152 prefsMenu->Add( ACTIONS::openPreferences );
153
154 prefsMenu->AppendSeparator();
155 AddMenuLanguageList( prefsMenu, tool );
156
157
158 //-- Menubar -------------------------------------------------------------
159 //
160 menuBar->Append( fileMenu, _( "&File" ) );
161 menuBar->Append( viewMenu, _( "&View" ) );
162 menuBar->Append( simulationMenu, _( "&Simulation" ) );
163 menuBar->Append( prefsMenu, _( "&Preferences" ) );
164 base_frame->AddStandardHelpMenu( menuBar );
165
166 base_frame->SetMenuBar( menuBar );
167 delete oldMenuBar;
168}
static TOOL_ACTION toggleGrid
Definition: actions.h:148
static TOOL_ACTION zoomOutCenter
Definition: actions.h:98
static TOOL_ACTION zoomRedo
Definition: actions.h:105
static TOOL_ACTION openPreferences
Definition: actions.h:187
static TOOL_ACTION zoomFitScreen
Definition: actions.h:100
static TOOL_ACTION zoomInCenter
Definition: actions.h:97
static TOOL_ACTION zoomUndo
Definition: actions.h:104
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
static constexpr bool CHECK
Definition: action_menu.h:198
void AddClose(const wxString &aAppname="")
Add a standard close item to the menu with the accelerator key CTRL-W.
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
Define the structure of a toolbar with buttons that invoke ACTIONs.
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
bool KiRealize()
Use this over Realize() to avoid a rendering glitch with fixed orientation toolbars.
void SetToolManager(TOOL_MANAGER *aManager)
void ClearToolbar()
Clear the toolbar and remove all associated menus.
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false, bool aIsCancellable=false)
Add a TOOL_ACTION-based button to the toolbar.
Handle actions that are shared between different applications.
The base frame for deriving all KiCad main window classes.
static constexpr int KICAD_AUI_TB_STYLE
< Default style flags used for wxAUI toolbars.
void AddMenuLanguageList(ACTION_MENU *aMasterMenu, TOOL_INTERACTIVE *aControlTool)
Function AddMenuLanguageList creates a menu list for language choice, and add it as submenu to Master...
static TOOL_ACTION simAnalysisProperties
Definition: ee_actions.h:277
static TOOL_ACTION editUserDefinedSignals
Definition: ee_actions.h:280
static TOOL_ACTION openWorkbook
Definition: ee_actions.h:266
static TOOL_ACTION stopSimulation
Definition: ee_actions.h:279
static TOOL_ACTION toggleLegend
Definition: ee_actions.h:274
static TOOL_ACTION saveWorkbook
Definition: ee_actions.h:267
static TOOL_ACTION saveWorkbookAs
Definition: ee_actions.h:268
static TOOL_ACTION exportPlotAsCSV
Definition: ee_actions.h:270
static TOOL_ACTION simTune
Definition: ee_actions.h:273
static TOOL_ACTION toggleDarkModePlots
Definition: ee_actions.h:276
static TOOL_ACTION exportPlotAsPNG
Definition: ee_actions.h:269
static TOOL_ACTION showNetlist
Definition: ee_actions.h:281
static TOOL_ACTION simProbe
Definition: ee_actions.h:272
static TOOL_ACTION toggleDottedSecondary
Definition: ee_actions.h:275
static TOOL_ACTION runSimulation
Definition: ee_actions.h:278
static TOOL_ACTION newAnalysisTab
Definition: ee_actions.h:265
ACTION_TOOLBAR * m_toolBar
void doReCreateMenuBar() override
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:165
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
Wrapper around a wxMenuBar object that prevents the accelerator table from being used.
Definition: wx_menubar.h:46
#define _(s)