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
47 case TOOLBAR_LOC::TOP_AUX:
48 return std::nullopt;
49
50 case TOOLBAR_LOC::LEFT:
51 config.AppendAction( ACTIONS::toggleGrid )
52 .AppendAction( ACTIONS::toggleGridOverrides )
53 .AppendAction( PCB_ACTIONS::togglePolarCoords )
54 .AppendAction( ACTIONS::inchesUnits )
55 .AppendAction( ACTIONS::milsUnits )
56 .AppendAction( ACTIONS::millimetersUnits )
57 .AppendAction( ACTIONS::toggleCursorStyle );
58
59 config.AppendSeparator()
60 .AppendAction( PCB_ACTIONS::toggleHV45Mode );
61
62 config.AppendSeparator()
63 .AppendAction( PCB_ACTIONS::padDisplayMode )
64 .AppendAction( PCB_ACTIONS::graphicsOutlines )
65 .AppendAction( PCB_ACTIONS::textOutlines )
66 .AppendAction( ACTIONS::highContrastMode );
67
68 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
70
71 config.AppendSeparator()
72 .AppendAction( ACTIONS::showLibraryTree )
73 .AppendAction( PCB_ACTIONS::showLayersManager )
74 .AppendAction( ACTIONS::showProperties );
75
76 /* TODO (ISM): Implement context menus
77 PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
78 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
79 gridMenu->Add( ACTIONS::gridProperties );
80 gridMenu->Add( ACTIONS::gridOrigin );
81 m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
82 */
83 break;
84
85 case TOOLBAR_LOC::RIGHT:
86 config.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Selection modes" ) )
87 .AddAction( ACTIONS::selectSetRect )
88 .AddAction( ACTIONS::selectSetLasso ) );
89
90 config.AppendSeparator()
91 .AppendAction( PCB_ACTIONS::placePad )
92 .AppendAction( PCB_ACTIONS::drawRuleArea );
93
94 config.AppendSeparator()
95 .AppendAction( PCB_ACTIONS::drawLine )
96 .AppendAction( PCB_ACTIONS::drawArc )
97 .AppendAction( PCB_ACTIONS::drawRectangle )
98 .AppendAction( PCB_ACTIONS::drawCircle )
99 .AppendAction( PCB_ACTIONS::drawPolygon )
100 .AppendAction( PCB_ACTIONS::drawBezier )
101 .AppendAction( PCB_ACTIONS::placeReferenceImage )
102 .AppendAction( PCB_ACTIONS::placeText )
103 .AppendAction( PCB_ACTIONS::drawTextBox )
104 .AppendAction( PCB_ACTIONS::drawTable )
105 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Dimension objects" ) )
110 .AddAction( PCB_ACTIONS::drawLeader ) )
111 .AppendAction( ACTIONS::deleteTool );
112
113 config.AppendSeparator()
114 .AppendAction( PCB_ACTIONS::setAnchor )
115 .AppendAction( ACTIONS::gridSetOrigin )
116 .AppendAction( ACTIONS::measureTool );
117
118 /* TODO (ISM): Implement context menus
119 PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
120
121 auto makeArcMenu = [&]()
122 {
123 std::unique_ptr<ACTION_MENU> arcMenu = std::make_unique<ACTION_MENU>( false, selTool );
124
125 arcMenu->Add( ACTIONS::pointEditorArcKeepCenter, ACTION_MENU::CHECK );
126 arcMenu->Add( ACTIONS::pointEditorArcKeepEndpoint, ACTION_MENU::CHECK );
127 arcMenu->Add( ACTIONS::pointEditorArcKeepRadius, ACTION_MENU::CHECK );
128
129 return arcMenu;
130 };
131
132 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawArc, makeArcMenu() );
133 */
134 break;
135
136 case TOOLBAR_LOC::TOP_MAIN:
137 config.AppendAction( PCB_ACTIONS::newFootprint )
138 .AppendAction( PCB_ACTIONS::createFootprint )
139 .AppendAction( ACTIONS::save );
140
141 config.AppendSeparator()
142 .AppendAction( ACTIONS::print );
143
144 config.AppendSeparator()
145 .AppendAction( ACTIONS::undo )
146 .AppendAction( ACTIONS::redo );
147
148 config.AppendSeparator()
149 .AppendAction( ACTIONS::zoomRedraw )
150 .AppendAction( ACTIONS::zoomInCenter )
151 .AppendAction( ACTIONS::zoomOutCenter )
152 .AppendAction( ACTIONS::zoomFitScreen )
153 .AppendAction( ACTIONS::zoomTool );
154
155 config.AppendSeparator()
156 .AppendAction( PCB_ACTIONS::rotateCcw )
157 .AppendAction( PCB_ACTIONS::rotateCw )
158 .AppendAction( PCB_ACTIONS::mirrorH )
159 .AppendAction( PCB_ACTIONS::mirrorV )
160 .AppendAction( ACTIONS::group )
161 .AppendAction( ACTIONS::ungroup );
162
163 config.AppendSeparator()
164 .AppendAction( PCB_ACTIONS::footprintProperties )
165 .AppendAction( PCB_ACTIONS::defaultPadProperties )
166 .AppendAction( ACTIONS::showDatasheet )
167 .AppendAction( PCB_ACTIONS::checkFootprint );
168
169 config.AppendSeparator()
170 .AppendAction( PCB_ACTIONS::loadFpFromBoard )
171 .AppendAction( PCB_ACTIONS::saveFpToBoard );
172
173 config.AppendSeparator()
174 .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect );
175
176 config.AppendSeparator()
177 .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect );
178
179 config.AppendSeparator()
181 break;
182 }
183
184 // clang-format on
185 return config;
186}
187
188
189void FOOTPRINT_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
190{
191 if( !m_SelLayerBox )
192 return;
193
194 m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
196
197 if( aForceResizeToolbar )
199}
static TOOL_ACTION toggleGrid
Definition: actions.h:195
static TOOL_ACTION zoomRedraw
Definition: actions.h:131
static TOOL_ACTION millimetersUnits
Definition: actions.h:203
static TOOL_ACTION showLibraryTree
Definition: actions.h:161
static TOOL_ACTION zoomOutCenter
Definition: actions.h:135
static TOOL_ACTION togglePolarCoords
Definition: actions.h:206
static TOOL_ACTION selectSetLasso
Definition: actions.h:218
static TOOL_ACTION selectSetRect
Set lasso selection mode.
Definition: actions.h:217
static TOOL_ACTION group
Definition: actions.h:236
static TOOL_ACTION showDatasheet
Definition: actions.h:264
static TOOL_ACTION milsUnits
Definition: actions.h:202
static TOOL_ACTION ungroup
Definition: actions.h:237
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:154
static TOOL_ACTION undo
Definition: actions.h:75
static TOOL_ACTION inchesUnits
Definition: actions.h:201
static TOOL_ACTION highContrastMode
Definition: actions.h:152
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:151
static TOOL_ACTION measureTool
Definition: actions.h:249
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 print
Definition: actions.h:64
static TOOL_ACTION showProperties
Definition: actions.h:263
static TOOL_ACTION zoomInCenter
Definition: actions.h:134
static TOOL_ACTION gridSetOrigin
Definition: actions.h:192
static TOOL_ACTION toggleGridOverrides
Definition: actions.h:196
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 toggleHV45Mode
Definition: pcb_actions.h:539
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:211
static TOOL_ACTION drawBezier
Definition: pcb_actions.h:194
static TOOL_ACTION placeText
Definition: pcb_actions.h:196
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:207
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:191
static TOOL_ACTION setAnchor
Definition: pcb_actions.h:218
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:319
static TOOL_ACTION placeReferenceImage
Definition: pcb_actions.h:195
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:451
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:192
static TOOL_ACTION mirrorH
Mirroring of selected items.
Definition: pcb_actions.h:125
static TOOL_ACTION createFootprint
Definition: pcb_actions.h:475
static TOOL_ACTION drawTable
Definition: pcb_actions.h:198
static TOOL_ACTION drawTextBox
Definition: pcb_actions.h:197
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:190
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:499
static TOOL_ACTION drawRadialDimension
Definition: pcb_actions.h:206
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:208
static TOOL_ACTION newFootprint
Definition: pcb_actions.h:472
static TOOL_ACTION defaultPadProperties
Definition: pcb_actions.h:488
static TOOL_ACTION drawArc
Definition: pcb_actions.h:193
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:511
static TOOL_ACTION loadFpFromBoard
Definition: pcb_actions.h:492
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:205
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:487
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:514
static TOOL_ACTION checkFootprint
Definition: pcb_actions.h:490
static TOOL_ACTION mirrorV
Definition: pcb_actions.h:126
static TOOL_ACTION saveFpToBoard
Definition: pcb_actions.h:493
static TOOL_ACTION drawLine
Definition: pcb_actions.h:189
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:118
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:119
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:204
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
#define _(s)