KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 <dick@softplc.com>
6 * Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
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 {
46 case TOOLBAR_LOC::RIGHT:
47 case TOOLBAR_LOC::TOP_AUX:
48 return std::nullopt;
49
50 case TOOLBAR_LOC::TOP_MAIN:
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
73 case TOOLBAR_LOC::LEFT:
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 .AppendAction( ACTIONS::toggleCursorStyle );
84
85 config.AppendSeparator()
86 .AppendAction( PCB_ACTIONS::showPadNumbers )
87 .AppendAction( PCB_ACTIONS::padDisplayMode )
88 .AppendAction( PCB_ACTIONS::textOutlines )
89 .AppendAction( PCB_ACTIONS::graphicsOutlines );
90
91 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
93
94 break;
95 }
96
97 // clang-format on
98 return config;
99}
100
101
103{
105
106 // wxWidgets handles the Mac Application menu behind the scenes, but that means
107 // we always have to start from scratch with a new wxMenuBar.
108 wxMenuBar* oldMenuBar = GetMenuBar();
109 WX_MENUBAR* menuBar = new WX_MENUBAR();
110
111
112 //----- File menu -----------------------------------------------------------
113 //
114 ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
115
116 fileMenu->AddClose( _( "Footprint Viewer" ) );
117
118 //----- View menu -----------------------------------------------------------
119 //
120 ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
121
122 viewMenu->AppendSeparator();
123 viewMenu->Add( ACTIONS::zoomInCenter );
124 viewMenu->Add( ACTIONS::zoomOutCenter );
125 viewMenu->Add( ACTIONS::zoomFitScreen );
126 viewMenu->Add( ACTIONS::zoomRedraw );
127
128 viewMenu->AppendSeparator();
129 viewMenu->Add( ACTIONS::show3DViewer );
130
131 //----- Menubar -------------------------------------------------------------
132 //
133 menuBar->Append( fileMenu, _( "&File" ) );
134 menuBar->Append( viewMenu, _( "&View" ) );
135 AddStandardHelpMenu( menuBar );
136
137 SetMenuBar( menuBar );
138 delete oldMenuBar;
139}
static TOOL_ACTION toggleGrid
Definition: actions.h:191
static TOOL_ACTION zoomRedraw
Definition: actions.h:124
static TOOL_ACTION millimetersUnits
Definition: actions.h:199
static TOOL_ACTION show3DViewer
Definition: actions.h:213
static TOOL_ACTION zoomOutCenter
Definition: actions.h:128
static TOOL_ACTION togglePolarCoords
Definition: actions.h:202
static TOOL_ACTION milsUnits
Definition: actions.h:198
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:147
static TOOL_ACTION inchesUnits
Definition: actions.h:197
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:144
static TOOL_ACTION measureTool
Definition: actions.h:207
static TOOL_ACTION selectionTool
Definition: actions.h:206
static TOOL_ACTION zoomFitScreen
Definition: actions.h:134
static TOOL_ACTION zoomTool
Definition: actions.h:138
static TOOL_ACTION zoomInCenter
Definition: actions.h:127
Define 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.
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 SetMenuBar(wxMenuBar *menu_bar) override
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
Definition: pcb_actions.h:501
static TOOL_ACTION previousFootprint
Definition: pcb_actions.h:500
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:341
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:516
static TOOL_ACTION fpAutoZoom
Definition: pcb_actions.h:349
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:519
static TOOL_ACTION showPadNumbers
Definition: pcb_actions.h:348
static TOOL_ACTION saveFpToBoard
Definition: pcb_actions.h:498
The selection tool: currently supports:
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)
This file contains miscellaneous commonly used macros and functions.