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@verizon.net>
7  * Copyright (C) 1992-2019 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 <fctsys.h>
24 #include <tool/actions.h>
25 #include <pcbnew.h>
26 #include <class_board.h>
27 #include <footprint_edit_frame.h>
28 #include <dialog_helpers.h>
29 #include <pcbnew_id.h>
30 #include <bitmaps.h>
31 #include <tool/action_toolbar.h>
32 #include <tools/pcb_actions.h>
33 #include <pcb_layer_box_selector.h>
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 )
46  else
47  m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
48  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
49 
50  wxString msg;
51 
52  // Set up toolbar
54 #ifdef KICAD_SCRIPTING
56 #endif
57 
58  if( IsCurrentFPFromBoard() )
60  else
62 
65 
69 
76 
80 
82  m_mainToolBar->AddTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString,
84  _( "Load footprint from current board" ) );
85 
86  m_mainToolBar->AddTool( ID_ADD_FOOTPRINT_TO_BOARD, wxEmptyString,
87  KiScaledBitmap( export_xpm, this ),
88  _( "Insert footprint into current board" ) );
89 
90 #if 0 // Currently there is no check footprint function defined, so do not show this tool
92  m_mainToolBar->AddTool( ID_MODEDIT_CHECK, wxEmptyString,
94  _( "Check footprint" ) );
95 #endif
96 
98 
99  // Grid selection choice box.
100  if( m_gridSelectBox == nullptr )
102  wxDefaultPosition, wxDefaultSize, 0, NULL );
103 
105  m_mainToolBar->AddControl( m_gridSelectBox );
106 
108 
109  // Zoom selection choice box.
110  if( m_zoomSelectBox == nullptr )
112  wxDefaultPosition, wxDefaultSize, 0, NULL );
113 
115  m_mainToolBar->AddControl( m_zoomSelectBox );
116 
118 
119  // Layer selection choice box.
120  if( m_selLayerBox == nullptr )
121  {
123  m_selLayerBox->SetBoardFrame( this );
124 
125  // Some layers cannot be seclect (they are shown in the layer manager
126  // only to set the color and visibility, but not for selection)
127  // Disable them in layer box
130  }
131 
132  ReCreateLayerBox( false );
133  m_mainToolBar->AddControl( m_selLayerBox );
134 
135  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
136  m_mainToolBar->Realize();
137 }
138 
139 
141 {
142  if( m_drawToolBar )
144  else
145  m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
146  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
147 
149 
160 
165 
166  m_drawToolBar->Realize();
167 }
168 
169 
171 {
172  if( m_optionsToolBar )
174  else
175  m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
176  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
177 
183 
189 
192 
193  m_optionsToolBar->Realize();
194 }
195 
196 
197 void FOOTPRINT_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
198 {
199  if( m_selLayerBox == NULL || m_mainToolBar == NULL )
200  return;
201 
202  m_selLayerBox->SetToolTip( _( "+/- to switch" ) );
204 
205  if( aForceResizeToolbar )
206  {
207  // the layer box can have its size changed
208  // Update the aui manager, to take in account the new size
209  m_auimgr.Update();
210  }
211 }
212 
213 
214 void FOOTPRINT_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
215 {
217 }
static TOOL_ACTION drawLine
Definition: pcb_actions.h:139
static TOOL_ACTION saveToBoard
Definition: pcb_actions.h:345
ACTION_TOOLBAR.
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:356
void ReCreateHToolbar() override
Create the main horizontal toolbar for the footprint editor.
static TOOL_ACTION zoomInCenter
Definition: actions.h:91
static LSET ForbiddenFootprintLayers()
Function ForbiddenFootprintLayers Layers which are not allowed within footprint definitions.
Definition: lset.cpp:832
static TOOL_ACTION drawArc
Definition: pcb_actions.h:143
ACTION_TOOLBAR * m_optionsToolBar
void SetNotAllowedLayerSet(LSET aMask)
static constexpr bool TOGGLE
static TOOL_ACTION zoomTool
Definition: actions.h:97
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
static TOOL_ACTION drawZoneKeepout
Definition: pcb_actions.h:150
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false, bool aIsCancellable=false)
Adds a TOOL_ACTION-based button to the toolbar.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:140
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:360
void UpdateZoomSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
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:60
static TOOL_ACTION setAnchor
Definition: pcb_actions.h:156
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, wxWindow *aWindow)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:116
static TOOL_ACTION imperialUnits
Definition: actions.h:142
wxChoice * m_gridSelectBox
static TOOL_ACTION placeText
Definition: pcb_actions.h:144
static TOOL_ACTION zoomOutCenter
Definition: actions.h:92
static TOOL_ACTION createFootprint
Definition: pcb_actions.h:341
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:150
const BITMAP_OPAQUE load_module_board_xpm[1]
static constexpr bool CANCEL
static TOOL_ACTION toggleFootprintTree
Definition: pcb_actions.h:334
#define NULL
static TOOL_ACTION toggleGrid
Definition: actions.h:138
wxChoice * m_zoomSelectBox
const BITMAP_OPAQUE export_xpm[1]
Definition: export.cpp:75
static TOOL_ACTION togglePolarCoords
Definition: actions.h:145
Helper dialog and control classes.
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:141
int SetLayerSelection(LAYER_NUM layer)
PCB_LAYER_BOX_SELECTOR * m_selLayerBox
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:228
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:142
static TOOL_ACTION graphicsOutlines
Display module edges as outlines.
Definition: pcb_actions.h:372
static TOOL_ACTION saveToLibrary
Definition: pcb_actions.h:346
static TOOL_ACTION metricUnits
Definition: actions.h:143
static TOOL_ACTION redo
Definition: actions.h:68
static TOOL_ACTION defaultPadProperties
Definition: pcb_actions.h:357
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION zoomRedraw
Definition: actions.h:88
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
const BITMAP_OPAQUE module_check_xpm[1]
static TOOL_ACTION deleteTool
Definition: actions.h:76
static TOOL_ACTION undo
Definition: actions.h:67
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:100
static TOOL_ACTION gridSetOrigin
Definition: actions.h:135
static TOOL_ACTION highContrastMode
Definition: actions.h:101
void OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
static TOOL_ACTION selectionTool
Definition: actions.h:149
static TOOL_ACTION newFootprint
Definition: pcb_actions.h:338
void ReCreateLayerBox(bool aForceResizeToolbar=true)
Re create the layer Box by clearing the old list, and building le new one, from the new layers names ...
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:375
void ClearToolbar()
Clear the toolbar and remove all associated menus.
ACTION_TOOLBAR * m_drawToolBar