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-2022 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 <tool/action_toolbar.h>
28#include <tool/tool_manager.h>
29#include <tools/pcb_actions.h>
32#include <wx/choice.h>
33#include <wx/wupdlock.h>
34#include <advanced_config.h>
35
37{
38 // Note:
39 // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
40 // all wxAuiToolBarItems.
41 // However the wxAuiToolBarItems are not the owners of controls managed by
42 // them ( m_zoomSelectBox and m_gridSelectBox ), and therefore do not delete them
43 // So we do not recreate them after clearing the tools.
44
45 if( m_mainToolBar )
46 {
48 }
49 else
50 {
51 m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
52 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT |
53 wxAUI_TB_HORIZONTAL );
55 }
56
57 // Set up toolbar
61
64
68
75
83
88
90 m_mainToolBar->AddTool( ID_LOAD_FOOTPRINT_FROM_BOARD, wxEmptyString,
91 KiScaledBitmap( BITMAPS::import_brd_file, this ),
92 _( "Load footprint from current board" ) );
93
94 m_mainToolBar->AddTool( ID_ADD_FOOTPRINT_TO_BOARD, wxEmptyString,
95 KiScaledBitmap( BITMAPS::insert_module_board, this ),
96 _( "Insert footprint into current board" ) );
97
99
100 // Grid selection choice box.
101 if( m_gridSelectBox == nullptr )
103 wxDefaultPosition, wxDefaultSize, 0, nullptr );
104
106 m_mainToolBar->AddControl( m_gridSelectBox );
107
109
110 // Zoom selection choice box.
111 if( m_zoomSelectBox == nullptr )
113 wxDefaultPosition, wxDefaultSize, 0, nullptr );
114
116 m_mainToolBar->AddControl( m_zoomSelectBox );
117
119
120 // Layer selection choice box.
121 if( m_selLayerBox == nullptr )
122 {
125
126 // Some layers cannot be select (they are shown in the layer manager
127 // only to set the color and visibility, but not for selection)
128 // Disable them in layer box
131 }
132
133 ReCreateLayerBox( false );
134 m_mainToolBar->AddControl( m_selLayerBox );
135
136 // Go through and ensure the comboboxes are the correct size, since the strings in the
137 // box could have changed widths.
141
142 // after adding the buttons to the toolbar, must call Realize() to reflect the changes
144}
145
146
148{
149 wxWindowUpdateLocker dummy( this );
150
151 if( m_drawToolBar )
152 {
154 }
155 else
156 {
157 m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
158 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
160 }
161
162 // Groups contained on this toolbar
163 static ACTION_GROUP* dimensionGroup = nullptr;
164
165 if( !dimensionGroup )
166 {
167 dimensionGroup = new ACTION_GROUP( "group.pcbDimensions",
173 }
174
176
180
192
197
199
200 auto makeArcMenu = [&]()
201 {
202 std::unique_ptr<ACTION_MENU> arcMenu = std::make_unique<ACTION_MENU>( false, selTool );
203
206
207 return arcMenu;
208 };
209
211
213}
214
215
217{
218 if( m_optionsToolBar )
219 {
221 }
222 else
223 {
224 m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition,
225 wxDefaultSize,
226 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
228 }
229
236
239
245
246 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
248
253
255 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
256 gridMenu->Add( ACTIONS::gridProperties );
258
260}
261
262
264{
265 if( m_mainToolBar )
266 {
267 // Update the item widths
271 }
272}
273
274
275void FOOTPRINT_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
276{
277 if( m_selLayerBox == nullptr || m_mainToolBar == nullptr )
278 return;
279
280 m_selLayerBox->SetToolTip( _( "+/- to switch" ) );
282
283 if( aForceResizeToolbar )
285}
286
287
288void FOOTPRINT_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
289{
291}
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:157
static TOOL_ACTION gridProperties
Definition: actions.h:145
static TOOL_ACTION toggleGrid
Definition: actions.h:144
static TOOL_ACTION zoomRedraw
Definition: actions.h:93
static TOOL_ACTION millimetersUnits
Definition: actions.h:150
static TOOL_ACTION zoomOutCenter
Definition: actions.h:97
static TOOL_ACTION togglePolarCoords
Definition: actions.h:153
static TOOL_ACTION milsUnits
Definition: actions.h:149
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:108
static TOOL_ACTION undo
Definition: actions.h:65
static TOOL_ACTION inchesUnits
Definition: actions.h:148
static TOOL_ACTION highContrastMode
Definition: actions.h:106
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:105
static TOOL_ACTION measureTool
Definition: actions.h:158
static TOOL_ACTION selectionTool
Definition: actions.h:157
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION redo
Definition: actions.h:66
static TOOL_ACTION deleteTool
Definition: actions.h:74
static TOOL_ACTION zoomTool
Definition: actions.h:102
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION zoomInCenter
Definition: actions.h:96
static TOOL_ACTION gridSetOrigin
Definition: actions.h:141
A group of actions that will be displayed together on a toolbar palette.
static constexpr bool CHECK
Definition: action_menu.h:189
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:915
static TOOL_ACTION toggleHV45Mode
Definition: pcb_actions.h:467
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:185
static TOOL_ACTION placeText
Definition: pcb_actions.h:176
static TOOL_ACTION pointEditorArcKeepCenter
Definition: pcb_actions.h:248
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:181
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:172
static TOOL_ACTION setAnchor
Definition: pcb_actions.h:192
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:280
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:390
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:173
static TOOL_ACTION mirrorH
Mirroring of selected items.
Definition: pcb_actions.h:129
static TOOL_ACTION placeImage
Definition: pcb_actions.h:175
static TOOL_ACTION createFootprint
Definition: pcb_actions.h:404
static TOOL_ACTION showFootprintTree
Definition: pcb_actions.h:396
static TOOL_ACTION drawTextBox
Definition: pcb_actions.h:177
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:171
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:427
static TOOL_ACTION group
Definition: pcb_actions.h:475
static TOOL_ACTION drawRadialDimension
Definition: pcb_actions.h:180
static TOOL_ACTION showProperties
Definition: pcb_actions.h:391
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:182
static TOOL_ACTION newFootprint
Definition: pcb_actions.h:401
static TOOL_ACTION defaultPadProperties
Definition: pcb_actions.h:422
static TOOL_ACTION ungroup
Definition: pcb_actions.h:476
static TOOL_ACTION drawArc
Definition: pcb_actions.h:174
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:439
static TOOL_ACTION pointEditorArcKeepEndpoint
Definition: pcb_actions.h:249
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:179
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:421
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:442
static TOOL_ACTION checkFootprint
Definition: pcb_actions.h:424
static TOOL_ACTION mirrorV
Definition: pcb_actions.h:130
static TOOL_ACTION drawLine
Definition: pcb_actions.h:170
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:122
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:123
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:178
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:170
#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