KiCad PCB EDA Suite
toolbars_footprint_viewer.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) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 2012 Wayne Stambaugh <[email protected]>
7 * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation, either version 3 of the License, or (at your
12 * option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23
24#include <advanced_config.h>
25#include <macros.h>
26#include <bitmaps.h>
27#include <tool/action_toolbar.h>
29#include <tool/tool_manager.h>
31#include <tools/pcb_actions.h>
33#include "pcbnew_id.h"
34#include <widgets/wx_menubar.h>
35#include <wx/choice.h>
36
37
39{
40 // Note:
41 // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
42 // all wxAuiToolBarItems.
43 // However the wxAuiToolBarItems are not the owners of controls managed by
44 // them ( m_zoomSelectBox and m_gridSelectBox ), and therefore do not delete them
45 // So we do not recreate them after clearing the tools.
46
47 if( m_mainToolBar )
48 {
50 }
51 else
52 {
53 m_mainToolBar = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
54 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT |
55 wxAUI_TB_HORIZONTAL );
57 }
58
59 // Set up toolbar
60 m_mainToolBar->AddTool( ID_MODVIEW_PREVIOUS, wxEmptyString,
62 _( "Display previous footprint" ) );
63 m_mainToolBar->AddTool( ID_MODVIEW_NEXT, wxEmptyString,
65 _( "Display next footprint" ) );
66
73
76 m_mainToolBar->AddTool( ID_ADD_FOOTPRINT_TO_BOARD, wxEmptyString,
78 _( "Insert footprint in board" ) );
79
81
82 // Grid selection choice box.
83 if( m_gridSelectBox == nullptr )
84 {
85 m_gridSelectBox = new wxChoice( m_mainToolBar, ID_ON_GRID_SELECT, wxDefaultPosition,
86 wxDefaultSize, 0, nullptr );
87 }
88
90 m_mainToolBar->AddControl( m_gridSelectBox );
91
93
94 // Zoom selection choice box.
95 if( m_zoomSelectBox == nullptr )
96 {
97 m_zoomSelectBox = new wxChoice( m_mainToolBar, ID_ON_ZOOM_SELECT, wxDefaultPosition,
98 wxDefaultSize, 0, nullptr );
99 }
100
102 m_mainToolBar->AddControl( m_zoomSelectBox );
103
104 // Option to run Zoom automatique on footprint selection change
105 m_mainToolBar->AddTool( ID_FPVIEWER_AUTOZOOM_TOOL, wxEmptyString,
107 _( "Automatic Zoom on footprint change" ),
108 wxITEM_CHECK );
109
111
112 // after adding the buttons to the toolbar, must call Realize() to
113 // reflect the changes
115}
116
117
119{
120 if( m_optionsToolBar )
121 {
123 }
124 else
125 {
126 m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition,
127 wxDefaultSize,
128 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
130 }
131
134
142
148
149 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
151
153}
154
155
157{
158 // This toolbar is not currently used
159}
160
161
163{
165
166 // wxWidgets handles the Mac Application menu behind the scenes, but that means
167 // we always have to start from scratch with a new wxMenuBar.
168 wxMenuBar* oldMenuBar = GetMenuBar();
169 WX_MENUBAR* menuBar = new WX_MENUBAR();
170
171
172 //----- File menu -----------------------------------------------------------
173 //
174 ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
175
176 fileMenu->AddClose( _( "Footprint Viewer" ) );
177
178 //----- View menu -----------------------------------------------------------
179 //
180 ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
181
182 viewMenu->AppendSeparator();
183 viewMenu->Add( ACTIONS::zoomInCenter );
184 viewMenu->Add( ACTIONS::zoomOutCenter );
185 viewMenu->Add( ACTIONS::zoomFitScreen );
186 viewMenu->Add( ACTIONS::zoomRedraw );
187
188 viewMenu->AppendSeparator();
189 viewMenu->Add( ACTIONS::show3DViewer );
190
191 //----- Menubar -------------------------------------------------------------
192 //
193 menuBar->Append( fileMenu, _( "&File" ) );
194 menuBar->Append( viewMenu, _( "&View" ) );
195 AddStandardHelpMenu( menuBar );
196
197 SetMenuBar( menuBar );
198 delete oldMenuBar;
199}
wxBitmap KiScaledBitmap(BITMAPS aBitmap, wxWindow *aWindow, int aHeight, bool aQuantized)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:156
@ lib_previous
@ insert_module_board
@ zoom_auto_fit_in_page
static TOOL_ACTION toggleGrid
Definition: actions.h:143
static TOOL_ACTION zoomRedraw
Definition: actions.h:92
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
static TOOL_ACTION show3DViewer
Definition: actions.h:162
static TOOL_ACTION zoomOutCenter
Definition: actions.h:96
static TOOL_ACTION togglePolarCoords
Definition: actions.h:152
static TOOL_ACTION milsUnits
Definition: actions.h:148
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:107
static TOOL_ACTION inchesUnits
Definition: actions.h:147
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:104
static TOOL_ACTION measureTool
Definition: actions.h:157
static TOOL_ACTION selectionTool
Definition: actions.h:156
static TOOL_ACTION zoomFitScreen
Definition: actions.h:98
static TOOL_ACTION zoomTool
Definition: actions.h:101
static TOOL_ACTION zoomInCenter
Definition: actions.h:95
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
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.
static constexpr bool TOGGLE
static constexpr bool CANCEL
void SetAuiManager(wxAuiManager *aManager)
Set the AUI manager that this toolbar belongs to.
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 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.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
static constexpr int KICAD_AUI_TB_STYLE
< Default style flags used for wxAUI toolbars.
wxAuiManager m_auimgr
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
wxChoice * m_gridSelectBox
ACTION_TOOLBAR * m_optionsToolBar
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
void UpdateZoomSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
ACTION_TOOLBAR * m_mainToolBar
wxChoice * m_zoomSelectBox
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:280
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:438
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:441
static TOOL_ACTION showPadNumbers
Definition: pcb_actions.h:287
The selection tool: currently supports:
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:170
Wrapper around a wxMenuBar object that prevents the accelerator table from being used.
Definition: wx_menubar.h:46
#define _(s)
@ ID_ON_GRID_SELECT
Definition: id.h:145
@ ID_OPT_TOOLBAR
Definition: id.h:102
@ ID_ON_ZOOM_SELECT
Definition: id.h:143
This file contains miscellaneous commonly used macros and functions.
@ ID_ADD_FOOTPRINT_TO_BOARD
Definition: pcbnew_id.h:116
@ ID_MODVIEW_PREVIOUS
Definition: pcbnew_id.h:104
@ ID_FPVIEWER_AUTOZOOM_TOOL
Definition: pcbnew_id.h:106
@ ID_MODVIEW_NEXT
Definition: pcbnew_id.h:105