KiCad PCB EDA Suite
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 <dick@softplc.com>
6  * Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
7  * Copyright (C) 1992-2021 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>
24 #include <footprint_edit_frame.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>
31 #include <pcb_layer_box_selector.h>
32 #include <wx/choice.h>
33 
34 
36 {
37  // Note:
38  // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
39  // all wxAuiToolBarItems.
40  // However the wxAuiToolBarItems are not the owners of controls managed by
41  // them ( m_zoomSelectBox and m_gridSelectBox ), and therefore do not delete them
42  // So we do not recreate them after clearing the tools.
43 
44  if( m_mainToolBar )
45  {
47  }
48  else
49  {
50  m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
51  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT |
52  wxAUI_TB_HORIZONTAL );
54  }
55 
56  wxString msg;
57 
58  // Set up toolbar
62 
65 
69 
76 
83 
88 
90  m_mainToolBar->AddTool( ID_LOAD_FOOTPRINT_FROM_BOARD, wxEmptyString,
92  _( "Load footprint from current board" ) );
93 
94  m_mainToolBar->AddTool( ID_ADD_FOOTPRINT_TO_BOARD, wxEmptyString,
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  {
124  m_selLayerBox->SetBoardFrame( this );
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  if( m_drawToolBar )
150  {
152  }
153  else
154  {
155  m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
156  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
158  }
159 
161 
172 
177 
179 }
180 
181 
183 {
184  if( m_optionsToolBar )
185  {
187  }
188  else
189  {
190  m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition,
191  wxDefaultSize,
192  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
194  }
195 
202 
208 
211 
213  std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
214  gridMenu->Add( ACTIONS::gridProperties );
215  m_optionsToolBar->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
216 
218 }
219 
220 
222 {
223  if( m_mainToolBar )
224  {
225  // Update the item widths
229  }
230 }
231 
232 
233 void FOOTPRINT_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
234 {
235  if( m_selLayerBox == nullptr || m_mainToolBar == nullptr )
236  return;
237 
238  m_selLayerBox->SetToolTip( _( "+/- to switch" ) );
240 
241  if( aForceResizeToolbar )
243 }
244 
245 
246 void FOOTPRINT_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
247 {
249 }
static TOOL_ACTION drawLine
Definition: pcb_actions.h:142
Define the structure of a toolbar with buttons that invoke ACTIONs.
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:373
void ReCreateHToolbar() override
Create the main horizontal toolbar for the footprint editor.
static TOOL_ACTION zoomInCenter
Definition: actions.h:93
static LSET ForbiddenFootprintLayers()
Layers which are not allowed within footprint definitions.
Definition: lset.cpp:888
void AddToolContextMenu(const TOOL_ACTION &aAction, std::unique_ptr< ACTION_MENU > aMenu)
Add a context menu to a specific tool item on the toolbar.
static TOOL_ACTION checkFootprint
Definition: pcb_actions.h:376
static TOOL_ACTION drawArc
Definition: pcb_actions.h:146
ACTION_TOOLBAR * m_optionsToolBar
void SetNotAllowedLayerSet(LSET aMask)
static constexpr bool TOGGLE
static TOOL_ACTION zoomTool
Definition: actions.h:99
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false, bool aIsCancellable=false)
Add a TOOL_ACTION-based button to the toolbar.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
static TOOL_ACTION millimetersUnits
Definition: actions.h:146
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:143
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:379
void SetAuiManager(wxAuiManager *aManager)
Set the AUI manager that this toolbar belongs to.
static TOOL_ACTION mirror
Mirroring of selected items.
Definition: pcb_actions.h:108
void UpdateZoomSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
static TOOL_ACTION group
Definition: pcb_actions.h:426
Class to display a pcb layer list in a wxBitmapComboBox.
wxAuiManager m_auimgr
void SetBoardFrame(PCB_BASE_FRAME *aFrame)
ACTION_TOOLBAR * m_mainToolBar
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION ungroup
Definition: pcb_actions.h:427
static TOOL_ACTION setAnchor
Definition: pcb_actions.h:162
wxChoice * m_gridSelectBox
static TOOL_ACTION placeText
Definition: pcb_actions.h:147
bool KiRealize()
Use this over Realize() to avoid a rendering glitch with fixed orientation toolbars.
static TOOL_ACTION zoomOutCenter
Definition: actions.h:94
static TOOL_ACTION createFootprint
Definition: pcb_actions.h:358
virtual PCB_LAYER_ID GetActiveLayer() const
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
static TOOL_ACTION measureTool
Definition: actions.h:154
static constexpr bool CANCEL
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:101
static TOOL_ACTION toggleGrid
Definition: actions.h:140
static TOOL_ACTION inchesUnits
Definition: actions.h:144
static TOOL_ACTION save
Definition: actions.h:51
wxChoice * m_zoomSelectBox
void UpdateControlWidth(int aID)
Update the toolbar item width of a control using its best size.
static TOOL_ACTION togglePolarCoords
Definition: actions.h:149
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:144
void UpdateToolbarControlSizes() override
Update the sizes of any controls in the toolbars of the frame.
#define _(s)
int SetLayerSelection(LAYER_NUM layer)
PCB_LAYER_BOX_SELECTOR * m_selLayerBox
static TOOL_ACTION milsUnits
Definition: actions.h:145
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:148
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:241
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:102
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:145
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:391
static TOOL_ACTION redo
Definition: actions.h:65
static TOOL_ACTION defaultPadProperties
Definition: pcb_actions.h:374
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:154
static TOOL_ACTION showFootprintTree
Definition: pcb_actions.h:350
static TOOL_ACTION zoomRedraw
Definition: actions.h:90
The selection tool: currently supports:
static constexpr int KICAD_AUI_TB_STYLE
< Default style flags used for wxAUI toolbars.
static TOOL_ACTION gridProperties
Definition: actions.h:141
static TOOL_ACTION deleteTool
Definition: actions.h:73
static TOOL_ACTION undo
Definition: actions.h:64
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:102
static TOOL_ACTION gridSetOrigin
Definition: actions.h:137
static TOOL_ACTION highContrastMode
Definition: actions.h:103
void OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
static TOOL_ACTION selectionTool
Definition: actions.h:153
static TOOL_ACTION newFootprint
Definition: pcb_actions.h:355
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...
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:394
void ClearToolbar()
Clear the toolbar and remove all associated menus.
ACTION_TOOLBAR * m_drawToolBar