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 
35 {
36  // Note:
37  // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
38  // all wxAuiToolBarItems.
39  // However the wxAuiToolBarItems are not the owners of controls managed by
40  // them ( m_zoomSelectBox and m_gridSelectBox ), and therefore do not delete them
41  // So we do not recreate them after clearing the tools.
42 
43  if( m_mainToolBar )
44  m_mainToolBar->Clear();
45  else
46  m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
47  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
48 
49  wxString msg;
50 
51  // Set up toolbar
53 #ifdef KICAD_SCRIPTING
55 #endif
56 
57  if( IsCurrentFPFromBoard() )
59  else
61 
64 
68 
69  m_mainToolBar->AddSeparator();
75 
79 
81  m_mainToolBar->AddTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString,
82  KiScaledBitmap( load_module_board_xpm, this ),
83  _( "Load footprint from current board" ) );
84 
85  m_mainToolBar->AddTool( ID_ADD_FOOTPRINT_TO_BOARD, wxEmptyString,
86  KiScaledBitmap( export_xpm, this ),
87  _( "Insert footprint into current board" ) );
88 
89 #if 0 // Currently there is no check footprint function defined, so do not show this tool
91  m_mainToolBar->AddTool( ID_MODEDIT_CHECK, wxEmptyString,
92  KiScaledBitmap( module_check_xpm, this ),
93  _( "Check footprint" ) );
94 #endif
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 
116  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
117  m_mainToolBar->Realize();
118 }
119 
120 
122 {
123  if( m_drawToolBar )
124  m_drawToolBar->Clear();
125  else
126  m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
127  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
128 
130 
139 
144 
145  m_drawToolBar->Realize();
146 }
147 
148 
150 {
151  if( m_optionsToolBar )
152  m_optionsToolBar->Clear();
153  else
154  m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
155  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
156 
162 
163  m_optionsToolBar->AddSeparator();
167 
168  m_optionsToolBar->AddSeparator();
170 
171  m_optionsToolBar->Realize();
172 }
173 
174 
176 {
177 #define TOGGLE_TOOL( toolbar, tool ) toolbar->Toggle( tool, IsCurrentTool( tool ) )
178 
180 
181  if( IsCurrentFPFromBoard() )
183  else
185 
186  m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 );
187  m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 );
190  m_mainToolBar->Refresh();
191 
200  m_optionsToolBar->Refresh();
201 
213  m_drawToolBar->Refresh();
214 }
static TOOL_ACTION drawLine
Definition: pcb_actions.h:150
static TOOL_ACTION saveToBoard
Definition: pcb_actions.h:344
Class ACTION_TOOLBAR.
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:355
void ReCreateHToolbar() override
Create the main horizontal toolbar for the footprint editor.
static TOOL_ACTION zoomInCenter
Definition: actions.h:90
void SyncToolbars() override
Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state.
static TOOL_ACTION drawArc
Definition: pcb_actions.h:153
ACTION_TOOLBAR * m_optionsToolBar
static const bool TOGGLE
static TOOL_ACTION zoomTool
Definition: actions.h:95
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false)
Function Add() Adds a TOOL_ACTION-based button to the toolbar.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:151
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:359
ACTION_TOOLBAR * m_mainToolBar
static TOOL_ACTION print
Definition: actions.h:60
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, EDA_BASE_FRAME *aWindow)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:116
static TOOL_ACTION setAnchor
Definition: pcb_actions.h:164
static TOOL_ACTION imperialUnits
Definition: actions.h:136
wxChoice * m_gridSelectBox
static TOOL_ACTION placeText
Definition: pcb_actions.h:154
static TOOL_ACTION zoomOutCenter
Definition: actions.h:91
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
static TOOL_ACTION createFootprint
Definition: pcb_actions.h:340
static TOOL_ACTION measureTool
Definition: actions.h:144
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
static TOOL_ACTION toggleFootprintTree
Definition: pcb_actions.h:333
bool IsGridVisible() const override
static TOOL_ACTION toggleGrid
Definition: actions.h:132
Definition: common.h:134
wxChoice * m_zoomSelectBox
static TOOL_ACTION togglePolarCoords
Definition: actions.h:139
Helper dialog and control classes.
#define TOGGLE_TOOL(toolbar, tool)
#define _(s)
static TOOL_ACTION moduleEdgeOutlines
Display module edges as outlines.
Definition: pcb_actions.h:371
void UpdateGridSelectBox()
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:230
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:152
static TOOL_ACTION saveToLibrary
Definition: pcb_actions.h:345
static TOOL_ACTION metricUnits
Definition: actions.h:137
static TOOL_ACTION redo
Definition: actions.h:68
static TOOL_ACTION defaultPadProperties
Definition: pcb_actions.h:356
bool GetShowPolarCoords() const
For those frames that support polar coordinates.
EDA_UNITS_T GetUserUnits() const
Return the user units currently in use.
static TOOL_ACTION zoomRedraw
Definition: actions.h:87
void Toggle(const TOOL_ACTION &aAction, bool aState)
Applies the default toggle action.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void KiScaledSeparator(wxAuiToolBar *aToolbar, EDA_BASE_FRAME *aWindow)
Add a separator to the given toolbar scaled the same way as KiScaledBitmap.
Definition: bitmap.cpp:167
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
static TOOL_ACTION deleteTool
Definition: actions.h:75
static TOOL_ACTION undo
Definition: actions.h:67
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:98
BOARD * GetBoard() const
static TOOL_ACTION gridSetOrigin
Definition: actions.h:129
void updateZoomSelectBox()
static TOOL_ACTION highContrastMode
Definition: actions.h:99
static TOOL_ACTION selectionTool
Definition: actions.h:143
static TOOL_ACTION newFootprint
Definition: pcb_actions.h:337
ACTION_TOOLBAR * m_drawToolBar