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 <footprint_edit_frame.h>
27 #include <dialog_helpers.h>
28 #include <pcbnew_id.h>
29 #include <hotkeys.h>
30 #include <bitmaps.h>
31 
32 
34 {
35  // Note:
36  // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
37  // all wxAuiToolBarItems.
38  // However the wxAuiToolBarItems are not the owners of controls managed by
39  // them ( m_zoomSelectBox and m_gridSelectBox ), and therefore do not delete them
40  // So we do not recreate them after clearing the tools.
41 
42  if( m_mainToolBar )
43  m_mainToolBar->Clear();
44  else
45  m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
46  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
47 
48  wxString msg;
49 
50  // Set up toolbar
51  m_mainToolBar->AddTool( ID_MODEDIT_NEW_MODULE, wxEmptyString,
52  KiScaledBitmap( new_footprint_xpm, this ),
53  _( "New footprint" ) );
54 
55 #ifdef KICAD_SCRIPTING
56  m_mainToolBar->AddTool( ID_MODEDIT_NEW_MODULE_FROM_WIZARD, wxEmptyString,
57  KiScaledBitmap( module_wizard_xpm, this ),
58  _( "New footprint using footprint wizard" ) );
59 #endif
60 
61  if( IsCurrentFPFromBoard() )
62  {
63  m_mainToolBar->AddTool( ID_MODEDIT_SAVE, wxEmptyString,
64  KiScaledBitmap( save_fp_to_board_xpm, this ),
65  _( "Update footprint on board" ) );
66  }
67  else
68  {
69  m_mainToolBar->AddTool( ID_MODEDIT_SAVE, wxEmptyString,
70  KiScaledBitmap( save_xpm, this ),
71  _( "Save changes to library" ) );
72  }
73 
75  m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString,
76  KiScaledBitmap( print_button_xpm, this ),
77  _( "Print footprint" ) );
78 
80  m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiScaledBitmap( undo_xpm, this ),
81  _( "Undo last edit" ) );
82  m_mainToolBar->AddTool( wxID_REDO, wxEmptyString, KiScaledBitmap( redo_xpm, this ),
83  _( "Redo last undo command" ) );
84 
85  m_mainToolBar->AddSeparator();
91 
93  m_mainToolBar->AddTool( ID_MODEDIT_EDIT_MODULE_PROPERTIES, wxEmptyString,
94  KiScaledBitmap( module_options_xpm, this ),
95  _( "Footprint properties" ) );
96 
97  m_mainToolBar->AddTool( ID_MODEDIT_PAD_SETTINGS, wxEmptyString,
98  KiScaledBitmap( options_pad_xpm, this ),
99  _( "Default pad properties" ) );
100 
102  m_mainToolBar->AddTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString,
103  KiScaledBitmap( load_module_board_xpm, this ),
104  _( "Load footprint from current board" ) );
105 
106  m_mainToolBar->AddTool( ID_ADD_FOOTPRINT_TO_BOARD, wxEmptyString,
107  KiScaledBitmap( export_xpm, this ),
108  _( "Insert footprint into current board" ) );
109 
110 #if 0 // Currently there is no check footprint function defined, so do not show this tool
112  m_mainToolBar->AddTool( ID_MODEDIT_CHECK, wxEmptyString,
113  KiScaledBitmap( module_check_xpm, this ),
114  _( "Check footprint" ) );
115 #endif
116 
118 
119  // Grid selection choice box.
120  if( m_gridSelectBox == nullptr )
122  wxDefaultPosition, wxDefaultSize, 0, NULL );
123 
125  m_mainToolBar->AddControl( m_gridSelectBox );
126 
128 
129  // Zoom selection choice box.
130  if( m_zoomSelectBox == nullptr )
132  wxDefaultPosition, wxDefaultSize, 0, NULL );
133 
135  m_mainToolBar->AddControl( m_zoomSelectBox );
136 
137  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
138  m_mainToolBar->Realize();
139 }
140 
141 
143 {
144  if( m_drawToolBar )
145  m_drawToolBar->Clear();
146  else
147  m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
148  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
149 
150  // Set up toolbar
151  m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiScaledBitmap( cursor_xpm, this ),
152  _( "Select item" ), wxITEM_CHECK );
153 
155  m_drawToolBar->AddTool( ID_MODEDIT_PAD_TOOL, wxEmptyString, KiScaledBitmap( pad_xpm, this ),
156  _( "Add pad" ), wxITEM_CHECK );
157 
159  m_drawToolBar->AddTool( ID_MODEDIT_LINE_TOOL, wxEmptyString, KiScaledBitmap( add_graphical_segments_xpm, this ),
160  _( "Add graphic line" ), wxITEM_CHECK );
161 
162  m_drawToolBar->AddTool( ID_MODEDIT_CIRCLE_TOOL, wxEmptyString, KiScaledBitmap( add_circle_xpm, this ),
163  _( "Add graphic circle" ), wxITEM_CHECK );
164 
165  m_drawToolBar->AddTool( ID_MODEDIT_ARC_TOOL, wxEmptyString, KiScaledBitmap( add_arc_xpm, this ),
166  _( "Add graphic arc" ), wxITEM_CHECK );
167 
168  m_drawToolBar->AddTool( ID_MODEDIT_POLYGON_TOOL, wxEmptyString, KiScaledBitmap( add_graphical_polygon_xpm, this ),
169  _( "Add graphic polygon" ), wxITEM_CHECK );
170 
171  m_drawToolBar->AddTool( ID_MODEDIT_TEXT_TOOL, wxEmptyString, KiScaledBitmap( text_xpm, this ),
172  _( "Add Text" ), wxITEM_CHECK );
173 
175  m_drawToolBar->AddTool( ID_MODEDIT_ANCHOR_TOOL, wxEmptyString, KiScaledBitmap( anchor_xpm, this ),
176  _( "Place footprint reference anchor" ),
177  wxITEM_CHECK );
178 
180  m_drawToolBar->AddTool( ID_MODEDIT_DELETE_TOOL, wxEmptyString, KiScaledBitmap( delete_xpm, this ),
181  _( "Delete item" ), wxITEM_CHECK );
182 
183  m_drawToolBar->AddTool( ID_MODEDIT_PLACE_GRID_COORD, wxEmptyString,
184  KiScaledBitmap( grid_select_axis_xpm, this ),
185  _( "Set grid origin" ),
186  wxITEM_CHECK );
187 
188  m_drawToolBar->AddTool( ID_MODEDIT_MEASUREMENT_TOOL, wxEmptyString,
189  KiScaledBitmap( measurement_xpm, this ),
190  _( "Measure distance" ),
191  wxITEM_CHECK );
192 
193  m_drawToolBar->Realize();
194 }
195 
196 
198 {
199  if( m_optionsToolBar )
200  m_optionsToolBar->Clear();
201  else
202  m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
203  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
204 
206 
207  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
208  KiScaledBitmap( polar_coord_xpm, this ),
209  _( "Display Polar Coord ON" ), wxITEM_CHECK );
210 
214 
215  m_optionsToolBar->AddSeparator();
216  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString,
217  KiScaledBitmap( pad_sketch_xpm, this ),
218  _( "Show Pads Sketch" ), wxITEM_CHECK );
219 
221  KiScaledBitmap( text_sketch_xpm, this ),
222  _( "Show Texts Sketch" ), wxITEM_CHECK );
223 
225  KiScaledBitmap( show_mod_edge_xpm, this ),
226  _( "Show Edges Sketch" ), wxITEM_CHECK );
227 
229  KiScaledBitmap( contrast_mode_xpm, this ),
230  _( "Enable high contrast display mode" ),
231  wxITEM_CHECK );
232 
234  m_optionsToolBar->AddTool( ID_MODEDIT_SHOW_HIDE_SEARCH_TREE, wxEmptyString,
235  KiScaledBitmap( search_tree_xpm, this ),
236  _( "Toggles the search tree" ), wxITEM_CHECK );
237 
238  m_optionsToolBar->Realize();
239 }
240 
241 
243 {
245 
249 
253 
254  m_optionsToolBar->Refresh();
255 }
Class ACTION_TOOLBAR.
void ReCreateHToolbar() override
Create the main horizontal toolbar for the footprint editor.
static TOOL_ACTION zoomInCenter
Definition: actions.h:60
ACTION_TOOLBAR * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:166
static const bool TOGGLE
static TOOL_ACTION zoomTool
Definition: actions.h:65
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:63
void SyncMenusAndToolbars() override
Update the toolbars and menus (mostly settings/check buttons/checkboxes) with the current controller ...
ACTION_TOOLBAR * m_mainToolBar
Definition: draw_frame.h:156
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 imperialUnits
Definition: actions.h:102
wxChoice * m_gridSelectBox
Definition: draw_frame.h:153
static TOOL_ACTION zoomOutCenter
Definition: actions.h:61
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
Pcbnew hotkeys.
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
virtual bool IsGridVisible() const override
static TOOL_ACTION toggleGrid
Definition: actions.h:98
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:289
Definition: common.h:158
wxChoice * m_zoomSelectBox
Definition: draw_frame.h:154
Helper dialog and control classes.
void UpdateGridSelectBox()
ID_MODEDIT_MEASUREMENT_TOOL
static TOOL_ACTION metricUnits
Definition: actions.h:103
static TOOL_ACTION zoomRedraw
Definition: actions.h:57
void Toggle(const TOOL_ACTION &aAction, bool aState)
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 const char * text_xpm[]
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:68
void updateZoomSelectBox()
ACTION_TOOLBAR * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:163