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
177
181
194
199
201
202 auto makeArcMenu = [&]()
203 {
204 std::unique_ptr<ACTION_MENU> arcMenu = std::make_unique<ACTION_MENU>( false, selTool );
205
208
209 return arcMenu;
210 };
211
213
215}
216
217
219{
220 if( m_optionsToolBar )
221 {
223 }
224 else
225 {
226 m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition,
227 wxDefaultSize,
228 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
230 }
231
239
242
248
249 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
251
256
258 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
259 gridMenu->Add( ACTIONS::gridProperties );
260 gridMenu->Add( ACTIONS::gridOrigin );
262
264}
265
266
268{
269 if( m_mainToolBar )
270 {
271 // Update the item widths
275 }
276}
277
278
279void FOOTPRINT_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
280{
281 if( m_selLayerBox == nullptr || m_mainToolBar == nullptr )
282 return;
283
284 m_selLayerBox->SetToolTip( _( "+/- to switch" ) );
286
287 if( aForceResizeToolbar )
289}
290
291
292void FOOTPRINT_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
293{
295}
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:858
static TOOL_ACTION toggleHV45Mode
Definition: pcb_actions.h:512
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:218
static TOOL_ACTION placeText
Definition: pcb_actions.h:203
static TOOL_ACTION pointEditorArcKeepCenter
Definition: pcb_actions.h:293
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:214
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:199
static TOOL_ACTION setAnchor
Definition: pcb_actions.h:225
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:330
static TOOL_ACTION placeReferenceImage
Definition: pcb_actions.h:202
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:442
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:200
static TOOL_ACTION mirrorH
Mirroring of selected items.
Definition: pcb_actions.h:139
static TOOL_ACTION createFootprint
Definition: pcb_actions.h:454
static TOOL_ACTION drawTable
Definition: pcb_actions.h:205
static TOOL_ACTION drawTextBox
Definition: pcb_actions.h:204
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:198
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:472
static TOOL_ACTION group
Definition: pcb_actions.h:520
static TOOL_ACTION drawRadialDimension
Definition: pcb_actions.h:213
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:215
static TOOL_ACTION newFootprint
Definition: pcb_actions.h:451
static TOOL_ACTION defaultPadProperties
Definition: pcb_actions.h:467
static TOOL_ACTION ungroup
Definition: pcb_actions.h:521
static TOOL_ACTION drawArc
Definition: pcb_actions.h:201
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:484
static TOOL_ACTION pointEditorArcKeepEndpoint
Definition: pcb_actions.h:294
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:212
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:466
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:487
static TOOL_ACTION checkFootprint
Definition: pcb_actions.h:469
static TOOL_ACTION mirrorV
Definition: pcb_actions.h:140
static TOOL_ACTION drawLine
Definition: pcb_actions.h:197
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:211
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:102
@ ID_V_TOOLBAR
Definition: id.h:101
@ ID_ON_ZOOM_SELECT
Definition: id.h:143
@ ID_H_TOOLBAR
Definition: id.h:100
@ 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