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 (C) 1992-2023 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{
39 // Note:
40 // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
41 // all wxAuiToolBarItems.
42 // However the wxAuiToolBarItems are not the owners of controls managed by
43 // them ( m_zoomSelectBox and m_gridSelectBox ), and therefore do not delete them
44 // So we do not recreate them after clearing the tools.
45
46 if( m_mainToolBar )
47 {
49 }
50 else
51 {
52 m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
53 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT |
54 wxAUI_TB_HORIZONTAL );
56 }
57
58 // Set up toolbar
62
65
69
76
84
89
91 m_mainToolBar->AddTool( ID_LOAD_FOOTPRINT_FROM_BOARD, wxEmptyString,
92 KiScaledBitmap( BITMAPS::import_brd_file, this ),
93 _( "Load footprint from current board" ) );
94
95 m_mainToolBar->AddTool( ID_ADD_FOOTPRINT_TO_BOARD, wxEmptyString,
96 KiScaledBitmap( BITMAPS::insert_module_board, this ),
97 _( "Insert footprint into current board" ) );
98
100
101 // Grid selection choice box.
102 if( m_gridSelectBox == nullptr )
104 wxDefaultPosition, wxDefaultSize, 0, nullptr );
105
107 m_mainToolBar->AddControl( m_gridSelectBox );
108
110
111 // Zoom selection choice box.
112 if( m_zoomSelectBox == nullptr )
114 wxDefaultPosition, wxDefaultSize, 0, nullptr );
115
117 m_mainToolBar->AddControl( m_zoomSelectBox );
118
120
121 // Layer selection choice box.
122 if( m_selLayerBox == nullptr )
123 {
126
127 // Some layers cannot be select (they are shown in the layer manager
128 // only to set the color and visibility, but not for selection)
129 // Disable them in layer box
132 }
133
134 ReCreateLayerBox( false );
135 m_mainToolBar->AddControl( m_selLayerBox );
136
137 // Go through and ensure the comboboxes are the correct size, since the strings in the
138 // box could have changed widths.
142
143 // after adding the buttons to the toolbar, must call Realize() to reflect the changes
145}
146
147
149{
150 wxWindowUpdateLocker dummy( this );
151
152 if( m_drawToolBar )
153 {
155 }
156 else
157 {
158 m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
159 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
161 }
162
163 // Groups contained on this toolbar
164 static ACTION_GROUP* dimensionGroup = nullptr;
165
166 if( !dimensionGroup )
167 {
168 dimensionGroup = new ACTION_GROUP( "group.pcbDimensions",
174 }
175
176 // clang-format off
178
182
196
201 // clang-format on
202
204
205 auto makeArcMenu = [&]()
206 {
207 std::unique_ptr<ACTION_MENU> arcMenu = std::make_unique<ACTION_MENU>( false, selTool );
208
211
212 return arcMenu;
213 };
214
216
218}
219
220
222{
223 if( m_optionsToolBar )
224 {
226 }
227 else
228 {
229 m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition,
230 wxDefaultSize,
231 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
233 }
234
242
245
251
252 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
254
259
261 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
262 gridMenu->Add( ACTIONS::gridProperties );
263 gridMenu->Add( ACTIONS::gridOrigin );
265
267}
268
269
271{
272 if( m_mainToolBar )
273 {
274 // Update the item widths
278 }
279}
280
281
282void FOOTPRINT_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
283{
284 if( m_selLayerBox == nullptr || m_mainToolBar == nullptr )
285 return;
286
287 m_selLayerBox->SetToolTip( _( "+/- to switch" ) );
289
290 if( aForceResizeToolbar )
292}
293
294
295void FOOTPRINT_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
296{
298}
wxBitmap KiScaledBitmap(BITMAPS aBitmap, wxWindow *aWindow, int aHeight, bool aQuantized)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:147
static TOOL_ACTION gridProperties
Definition: actions.h:179
static TOOL_ACTION toggleGrid
Definition: actions.h:177
static TOOL_ACTION zoomRedraw
Definition: actions.h:116
static TOOL_ACTION millimetersUnits
Definition: actions.h:185
static TOOL_ACTION showLibraryTree
Definition: actions.h:144
static TOOL_ACTION zoomOutCenter
Definition: actions.h:120
static TOOL_ACTION togglePolarCoords
Definition: actions.h:188
static TOOL_ACTION milsUnits
Definition: actions.h:184
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:137
static TOOL_ACTION undo
Definition: actions.h:68
static TOOL_ACTION inchesUnits
Definition: actions.h:183
static TOOL_ACTION highContrastMode
Definition: actions.h:135
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:134
static TOOL_ACTION gridOrigin
Definition: actions.h:180
static TOOL_ACTION measureTool
Definition: actions.h:193
static TOOL_ACTION selectionTool
Definition: actions.h:192
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:126
static TOOL_ACTION redo
Definition: actions.h:69
static TOOL_ACTION deleteTool
Definition: actions.h:78
static TOOL_ACTION zoomTool
Definition: actions.h:129
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION showProperties
Definition: actions.h:206
static TOOL_ACTION zoomInCenter
Definition: actions.h:119
static TOOL_ACTION gridSetOrigin
Definition: actions.h:174
static TOOL_ACTION toggleGridOverrides
Definition: actions.h:178
A group of actions that will be displayed together on a toolbar palette.
static constexpr bool CHECK
Definition: action_menu.h:201
Define the structure of a toolbar with buttons that invoke ACTIONs.
static constexpr bool TOGGLE
static constexpr bool CANCEL
void SetAuiManager(wxAuiManager *aManager)
Set the AUI manager that this toolbar belongs to.
void UpdateControlWidth(int aID)
Update the toolbar item width of a control using its best size.
void AddToolContextMenu(const TOOL_ACTION &aAction, std::unique_ptr< ACTION_MENU > aMenu)
Add a context menu to a specific tool item on the toolbar.
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
bool KiRealize()
Use this over Realize() to avoid a rendering glitch with fixed orientation toolbars.
void ClearToolbar()
Clear the toolbar and remove all associated menus.
void AddGroup(ACTION_GROUP *aGroup, bool aIsToggleEntry=false)
Add a set of actions to a toolbar as a group.
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false, bool aIsCancellable=false)
Add a TOOL_ACTION-based button to the toolbar.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
static constexpr int KICAD_AUI_TB_STYLE
< Default style flags used for wxAUI toolbars.
wxAuiManager m_auimgr
wxChoice * m_gridSelectBox
ACTION_TOOLBAR * m_optionsToolBar
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
void UpdateZoomSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
ACTION_TOOLBAR * m_mainToolBar
ACTION_TOOLBAR * m_drawToolBar
wxChoice * m_zoomSelectBox
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...
void OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
void UpdateToolbarControlSizes() override
Update the sizes of any controls in the toolbars of the frame.
void ReCreateHToolbar() override
Create the main horizontal toolbar for the footprint editor.
PCB_LAYER_BOX_SELECTOR * m_selLayerBox
int SetLayerSelection(int layer)
static LSET ForbiddenFootprintLayers()
Layers which are not allowed within footprint definitions.
Definition: lset.cpp:792
static TOOL_ACTION toggleHV45Mode
Definition: pcb_actions.h:520
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:223
static TOOL_ACTION drawBezier
Definition: pcb_actions.h:206
static TOOL_ACTION placeText
Definition: pcb_actions.h:208
static TOOL_ACTION pointEditorArcKeepCenter
Definition: pcb_actions.h:298
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:219
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:203
static TOOL_ACTION setAnchor
Definition: pcb_actions.h:230
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:336
static TOOL_ACTION placeReferenceImage
Definition: pcb_actions.h:207
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:450
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:204
static TOOL_ACTION mirrorH
Mirroring of selected items.
Definition: pcb_actions.h:139
static TOOL_ACTION createFootprint
Definition: pcb_actions.h:462
static TOOL_ACTION drawTable
Definition: pcb_actions.h:210
static TOOL_ACTION drawTextBox
Definition: pcb_actions.h:209
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:202
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:480
static TOOL_ACTION group
Definition: pcb_actions.h:528
static TOOL_ACTION drawRadialDimension
Definition: pcb_actions.h:218
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:220
static TOOL_ACTION newFootprint
Definition: pcb_actions.h:459
static TOOL_ACTION defaultPadProperties
Definition: pcb_actions.h:475
static TOOL_ACTION ungroup
Definition: pcb_actions.h:529
static TOOL_ACTION drawArc
Definition: pcb_actions.h:205
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:492
static TOOL_ACTION pointEditorArcKeepEndpoint
Definition: pcb_actions.h:299
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:217
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:474
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:495
static TOOL_ACTION checkFootprint
Definition: pcb_actions.h:477
static TOOL_ACTION mirrorV
Definition: pcb_actions.h:140
static TOOL_ACTION drawLine
Definition: pcb_actions.h:201
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:132
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:133
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:216
virtual PCB_LAYER_ID GetActiveLayer() const
Class to display a pcb layer list in a wxBitmapComboBox.
void SetBoardFrame(PCB_BASE_FRAME *aFrame)
void SetNotAllowedLayerSet(LSET aMask)
The selection tool: currently supports:
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:167
#define _(s)
@ ID_ON_GRID_SELECT
Definition: id.h:145
@ ID_OPT_TOOLBAR
Definition: id.h:101
@ ID_V_TOOLBAR
Definition: id.h:100
@ ID_ON_ZOOM_SELECT
Definition: id.h:143
@ ID_H_TOOLBAR
Definition: id.h:99
@ ID_ADD_FOOTPRINT_TO_BOARD
Definition: pcbnew_id.h:116
@ ID_LOAD_FOOTPRINT_FROM_BOARD
Definition: pcbnew_id.h:117
@ ID_TOOLBARH_PCB_SELECT_LAYER
Definition: pcbnew_id.h:96
std::vector< FAB_LAYER_COLOR > dummy