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
66
70
74
75 // after adding the buttons to the toolbar, must call Realize() to reflect the changes
77
78 m_toolBar->Refresh();
79}
80
81
83{
85 EDA_BASE_FRAME* base_frame = dynamic_cast<EDA_BASE_FRAME*>( this );
86
87 // base_frame == nullptr should not happen, but it makes Coverity happy
88 wxCHECK( base_frame, /* void */ );
89
90 // wxWidgets handles the OSX Application menu behind the scenes, but that means
91 // we always have to start from scratch with a new wxMenuBar.
92 wxMenuBar* oldMenuBar = base_frame->GetMenuBar();
93 WX_MENUBAR* menuBar = new WX_MENUBAR();
94
95 //-- File menu -----------------------------------------------------------
96 //
97 ACTION_MENU* fileMenu = new ACTION_MENU( false, tool );
98
100
101 fileMenu->AppendSeparator();
102 fileMenu->Add( EE_ACTIONS::openWorkbook );
103 fileMenu->Add( EE_ACTIONS::saveWorkbook );
104 fileMenu->Add( EE_ACTIONS::saveWorkbookAs );
105
106 fileMenu->AppendSeparator();
107 fileMenu->Add( EE_ACTIONS::exportPlotAsPNG );
108 fileMenu->Add( EE_ACTIONS::exportPlotAsCSV );
109 fileMenu->AppendSeparator();
112
113 fileMenu->AppendSeparator();
114 fileMenu->AddClose( _( "Simulator" ) );
115
116
117 //-- View menu -----------------------------------------------------------
118 //
119 ACTION_MENU* viewMenu = new ACTION_MENU( false, tool );
120
121 viewMenu->Add( ACTIONS::zoomUndo );
122 viewMenu->Add( ACTIONS::zoomRedo );
123
124 viewMenu->AppendSeparator();
125 viewMenu->Add( ACTIONS::zoomInCenter );
126 viewMenu->Add( ACTIONS::zoomOutCenter );
127 viewMenu->Add( ACTIONS::zoomInHorizontally );
129 viewMenu->Add( ACTIONS::zoomInVertically );
130 viewMenu->Add( ACTIONS::zoomOutVertically );
131 viewMenu->Add( ACTIONS::zoomFitScreen );
132
133 viewMenu->AppendSeparator();
138
139
140 //-- Simulation menu -----------------------------------------------------------
141 //
142 ACTION_MENU* simulationMenu = new ACTION_MENU( false, tool );
143
144 simulationMenu->Add( EE_ACTIONS::newAnalysisTab );
145 simulationMenu->Add( EE_ACTIONS::simAnalysisProperties );
146 simulationMenu->Add( EE_ACTIONS::runSimulation );
147
148 simulationMenu->AppendSeparator();
149 simulationMenu->Add( EE_ACTIONS::simProbe );
150 simulationMenu->Add( EE_ACTIONS::simTune );
151
152 simulationMenu->AppendSeparator();
153 simulationMenu->Add( EE_ACTIONS::editUserDefinedSignals );
154 simulationMenu->Add( EE_ACTIONS::showNetlist );
155
156
157 //-- Preferences menu -----------------------------------------------
158 //
159 ACTION_MENU* prefsMenu = new ACTION_MENU( false, tool );
160
161 //prefsMenu->Add( ACTIONS::configurePaths );
162 //prefsMenu->Add( EE_ACTIONS::showSimLibTable );
163 prefsMenu->Add( ACTIONS::openPreferences );
164
165 prefsMenu->AppendSeparator();
166 AddMenuLanguageList( prefsMenu, tool );
167
168
169 //-- Menubar -------------------------------------------------------------
170 //
171 menuBar->Append( fileMenu, _( "&File" ) );
172 menuBar->Append( viewMenu, _( "&View" ) );
173 menuBar->Append( simulationMenu, _( "&Simulation" ) );
174 menuBar->Append( prefsMenu, _( "&Preferences" ) );
175 base_frame->AddStandardHelpMenu( menuBar );
176
177 base_frame->SetMenuBar( menuBar );
178 delete oldMenuBar;
179}
static TOOL_ACTION toggleGrid
Definition: actions.h:187
static TOOL_ACTION zoomOutCenter
Definition: actions.h:128
static TOOL_ACTION zoomRedo
Definition: actions.h:140
static TOOL_ACTION openPreferences
Definition: actions.h:227
static TOOL_ACTION zoomOutHorizontally
Definition: actions.h:130
static TOOL_ACTION zoomOutVertically
Definition: actions.h:132
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
Defines 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.
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:301
static TOOL_ACTION editUserDefinedSignals
Definition: ee_actions.h:304
static TOOL_ACTION openWorkbook
Definition: ee_actions.h:288
static TOOL_ACTION stopSimulation
Definition: ee_actions.h:303
static TOOL_ACTION toggleLegend
Definition: ee_actions.h:298
static TOOL_ACTION saveWorkbook
Definition: ee_actions.h:289
static TOOL_ACTION saveWorkbookAs
Definition: ee_actions.h:290
static TOOL_ACTION exportPlotAsCSV
Definition: ee_actions.h:292
static TOOL_ACTION simTune
Definition: ee_actions.h:297
static TOOL_ACTION toggleDarkModePlots
Definition: ee_actions.h:300
static TOOL_ACTION exportPlotAsPNG
Definition: ee_actions.h:291
static TOOL_ACTION showNetlist
Definition: ee_actions.h:305
static TOOL_ACTION simProbe
Definition: ee_actions.h:296
static TOOL_ACTION toggleDottedSecondary
Definition: ee_actions.h:299
static TOOL_ACTION exportPlotToSchematic
Definition: ee_actions.h:294
static TOOL_ACTION runSimulation
Definition: ee_actions.h:302
static TOOL_ACTION newAnalysisTab
Definition: ee_actions.h:287
static TOOL_ACTION exportPlotToClipboard
Definition: ee_actions.h:293
ACTION_TOOLBAR * m_toolBar
void doReCreateMenuBar() override
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:167
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:47
#define _(s)