KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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
38
39std::optional<TOOLBAR_CONFIGURATION> FOOTPRINT_VIEWER_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
40{
42
43 // clang-format off
44 switch( aToolbar )
45 {
48 return std::nullopt;
49
52 .AppendAction( PCB_ACTIONS::nextFootprint );
53
54 config.AppendSeparator()
55 .AppendAction( ACTIONS::zoomRedraw )
56 .AppendAction( ACTIONS::zoomInCenter )
57 .AppendAction( ACTIONS::zoomOutCenter )
58 .AppendAction( ACTIONS::zoomFitScreen )
59 .AppendAction( ACTIONS::zoomTool );
60
61 config.AppendSeparator()
62 .AppendAction( ACTIONS::show3DViewer )
63 .AppendAction( PCB_ACTIONS::saveFpToBoard );
64
65 config.AppendSeparator()
67
68 config.AppendSeparator()
70 .AppendAction( PCB_ACTIONS::fpAutoZoom);
71 break;
72
74 config.AppendAction( ACTIONS::selectionTool )
75 .AppendAction( ACTIONS::measureTool );
76
77 config.AppendSeparator()
78 .AppendAction( ACTIONS::toggleGrid )
79 .AppendAction( ACTIONS::togglePolarCoords )
80 .AppendAction( ACTIONS::inchesUnits )
81 .AppendAction( ACTIONS::milsUnits )
82 .AppendAction( ACTIONS::millimetersUnits )
83 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
86 .AddAction( ACTIONS::cursor45Crosshairs ) );
87
88 config.AppendSeparator()
89 .AppendAction( PCB_ACTIONS::showPadNumbers )
90 .AppendAction( PCB_ACTIONS::padDisplayMode )
91 .AppendAction( PCB_ACTIONS::textOutlines )
92 .AppendAction( PCB_ACTIONS::graphicsOutlines );
93
94 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
96
97 break;
98 }
99
100 // clang-format on
101 return config;
102}
103
104
106{
108
109 // wxWidgets handles the Mac Application menu behind the scenes, but that means
110 // we always have to start from scratch with a new wxMenuBar.
111 wxMenuBar* oldMenuBar = GetMenuBar();
112 WX_MENUBAR* menuBar = new WX_MENUBAR();
113
114
115 //----- File menu -----------------------------------------------------------
116 //
117 ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
118
119 fileMenu->AddClose( _( "Footprint Viewer" ) );
120
121 //----- View menu -----------------------------------------------------------
122 //
123 ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
124
125 viewMenu->AppendSeparator();
126 viewMenu->Add( ACTIONS::zoomInCenter );
127 viewMenu->Add( ACTIONS::zoomOutCenter );
128 viewMenu->Add( ACTIONS::zoomFitScreen );
129 viewMenu->Add( ACTIONS::zoomRedraw );
130
131 viewMenu->AppendSeparator();
132 viewMenu->Add( ACTIONS::show3DViewer );
133
134 //----- Menubar -------------------------------------------------------------
135 //
136 menuBar->Append( fileMenu, _( "&File" ) );
137 menuBar->Append( viewMenu, _( "&View" ) );
138 AddStandardHelpMenu( menuBar );
139
140 SetMenuBar( menuBar );
141 delete oldMenuBar;
142}
static TOOL_ACTION toggleGrid
Definition actions.h:197
static TOOL_ACTION zoomRedraw
Definition actions.h:131
static TOOL_ACTION millimetersUnits
Definition actions.h:205
static TOOL_ACTION show3DViewer
Definition actions.h:257
static TOOL_ACTION cursorSmallCrosshairs
Definition actions.h:151
static TOOL_ACTION zoomOutCenter
Definition actions.h:135
static TOOL_ACTION togglePolarCoords
Definition actions.h:208
static TOOL_ACTION milsUnits
Definition actions.h:204
static TOOL_ACTION toggleBoundingBoxes
Definition actions.h:156
static TOOL_ACTION inchesUnits
Definition actions.h:203
static TOOL_ACTION measureTool
Definition actions.h:251
static TOOL_ACTION selectionTool
Definition actions.h:250
static TOOL_ACTION zoomFitScreen
Definition actions.h:141
static TOOL_ACTION zoomTool
Definition actions.h:145
static TOOL_ACTION cursor45Crosshairs
Definition actions.h:153
static TOOL_ACTION zoomInCenter
Definition actions.h:134
static TOOL_ACTION cursorFullCrosshairs
Definition actions.h:152
Define the structure of a menu based on ACTIONs.
Definition action_menu.h:47
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.
static ACTION_TOOLBAR_CONTROL gridSelect
static ACTION_TOOLBAR_CONTROL zoomSelect
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Add the standard KiCad help menu to the menubar.
std::optional< TOOLBAR_CONFIGURATION > DefaultToolbarConfig(TOOLBAR_LOC aToolbar) override
Get the default tools to show on the specified canvas toolbar.
static TOOL_ACTION nextFootprint
static TOOL_ACTION previousFootprint
static TOOL_ACTION padDisplayMode
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
static TOOL_ACTION fpAutoZoom
static TOOL_ACTION textOutlines
Display texts as lines.
static TOOL_ACTION showPadNumbers
static TOOL_ACTION saveFpToBoard
The selection tool: currently supports:
TOOL_MANAGER * m_toolManager
Wrapper around a wxMenuBar object that prevents the accelerator table from being used.
Definition wx_menubar.h:47
#define _(s)
This file contains miscellaneous commonly used macros and functions.
@ RIGHT
Toolbar on the right side of the canvas.
@ LEFT
Toolbar on the left side of the canvas.
@ TOP_AUX
Toolbar on the top of the canvas.
@ TOP_MAIN
Toolbar on the top of the canvas.