KiCad PCB EDA Suite
Loading...
Searching...
No Matches
toolbars_footprint_editor.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) 2015 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#include <tool/actions.h>
24#include <tool/action_menu.h>
26#include <pcbnew_id.h>
27#include <bitmaps.h>
28#include <lset.h>
29#include <tool/action_toolbar.h>
30#include <tool/tool_manager.h>
32#include <tools/pcb_actions.h>
35#include <wx/choice.h>
36#include <wx/wupdlock.h>
37#include <advanced_config.h>
38
40
41std::optional<TOOLBAR_CONFIGURATION> FOOTPRINT_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
42{
44
45 // clang-format off
46 switch( aToolbar )
47 {
48 // No Aux toolbar
50 return std::nullopt;
51
53 config.AppendAction( ACTIONS::toggleGrid )
54 .WithContextMenu(
55 []( TOOL_MANAGER* aToolMgr )
56 {
57 PCB_SELECTION_TOOL* selTool = aToolMgr->GetTool<PCB_SELECTION_TOOL>();
58 auto menu = std::make_unique<ACTION_MENU>( false, selTool );
59 menu->Add( ACTIONS::gridProperties );
60 menu->Add( ACTIONS::gridOrigin );
61 return menu;
62 } )
63 .AppendAction( ACTIONS::toggleGridOverrides )
64 .AppendAction( PCB_ACTIONS::togglePolarCoords )
65 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
66 .AddAction( ACTIONS::millimetersUnits )
67 .AddAction( ACTIONS::inchesUnits )
68 .AddAction( ACTIONS::milsUnits ) )
69 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
72 .AddAction( ACTIONS::cursor45Crosshairs ) );
73
74 config.AppendSeparator()
75 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Line modes" ) )
76 .AddAction( PCB_ACTIONS::lineModeFree )
77 .AddAction( PCB_ACTIONS::lineMode90 )
78 .AddAction( PCB_ACTIONS::lineMode45 ) );
79
80 config.AppendSeparator()
81 .AppendAction( PCB_ACTIONS::padDisplayMode )
82 .AppendAction( PCB_ACTIONS::graphicsOutlines )
83 .AppendAction( PCB_ACTIONS::textOutlines )
84 .AppendAction( ACTIONS::highContrastMode );
85
86 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
88
89 config.AppendSeparator()
90 .AppendAction( ACTIONS::showLibraryTree )
91 .AppendAction( PCB_ACTIONS::showLayersManager )
92 .AppendAction( ACTIONS::showProperties );
93 break;
94
96 config.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Selection modes" ) )
97 .AddAction( ACTIONS::selectSetRect )
98 .AddAction( ACTIONS::selectSetLasso ) );
99
100 config.AppendSeparator()
101 .AppendAction( PCB_ACTIONS::placePad )
102 .AppendAction( PCB_ACTIONS::drawRuleArea );
103
104 config.AppendSeparator()
105 .AppendAction( PCB_ACTIONS::drawLine )
106 .AppendAction( PCB_ACTIONS::drawArc )
107 .WithContextMenu(
108 []( TOOL_MANAGER* aToolMgr )
109 {
110 PCB_SELECTION_TOOL* selTool = aToolMgr->GetTool<PCB_SELECTION_TOOL>();
111 auto menu = std::make_unique<ACTION_MENU>( false, selTool );
115 return menu;
116 } )
117 .AppendAction( PCB_ACTIONS::drawRectangle )
118 .AppendAction( PCB_ACTIONS::drawCircle )
119 .AppendAction( PCB_ACTIONS::drawPolygon )
120 .AppendAction( PCB_ACTIONS::drawBezier )
121 .AppendAction( PCB_ACTIONS::placeReferenceImage )
122 .AppendAction( PCB_ACTIONS::placeText )
123 .AppendAction( PCB_ACTIONS::drawTextBox )
124 .AppendAction( PCB_ACTIONS::drawTable )
125 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Dimension objects" ) )
130 .AddAction( PCB_ACTIONS::drawLeader ) )
131 .AppendAction( ACTIONS::deleteTool );
132
133 config.AppendSeparator()
134 .AppendAction( PCB_ACTIONS::placePoint )
135 .AppendAction( PCB_ACTIONS::setAnchor )
136 .AppendAction( ACTIONS::gridSetOrigin )
137 .AppendAction( ACTIONS::measureTool );
138 break;
139
141 config.AppendAction( PCB_ACTIONS::newFootprint )
142 .AppendAction( PCB_ACTIONS::createFootprint )
143 .AppendAction( ACTIONS::save );
144
145 config.AppendSeparator()
146 .AppendAction( ACTIONS::print );
147
148 config.AppendSeparator()
149 .AppendAction( ACTIONS::undo )
150 .AppendAction( ACTIONS::redo );
151
152 config.AppendSeparator()
153 .AppendAction( ACTIONS::zoomRedraw )
154 .AppendAction( ACTIONS::zoomInCenter )
155 .AppendAction( ACTIONS::zoomOutCenter )
156 .AppendAction( ACTIONS::zoomFitScreen )
157 .AppendAction( ACTIONS::zoomTool );
158
159 config.AppendSeparator()
160 .AppendAction( PCB_ACTIONS::rotateCcw )
161 .AppendAction( PCB_ACTIONS::rotateCw )
162 .AppendAction( PCB_ACTIONS::mirrorV )
163 .AppendAction( PCB_ACTIONS::mirrorH )
164 .AppendAction( ACTIONS::group )
165 .AppendAction( ACTIONS::ungroup );
166
167 config.AppendSeparator()
168 .AppendAction( PCB_ACTIONS::footprintProperties )
169 .AppendAction( PCB_ACTIONS::padTable )
170 .AppendAction( PCB_ACTIONS::defaultPadProperties )
171 .AppendAction( ACTIONS::showDatasheet )
172 .AppendAction( PCB_ACTIONS::checkFootprint );
173
174 config.AppendSeparator()
175 .AppendAction( PCB_ACTIONS::loadFpFromBoard )
176 .AppendAction( PCB_ACTIONS::saveFpToBoard );
177
178 config.AppendSeparator()
179 .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect );
180
181 config.AppendSeparator()
182 .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect );
183
184 config.AppendSeparator()
186 break;
187 }
188
189 // clang-format on
190 return config;
191}
192
193
194void FOOTPRINT_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
195{
196 if( !m_SelLayerBox )
197 return;
198
199 m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
200 m_SelLayerBox->Resync();
201
202 if( aForceResizeToolbar )
204}
static TOOL_ACTION gridProperties
Definition actions.h:200
static TOOL_ACTION toggleGrid
Definition actions.h:198
static TOOL_ACTION zoomRedraw
Definition actions.h:132
static TOOL_ACTION millimetersUnits
Definition actions.h:206
static TOOL_ACTION showLibraryTree
Definition actions.h:164
static TOOL_ACTION cursorSmallCrosshairs
Definition actions.h:152
static TOOL_ACTION zoomOutCenter
Definition actions.h:136
static TOOL_ACTION togglePolarCoords
Definition actions.h:209
static TOOL_ACTION selectSetLasso
Definition actions.h:221
static TOOL_ACTION selectSetRect
Set lasso selection mode.
Definition actions.h:220
static TOOL_ACTION group
Definition actions.h:239
static TOOL_ACTION showDatasheet
Definition actions.h:267
static TOOL_ACTION pointEditorArcKeepCenter
Definition actions.h:273
static TOOL_ACTION milsUnits
Definition actions.h:205
static TOOL_ACTION ungroup
Definition actions.h:240
static TOOL_ACTION toggleBoundingBoxes
Definition actions.h:157
static TOOL_ACTION pointEditorArcKeepRadius
Definition actions.h:275
static TOOL_ACTION undo
Definition actions.h:75
static TOOL_ACTION inchesUnits
Definition actions.h:204
static TOOL_ACTION highContrastMode
Definition actions.h:155
static TOOL_ACTION gridOrigin
Definition actions.h:201
static TOOL_ACTION measureTool
Definition actions.h:252
static TOOL_ACTION save
Definition actions.h:58
static TOOL_ACTION zoomFitScreen
Definition actions.h:142
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION deleteTool
Definition actions.h:86
static TOOL_ACTION zoomTool
Definition actions.h:146
static TOOL_ACTION cursor45Crosshairs
Definition actions.h:154
static TOOL_ACTION print
Definition actions.h:64
static TOOL_ACTION showProperties
Definition actions.h:266
static TOOL_ACTION zoomInCenter
Definition actions.h:135
static TOOL_ACTION gridSetOrigin
Definition actions.h:195
static TOOL_ACTION toggleGridOverrides
Definition actions.h:199
static TOOL_ACTION pointEditorArcKeepEndpoint
Definition actions.h:274
static TOOL_ACTION cursorFullCrosshairs
Definition actions.h:153
static constexpr bool CHECK
static ACTION_TOOLBAR_CONTROL gridSelect
static ACTION_TOOLBAR_CONTROL layerSelector
static ACTION_TOOLBAR_CONTROL zoomSelect
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
virtual void UpdateToolbarControlSizes()
Update the sizes of any controls in the toolbars of the frame.
void ReCreateLayerBox(bool aForceResizeToolbar=true)
Re create the layer Box by clearing the old list, and building a new one from the new layers names an...
std::optional< TOOLBAR_CONFIGURATION > DefaultToolbarConfig(TOOLBAR_LOC aToolbar) override
Get the default tools to show on the specified canvas toolbar.
static TOOL_ACTION lineModeFree
Unconstrained angle mode (icon lines_any)
static TOOL_ACTION drawRuleArea
static TOOL_ACTION drawBezier
static TOOL_ACTION placeText
static TOOL_ACTION drawOrthogonalDimension
static TOOL_ACTION drawRectangle
static TOOL_ACTION setAnchor
static TOOL_ACTION padDisplayMode
static TOOL_ACTION placeReferenceImage
static TOOL_ACTION showLayersManager
static TOOL_ACTION drawCircle
static TOOL_ACTION mirrorH
Mirroring of selected items.
static TOOL_ACTION createFootprint
static TOOL_ACTION drawTable
static TOOL_ACTION drawTextBox
static TOOL_ACTION drawPolygon
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
static TOOL_ACTION drawRadialDimension
static TOOL_ACTION padTable
static TOOL_ACTION drawLeader
static TOOL_ACTION lineMode45
45-degree-or-orthogonal mode (icon hv45mode)
static TOOL_ACTION newFootprint
static TOOL_ACTION defaultPadProperties
static TOOL_ACTION drawArc
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
static TOOL_ACTION loadFpFromBoard
static TOOL_ACTION drawCenterDimension
static TOOL_ACTION footprintProperties
static TOOL_ACTION lineMode90
90-degree-only mode (icon lines90)
static TOOL_ACTION textOutlines
Display texts as lines.
static TOOL_ACTION checkFootprint
static TOOL_ACTION placePoint
static TOOL_ACTION mirrorV
static TOOL_ACTION saveFpToBoard
static TOOL_ACTION drawLine
static TOOL_ACTION rotateCw
Rotation of selected objects.
static TOOL_ACTION rotateCcw
static TOOL_ACTION drawAlignedDimension
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
The selection tool: currently supports:
Master controller class:
#define _(s)
@ 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.