KiCad PCB EDA Suite
tool_pcb.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) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2012=2015 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 #include <kiface_i.h>
34 #include <help_common_strings.h>
35 #include <dialog_helpers.h>
37 #include <wxPcbStruct.h>
38 #include <class_drawpanel.h>
39 #include <confirm.h>
40 #include <bitmaps.h>
41 
42 #include <class_board.h>
43 
44 #include <pcbnew.h>
45 #include <pcbnew_id.h>
46 #include <hotkeys.h>
48 
49 #include <wx/wupdlock.h>
50 
51 extern bool IsWxPythonLoaded();
52 
53 #define SEL_LAYER_HELP _( \
54  "Show active layer selections\nand select layer pair for route and place via" )
55 
56 
57 /* Data to build the layer pair indicator button */
58 static wxBitmap* LayerPairBitmap = NULL;
59 
60 #define BM_LAYERICON_SIZE 24
62 {
63  // 0 = draw pixel with active layer color
64  // 1 = draw pixel with top layer color (top/bottom layer used inautoroute and place via)
65  // 2 = draw pixel with bottom layer color
66  // 3 = draw pixel with via color
67  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0 },
68  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0 },
69  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0 },
70  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
71  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 },
72  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
73  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 },
74  { 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0 },
75  { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 0, 1, 1, 1, 1, 3, 3, 2, 2, 2, 2, 2, 2, 2 },
76  { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 0, 3, 3, 2, 2, 2, 2, 2, 2, 2 },
77  { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 0, 3, 3, 2, 2, 2, 2, 2, 2, 2 },
78  { 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 1, 1, 1, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0 },
79  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
80  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
81  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
82  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
83  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
84  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
85  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
86  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
87  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
88  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
89 };
90 
91 
93 {
94  int ii, jj;
95  COLOR4D active_layer_color, Route_Layer_TOP_color,
96  Route_Layer_BOTTOM_color, via_color;
97  bool change = false;
98  bool first_call = LayerPairBitmap == NULL;
99 
100  static COLOR4D previous_active_layer_color, previous_Route_Layer_TOP_color,
101  previous_Route_Layer_BOTTOM_color, previous_via_color;
102 
103  /* get colors, and redraw bitmap button only on changes */
104  active_layer_color = Settings().Colors().GetLayerColor(GetActiveLayer());
105 
106  if( previous_active_layer_color != active_layer_color )
107  {
108  previous_active_layer_color = active_layer_color;
109  change = true;
110  }
111 
112  Route_Layer_TOP_color =
113  Settings().Colors().GetLayerColor( GetScreen()->m_Route_Layer_TOP );
114 
115  if( previous_Route_Layer_TOP_color != Route_Layer_TOP_color )
116  {
117  previous_Route_Layer_TOP_color = Route_Layer_TOP_color;
118  change = true;
119  }
120 
121  Route_Layer_BOTTOM_color =
122  Settings().Colors().GetLayerColor( GetScreen()->m_Route_Layer_BOTTOM );
123 
124  if( previous_Route_Layer_BOTTOM_color != Route_Layer_BOTTOM_color )
125  {
126  previous_Route_Layer_BOTTOM_color = Route_Layer_BOTTOM_color;
127  change = true;
128  }
129 
130  int via_type = GetDesignSettings().m_CurrentViaType;
131  via_color = Settings().Colors().GetItemColor( LAYER_VIAS + via_type );
132 
133  if( previous_via_color != via_color )
134  {
135  previous_via_color = via_color;
136  change = true;
137  }
138 
139  if( !change && (LayerPairBitmap != NULL) )
140  return;
141 
142  /* Create the bitmap and its Memory DC, if not already made */
143  if( LayerPairBitmap == NULL )
144  {
145  LayerPairBitmap = new wxBitmap( 24, 24 );
146  }
147 
148  /* Draw the icon, with colors according to the active layer and layer
149  * pairs for via command (change layer)
150  */
151  wxMemoryDC iconDC;
152  iconDC.SelectObject( *LayerPairBitmap );
153  wxPen pen;
154  int buttonColor = -1;
155 
156  for( ii = 0; ii < BM_LAYERICON_SIZE; ii++ )
157  {
158  for( jj = 0; jj < BM_LAYERICON_SIZE; jj++ )
159  {
160  if( s_BitmapLayerIcon[ii][jj] != buttonColor )
161  {
162  switch( s_BitmapLayerIcon[ii][jj] )
163  {
164  default:
165  case 0:
166  pen.SetColour( active_layer_color.ToColour() );
167  break;
168 
169  case 1:
170  pen.SetColour( Route_Layer_TOP_color.ToColour() );
171  break;
172 
173  case 2:
174  pen.SetColour( Route_Layer_BOTTOM_color.ToColour() );
175  break;
176 
177  case 3:
178  pen.SetColour( via_color.ToColour() );
179  break;
180  }
181 
182  buttonColor = s_BitmapLayerIcon[ii][jj];
183  iconDC.SetPen( pen );
184  }
185 
186  iconDC.DrawPoint( jj, ii );
187  }
188  }
189 
190  /* Deselect the Tool Bitmap from DC,
191  * in order to delete the MemoryDC safely without deleting the bitmap */
192  iconDC.SelectObject( wxNullBitmap );
193 
194  if( m_mainToolBar && ! first_call )
195  {
197  m_mainToolBar->Refresh();
198  }
199 }
200 
201 
203 {
204  wxString msg;
205 
206  if( m_mainToolBar )
207  return;
208 
209  wxWindowUpdateLocker dummy( this );
210 
211  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
212  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
213 
214  // Set up toolbar
215  if( Kiface().IsSingle() )
216  {
217  m_mainToolBar->AddTool( ID_NEW_BOARD, wxEmptyString, KiBitmap( new_generic_xpm ),
218  _( "New board" ) );
219  m_mainToolBar->AddTool( ID_LOAD_FILE, wxEmptyString, KiBitmap( open_brd_file_xpm ),
220  _( "Open existing board" ) );
221  }
222 
223  m_mainToolBar->AddTool( ID_SAVE_BOARD, wxEmptyString, KiBitmap( save_xpm ),
224  _( "Save board" ) );
225 
226  m_mainToolBar->AddSeparator();
227  m_mainToolBar->AddTool( ID_SHEET_SET, wxEmptyString, KiBitmap( sheetset_xpm ),
228  _( "Page settings for paper size and texts" ) );
229 
230  m_mainToolBar->AddSeparator();
231  m_mainToolBar->AddTool( ID_OPEN_MODULE_EDITOR, wxEmptyString,
232  KiBitmap( module_editor_xpm ),
233  _( "Open footprint editor" ) );
234 
235  m_mainToolBar->AddTool( ID_OPEN_MODULE_VIEWER, wxEmptyString,
236  KiBitmap( modview_icon_xpm ),
237  _( "Open footprint viewer" ) );
238 
239  m_mainToolBar->AddSeparator();
241  m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiBitmap( undo_xpm ), msg );
243  m_mainToolBar->AddTool( wxID_REDO, wxEmptyString, KiBitmap( redo_xpm ), msg );
244 
245  m_mainToolBar->AddSeparator();
246  m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiBitmap( print_button_xpm ),
247  _( "Print board" ) );
248  m_mainToolBar->AddTool( ID_GEN_PLOT, wxEmptyString, KiBitmap( plot_xpm ),
249  _( "Plot (HPGL, PostScript, or GERBER format)" ) );
250 
251  m_mainToolBar->AddSeparator();
253  IS_COMMENT );
254  m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiBitmap( zoom_redraw_xpm ), msg );
255 
257  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiBitmap( zoom_in_xpm ), msg );
258 
260  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiBitmap( zoom_out_xpm ), msg );
261 
263  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ), msg );
264 
265  m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiBitmap( zoom_area_xpm ),
266  _( "Zoom to selection" ), wxITEM_CHECK );
267 
268  m_mainToolBar->AddSeparator();
270  m_mainToolBar->AddTool( ID_FIND_ITEMS, wxEmptyString, KiBitmap( find_xpm ), msg );
271 
272  m_mainToolBar->AddSeparator();
273  m_mainToolBar->AddTool( ID_GET_NETLIST, wxEmptyString, KiBitmap( netlist_xpm ),
274  _( "Read netlist" ) );
275  m_mainToolBar->AddTool( ID_DRC_CONTROL, wxEmptyString, KiBitmap( erc_xpm ),
276  _( "Perform design rules check" ) );
277 
278  m_mainToolBar->AddSeparator();
279 
280  if( m_SelLayerBox == NULL )
281  {
283  m_SelLayerBox->SetBoardFrame( this );
284  }
285 
286  ReCreateLayerBox( false );
287  m_mainToolBar->AddControl( m_SelLayerBox );
288 
289  PrepareLayerIndicator(); // Initialize the bitmap with current
290  // active layer colors for the next tool
291  m_mainToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, wxEmptyString,
293 
294  m_mainToolBar->AddSeparator();
295  m_mainToolBar->AddTool( ID_TOOLBARH_PCB_MODE_MODULE, wxEmptyString, KiBitmap( mode_module_xpm ),
296  _( "Mode footprint: manual and automatic movement and placement" ),
297  wxITEM_CHECK );
298  m_mainToolBar->AddTool( ID_TOOLBARH_PCB_MODE_TRACKS, wxEmptyString, KiBitmap( mode_track_xpm ),
299  _( "Mode track: autorouting" ), wxITEM_CHECK );
300 
301  // Fast call to FreeROUTE Web Bases router
302  m_mainToolBar->AddSeparator();
303  m_mainToolBar->AddTool( ID_TOOLBARH_PCB_FREEROUTE_ACCESS, wxEmptyString,
304  KiBitmap( web_support_xpm ),
305  _( "Fast access to the FreeROUTE external advanced router" ) );
306 
307  // Access to the scripting console
308 #if defined(KICAD_SCRIPTING_WXPYTHON)
309  if( IsWxPythonLoaded() )
310  {
311  m_mainToolBar->AddSeparator();
312 
313  m_mainToolBar->AddTool( ID_TOOLBARH_PCB_SCRIPTING_CONSOLE, wxEmptyString,
314  KiBitmap( py_script_xpm ),
315  _( "Show/Hide the Python Scripting console" ),
316  wxITEM_CHECK );
317  }
318 #endif
319 
320  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
321  m_mainToolBar->Realize();
322 }
323 
324 
326 {
327  if( m_optionsToolBar )
328  return;
329 
330  wxWindowUpdateLocker dummy( this );
331 
332  m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
333  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
334 
335  m_optionsToolBar->AddTool( ID_TB_OPTIONS_DRC_OFF, wxEmptyString, KiBitmap( drc_off_xpm ),
336  _( "Enable design rule checking" ), wxITEM_CHECK );
337  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, KiBitmap( grid_xpm ),
338  _( "Hide grid" ), wxITEM_CHECK );
339  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
340  KiBitmap( polar_coord_xpm ),
341  _( "Display polar coordinates" ), wxITEM_CHECK );
342  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
343  KiBitmap( unit_inch_xpm ),
344  _( "Set units to inches" ), wxITEM_CHECK );
345  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
346  KiBitmap( unit_mm_xpm ),
347  _( "Set units to millimeters" ), wxITEM_CHECK );
348 
349 #ifndef __APPLE__
350  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
351  KiBitmap( cursor_shape_xpm ),
352  _( "Change cursor shape" ), wxITEM_CHECK );
353 #endif // !__APPLE__
354 
355  m_optionsToolBar->AddSeparator();
356  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_RATSNEST, wxEmptyString,
357  KiBitmap( general_ratsnest_xpm ),
358  _( "Show board ratsnest" ), wxITEM_CHECK );
359 
360  m_optionsToolBar->AddSeparator();
361  m_optionsToolBar->AddTool( ID_TB_OPTIONS_AUTO_DEL_TRACK, wxEmptyString,
362  KiBitmap( auto_delete_track_xpm ),
363  _( "Enable automatic track deletion" ),
364  wxITEM_CHECK );
365 
366  m_optionsToolBar->AddSeparator();
367  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_ZONES, wxEmptyString, KiBitmap( show_zone_xpm ),
368  _( "Show filled areas in zones" ), wxITEM_CHECK );
369  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_ZONES_DISABLE, wxEmptyString,
370  KiBitmap( show_zone_disable_xpm ),
371  _( "Do not show filled areas in zones" ) , wxITEM_CHECK );
373  KiBitmap( show_zone_outline_only_xpm ),
374  _( "Show outlines of filled areas only in zones" ), wxITEM_CHECK );
375 
376  m_optionsToolBar->AddSeparator();
377  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString,
378  KiBitmap( pad_sketch_xpm ),
379  _( "Show pads in outline mode" ), wxITEM_CHECK );
380 
381  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, wxEmptyString,
382  KiBitmap( via_sketch_xpm ),
383  _( "Show vias in outline mode" ), wxITEM_CHECK );
384 
385  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, wxEmptyString,
386  KiBitmap( showtrack_xpm ),
387  _( "Show tracks in outline mode" ),
388  wxITEM_CHECK );
389 
391  KiBitmap( contrast_mode_xpm ),
392  _( "Enable high contrast display mode" ),
393  wxITEM_CHECK );
394 
395  // Tools to show/hide toolbars:
396  m_optionsToolBar->AddSeparator();
398  wxEmptyString,
399  KiBitmap( layers_manager_xpm ),
401  wxITEM_CHECK );
403  wxEmptyString,
404  KiBitmap( mw_toolbar_xpm ),
406  wxITEM_CHECK );
407 
408 
409  m_optionsToolBar->AddSeparator();
410  m_optionsToolBar->Realize();
411 }
412 
413 
415 {
416  if( m_drawToolBar )
417  return;
418 
419  wxWindowUpdateLocker dummy( this );
420 
421  m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
422  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
423 
424  // Set up toolbar
425  m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiBitmap( cursor_xpm ),
426  wxEmptyString, wxITEM_CHECK );
427 
428  m_drawToolBar->AddSeparator();
429 
430  m_drawToolBar->AddTool( ID_PCB_HIGHLIGHT_BUTT, wxEmptyString, KiBitmap( net_highlight_xpm ),
431  _( "Highlight net" ), wxITEM_CHECK );
432 
433  m_drawToolBar->AddTool( ID_PCB_SHOW_1_RATSNEST_BUTT, wxEmptyString,
434  KiBitmap( tool_ratsnest_xpm ),
435  _( "Display local ratsnest" ), wxITEM_CHECK );
436 
437  m_drawToolBar->AddSeparator();
438  m_drawToolBar->AddTool( ID_PCB_MODULE_BUTT, wxEmptyString, KiBitmap( module_xpm ),
439  _( "Add footprints" ), wxITEM_CHECK );
440 
441  m_drawToolBar->AddTool( ID_TRACK_BUTT, wxEmptyString, KiBitmap( add_tracks_xpm ),
442  _( "Route tracks" ), wxITEM_CHECK );
443 
444  m_drawToolBar->AddTool( ID_PCB_DRAW_VIA_BUTT, wxEmptyString, KiBitmap( add_via_xpm ),
445  _( "Add vias" ), wxITEM_CHECK );
446 
447  m_drawToolBar->AddTool( ID_PCB_ZONES_BUTT, wxEmptyString, KiBitmap( add_zone_xpm ),
448  _( "Add filled zones" ), wxITEM_CHECK );
449 
450  m_drawToolBar->AddTool( ID_PCB_KEEPOUT_AREA_BUTT, wxEmptyString,
451  KiBitmap( add_keepout_area_xpm ),
452  _( "Add keepout areas" ), wxITEM_CHECK );
453 
454  m_drawToolBar->AddSeparator();
455 
456  m_drawToolBar->AddTool( ID_PCB_ADD_LINE_BUTT, wxEmptyString, KiBitmap( add_graphical_segments_xpm ),
457  _( "Add graphic lines" ), wxITEM_CHECK );
458 
459  m_drawToolBar->AddTool( ID_PCB_CIRCLE_BUTT, wxEmptyString, KiBitmap( add_circle_xpm ),
460  _( "Add graphic circle" ), wxITEM_CHECK );
461 
462  m_drawToolBar->AddTool( ID_PCB_ARC_BUTT, wxEmptyString, KiBitmap( add_arc_xpm ),
463  _( "Add graphic arc" ), wxITEM_CHECK );
464 
465  m_drawToolBar->AddTool( ID_PCB_ADD_POLYGON_BUTT, wxEmptyString, KiBitmap( add_graphical_polygon_xpm ),
466  _( "Add graphic polygon" ), wxITEM_CHECK );
467 
468  m_drawToolBar->AddTool( ID_PCB_ADD_TEXT_BUTT, wxEmptyString, KiBitmap( text_xpm ),
469  _( "Add text on copper layers or graphic text" ), wxITEM_CHECK );
470 
471  m_drawToolBar->AddSeparator();
472  m_drawToolBar->AddTool( ID_PCB_DIMENSION_BUTT, wxEmptyString, KiBitmap( add_dimension_xpm ),
473  _( "Add dimension" ), wxITEM_CHECK );
474 
475  m_drawToolBar->AddTool( ID_PCB_TARGET_BUTT, wxEmptyString, KiBitmap( add_pcb_target_xpm ),
476  _( "Add layer alignment target" ), wxITEM_CHECK );
477 
478  m_drawToolBar->AddSeparator();
479  m_drawToolBar->AddTool( ID_PCB_DELETE_ITEM_BUTT, wxEmptyString, KiBitmap( delete_xpm ),
480  _( "Delete items" ), wxITEM_CHECK );
481 
482  m_drawToolBar->AddSeparator();
483  m_drawToolBar->AddTool( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxEmptyString,
484  KiBitmap( pcb_offset_xpm ),
485  _( "Place the origin point for drill and place files" ),
486  wxITEM_CHECK );
487 
488  m_drawToolBar->AddTool( ID_PCB_PLACE_GRID_COORD_BUTT, wxEmptyString,
489  KiBitmap( grid_select_axis_xpm ),
490  _( "Set the origin point for the grid" ),
491  wxITEM_CHECK );
492 
493  m_drawToolBar->AddTool( ID_PCB_MEASUREMENT_TOOL, wxEmptyString,
494  KiBitmap( measurement_xpm ),
495  _( "Measure distance" ),
496  wxITEM_CHECK );
497 
498  m_drawToolBar->Realize();
499 }
500 
501 
502 /* Create the auxiliary vertical right toolbar, showing tools for microwave applications
503  */
505 {
506  if( m_microWaveToolBar )
507  return;
508 
509  wxWindowUpdateLocker dummy(this);
510 
511  m_microWaveToolBar = new wxAuiToolBar( this, ID_MICROWAVE_V_TOOLBAR, wxDefaultPosition,
512  wxDefaultSize, KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
513 
514  // Set up toolbar
515  m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_SELF_CMD, wxEmptyString,
516  KiBitmap( mw_add_line_xpm ),
517  _( "Create line of specified length for microwave applications" ),
518  wxITEM_CHECK );
519 
520  m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_GAP_CMD, wxEmptyString,
521  KiBitmap( mw_add_gap_xpm ),
522  _( "Create gap of specified length for microwave applications" ),
523  wxITEM_CHECK );
524 
525  m_microWaveToolBar->AddSeparator();
526 
527  m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_CMD, wxEmptyString,
528  KiBitmap( mw_add_stub_xpm ),
529  _( "Create stub of specified length for microwave applications" ),
530  wxITEM_CHECK );
531 
532  m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD, wxEmptyString,
533  KiBitmap( mw_add_stub_arc_xpm ),
534  _( "Create stub (arc) of specified length for microwave applications" ),
535  wxITEM_CHECK );
536 
538  KiBitmap( mw_add_shape_xpm ),
539  _( "Create a polynomial shape for microwave applications" ),
540  wxITEM_CHECK );
541 
542  m_microWaveToolBar->Realize();
543 }
544 
545 
547 {
548  wxWindowUpdateLocker dummy( this );
549 
550  if( m_auxiliaryToolBar )
551  {
554 
555  // combobox sizes can have changed: apply new best sizes
556  wxAuiToolBarItem* item = m_auxiliaryToolBar->FindTool( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH );
557  item->SetMinSize( m_SelTrackWidthBox->GetBestSize() );
559  item->SetMinSize( m_SelViaSizeBox->GetBestSize() );
560 
561  m_auxiliaryToolBar->Realize();
562  m_auimgr.Update();
563  return;
564  }
565 
566  m_auxiliaryToolBar = new wxAuiToolBar( this, ID_AUX_TOOLBAR, wxDefaultPosition, wxDefaultSize,
567  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
568 
569  /* Set up toolbar items */
570 
571  // Creates box to display and choose tracks widths:
572  m_SelTrackWidthBox = new wxChoice( m_auxiliaryToolBar,
574  wxDefaultPosition, wxDefaultSize,
575  0, NULL );
577  m_auxiliaryToolBar->AddControl( m_SelTrackWidthBox );
578 
579  // Creates box to display and choose vias diameters:
580  m_SelViaSizeBox = new wxChoice( m_auxiliaryToolBar,
582  wxDefaultPosition, wxDefaultSize,
583  0, NULL );
585  m_auxiliaryToolBar->AddControl( m_SelViaSizeBox );
586  m_auxiliaryToolBar->AddSeparator();
587 
588  // Creates box to display and choose strategy to handle tracks an vias sizes:
590  wxEmptyString,
591  KiBitmap( auto_track_width_xpm ),
592  _( "Auto track width: when starting on an existing track "
593  "use its width\notherwise, use current width setting" ),
594  wxITEM_CHECK );
595 
596  // Add the box to display and select the current grid size:
597  m_auxiliaryToolBar->AddSeparator();
598  m_gridSelectBox = new wxChoice( m_auxiliaryToolBar,
600  wxDefaultPosition, wxDefaultSize,
601  0, NULL );
603  m_auxiliaryToolBar->AddControl( m_gridSelectBox );
604 
605  // Add the box to display and select the current Zoom
606  m_auxiliaryToolBar->AddSeparator();
607  m_zoomSelectBox = new wxChoice( m_auxiliaryToolBar,
609  wxDefaultPosition, wxDefaultSize,
610  0, NULL );
612  m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
613 
614  // after adding the buttons to the toolbar, must call Realize()
615  m_auxiliaryToolBar->Realize();
616 }
617 
618 
620 {
621  if( m_SelTrackWidthBox == NULL )
622  return;
623 
624  wxString msg;
625  bool mmFirst = g_UserUnit != INCHES;
626 
627  m_SelTrackWidthBox->Clear();
628 
629  for( unsigned ii = 0; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
630  {
631  int size = GetDesignSettings().m_TrackWidthList[ii];
632 
633  double valueMils = To_User_Unit( INCHES, size ) * 1000;
634  double value_mm = To_User_Unit( MILLIMETRES, size );
635 
636  if( mmFirst )
637  msg.Printf( _( "Track: %.3f mm (%.2f mils)" ),
638  value_mm, valueMils );
639  else
640  msg.Printf( _( "Track: %.2f mils (%.3f mm)" ),
641  valueMils, value_mm );
642 
643  // Mark the netclass track width value (the first in list)
644  if( ii == 0 )
645  msg << wxT( " *" );
646 
647  m_SelTrackWidthBox->Append( msg );
648  }
649 
650  if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
652 
653  m_SelTrackWidthBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
654 }
655 
656 
658 {
659  if( m_SelViaSizeBox == NULL )
660  return;
661 
662  wxString msg;
663 
664  m_SelViaSizeBox->Clear();
665  bool mmFirst = g_UserUnit != INCHES;
666 
667  for( unsigned ii = 0; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
668  {
669  int diam = GetDesignSettings().m_ViasDimensionsList[ii].m_Diameter;
670 
671  double valueMils = To_User_Unit( INCHES, diam ) * 1000;
672  double value_mm = To_User_Unit( MILLIMETRES, diam );
673 
674  if( mmFirst )
675  msg.Printf( _( "Via: %.2f mm (%.1f mils)" ),
676  value_mm, valueMils );
677  else
678  msg.Printf( _( "Via: %.1f mils (%.2f mm)" ),
679  valueMils, value_mm );
680 
681  int hole = GetDesignSettings().m_ViasDimensionsList[ii].m_Drill;
682 
683  if( hole )
684  {
685  msg << wxT("/ ");
686  wxString hole_str;
687  valueMils = To_User_Unit( INCHES, hole ) * 1000;
688  value_mm = To_User_Unit( MILLIMETRES, hole );
689 
690  if( mmFirst )
691  hole_str.Printf( _( "%.2f mm (%.1f mils)" ),
692  value_mm, valueMils );
693  else
694  hole_str.Printf( _( "%.1f mils (%.2f mm)" ),
695  valueMils, value_mm );
696 
697  msg += hole_str;
698  }
699 
700  // Mark the netclass via size value (the first in list)
701  if( ii == 0 )
702  msg << wxT( " *" );
703 
704  m_SelViaSizeBox->Append( msg );
705  }
706 
707  if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )
709 
710  m_SelViaSizeBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
711 }
712 
713 
714 void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
715 {
716  if( m_SelLayerBox == NULL || m_mainToolBar == NULL )
717  return;
718 
719  m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
722 
723  if( aForceResizeToolbar )
724  {
725  // the layer box can have its size changed
726  // Update the aui manager, to take in account the new size
727  m_auimgr.Update();
728  }
729 }
730 
731 
732 void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
733 {
734  int id = event.GetId();
735  bool state = event.IsChecked();
736  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
737 
738  switch( id )
739  {
741  Settings().m_legacyDrcOn = !state;
742 
743  if( GetToolId() == ID_TRACK_BUTT )
744  {
745  if( Settings().m_legacyDrcOn )
746  m_canvas->SetCursor( wxCURSOR_PENCIL );
747  else
748  m_canvas->SetCursor( wxCURSOR_QUESTION_ARROW );
749  }
750  break;
751 
754  OnModify();
755  Compile_Ratsnest( NULL, true );
756 
757  m_canvas->Refresh();
758  break;
759 
762  break;
763 
765  displ_opts->m_DisplayZonesMode = 0;
766  m_canvas->Refresh();
767  break;
768 
770  displ_opts->m_DisplayZonesMode = 1;
771  m_canvas->Refresh();
772  break;
773 
775  displ_opts->m_DisplayZonesMode = 2;
776  m_canvas->Refresh();
777  break;
778 
780  displ_opts->m_DisplayViaFill = !state;
781  m_canvas->Refresh();
782  break;
783 
785  displ_opts->m_DisplayPcbTrackFill = !state;
786  m_canvas->Refresh();
787  break;
788 
790  {
791  displ_opts->m_ContrastModeDisplay = state;
792  m_canvas->Refresh();
793  break;
794  }
795 
797  m_show_microwave_tools = state;
798  m_auimgr.GetPane( wxT( "m_microWaveToolBar" ) ).Show( m_show_microwave_tools );
799  m_auimgr.Update();
800 
801  GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_MUWAVE_TOOLBAR,
803  _( "Hide Microwa&ve Toolbar" ): _( "Show Microwa&ve Toolbar" ));
804  break;
805 
807  // show auxiliary Vertical layers and visibility manager toolbar
809  m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools );
810  m_auimgr.Update();
811 
812  GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER,
814  _( "Hide &Layers Manager" ) : _( "Show &Layers Manager" ) );
815  break;
816 
817  default:
818  DisplayErrorMessage( this, "Invalid toolbar option",
819  "PCB_EDIT_FRAME::OnSelectOptionToolbar error \n (event not handled!)" );
820  break;
821  }
822 }
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:994
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
Definition: pcbframe.cpp:934
void SetTrackWidthIndex(unsigned aIndex)
Function SetTrackWidthIndex sets the current track width list index to aIndex.
VIATYPE_T m_CurrentViaType
via type (VIA_BLIND_BURIED, VIA_THROUGH VIA_MICROVIA)
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
void PrepareLayerIndicator()
Definition: tool_pcb.cpp:92
This file is part of the common library.
#define HELP_SHOW_HIDE_MICROWAVE_TOOLS
std::vector< int > m_TrackWidthList
Track width list.
#define HELP_ZOOM_FIT
void ReCreateMicrowaveVToolbar()
Definition: tool_pcb.cpp:504
Class BOARD to handle a board.
wxChoice * m_SelViaSizeBox
Definition: wxPcbStruct.h:239
void updateGridSelectBox()
Definition: id.h:232
void ReCreateLayerBox(bool aForceResizeToolbar=true)
Re create the layer Box by clearing the old list, and building le new one, from the new layers names ...
Definition: tool_pcb.cpp:714
Class to display a pcb layer list in a wxBitmapComboBox.
wxAuiManager m_auimgr
Definition: wxstruct.h:149
bool m_show_microwave_tools
Definition: wxPcbStruct.h:241
void SetBoardFrame(PCB_BASE_FRAME *aFrame)
void ReCreateHToolbar() override
Definition: tool_pcb.cpp:202
wxChoice * m_SelTrackWidthBox
Definition: wxPcbStruct.h:238
wxChoice * m_gridSelectBox
Choice box to choose the grid size.
Definition: draw_frame.h:116
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
#define HELP_ZOOM_OUT
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
Pcbnew hotkeys.
EDA_DRAW_FRAME::OnSelectGrid ID_TB_OPTIONS_SELECT_UNIT_INCH
Definition: draw_frame.cpp:124
bool m_show_layer_manager_tools
Definition: wxPcbStruct.h:242
struct EDA_HOTKEY_CONFIG g_Board_Editor_Hokeys_Descr[]
bool IsWxPythonLoaded()
COLOR4D GetItemColor(int aItemIdx) const
Function GetItemColor.
#define HELP_ZOOM_REDRAW
void SetViaSizeIndex(unsigned aIndex)
Function SetViaSizeIndex sets the current via size list index to aIndex.
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
wxAuiToolBar * m_microWaveToolBar
The auxiliary right vertical tool bar used to access the microwave tools.
Definition: wxPcbStruct.h:90
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:87
wxAuiToolBar * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:126
void OnSelectOptionToolbar(wxCommandEvent &event)
Definition: tool_pcb.cpp:732
PCB_GENERAL_SETTINGS & Settings()
Definition: common.h:145
wxChoice * m_zoomSelectBox
Choice box to choose the zoom value.
Definition: draw_frame.h:119
void ReCreateVToolbar() override
Definition: tool_pcb.cpp:414
#define BM_LAYERICON_SIZE
Definition: tool_pcb.cpp:60
Helper dialog and control classes.
static const char s_BitmapLayerIcon[BM_LAYERICON_SIZE][BM_LAYERICON_SIZE]
Definition: tool_pcb.cpp:61
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame...
void ReCreateOptToolbar()
Definition: tool_pcb.cpp:325
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:123
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:145
COLORS_DESIGN_SETTINGS & Colors()
PCB_EDIT_FRAME::OnResetModuleTextSizes PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY
Definition: pcbframe.cpp:253
void Compile_Ratsnest(wxDC *aDC, bool aDisplayStatus)
Function Compile_Ratsnest Create the entire board ratsnest.
Definition: ratsnest.cpp:56
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
#define HELP_REDO
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 LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
void updateViaSizeSelectBox()
Definition: tool_pcb.cpp:657
#define HELP_ZOOM_IN
#define HELP_SHOW_HIDE_LAYERMANAGER
int GetToolId() const
Definition: draw_frame.h:465
static wxBitmap * LayerPairBitmap
Definition: tool_pcb.cpp:58
#define SEL_LAYER_HELP
Definition: tool_pcb.cpp:53
#define HELP_UNDO
These strings are used in menus and tools, that do the same command But they are internationalized, and therefore must be created at run time, on the fly.
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
std::vector< VIA_DIMENSION > m_ViasDimensionsList
Vias size and drill list.
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
Definition: wxstruct.h:168
Definition: id.h:96
double To_User_Unit(EDA_UNITS_T aUnit, double aValue)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: base_units.cpp:91
static const char * text_xpm[]
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
Definition: wxPcbStruct.h:237
void updateZoomSelectBox()
void updateTraceWidthSelectBox()
Definition: tool_pcb.cpp:619
strings common to toolbars and menubar
#define HELP_FIND
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
wxAuiToolBar * m_auxiliaryToolBar
Auxiliary tool bar typically shown below the main tool bar at the top of the main window...
void ReCreateAuxiliaryToolbar() override
Definition: tool_pcb.cpp:546
PCB_EDIT_FRAME::OnResetModuleTextSizes PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar ID_PCB_MEASUREMENT_TOOL
Definition: pcbframe.cpp:262
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39