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 <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
193
198
200
201 auto makeArcMenu = [&]()
202 {
203 std::unique_ptr<ACTION_MENU> arcMenu = std::make_unique<ACTION_MENU>( false, selTool );
204
207
208 return arcMenu;
209 };
210
212
214}
215
216
218{
219 if( m_optionsToolBar )
220 {
222 }
223 else
224 {
225 m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition,
226 wxDefaultSize,
227 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
229 }
230
238
241
247
248 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
250
255
257 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
258 gridMenu->Add( ACTIONS::gridProperties );
259 gridMenu->Add( ACTIONS::gridOrigin );
261
263}
264
265
267{
268 if( m_mainToolBar )
269 {
270 // Update the item widths
274 }
275}
276
277
278void FOOTPRINT_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
279{
280 if( m_selLayerBox == nullptr || m_mainToolBar == nullptr )
281 return;
282
283 m_selLayerBox->SetToolTip( _( "+/- to switch" ) );
285
286 if( aForceResizeToolbar )
288}
289
290
291void FOOTPRINT_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
292{
294}
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:178
static TOOL_ACTION toggleGrid
Definition: actions.h:176
static TOOL_ACTION zoomRedraw
Definition: actions.h:115
static TOOL_ACTION millimetersUnits
Definition: actions.h:184
static TOOL_ACTION showLibraryTree
Definition: actions.h:143
static TOOL_ACTION zoomOutCenter
Definition: actions.h:119
static TOOL_ACTION togglePolarCoords
Definition: actions.h:187
static TOOL_ACTION milsUnits
Definition: actions.h:183
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:136
static TOOL_ACTION undo
Definition: actions.h:67
static TOOL_ACTION inchesUnits
Definition: actions.h:182
static TOOL_ACTION highContrastMode
Definition: actions.h:134
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:133
static TOOL_ACTION gridOrigin
Definition: actions.h:179
static TOOL_ACTION measureTool
Definition: actions.h:192
static TOOL_ACTION selectionTool
Definition: actions.h:191
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:125
static TOOL_ACTION redo
Definition: actions.h:68
static TOOL_ACTION deleteTool
Definition: actions.h:77
static TOOL_ACTION zoomTool
Definition: actions.h:128
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION showProperties
Definition: actions.h:205
static TOOL_ACTION zoomInCenter
Definition: actions.h:118
static TOOL_ACTION gridSetOrigin
Definition: actions.h:173
static TOOL_ACTION toggleGridOverrides
Definition: actions.h:177
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:1005
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