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>
25#include <pcbnew_id.h>
26#include <bitmaps.h>
27#include <lset.h>
28#include <tool/action_toolbar.h>
29#include <tool/tool_manager.h>
30#include <tools/pcb_actions.h>
33#include <wx/choice.h>
34#include <wx/wupdlock.h>
35#include <advanced_config.h>
36
38
39std::optional<TOOLBAR_CONFIGURATION> FOOTPRINT_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
40{
42
43 // clang-format off
44 switch( aToolbar )
45 {
46 // No Aux toolbar
48 return std::nullopt;
49
51 config.AppendAction( ACTIONS::toggleGrid )
52 .AppendAction( ACTIONS::toggleGridOverrides )
53 .AppendAction( PCB_ACTIONS::togglePolarCoords )
54 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
55 .AddAction( ACTIONS::millimetersUnits )
56 .AddAction( ACTIONS::inchesUnits )
57 .AddAction( ACTIONS::milsUnits ) )
58 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
61 .AddAction( ACTIONS::cursor45Crosshairs ) );
62
63 config.AppendSeparator()
64 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Line modes" ) )
65 .AddAction( PCB_ACTIONS::lineModeFree )
66 .AddAction( PCB_ACTIONS::lineMode90 )
67 .AddAction( PCB_ACTIONS::lineMode45 ) );
68
69 config.AppendSeparator()
70 .AppendAction( PCB_ACTIONS::padDisplayMode )
71 .AppendAction( PCB_ACTIONS::graphicsOutlines )
72 .AppendAction( PCB_ACTIONS::textOutlines )
73 .AppendAction( ACTIONS::highContrastMode );
74
75 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
77
78 config.AppendSeparator()
79 .AppendAction( ACTIONS::showLibraryTree )
80 .AppendAction( PCB_ACTIONS::showLayersManager )
81 .AppendAction( ACTIONS::showProperties );
82
83 /* TODO (ISM): Implement context menus
84 PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
85 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
86 gridMenu->Add( ACTIONS::gridProperties );
87 gridMenu->Add( ACTIONS::gridOrigin );
88 m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
89 */
90 break;
91
93 config.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Selection modes" ) )
94 .AddAction( ACTIONS::selectSetRect )
95 .AddAction( ACTIONS::selectSetLasso ) );
96
97 config.AppendSeparator()
98 .AppendAction( PCB_ACTIONS::placePad )
99 .AppendAction( PCB_ACTIONS::drawRuleArea );
100
101 config.AppendSeparator()
102 .AppendAction( PCB_ACTIONS::drawLine )
103 .AppendAction( PCB_ACTIONS::drawArc )
104 .AppendAction( PCB_ACTIONS::drawRectangle )
105 .AppendAction( PCB_ACTIONS::drawCircle )
106 .AppendAction( PCB_ACTIONS::drawPolygon )
107 .AppendAction( PCB_ACTIONS::drawBezier )
108 .AppendAction( PCB_ACTIONS::placeReferenceImage )
109 .AppendAction( PCB_ACTIONS::placeText )
110 .AppendAction( PCB_ACTIONS::drawTextBox )
111 .AppendAction( PCB_ACTIONS::drawTable )
112 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Dimension objects" ) )
117 .AddAction( PCB_ACTIONS::drawLeader ) )
118 .AppendAction( ACTIONS::deleteTool );
119
120 config.AppendSeparator()
121 .AppendAction( PCB_ACTIONS::placePoint )
122 .AppendAction( PCB_ACTIONS::setAnchor )
123 .AppendAction( ACTIONS::gridSetOrigin )
124 .AppendAction( ACTIONS::measureTool );
125
126 /* TODO (ISM): Implement context menus
127 PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
128
129 auto makeArcMenu = [&]()
130 {
131 std::unique_ptr<ACTION_MENU> arcMenu = std::make_unique<ACTION_MENU>( false, selTool );
132
133 arcMenu->Add( ACTIONS::pointEditorArcKeepCenter, ACTION_MENU::CHECK );
134 arcMenu->Add( ACTIONS::pointEditorArcKeepEndpoint, ACTION_MENU::CHECK );
135 arcMenu->Add( ACTIONS::pointEditorArcKeepRadius, ACTION_MENU::CHECK );
136
137 return arcMenu;
138 };
139
140 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawArc, makeArcMenu() );
141 */
142 break;
143
145 config.AppendAction( PCB_ACTIONS::newFootprint )
146 .AppendAction( PCB_ACTIONS::createFootprint )
147 .AppendAction( ACTIONS::save );
148
149 config.AppendSeparator()
150 .AppendAction( ACTIONS::print );
151
152 config.AppendSeparator()
153 .AppendAction( ACTIONS::undo )
154 .AppendAction( ACTIONS::redo );
155
156 config.AppendSeparator()
157 .AppendAction( ACTIONS::zoomRedraw )
158 .AppendAction( ACTIONS::zoomInCenter )
159 .AppendAction( ACTIONS::zoomOutCenter )
160 .AppendAction( ACTIONS::zoomFitScreen )
161 .AppendAction( ACTIONS::zoomTool );
162
163 config.AppendSeparator()
164 .AppendAction( PCB_ACTIONS::rotateCcw )
165 .AppendAction( PCB_ACTIONS::rotateCw )
166 .AppendAction( PCB_ACTIONS::mirrorH )
167 .AppendAction( PCB_ACTIONS::mirrorV )
168 .AppendAction( ACTIONS::group )
169 .AppendAction( ACTIONS::ungroup );
170
171 config.AppendSeparator()
172 .AppendAction( PCB_ACTIONS::footprintProperties )
173 .AppendAction( PCB_ACTIONS::padTable )
174 .AppendAction( PCB_ACTIONS::defaultPadProperties )
175 .AppendAction( ACTIONS::showDatasheet )
176 .AppendAction( PCB_ACTIONS::checkFootprint );
177
178 config.AppendSeparator()
179 .AppendAction( PCB_ACTIONS::loadFpFromBoard )
180 .AppendAction( PCB_ACTIONS::saveFpToBoard );
181
182 config.AppendSeparator()
183 .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect );
184
185 config.AppendSeparator()
186 .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect );
187
188 config.AppendSeparator()
190 break;
191 }
192
193 // clang-format on
194 return config;
195}
196
197
198void FOOTPRINT_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
199{
200 if( !m_SelLayerBox )
201 return;
202
203 m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
204 m_SelLayerBox->Resync();
205
206 if( aForceResizeToolbar )
208}
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 showLibraryTree
Definition actions.h:163
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 selectSetLasso
Definition actions.h:220
static TOOL_ACTION selectSetRect
Set lasso selection mode.
Definition actions.h:219
static TOOL_ACTION group
Definition actions.h:238
static TOOL_ACTION showDatasheet
Definition actions.h:266
static TOOL_ACTION milsUnits
Definition actions.h:204
static TOOL_ACTION ungroup
Definition actions.h:239
static TOOL_ACTION toggleBoundingBoxes
Definition actions.h:156
static TOOL_ACTION undo
Definition actions.h:75
static TOOL_ACTION inchesUnits
Definition actions.h:203
static TOOL_ACTION highContrastMode
Definition actions.h:154
static TOOL_ACTION measureTool
Definition actions.h:251
static TOOL_ACTION save
Definition actions.h:58
static TOOL_ACTION zoomFitScreen
Definition actions.h:141
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION deleteTool
Definition actions.h:86
static TOOL_ACTION zoomTool
Definition actions.h:145
static TOOL_ACTION cursor45Crosshairs
Definition actions.h:153
static TOOL_ACTION print
Definition actions.h:64
static TOOL_ACTION showProperties
Definition actions.h:265
static TOOL_ACTION zoomInCenter
Definition actions.h:134
static TOOL_ACTION gridSetOrigin
Definition actions.h:194
static TOOL_ACTION toggleGridOverrides
Definition actions.h:198
static TOOL_ACTION cursorFullCrosshairs
Definition actions.h:152
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
#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.