KiCad PCB EDA Suite
tool_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-2018 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 
28 #include <fctsys.h>
29 
30 #include <pcbnew.h>
31 #include <footprint_edit_frame.h>
32 #include <dialog_helpers.h>
33 #include <pcbnew_id.h>
34 #include <hotkeys.h>
35 #include <bitmaps.h>
36 
37 
39 {
40  // Note:
41  // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
42  // all wxAuiToolBarItems.
43  // However the wxAuiToolBarItems are not the owners of controls managed by
44  // them ( m_zoomSelectBox and m_gridSelectBox ), and therefore do not delete them
45  // So we do not recreate them after clearing the tools.
46 
47  if( m_mainToolBar )
48  m_mainToolBar->Clear();
49  else
50  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
51  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
52 
53  wxString msg;
54 
55  // Set up toolbar
56  m_mainToolBar->AddTool( ID_MODEDIT_NEW_MODULE, wxEmptyString,
57  KiScaledBitmap( new_footprint_xpm, this ),
58  _( "New footprint" ) );
59 
60 #ifdef KICAD_SCRIPTING
61  m_mainToolBar->AddTool( ID_MODEDIT_NEW_MODULE_FROM_WIZARD, wxEmptyString,
62  KiScaledBitmap( module_wizard_xpm, this ),
63  _( "New footprint using footprint wizard" ) );
64 #endif
65 
66  m_mainToolBar->AddTool( ID_MODEDIT_SAVE, wxEmptyString,
67  KiScaledBitmap( IsCurrentFPFromBoard() ? save_fp_to_board_xpm : save_xpm,
68  this ),
70  _( "Save changes to board" ) : _( "Save changes to library" ) );
71 
73  m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString,
74  KiScaledBitmap( print_button_xpm, this ),
75  _( "Print footprint" ) );
76 
78  m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiScaledBitmap( undo_xpm, this ),
79  _( "Undo last edit" ) );
80  m_mainToolBar->AddTool( wxID_REDO, wxEmptyString, KiScaledBitmap( redo_xpm, this ),
81  _( "Redo last undo command" ) );
82 
85  m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiScaledBitmap( zoom_redraw_xpm, this ), msg );
86 
88  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiScaledBitmap( zoom_in_xpm, this ), msg );
89 
91  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiScaledBitmap( zoom_out_xpm, this ), msg );
92 
94  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiScaledBitmap( zoom_fit_in_page_xpm, this ), msg );
95 
96  m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiScaledBitmap( zoom_area_xpm, this ),
97  _( "Zoom to selection" ), wxITEM_CHECK );
98 
100  m_mainToolBar->AddTool( ID_MODEDIT_EDIT_MODULE_PROPERTIES, wxEmptyString,
101  KiScaledBitmap( module_options_xpm, this ),
102  _( "Footprint properties" ) );
103 
104  m_mainToolBar->AddTool( ID_MODEDIT_PAD_SETTINGS, wxEmptyString,
105  KiScaledBitmap( options_pad_xpm, this ),
106  _( "Default pad properties" ) );
107 
109  m_mainToolBar->AddTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString,
110  KiScaledBitmap( load_module_board_xpm, this ),
111  _( "Load footprint from current board" ) );
112 
113  m_mainToolBar->AddTool( ID_MODEDIT_INSERT_MODULE_IN_BOARD, wxEmptyString,
114  KiScaledBitmap( insert_module_board_xpm, this ),
115  _( "Insert footprint into current board" ) );
116 
117 #if 0 // Currently there is no check footprint function defined, so do not show this tool
119  m_mainToolBar->AddTool( ID_MODEDIT_CHECK, wxEmptyString,
120  KiScaledBitmap( module_check_xpm, this ),
121  _( "Check footprint" ) );
122 #endif
123 
125 
126  // Grid selection choice box.
127  if( m_gridSelectBox == nullptr )
129  wxDefaultPosition, wxDefaultSize, 0, NULL );
130 
132  m_mainToolBar->AddControl( m_gridSelectBox );
133 
135 
136  // Zoom selection choice box.
137  if( m_zoomSelectBox == nullptr )
139  wxDefaultPosition, wxDefaultSize, 0, NULL );
140 
142  m_mainToolBar->AddControl( m_zoomSelectBox );
143 
144  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
145  m_mainToolBar->Realize();
146 }
147 
148 
150 {
151  if( m_drawToolBar )
152  m_drawToolBar->Clear();
153  else
154  m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
155  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
156 
157  // Set up toolbar
158  m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiScaledBitmap( cursor_xpm, this ),
159  _( "Select item" ), wxITEM_CHECK );
160 
162  m_drawToolBar->AddTool( ID_MODEDIT_PAD_TOOL, wxEmptyString, KiScaledBitmap( pad_xpm, this ),
163  _( "Add pad" ), wxITEM_CHECK );
164 
166  m_drawToolBar->AddTool( ID_MODEDIT_LINE_TOOL, wxEmptyString, KiScaledBitmap( add_graphical_segments_xpm, this ),
167  _( "Add graphic line" ), wxITEM_CHECK );
168 
169  m_drawToolBar->AddTool( ID_MODEDIT_CIRCLE_TOOL, wxEmptyString, KiScaledBitmap( add_circle_xpm, this ),
170  _( "Add graphic circle" ), wxITEM_CHECK );
171 
172  m_drawToolBar->AddTool( ID_MODEDIT_ARC_TOOL, wxEmptyString, KiScaledBitmap( add_arc_xpm, this ),
173  _( "Add graphic arc" ), wxITEM_CHECK );
174 
175  m_drawToolBar->AddTool( ID_MODEDIT_POLYGON_TOOL, wxEmptyString, KiScaledBitmap( add_graphical_polygon_xpm, this ),
176  _( "Add graphic polygon" ), wxITEM_CHECK );
177 
178  m_drawToolBar->AddTool( ID_MODEDIT_TEXT_TOOL, wxEmptyString, KiScaledBitmap( text_xpm, this ),
179  _( "Add Text" ), wxITEM_CHECK );
180 
182  m_drawToolBar->AddTool( ID_MODEDIT_ANCHOR_TOOL, wxEmptyString, KiScaledBitmap( anchor_xpm, this ),
183  _( "Place footprint reference anchor" ),
184  wxITEM_CHECK );
185 
187  m_drawToolBar->AddTool( ID_MODEDIT_DELETE_TOOL, wxEmptyString, KiScaledBitmap( delete_xpm, this ),
188  _( "Delete item" ), wxITEM_CHECK );
189 
190  m_drawToolBar->AddTool( ID_MODEDIT_PLACE_GRID_COORD, wxEmptyString,
191  KiScaledBitmap( grid_select_axis_xpm, this ),
192  _( "Set grid origin" ),
193  wxITEM_CHECK );
194 
195  m_drawToolBar->AddTool( ID_MODEDIT_MEASUREMENT_TOOL, wxEmptyString,
196  KiScaledBitmap( measurement_xpm, this ),
197  _( "Measure distance" ),
198  wxITEM_CHECK );
199 
200  m_drawToolBar->Realize();
201 }
202 
203 
205 {
206  if( m_optionsToolBar )
207  m_optionsToolBar->Clear();
208  else
209  m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
210  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
211 
212  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString,
213  KiScaledBitmap( grid_xpm, this ),
214  _( "Hide grid" ), wxITEM_CHECK );
215 
216  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
217  KiScaledBitmap( polar_coord_xpm, this ),
218  _( "Display Polar Coord ON" ), wxITEM_CHECK );
219 
220  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
221  KiScaledBitmap( unit_inch_xpm, this ),
222  _( "Set units to inches" ), wxITEM_CHECK );
223 
224  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
225  KiScaledBitmap( unit_mm_xpm, this ),
226  _( "Set units to millimeters" ), wxITEM_CHECK );
227 
228  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
229  KiScaledBitmap( cursor_shape_xpm, this ),
230  _( "Change cursor shape" ), wxITEM_CHECK );
231 
233  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString,
234  KiScaledBitmap( pad_sketch_xpm, this ),
235  _( "Show Pads Sketch" ), wxITEM_CHECK );
236 
238  KiScaledBitmap( text_sketch_xpm, this ),
239  _( "Show Texts Sketch" ), wxITEM_CHECK );
240 
242  KiScaledBitmap( show_mod_edge_xpm, this ),
243  _( "Show Edges Sketch" ), wxITEM_CHECK );
244 
246  KiScaledBitmap( contrast_mode_xpm, this ),
247  _( "Enable high contrast display mode" ),
248  wxITEM_CHECK );
249 
251  m_optionsToolBar->AddTool( ID_MODEDIT_SHOW_HIDE_SEARCH_TREE, wxEmptyString,
252  KiScaledBitmap( search_tree_xpm, this ),
253  _( "Toggles the search tree" ), wxITEM_CHECK );
254 
255  m_optionsToolBar->Realize();
256 }
257 
258 
void ReCreateHToolbar() override
Create the main horizontal toolbar for the footprint editor.
struct EDA_HOTKEY_CONFIG g_Module_Editor_Hotkeys_Descr[]
Definition: id.h:241
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
void ReCreateOptToolbar() override
Definition of class FOOTPRINT_EDIT_FRAME.
wxChoice * m_gridSelectBox
Definition: draw_frame.h:151
Pcbnew hotkeys.
wxAuiToolBar * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:163
EDA_DRAW_FRAME::OnSelectGrid ID_TB_OPTIONS_SELECT_UNIT_INCH
wxChoice * m_zoomSelectBox
Definition: draw_frame.h:152
Helper dialog and control classes.
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:160
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
ID_MODEDIT_MEASUREMENT_TOOL
wxString AddHotkeyName(const wxString &aText, EDA_HOTKEY **aList, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType)
Function AddHotkeyName Add the key name from the Command id value ( m_Idcommand member value)
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[]