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#include "menus_helpers.h"
29
30
32{
33 if( m_toolBar )
34 {
37 }
38 else
39 {
40 EDA_BASE_FRAME* parent = dynamic_cast<EDA_BASE_FRAME*>( this );
41
42 wxCHECK( parent, /* void */ );
43
44 m_toolBar = new ACTION_TOOLBAR( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
45 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
46 }
47
50
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
95 fileMenu->Add( EE_ACTIONS::newPlot );
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::zoomInCenter );
115 viewMenu->Add( ACTIONS::zoomOutCenter );
116 viewMenu->Add( ACTIONS::zoomFitScreen );
117
118 viewMenu->AppendSeparator();
123
124
125 //-- Simulation menu -----------------------------------------------------------
126 //
127 ACTION_MENU* simulationMenu = new ACTION_MENU( false, tool );
128
129 simulationMenu->Add( EE_ACTIONS::simCommand );
130 simulationMenu->Add( EE_ACTIONS::runSimulation );
131
132 simulationMenu->AppendSeparator();
133 simulationMenu->Add( EE_ACTIONS::simProbe );
134 simulationMenu->Add( EE_ACTIONS::simTune );
135
136 simulationMenu->AppendSeparator();
137 simulationMenu->Add( EE_ACTIONS::showNetlist );
138
139
140 //-- Preferences menu -----------------------------------------------
141 //
142 ACTION_MENU* prefsMenu = new ACTION_MENU( false, tool );
143
144 //prefsMenu->Add( ACTIONS::configurePaths );
145 //prefsMenu->Add( EE_ACTIONS::showSimLibTable );
146
147 // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
148 // Mac, and it needs the wxID_PREFERENCES id to find it.
149 prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,",
150 _( "Show preferences for all open tools" ),
151 wxID_PREFERENCES,
152 BITMAPS::preference );
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:144
static TOOL_ACTION zoomOutCenter
Definition: actions.h:97
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION zoomInCenter
Definition: actions.h:96
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
static constexpr bool CHECK
Definition: action_menu.h:189
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.
static TOOL_ACTION editUserDefinedSignals
Definition: ee_actions.h:279
static TOOL_ACTION simCommand
Definition: ee_actions.h:276
static TOOL_ACTION openWorkbook
Definition: ee_actions.h:265
static TOOL_ACTION stopSimulation
Definition: ee_actions.h:278
static TOOL_ACTION toggleLegend
Definition: ee_actions.h:273
static TOOL_ACTION saveWorkbook
Definition: ee_actions.h:266
static TOOL_ACTION saveWorkbookAs
Definition: ee_actions.h:267
static TOOL_ACTION exportPlotAsCSV
Definition: ee_actions.h:269
static TOOL_ACTION simTune
Definition: ee_actions.h:272
static TOOL_ACTION toggleDarkModePlots
Definition: ee_actions.h:275
static TOOL_ACTION exportPlotAsPNG
Definition: ee_actions.h:268
static TOOL_ACTION showNetlist
Definition: ee_actions.h:280
static TOOL_ACTION simProbe
Definition: ee_actions.h:271
static TOOL_ACTION toggleDottedSecondary
Definition: ee_actions.h:274
static TOOL_ACTION newPlot
Definition: ee_actions.h:264
static TOOL_ACTION runSimulation
Definition: ee_actions.h:277
ACTION_TOOLBAR * m_toolBar
void doReCreateMenuBar() override
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:170
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
Wrapper around a wxMenuBar object that prevents the accelerator table from being used.
Definition: wx_menubar.h:46
#define _(s)
void AddMenuLanguageList(ACTION_MENU *aMasterMenu, TOOL_INTERACTIVE *aControlTool)
Function AddMenuLanguageList creates a menu list for language choice, and add it as submenu to Master...
Macros and inline functions to create menus items in menubars or popup menus.