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
20 * along with this program. If not, see <https://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 ) )
80
81 config.AppendSeparator()
82 .AppendAction( PCB_ACTIONS::padDisplayMode )
83 .AppendAction( PCB_ACTIONS::graphicsOutlines )
84 .AppendAction( PCB_ACTIONS::textOutlines )
85 .AppendAction( ACTIONS::highContrastMode );
86
87 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
89
90 config.AppendSeparator()
91 .AppendAction( ACTIONS::showLibraryTree )
92 .AppendAction( PCB_ACTIONS::showLayersManager )
93 .AppendAction( ACTIONS::showProperties );
94 break;
95
97 config.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Selection modes" ) )
98 .AddAction( ACTIONS::selectSetRect )
99 .AddAction( ACTIONS::selectSetLasso ) );
100
101 config.AppendSeparator()
102 .AppendAction( PCB_ACTIONS::placePad )
103 .AppendAction( PCB_ACTIONS::drawRuleArea );
104
105 config.AppendSeparator()
106 .AppendAction( PCB_ACTIONS::drawLine )
107 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Arc" ) )
108 .AddAction( PCB_ACTIONS::drawArc )
109 .AddAction( PCB_ACTIONS::drawEllipseArc )
110 .AddContextMenu(
111 []( TOOL_MANAGER* aToolMgr )
112 {
113 PCB_SELECTION_TOOL* selTool = aToolMgr->GetTool<PCB_SELECTION_TOOL>();
114 auto menu = std::make_unique<ACTION_MENU>( false, selTool );
118 return menu;
119 } ) )
120 .AppendAction( PCB_ACTIONS::drawRectangle )
121 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Circle" ) )
122 .AddAction( PCB_ACTIONS::drawCircle )
123 .AddAction( PCB_ACTIONS::drawEllipse ) )
124 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Constraints" ) )
143 .AppendAction( PCB_ACTIONS::drawPolygon )
144 .AppendAction( PCB_ACTIONS::drawBezier )
145 .AppendAction( PCB_ACTIONS::placeReferenceImage )
146 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Text objects" ) )
147 .AddAction( PCB_ACTIONS::placeText )
148 .AddAction( PCB_ACTIONS::drawTextBox ) )
149 .AppendAction( PCB_ACTIONS::drawTable )
150 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Dimension objects" ) )
155 .AddAction( PCB_ACTIONS::drawLeader ) )
156 .AppendAction( PCB_ACTIONS::placeBarcode )
157 .AppendAction( ACTIONS::deleteTool );
158
159 config.AppendSeparator()
160 .AppendAction( PCB_ACTIONS::placePoint )
161 .AppendAction( PCB_ACTIONS::setAnchor )
162 .AppendAction( ACTIONS::gridSetOrigin )
163 .AppendAction( ACTIONS::measureTool );
164 break;
165
167 config.AppendAction( PCB_ACTIONS::newFootprint )
168 .AppendAction( PCB_ACTIONS::createFootprint )
169 .AppendAction( ACTIONS::save );
170
171 config.AppendSeparator()
172 .AppendAction( ACTIONS::print );
173
174 config.AppendSeparator()
175 .AppendAction( ACTIONS::undo )
176 .AppendAction( ACTIONS::redo );
177
178 config.AppendSeparator()
179 .AppendAction( ACTIONS::zoomRedraw )
180 .AppendAction( ACTIONS::zoomInCenter )
181 .AppendAction( ACTIONS::zoomOutCenter )
182 .AppendAction( ACTIONS::zoomFitScreen )
183 .AppendAction( ACTIONS::zoomTool );
184
185 config.AppendSeparator()
186 .AppendAction( PCB_ACTIONS::rotateCcw )
187 .AppendAction( PCB_ACTIONS::rotateCw )
188 .AppendAction( PCB_ACTIONS::mirrorV )
189 .AppendAction( PCB_ACTIONS::mirrorH )
190 .AppendAction( ACTIONS::group )
191 .AppendAction( ACTIONS::ungroup );
192
193 config.AppendSeparator()
194 .AppendAction( PCB_ACTIONS::footprintProperties )
195 .AppendAction( PCB_ACTIONS::padTable )
196 .AppendAction( PCB_ACTIONS::defaultPadProperties )
197 .AppendAction( ACTIONS::showDatasheet )
198 .AppendAction( PCB_ACTIONS::checkFootprint );
199
200 config.AppendSeparator()
201 .AppendAction( PCB_ACTIONS::loadFpFromBoard )
202 .AppendAction( PCB_ACTIONS::saveFpToBoard );
203
204 config.AppendSeparator()
205 .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect );
206
207 config.AppendSeparator()
208 .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect );
209
210 config.AppendSeparator()
212 break;
213 }
214
215 // clang-format on
216 return config;
217}
218
219
220void FOOTPRINT_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
221{
222 if( !m_SelLayerBox )
223 return;
224
225 m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
226 m_SelLayerBox->Resync();
227
228 if( aForceResizeToolbar )
230}
static TOOL_ACTION gridProperties
Definition actions.h:196
static TOOL_ACTION toggleGrid
Definition actions.h:194
static TOOL_ACTION zoomRedraw
Definition actions.h:128
static TOOL_ACTION millimetersUnits
Definition actions.h:202
static TOOL_ACTION showLibraryTree
Definition actions.h:160
static TOOL_ACTION cursorSmallCrosshairs
Definition actions.h:148
static TOOL_ACTION zoomOutCenter
Definition actions.h:132
static TOOL_ACTION togglePolarCoords
Definition actions.h:205
static TOOL_ACTION selectSetLasso
Definition actions.h:217
static TOOL_ACTION selectSetRect
Set lasso selection mode.
Definition actions.h:216
static TOOL_ACTION group
Definition actions.h:235
static TOOL_ACTION showDatasheet
Definition actions.h:263
static TOOL_ACTION pointEditorArcKeepCenter
Definition actions.h:271
static TOOL_ACTION milsUnits
Definition actions.h:201
static TOOL_ACTION ungroup
Definition actions.h:236
static TOOL_ACTION toggleBoundingBoxes
Definition actions.h:153
static TOOL_ACTION pointEditorArcKeepRadius
Definition actions.h:273
static TOOL_ACTION undo
Definition actions.h:71
static TOOL_ACTION inchesUnits
Definition actions.h:200
static TOOL_ACTION highContrastMode
Definition actions.h:151
static TOOL_ACTION gridOrigin
Definition actions.h:197
static TOOL_ACTION measureTool
Definition actions.h:248
static TOOL_ACTION save
Definition actions.h:54
static TOOL_ACTION zoomFitScreen
Definition actions.h:138
static TOOL_ACTION redo
Definition actions.h:72
static TOOL_ACTION deleteTool
Definition actions.h:82
static TOOL_ACTION zoomTool
Definition actions.h:142
static TOOL_ACTION cursor45Crosshairs
Definition actions.h:150
static TOOL_ACTION print
Definition actions.h:60
static TOOL_ACTION showProperties
Definition actions.h:262
static TOOL_ACTION zoomInCenter
Definition actions.h:131
static TOOL_ACTION gridSetOrigin
Definition actions.h:191
static TOOL_ACTION toggleGridOverrides
Definition actions.h:195
static TOOL_ACTION pointEditorArcKeepEndpoint
Definition actions.h:272
static TOOL_ACTION cursorFullCrosshairs
Definition actions.h:149
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 addConstraintVertical
static TOOL_ACTION drawCircle
static TOOL_ACTION mirrorH
Mirroring of selected items.
static TOOL_ACTION createFootprint
static TOOL_ACTION drawEllipseArc
static TOOL_ACTION drawTable
static TOOL_ACTION drawTextBox
static TOOL_ACTION addConstraintPerpendicular
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 addConstraintAngular
static TOOL_ACTION lineMode45
45-degree-or-orthogonal mode (icon hv45mode)
static TOOL_ACTION addConstraintArcAngle
static TOOL_ACTION newFootprint
static TOOL_ACTION defaultPadProperties
static TOOL_ACTION addConstraintHorizontal
static TOOL_ACTION drawEllipse
static TOOL_ACTION addConstraintCollinear
static TOOL_ACTION drawArc
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
static TOOL_ACTION addConstraintEqualRadius
static TOOL_ACTION addConstraintTangent
static TOOL_ACTION loadFpFromBoard
static TOOL_ACTION drawCenterDimension
static TOOL_ACTION addConstraintFixedLength
static TOOL_ACTION footprintProperties
static TOOL_ACTION lineMode90
90-degree-only mode (icon lines90)
static TOOL_ACTION toggleAutoConstraints
Toggle authoring constraints automatically while drawing.
static TOOL_ACTION textOutlines
Display texts as lines.
static TOOL_ACTION checkFootprint
static TOOL_ACTION placeBarcode
static TOOL_ACTION placePoint
static TOOL_ACTION addConstraintSymmetric
static TOOL_ACTION addConstraintFixedPosition
Ground a point, and the cluster holding it.
static TOOL_ACTION mirrorV
static TOOL_ACTION addConstraintPointOnLine
static TOOL_ACTION saveFpToBoard
static TOOL_ACTION addConstraintCoincident
static TOOL_ACTION drawLine
static TOOL_ACTION rotateCw
Rotation of selected objects.
static TOOL_ACTION rotateCcw
static TOOL_ACTION addConstraintParallel
static TOOL_ACTION drawAlignedDimension
static TOOL_ACTION addConstraintFixedRadius
static TOOL_ACTION addConstraintEqualLength
static TOOL_ACTION addConstraintMidpoint
static TOOL_ACTION addConstraintConcentric
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.