KiCad PCB EDA Suite
tool_modedit.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-2016 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
32 #include <fctsys.h>
33 
34 #include <pcbnew.h>
35 #include <wxPcbStruct.h>
36 #include <module_editor_frame.h>
37 #include <dialog_helpers.h>
38 #include <pcbnew_id.h>
39 #include <hotkeys.h>
40 #include <bitmaps.h>
41 
42 
44 {
45  if( m_mainToolBar != NULL )
46  return;
47 
48  wxString msg;
49 
50  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
51  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
52 
53  // Set up toolbar
54  m_mainToolBar->AddTool( ID_MODEDIT_SELECT_CURRENT_LIB, wxEmptyString,
55  KiBitmap( open_library_xpm ),
56  _( "Select active library" ) );
57 
58  m_mainToolBar->AddTool( ID_MODEDIT_SAVE_LIBMODULE, wxEmptyString, KiBitmap( save_library_xpm ),
59  _( "Save footprint in active library" ) );
60 
62  KiBitmap( new_library_xpm ),
63  _( "Create new library and save current footprint" ) );
64 
65  m_mainToolBar->AddTool( ID_OPEN_MODULE_VIEWER, wxEmptyString, KiBitmap( modview_icon_xpm ),
66  _( "Open footprint viewer" ) );
67 
68  m_mainToolBar->AddSeparator();
69  m_mainToolBar->AddTool( ID_MODEDIT_DELETE_PART, wxEmptyString, KiBitmap( delete_xpm ),
70  _( "Delete part from active library" ) );
71 
72  m_mainToolBar->AddSeparator();
73  m_mainToolBar->AddTool( ID_MODEDIT_NEW_MODULE, wxEmptyString, KiBitmap( new_footprint_xpm ),
74  _( "New footprint" ) );
75 
76 #ifdef KICAD_SCRIPTING
77  m_mainToolBar->AddTool( ID_MODEDIT_NEW_MODULE_FROM_WIZARD, wxEmptyString,
78  KiBitmap( module_wizard_xpm ),
79  _( "New footprint using footprint wizard" ) );
80 #endif
81 
82 
83  m_mainToolBar->AddTool( ID_MODEDIT_LOAD_MODULE, wxEmptyString,
84  KiBitmap( load_module_lib_xpm ),
85  _( "Load footprint from library" ) );
86 
87  m_mainToolBar->AddSeparator();
88  m_mainToolBar->AddTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString,
89  KiBitmap( load_module_board_xpm ),
90  _( "Load footprint from current board" ) );
91 
92  m_mainToolBar->AddTool( ID_MODEDIT_UPDATE_MODULE_IN_BOARD, wxEmptyString,
93  KiBitmap( update_module_board_xpm ),
94  _( "Update footprint into current board" ) );
95 
96  m_mainToolBar->AddTool( ID_MODEDIT_INSERT_MODULE_IN_BOARD, wxEmptyString,
97  KiBitmap( insert_module_board_xpm ),
98  _( "Insert footprint into current board" ) );
99 
100  m_mainToolBar->AddSeparator();
101  m_mainToolBar->AddTool( ID_MODEDIT_IMPORT_PART, wxEmptyString, KiBitmap( import_module_xpm ),
102  _( "Import footprint" ) );
103 
104  m_mainToolBar->AddTool( ID_MODEDIT_EXPORT_PART, wxEmptyString, KiBitmap( export_module_xpm ),
105  _( "Export footprint" ) );
106 
107 
108  m_mainToolBar->AddSeparator();
109  m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiBitmap( undo_xpm ),
110  _( "Undo last edition" ) );
111  m_mainToolBar->AddTool( wxID_REDO, wxEmptyString, KiBitmap( redo_xpm ),
112  _( "Redo last undo command" ) );
113 
114  m_mainToolBar->AddSeparator();
115  m_mainToolBar->AddTool( ID_MODEDIT_EDIT_MODULE_PROPERTIES, wxEmptyString,
116  KiBitmap( module_options_xpm ),
117  _( "Footprint properties" ) );
118 
119  m_mainToolBar->AddSeparator();
120  m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiBitmap( print_button_xpm ),
121  _( "Print footprint" ) );
122 
123  m_mainToolBar->AddSeparator();
124  msg = AddHotkeyName( _( "Redraw view" ), g_Module_Editor_Hokeys_Descr, HK_ZOOM_REDRAW,
125  IS_COMMENT );
126  m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiBitmap( zoom_redraw_xpm ), msg );
127 
129  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiBitmap( zoom_in_xpm ), msg );
130 
132  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiBitmap( zoom_out_xpm ), msg );
133 
135  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ), msg );
136 
137  m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiBitmap( zoom_area_xpm ),
138  _( "Zoom to selection" ), wxITEM_CHECK );
139 
140  m_mainToolBar->AddSeparator();
141  m_mainToolBar->AddTool( ID_MODEDIT_PAD_SETTINGS, wxEmptyString, KiBitmap( options_pad_xpm ),
142  _( "Pad properties" ) );
143 
144 #if 0 // Currently there is no check footprint function defined, so do not show this tool
145  m_mainToolBar->AddSeparator();
146  m_mainToolBar->AddTool( ID_MODEDIT_CHECK, wxEmptyString,
147  KiBitmap( module_check_xpm ),
148  _( "Check footprint" ) );
149 #endif
150 
151  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
152  m_mainToolBar->Realize();
153 }
154 
155 
157 {
158  if( m_drawToolBar )
159  return;
160 
161  m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
162  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
163 
164  // Set up toolbar
165  m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiBitmap( cursor_xpm ),
166  wxEmptyString, wxITEM_CHECK );
167 
168  m_drawToolBar->AddSeparator();
169  m_drawToolBar->AddTool( ID_MODEDIT_PAD_TOOL, wxEmptyString, KiBitmap( pad_xpm ),
170  _( "Add pad" ), wxITEM_CHECK );
171 
172  m_drawToolBar->AddSeparator();
173  m_drawToolBar->AddTool( ID_MODEDIT_LINE_TOOL, wxEmptyString, KiBitmap( add_polygon_xpm ),
174  _( "Add graphic line or polygon" ), wxITEM_CHECK );
175 
176  m_drawToolBar->AddTool( ID_MODEDIT_CIRCLE_TOOL, wxEmptyString, KiBitmap( add_circle_xpm ),
177  _( "Add graphic circle" ), wxITEM_CHECK );
178 
179  m_drawToolBar->AddTool( ID_MODEDIT_ARC_TOOL, wxEmptyString, KiBitmap( add_arc_xpm ),
180  _( "Add graphic arc" ), wxITEM_CHECK );
181 
182  m_drawToolBar->AddTool( ID_MODEDIT_TEXT_TOOL, wxEmptyString, KiBitmap( text_xpm ),
183  _( "Add Text" ), wxITEM_CHECK );
184 
185  m_drawToolBar->AddSeparator();
186  m_drawToolBar->AddTool( ID_MODEDIT_ANCHOR_TOOL, wxEmptyString, KiBitmap( anchor_xpm ),
187  _( "Place footprint reference anchor" ),
188  wxITEM_CHECK );
189 
190  m_drawToolBar->AddSeparator();
191  m_drawToolBar->AddTool( ID_MODEDIT_DELETE_TOOL, wxEmptyString, KiBitmap( delete_xpm ),
192  _( "Delete item" ), wxITEM_CHECK );
193 
194  m_drawToolBar->AddTool( ID_MODEDIT_PLACE_GRID_COORD, wxEmptyString,
195  KiBitmap( grid_select_axis_xpm ),
196  _( "Set grid origin" ),
197  wxITEM_CHECK );
198 
199  m_drawToolBar->AddTool( ID_MODEDIT_MEASUREMENT_TOOL, wxEmptyString,
200  KiBitmap( measurement_xpm ),
201  _( "Measure distance" ),
202  wxITEM_CHECK );
203 
204  m_drawToolBar->Realize();
205 }
206 
207 
209 {
210  if( m_optionsToolBar )
211  return;
212 
213  // Create options tool bar.
214  m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
215  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
216  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, KiBitmap( grid_xpm ),
217  _( "Hide grid" ), wxITEM_CHECK );
218 
219  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
220  KiBitmap( polar_coord_xpm ),
221  _( "Display Polar Coord ON" ), wxITEM_CHECK );
222 
223  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
224  KiBitmap( unit_inch_xpm ),
225  _( "Set units to inches" ), wxITEM_CHECK );
226 
227  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
228  KiBitmap( unit_mm_xpm ),
229  _( "Set units to millimeters" ), wxITEM_CHECK );
230 
231 #ifndef __APPLE__
232  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
233  KiBitmap( cursor_shape_xpm ),
234  _( "Change Cursor Shape" ), wxITEM_CHECK );
235 #endif // !__APPLE__
236 
237  m_optionsToolBar->AddSeparator();
238  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString,
239  KiBitmap( pad_sketch_xpm ),
240  _( "Show Pads Sketch" ), wxITEM_CHECK );
241 
243  KiBitmap( text_sketch_xpm ),
244  _( "Show Texts Sketch" ), wxITEM_CHECK );
245 
247  KiBitmap( show_mod_edge_xpm ),
248  _( "Show Edges Sketch" ), wxITEM_CHECK );
249 
251  KiBitmap( contrast_mode_xpm ),
252  _( "Enable high contrast display mode" ),
253  wxITEM_CHECK );
254 
255  m_optionsToolBar->Realize();
256 }
257 
258 
260 {
261  if( m_auxiliaryToolBar )
262  return;
263 
264  m_auxiliaryToolBar = new wxAuiToolBar( this, ID_AUX_TOOLBAR, wxDefaultPosition, wxDefaultSize,
265  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
266 
267  // Set up toolbar
268  m_auxiliaryToolBar->AddSeparator();
269 
270  // Grid selection choice box.
271  m_gridSelectBox = new wxChoice( m_auxiliaryToolBar,
273  wxDefaultPosition, wxDefaultSize,
274  0, NULL );
275  // Update tool bar to reflect setting.
277  m_auxiliaryToolBar->AddControl( m_gridSelectBox );
278 
279  // Zoom selection choice box.
280  m_auxiliaryToolBar->AddSeparator();
281  m_zoomSelectBox = new wxChoice( m_auxiliaryToolBar,
283  wxDefaultPosition, wxDefaultSize,
284  0, NULL );
286  m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
287 
288  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
289  m_auxiliaryToolBar->Realize();
290 }
Definition of class FOOTPRINT_EDIT_FRAME.
void ReCreateHToolbar() override
Function ReCreateHToolbar create the main horizontal toolbar for the footprint editor.
void ReCreateVToolbar() override
void ReCreateAuxiliaryToolbar() override
void updateGridSelectBox()
Definition: id.h:232
wxChoice * m_gridSelectBox
Choice box to choose the grid size.
Definition: draw_frame.h:115
Pcbnew hotkeys.
EDA_DRAW_FRAME::OnSelectGrid ID_TB_OPTIONS_SELECT_UNIT_INCH
Definition: draw_frame.cpp:121
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
wxAuiToolBar * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:125
wxChoice * m_zoomSelectBox
Choice box to choose the zoom value.
Definition: draw_frame.h:118
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:122
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:136
struct EDA_HOTKEY_CONFIG g_Module_Editor_Hokeys_Descr[]
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) ...
static const char * text_xpm[]
void updateZoomSelectBox()
wxAuiToolBar * m_auxiliaryToolBar
Auxiliary tool bar typically shown below the main tool bar at the top of the main window...