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 <tool/actions.h>
24 #include <board.h>
25 #include <footprint_edit_frame.h>
26 #include <dialog_helpers.h>
27 #include <pcbnew_id.h>
28 #include <bitmaps.h>
29 #include <tool/action_toolbar.h>
30 #include <tool/tool_manager.h>
31 #include <tools/pcb_actions.h>
32 #include <tools/selection_tool.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 )
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 | wxAUI_TB_HORIZONTAL);
53  }
54 
55  wxString msg;
56 
57  // Set up toolbar
59 #ifdef KICAD_SCRIPTING
61 #endif
62 
63  if( IsCurrentFPFromBoard() )
65  else
67 
70 
74 
81 
86 
88  m_mainToolBar->AddTool( ID_LOAD_FOOTPRINT_FROM_BOARD, wxEmptyString,
90  _( "Load footprint from current board" ) );
91 
92  m_mainToolBar->AddTool( ID_ADD_FOOTPRINT_TO_BOARD, wxEmptyString,
93  KiScaledBitmap( export_xpm, this ),
94  _( "Insert footprint into current board" ) );
95 
97 
98  // Grid selection choice box.
99  if( m_gridSelectBox == nullptr )
101  wxDefaultPosition, wxDefaultSize, 0, NULL );
102 
104  m_mainToolBar->AddControl( m_gridSelectBox );
105 
107 
108  // Zoom selection choice box.
109  if( m_zoomSelectBox == nullptr )
111  wxDefaultPosition, wxDefaultSize, 0, NULL );
112 
114  m_mainToolBar->AddControl( m_zoomSelectBox );
115 
117 
118  // Layer selection choice box.
119  if( m_selLayerBox == nullptr )
120  {
122  m_selLayerBox->SetBoardFrame( this );
123 
124  // Some layers cannot be seclect (they are shown in the layer manager
125  // only to set the color and visibility, but not for selection)
126  // Disable them in layer box
129  }
130 
131  ReCreateLayerBox( false );
132  m_mainToolBar->AddControl( m_selLayerBox );
133 
134  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
136 }
137 
138 
140 {
141  if( m_drawToolBar )
142  {
144  }
145  else
146  {
147  m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
148  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
150  }
151 
153 
164 
169 
171 }
172 
173 
175 {
176  if( m_optionsToolBar )
177  {
179  }
180  else
181  {
182  m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
183  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
185  }
186 
193 
199 
202 
204  std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
205  gridMenu->Add( ACTIONS::gridProperties );
206  m_optionsToolBar->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
207 
209 }
210 
211 
212 void FOOTPRINT_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
213 {
214  if( m_selLayerBox == NULL || m_mainToolBar == NULL )
215  return;
216 
217  m_selLayerBox->SetToolTip( _( "+/- to switch" ) );
219 
220  if( aForceResizeToolbar )
221  {
222  // the layer box can have its size changed
223  // Update the aui manager, to take in account the new size
224  m_auimgr.Update();
225  }
226 }
227 
228 
229 void FOOTPRINT_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
230 {
232 }
static TOOL_ACTION drawLine
Definition: pcb_actions.h:145
static TOOL_ACTION saveToBoard
Definition: pcb_actions.h:357
ACTION_TOOLBAR.
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:368
void ReCreateHToolbar() override
Create the main horizontal toolbar for the footprint editor.
static TOOL_ACTION zoomInCenter
Definition: actions.h:91
static LSET ForbiddenFootprintLayers()
Layers which are not allowed within footprint definitions.
Definition: lset.cpp:881
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:371
static TOOL_ACTION drawArc
Definition: pcb_actions.h:149
ACTION_TOOLBAR * m_optionsToolBar
void SetNotAllowedLayerSet(LSET aMask)
static constexpr bool TOGGLE
static TOOL_ACTION zoomTool
Definition: actions.h:97
SELECTION_TOOL.
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)
Adds a TOOL_ACTION-based button to the toolbar.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
static TOOL_ACTION millimetersUnits
Definition: actions.h:144
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:146
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:374
void SetAuiManager(wxAuiManager *aManager)
Set the AUI manager that this toolbar belongs to.
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:163
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, wxWindow *aWindow)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:118
wxChoice * m_gridSelectBox
static TOOL_ACTION placeText
Definition: pcb_actions.h:150
bool KiRealize()
Use this over Realize() to avoid a rendering glitch with fixed orientation toolbars.
static TOOL_ACTION zoomOutCenter
Definition: actions.h:92
static TOOL_ACTION createFootprint
Definition: pcb_actions.h:353
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:152
const BITMAP_OPAQUE load_module_board_xpm[1]
static constexpr bool CANCEL
static TOOL_ACTION toggleFootprintTree
Definition: pcb_actions.h:346
#define NULL
static TOOL_ACTION toggleGrid
Definition: actions.h:138
static TOOL_ACTION inchesUnits
Definition: actions.h:142
wxChoice * m_zoomSelectBox
const BITMAP_OPAQUE export_xpm[1]
Definition: export.cpp:71
static TOOL_ACTION togglePolarCoords
Definition: actions.h:147
Helper dialog and control classes.
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:147
int SetLayerSelection(LAYER_NUM layer)
PCB_LAYER_BOX_SELECTOR * m_selLayerBox
static TOOL_ACTION milsUnits
Definition: actions.h:143
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:241
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:148
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:386
static TOOL_ACTION saveToLibrary
Definition: pcb_actions.h:358
static TOOL_ACTION redo
Definition: actions.h:68
static TOOL_ACTION defaultPadProperties
Definition: pcb_actions.h:369
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:48
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:157
#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
static TOOL_ACTION gridProperties
Definition: actions.h:139
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:151
static TOOL_ACTION newFootprint
Definition: pcb_actions.h:350
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:389
void ClearToolbar()
Clear the toolbar and remove all associated menus.
ACTION_TOOLBAR * m_drawToolBar