KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 The 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
22
23#include <sim/simulator_frame.h>
24#include <tool/action_menu.h>
25#include <tool/action_toolbar.h>
26#include <tool/common_control.h>
27#include <tool/tool_manager.h>
28#include <tools/sch_actions.h>
29#include <widgets/wx_menubar.h>
30
31
32std::optional<TOOLBAR_CONFIGURATION> SIMULATOR_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
33{
35
36 // clang-format off
37 switch( aToolbar )
38 {
39 case TOOLBAR_LOC::LEFT:
40 case TOOLBAR_LOC::RIGHT:
41 case TOOLBAR_LOC::TOP_AUX:
42 return std::nullopt;
43
44 case TOOLBAR_LOC::TOP_MAIN:
45 config.AppendAction( SCH_ACTIONS::openWorkbook )
46 .AppendAction( SCH_ACTIONS::saveWorkbook );
47
48 config.AppendSeparator()
49 .AppendAction( SCH_ACTIONS::newAnalysisTab )
51
52 config.AppendSeparator()
53 .AppendAction( SCH_ACTIONS::runSimulation )
54 .AppendAction( SCH_ACTIONS::stopSimulation );
55
56 config.AppendSeparator()
57 .AppendAction( ACTIONS::zoomInCenter )
58 .AppendAction( ACTIONS::zoomOutCenter )
59 .AppendAction( ACTIONS::zoomInHorizontally )
60 .AppendAction( ACTIONS::zoomOutHorizontally )
61 .AppendAction( ACTIONS::zoomInVertically )
62 .AppendAction( ACTIONS::zoomOutVertically )
63 .AppendAction( ACTIONS::zoomFitScreen );
64
65 config.AppendSeparator()
66 .AppendAction( SCH_ACTIONS::simProbe )
67 .AppendAction( SCH_ACTIONS::simTune );
68
69 config.AppendSeparator()
71 .AppendAction( SCH_ACTIONS::showNetlist );
72 break;
73 }
74
75 // clang-format on
76 return config;
77}
78
79
81{
83 EDA_BASE_FRAME* base_frame = dynamic_cast<EDA_BASE_FRAME*>( this );
84
85 // base_frame == nullptr should not happen, but it makes Coverity happy
86 wxCHECK( base_frame, /* void */ );
87
88 // wxWidgets handles the OSX Application menu behind the scenes, but that means
89 // we always have to start from scratch with a new wxMenuBar.
90 wxMenuBar* oldMenuBar = base_frame->GetMenuBar();
91 WX_MENUBAR* menuBar = new WX_MENUBAR();
92
93 //-- File menu -----------------------------------------------------------
94 //
95 ACTION_MENU* fileMenu = new ACTION_MENU( false, tool );
96
98
99 fileMenu->AppendSeparator();
100 fileMenu->Add( SCH_ACTIONS::openWorkbook );
101 fileMenu->Add( SCH_ACTIONS::saveWorkbook );
102 fileMenu->Add( SCH_ACTIONS::saveWorkbookAs );
103
104 fileMenu->AppendSeparator();
107 fileMenu->AppendSeparator();
110
111 fileMenu->AppendSeparator();
112 fileMenu->AddClose( _( "Simulator" ) );
113
114
115 //-- View menu -----------------------------------------------------------
116 //
117 ACTION_MENU* viewMenu = new ACTION_MENU( false, tool );
118
121
122 viewMenu->AppendSeparator();
123 viewMenu->Add( ACTIONS::zoomUndo );
124 viewMenu->Add( ACTIONS::zoomRedo );
125
126 viewMenu->AppendSeparator();
127 viewMenu->Add( ACTIONS::zoomInCenter );
128 viewMenu->Add( ACTIONS::zoomOutCenter );
129 viewMenu->Add( ACTIONS::zoomInHorizontally );
131 viewMenu->Add( ACTIONS::zoomInVertically );
132 viewMenu->Add( ACTIONS::zoomOutVertically );
133 viewMenu->Add( ACTIONS::zoomFitScreen );
134
135 viewMenu->AppendSeparator();
140
141
142 //-- Simulation menu -----------------------------------------------------------
143 //
144 ACTION_MENU* simulationMenu = new ACTION_MENU( false, tool );
145
146 simulationMenu->Add( SCH_ACTIONS::newAnalysisTab );
147 simulationMenu->Add( SCH_ACTIONS::simAnalysisProperties );
148 simulationMenu->Add( SCH_ACTIONS::runSimulation );
149
150 simulationMenu->AppendSeparator();
151 simulationMenu->Add( SCH_ACTIONS::simProbe );
152 simulationMenu->Add( SCH_ACTIONS::simTune );
153
154 simulationMenu->AppendSeparator();
155 simulationMenu->Add( SCH_ACTIONS::editUserDefinedSignals );
156 simulationMenu->Add( SCH_ACTIONS::showNetlist );
157
158
159 //-- Preferences menu -----------------------------------------------
160 //
161 ACTION_MENU* prefsMenu = new ACTION_MENU( false, tool );
162
163 //prefsMenu->Add( ACTIONS::configurePaths );
164 //prefsMenu->Add( SCH_ACTIONS::showSimLibTable );
165 prefsMenu->Add( ACTIONS::openPreferences );
166
167 prefsMenu->AppendSeparator();
168 AddMenuLanguageList( prefsMenu, tool );
169
170
171 //-- Menubar -------------------------------------------------------------
172 //
173 menuBar->Append( fileMenu, _( "&File" ) );
174 menuBar->Append( viewMenu, _( "&View" ) );
175 menuBar->Append( simulationMenu, _( "&Simulation" ) );
176 menuBar->Append( prefsMenu, _( "&Preferences" ) );
177 base_frame->AddStandardHelpMenu( menuBar );
178
179 base_frame->SetMenuBar( menuBar );
180 delete oldMenuBar;
181}
static TOOL_ACTION toggleGrid
Definition: actions.h:191
static TOOL_ACTION zoomOutCenter
Definition: actions.h:128
static TOOL_ACTION zoomRedo
Definition: actions.h:140
static TOOL_ACTION toggleSimulationSidePanel
Definition: actions.h:158
static TOOL_ACTION openPreferences
Definition: actions.h:231
static TOOL_ACTION zoomOutHorizontally
Definition: actions.h:130
static TOOL_ACTION zoomOutVertically
Definition: actions.h:132
static TOOL_ACTION toggleConsole
Definition: actions.h:157
static TOOL_ACTION zoomInHorizontally
Definition: actions.h:129
static TOOL_ACTION zoomFitScreen
Definition: actions.h:134
static TOOL_ACTION zoomInCenter
Definition: actions.h:127
static TOOL_ACTION zoomInVertically
Definition: actions.h:131
static TOOL_ACTION zoomUndo
Definition: actions.h:139
Define the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
static constexpr bool CHECK
Definition: action_menu.h:201
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.
Handle actions that are shared between different applications.
The base frame for deriving all KiCad main window classes.
void AddMenuLanguageList(ACTION_MENU *aMasterMenu, TOOL_INTERACTIVE *aControlTool)
Create a menu list for language choice, and add it as submenu to MasterMenu.
static TOOL_ACTION exportPlotToClipboard
Definition: sch_actions.h:292
static TOOL_ACTION saveWorkbookAs
Definition: sch_actions.h:289
static TOOL_ACTION exportPlotAsCSV
Definition: sch_actions.h:291
static TOOL_ACTION simAnalysisProperties
Definition: sch_actions.h:300
static TOOL_ACTION toggleDottedSecondary
Definition: sch_actions.h:298
static TOOL_ACTION simTune
Definition: sch_actions.h:296
static TOOL_ACTION toggleDarkModePlots
Definition: sch_actions.h:299
static TOOL_ACTION exportPlotAsPNG
Definition: sch_actions.h:290
static TOOL_ACTION exportPlotToSchematic
Definition: sch_actions.h:293
static TOOL_ACTION runSimulation
Definition: sch_actions.h:301
static TOOL_ACTION editUserDefinedSignals
Definition: sch_actions.h:303
static TOOL_ACTION newAnalysisTab
Definition: sch_actions.h:286
static TOOL_ACTION simProbe
Definition: sch_actions.h:295
static TOOL_ACTION showNetlist
Definition: sch_actions.h:304
static TOOL_ACTION openWorkbook
Definition: sch_actions.h:287
static TOOL_ACTION saveWorkbook
Definition: sch_actions.h:288
static TOOL_ACTION toggleLegend
Definition: sch_actions.h:297
static TOOL_ACTION stopSimulation
Definition: sch_actions.h:302
void doReCreateMenuBar() override
std::optional< TOOLBAR_CONFIGURATION > DefaultToolbarConfig(TOOLBAR_LOC aToolbar) override
Get the default tools to show on the specified canvas toolbar.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:171
Wrapper around a wxMenuBar object that prevents the accelerator table from being used.
Definition: wx_menubar.h:47
#define _(s)