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  if( m_mainToolBar )
41  m_mainToolBar->Clear();
42  else
43  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
44  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
45 
46  wxString msg;
47 
48  // Set up toolbar
49  m_mainToolBar->AddTool( ID_MODEDIT_NEW_MODULE, wxEmptyString,
50  KiScaledBitmap( new_footprint_xpm, this ),
51  _( "New footprint" ) );
52 
53 #ifdef KICAD_SCRIPTING
54  m_mainToolBar->AddTool( ID_MODEDIT_NEW_MODULE_FROM_WIZARD, wxEmptyString,
55  KiScaledBitmap( module_wizard_xpm, this ),
56  _( "New footprint using footprint wizard" ) );
57 #endif
58 
59  m_mainToolBar->AddTool( ID_MODEDIT_SAVE, wxEmptyString,
60  KiScaledBitmap( save_xpm, this ),
61  _( "Save changes" ) );
62 
64  m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString,
65  KiScaledBitmap( print_button_xpm, this ),
66  _( "Print footprint" ) );
67 
69  m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiScaledBitmap( undo_xpm, this ),
70  _( "Undo last edit" ) );
71  m_mainToolBar->AddTool( wxID_REDO, wxEmptyString, KiScaledBitmap( redo_xpm, this ),
72  _( "Redo last undo command" ) );
73 
76  m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiScaledBitmap( zoom_redraw_xpm, this ), msg );
77 
79  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiScaledBitmap( zoom_in_xpm, this ), msg );
80 
82  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiScaledBitmap( zoom_out_xpm, this ), msg );
83 
85  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiScaledBitmap( zoom_fit_in_page_xpm, this ), msg );
86 
87  m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiScaledBitmap( zoom_area_xpm, this ),
88  _( "Zoom to selection" ), wxITEM_CHECK );
89 
91  m_mainToolBar->AddTool( ID_MODEDIT_EDIT_MODULE_PROPERTIES, wxEmptyString,
92  KiScaledBitmap( module_options_xpm, this ),
93  _( "Footprint properties" ) );
94 
95  m_mainToolBar->AddTool( ID_MODEDIT_PAD_SETTINGS, wxEmptyString,
96  KiScaledBitmap( options_pad_xpm, this ),
97  _( "Default pad properties" ) );
98 
100  m_mainToolBar->AddTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString,
101  KiScaledBitmap( load_module_board_xpm, this ),
102  _( "Load footprint from current board" ) );
103 
104  m_mainToolBar->AddTool( ID_MODEDIT_INSERT_MODULE_IN_BOARD, wxEmptyString,
105  KiScaledBitmap( insert_module_board_xpm, this ),
106  _( "Insert footprint into current board" ) );
107 
108 #if 0 // Currently there is no check footprint function defined, so do not show this tool
110  m_mainToolBar->AddTool( ID_MODEDIT_CHECK, wxEmptyString,
111  KiScaledBitmap( module_check_xpm, this ),
112  _( "Check footprint" ) );
113 #endif
114 
116 
117  // Grid selection choice box.
119  wxDefaultPosition, wxDefaultSize, 0, NULL );
121  m_mainToolBar->AddControl( m_gridSelectBox );
122 
124 
125  // Zoom selection choice box.
127  wxDefaultPosition, wxDefaultSize, 0, NULL );
129  m_mainToolBar->AddControl( m_zoomSelectBox );
130 
131  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
132  m_mainToolBar->Realize();
133 }
134 
135 
137 {
138  if( m_drawToolBar )
139  m_drawToolBar->Clear();
140  else
141  m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
142  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
143 
144  // Set up toolbar
145  m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiScaledBitmap( cursor_xpm, this ),
146  wxEmptyString, wxITEM_CHECK );
147 
149  m_drawToolBar->AddTool( ID_MODEDIT_PAD_TOOL, wxEmptyString, KiScaledBitmap( pad_xpm, this ),
150  _( "Add pad" ), wxITEM_CHECK );
151 
153  m_drawToolBar->AddTool( ID_MODEDIT_LINE_TOOL, wxEmptyString, KiScaledBitmap( add_graphical_segments_xpm, this ),
154  _( "Add graphic line" ), wxITEM_CHECK );
155 
156  m_drawToolBar->AddTool( ID_MODEDIT_CIRCLE_TOOL, wxEmptyString, KiScaledBitmap( add_circle_xpm, this ),
157  _( "Add graphic circle" ), wxITEM_CHECK );
158 
159  m_drawToolBar->AddTool( ID_MODEDIT_ARC_TOOL, wxEmptyString, KiScaledBitmap( add_arc_xpm, this ),
160  _( "Add graphic arc" ), wxITEM_CHECK );
161 
162  m_drawToolBar->AddTool( ID_MODEDIT_POLYGON_TOOL, wxEmptyString, KiScaledBitmap( add_graphical_polygon_xpm, this ),
163  _( "Add graphic polygon" ), wxITEM_CHECK );
164 
165  m_drawToolBar->AddTool( ID_MODEDIT_TEXT_TOOL, wxEmptyString, KiScaledBitmap( text_xpm, this ),
166  _( "Add Text" ), wxITEM_CHECK );
167 
169  m_drawToolBar->AddTool( ID_MODEDIT_ANCHOR_TOOL, wxEmptyString, KiScaledBitmap( anchor_xpm, this ),
170  _( "Place footprint reference anchor" ),
171  wxITEM_CHECK );
172 
174  m_drawToolBar->AddTool( ID_MODEDIT_DELETE_TOOL, wxEmptyString, KiScaledBitmap( delete_xpm, this ),
175  _( "Delete item" ), wxITEM_CHECK );
176 
177  m_drawToolBar->AddTool( ID_MODEDIT_PLACE_GRID_COORD, wxEmptyString,
178  KiScaledBitmap( grid_select_axis_xpm, this ),
179  _( "Set grid origin" ),
180  wxITEM_CHECK );
181 
182  m_drawToolBar->AddTool( ID_MODEDIT_MEASUREMENT_TOOL, wxEmptyString,
183  KiScaledBitmap( measurement_xpm, this ),
184  _( "Measure distance" ),
185  wxITEM_CHECK );
186 
187  m_drawToolBar->Realize();
188 }
189 
190 
192 {
193  if( m_optionsToolBar )
194  m_optionsToolBar->Clear();
195  else
196  m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
197  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
198 
199  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString,
200  KiScaledBitmap( grid_xpm, this ),
201  _( "Hide grid" ), wxITEM_CHECK );
202 
203  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
204  KiScaledBitmap( polar_coord_xpm, this ),
205  _( "Display Polar Coord ON" ), wxITEM_CHECK );
206 
207  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
208  KiScaledBitmap( unit_inch_xpm, this ),
209  _( "Set units to inches" ), wxITEM_CHECK );
210 
211  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
212  KiScaledBitmap( unit_mm_xpm, this ),
213  _( "Set units to millimeters" ), wxITEM_CHECK );
214 
215  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
216  KiScaledBitmap( cursor_shape_xpm, this ),
217  _( "Change cursor shape" ), wxITEM_CHECK );
218 
220  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString,
221  KiScaledBitmap( pad_sketch_xpm, this ),
222  _( "Show Pads Sketch" ), wxITEM_CHECK );
223 
225  KiScaledBitmap( text_sketch_xpm, this ),
226  _( "Show Texts Sketch" ), wxITEM_CHECK );
227 
229  KiScaledBitmap( show_mod_edge_xpm, this ),
230  _( "Show Edges Sketch" ), wxITEM_CHECK );
231 
233  KiScaledBitmap( contrast_mode_xpm, this ),
234  _( "Enable high contrast display mode" ),
235  wxITEM_CHECK );
236 
238  m_optionsToolBar->AddTool( ID_MODEDIT_SHOW_HIDE_SEARCH_TREE, wxEmptyString,
239  KiScaledBitmap( search_tree_xpm, this ),
240  _( "Toggles the search tree" ), wxITEM_CHECK );
241 
242  m_optionsToolBar->Realize();
243 }
244 
245 
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:148
Pcbnew hotkeys.
wxAuiToolBar * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:160
EDA_DRAW_FRAME::OnSelectGrid ID_TB_OPTIONS_SELECT_UNIT_INCH
wxChoice * m_zoomSelectBox
Definition: draw_frame.h:149
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:157
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[]