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  wxAUI_TB_DEFAULT_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  wxAUI_TB_DEFAULT_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  wxAUI_TB_DEFAULT_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  m_drawToolBar->AddTool( ID_PCB_ADD_LINE_BUTT, wxEmptyString, KiBitmap( add_dashed_line_xpm ),
456  _( "Add graphic line or polygon" ), wxITEM_CHECK );
457 
458  m_drawToolBar->AddTool( ID_PCB_CIRCLE_BUTT, wxEmptyString, KiBitmap( add_circle_xpm ),
459  _( "Add graphic circle" ), wxITEM_CHECK );
460 
461  m_drawToolBar->AddTool( ID_PCB_ARC_BUTT, wxEmptyString, KiBitmap( add_arc_xpm ),
462  _( "Add graphic arc" ), wxITEM_CHECK );
463 
464  m_drawToolBar->AddTool( ID_PCB_ADD_TEXT_BUTT, wxEmptyString, KiBitmap( text_xpm ),
465  _( "Add text on copper layers or graphic text" ), wxITEM_CHECK );
466 
467  m_drawToolBar->AddSeparator();
468  m_drawToolBar->AddTool( ID_PCB_DIMENSION_BUTT, wxEmptyString, KiBitmap( add_dimension_xpm ),
469  _( "Add dimension" ), wxITEM_CHECK );
470 
471  m_drawToolBar->AddTool( ID_PCB_MIRE_BUTT, wxEmptyString, KiBitmap( add_mires_xpm ),
472  _( "Add layer alignment target" ), wxITEM_CHECK );
473 
474  m_drawToolBar->AddSeparator();
475  m_drawToolBar->AddTool( ID_PCB_DELETE_ITEM_BUTT, wxEmptyString, KiBitmap( delete_xpm ),
476  _( "Delete items" ), wxITEM_CHECK );
477 
478  m_drawToolBar->AddSeparator();
479  m_drawToolBar->AddTool( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxEmptyString,
480  KiBitmap( pcb_offset_xpm ),
481  _( "Place the origin point for drill and place files" ),
482  wxITEM_CHECK );
483 
484  m_drawToolBar->AddTool( ID_PCB_PLACE_GRID_COORD_BUTT, wxEmptyString,
485  KiBitmap( grid_select_axis_xpm ),
486  _( "Set the origin point for the grid" ),
487  wxITEM_CHECK );
488 
489  m_drawToolBar->AddTool( ID_PCB_MEASUREMENT_TOOL, wxEmptyString,
490  KiBitmap( measurement_xpm ),
491  _( "Measure distance" ),
492  wxITEM_CHECK );
493 
494  m_drawToolBar->Realize();
495 }
496 
497 
498 /* Create the auxiliary vertical right toolbar, showing tools for microwave applications
499  */
501 {
502  if( m_microWaveToolBar )
503  return;
504 
505  wxWindowUpdateLocker dummy(this);
506 
507  m_microWaveToolBar = new wxAuiToolBar( this, ID_MICROWAVE_V_TOOLBAR, wxDefaultPosition,
508  wxDefaultSize,
509  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
510 
511  // Set up toolbar
512  m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_SELF_CMD, wxEmptyString,
513  KiBitmap( mw_add_line_xpm ),
514  _( "Create line of specified length for microwave applications" ),
515  wxITEM_CHECK );
516 
517  m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_GAP_CMD, wxEmptyString,
518  KiBitmap( mw_add_gap_xpm ),
519  _( "Create gap of specified length for microwave applications" ),
520  wxITEM_CHECK );
521 
522  m_microWaveToolBar->AddSeparator();
523 
524  m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_CMD, wxEmptyString,
525  KiBitmap( mw_add_stub_xpm ),
526  _( "Create stub of specified length for microwave applications" ),
527  wxITEM_CHECK );
528 
529  m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD, wxEmptyString,
530  KiBitmap( mw_add_stub_arc_xpm ),
531  _( "Create stub (arc) of specified length for microwave applications" ),
532  wxITEM_CHECK );
533 
535  KiBitmap( mw_add_shape_xpm ),
536  _( "Create a polynomial shape for microwave applications" ),
537  wxITEM_CHECK );
538 
539  m_microWaveToolBar->Realize();
540 }
541 
542 
544 {
545  wxWindowUpdateLocker dummy( this );
546 
547  if( m_auxiliaryToolBar )
548  {
551 
552  // combobox sizes can have changed: apply new best sizes
553  wxAuiToolBarItem* item = m_auxiliaryToolBar->FindTool( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH );
554  item->SetMinSize( m_SelTrackWidthBox->GetBestSize() );
556  item->SetMinSize( m_SelViaSizeBox->GetBestSize() );
557 
558  m_auxiliaryToolBar->Realize();
559  m_auimgr.Update();
560  return;
561  }
562 
563  m_auxiliaryToolBar = new wxAuiToolBar( this, ID_AUX_TOOLBAR, wxDefaultPosition, wxDefaultSize,
564  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
565 
566  /* Set up toolbar items */
567 
568  // Creates box to display and choose tracks widths:
569  m_SelTrackWidthBox = new wxChoice( m_auxiliaryToolBar,
571  wxDefaultPosition, wxDefaultSize,
572  0, NULL );
574  m_auxiliaryToolBar->AddControl( m_SelTrackWidthBox );
575 
576  // Creates box to display and choose vias diameters:
577  m_SelViaSizeBox = new wxChoice( m_auxiliaryToolBar,
579  wxDefaultPosition, wxDefaultSize,
580  0, NULL );
582  m_auxiliaryToolBar->AddControl( m_SelViaSizeBox );
583  m_auxiliaryToolBar->AddSeparator();
584 
585  // Creates box to display and choose strategy to handle tracks an vias sizes:
587  wxEmptyString,
588  KiBitmap( auto_track_width_xpm ),
589  _( "Auto track width: when starting on an existing track "
590  "use its width\notherwise, use current width setting" ),
591  wxITEM_CHECK );
592 
593  // Add the box to display and select the current grid size:
594  m_auxiliaryToolBar->AddSeparator();
595  m_gridSelectBox = new wxChoice( m_auxiliaryToolBar,
597  wxDefaultPosition, wxDefaultSize,
598  0, NULL );
600  m_auxiliaryToolBar->AddControl( m_gridSelectBox );
601 
602  // Add the box to display and select the current Zoom
603  m_auxiliaryToolBar->AddSeparator();
604  m_zoomSelectBox = new wxChoice( m_auxiliaryToolBar,
606  wxDefaultPosition, wxDefaultSize,
607  0, NULL );
609  m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
610 
611  // after adding the buttons to the toolbar, must call Realize()
612  m_auxiliaryToolBar->Realize();
613 }
614 
615 
617 {
618  if( m_SelTrackWidthBox == NULL )
619  return;
620 
621  wxString msg;
622  bool mmFirst = g_UserUnit != INCHES;
623 
624  m_SelTrackWidthBox->Clear();
625 
626  for( unsigned ii = 0; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
627  {
628  int size = GetDesignSettings().m_TrackWidthList[ii];
629 
630  double valueMils = To_User_Unit( INCHES, size ) * 1000;
631  double value_mm = To_User_Unit( MILLIMETRES, size );
632 
633  if( mmFirst )
634  msg.Printf( _( "Track: %.3f mm (%.2f mils)" ),
635  value_mm, valueMils );
636  else
637  msg.Printf( _( "Track: %.2f mils (%.3f mm)" ),
638  valueMils, value_mm );
639 
640  // Mark the netclass track width value (the first in list)
641  if( ii == 0 )
642  msg << wxT( " *" );
643 
644  m_SelTrackWidthBox->Append( msg );
645  }
646 
647  if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
649 
650  m_SelTrackWidthBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
651 }
652 
653 
655 {
656  if( m_SelViaSizeBox == NULL )
657  return;
658 
659  wxString msg;
660 
661  m_SelViaSizeBox->Clear();
662  bool mmFirst = g_UserUnit != INCHES;
663 
664  for( unsigned ii = 0; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
665  {
666  int diam = GetDesignSettings().m_ViasDimensionsList[ii].m_Diameter;
667 
668  double valueMils = To_User_Unit( INCHES, diam ) * 1000;
669  double value_mm = To_User_Unit( MILLIMETRES, diam );
670 
671  if( mmFirst )
672  msg.Printf( _( "Via: %.2f mm (%.1f mils)" ),
673  value_mm, valueMils );
674  else
675  msg.Printf( _( "Via: %.1f mils (%.2f mm)" ),
676  valueMils, value_mm );
677 
678  int hole = GetDesignSettings().m_ViasDimensionsList[ii].m_Drill;
679 
680  if( hole )
681  {
682  msg << wxT("/ ");
683  wxString hole_str;
684  valueMils = To_User_Unit( INCHES, hole ) * 1000;
685  value_mm = To_User_Unit( MILLIMETRES, hole );
686 
687  if( mmFirst )
688  hole_str.Printf( _( "%.2f mm (%.1f mils)" ),
689  value_mm, valueMils );
690  else
691  hole_str.Printf( _( "%.1f mils (%.2f mm)" ),
692  valueMils, value_mm );
693 
694  msg += hole_str;
695  }
696 
697  // Mark the netclass via size value (the first in list)
698  if( ii == 0 )
699  msg << wxT( " *" );
700 
701  m_SelViaSizeBox->Append( msg );
702  }
703 
704  if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )
706 
707  m_SelViaSizeBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
708 }
709 
710 
711 void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
712 {
713  if( m_SelLayerBox == NULL || m_mainToolBar == NULL )
714  return;
715 
716  m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
719 
720  if( aForceResizeToolbar )
721  {
722  // the layer box can have its size changed
723  // Update the aui manager, to take in account the new size
724  m_auimgr.Update();
725  }
726 }
727 
728 
729 void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
730 {
731  int id = event.GetId();
732  bool state = event.IsChecked();
734 
735  switch( id )
736  {
738  Settings().m_legacyDrcOn = !state;
739 
740  if( GetToolId() == ID_TRACK_BUTT )
741  {
742  if( Settings().m_legacyDrcOn )
743  m_canvas->SetCursor( wxCURSOR_PENCIL );
744  else
745  m_canvas->SetCursor( wxCURSOR_QUESTION_ARROW );
746  }
747  break;
748 
751  OnModify();
752  Compile_Ratsnest( NULL, true );
753 
754  m_canvas->Refresh();
755  break;
756 
759  break;
760 
762  displ_opts->m_DisplayZonesMode = 0;
763  m_canvas->Refresh();
764  break;
765 
767  displ_opts->m_DisplayZonesMode = 1;
768  m_canvas->Refresh();
769  break;
770 
772  displ_opts->m_DisplayZonesMode = 2;
773  m_canvas->Refresh();
774  break;
775 
777  displ_opts->m_DisplayViaFill = !state;
778  m_canvas->Refresh();
779  break;
780 
782  displ_opts->m_DisplayPcbTrackFill = !state;
783  m_canvas->Refresh();
784  break;
785 
787  {
788  displ_opts->m_ContrastModeDisplay = state;
789  m_canvas->Refresh();
790  break;
791  }
792 
794  m_show_microwave_tools = state;
795  m_auimgr.GetPane( wxT( "m_microWaveToolBar" ) ).Show( m_show_microwave_tools );
796  m_auimgr.Update();
797 
798  GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_MUWAVE_TOOLBAR,
800  _( "Hide Microwa&ve Toolbar" ): _( "Show Microwa&ve Toolbar" ));
801  break;
802 
804  // show auxiliary Vertical layers and visibility manager toolbar
806  m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools );
807  m_auimgr.Update();
808 
809  GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER,
811  _( "Hide &Layers Manager" ) : _( "Show &Layers Manager" ) );
812  break;
813 
814  default:
815  DisplayErrorMessage( this, "Invalid toolbar option",
816  "PCB_EDIT_FRAME::OnSelectOptionToolbar error \n (event not handled!)" );
817  break;
818  }
819 }
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
Definition: draw_panel.cpp:326
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:500
Class BOARD to handle a board.
wxChoice * m_SelViaSizeBox
Definition: wxPcbStruct.h:245
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:711
Class to display a pcb layer list in a wxBitmapComboBox.
wxAuiManager m_auimgr
Definition: wxstruct.h:140
bool m_show_microwave_tools
Definition: wxPcbStruct.h:247
void SetBoardFrame(PCB_BASE_FRAME *aFrame)
void ReCreateHToolbar() override
Definition: tool_pcb.cpp:202
wxChoice * m_SelTrackWidthBox
Definition: wxPcbStruct.h:244
wxChoice * m_gridSelectBox
Choice box to choose the grid size.
Definition: draw_frame.h:115
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:121
bool m_show_layer_manager_tools
Definition: wxPcbStruct.h:248
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
bool m_DisplayPcbTrackFill
Definition: pcbstruct.h:71
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:85
wxAuiToolBar * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:125
void OnSelectOptionToolbar(wxCommandEvent &event)
Definition: tool_pcb.cpp:729
PCB_GENERAL_SETTINGS & Settings()
Definition: common.h:145
wxChoice * m_zoomSelectBox
Choice box to choose the zoom value.
Definition: draw_frame.h:118
void ReCreateVToolbar() override
Definition: tool_pcb.cpp:414
bool m_ContrastModeDisplay
Definition: pcbstruct.h:85
#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...
int m_DisplayZonesMode
Definition: pcbstruct.h:77
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:122
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:136
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
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
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:92
#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:654
#define HELP_ZOOM_IN
#define HELP_SHOW_HIDE_LAYERMANAGER
int GetToolId() const
Definition: draw_frame.h:419
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.
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:90
static const char * text_xpm[]
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
Definition: wxPcbStruct.h:243
void updateZoomSelectBox()
void updateTraceWidthSelectBox()
Definition: tool_pcb.cpp:616
bool m_DisplayViaFill
Definition: pcbstruct.h:66
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:543
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