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 <colors_selection.h>
38 #include <wxPcbStruct.h>
39 #include <class_drawpanel.h>
40 #include <confirm.h>
41 #include <bitmaps.h>
42 
43 #include <class_board.h>
44 
45 #include <pcbnew.h>
46 #include <pcbnew_id.h>
47 #include <hotkeys.h>
49 
50 #include <wx/wupdlock.h>
51 
52 extern bool IsWxPythonLoaded();
53 
54 #define SEL_LAYER_HELP _( \
55  "Show active layer selections\nand select layer pair for route and place via" )
56 
57 
58 /* Data to build the layer pair indicator button */
59 static wxBitmap* LayerPairBitmap = NULL;
60 
61 #define BM_LAYERICON_SIZE 24
63 {
64  // 0 = draw pixel with active layer color
65  // 1 = draw pixel with top layer color (top/bottom layer used inautoroute and place via)
66  // 2 = draw pixel with bottom layer color
67  // 3 = draw pixel with via color
68  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0 },
69  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0 },
70  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0 },
71  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
72  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 },
73  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
74  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 },
75  { 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0 },
76  { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 0, 1, 1, 1, 1, 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  { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 0, 3, 3, 2, 2, 2, 2, 2, 2, 2 },
79  { 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 1, 1, 1, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0 },
80  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
81  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, 3, 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  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
90 };
91 
92 
94 {
95  int ii, jj;
96  COLOR4D active_layer_color, Route_Layer_TOP_color,
97  Route_Layer_BOTTOM_color, via_color;
98  bool change = false;
99  bool first_call = LayerPairBitmap == NULL;
100 
101  static COLOR4D previous_active_layer_color, previous_Route_Layer_TOP_color,
102  previous_Route_Layer_BOTTOM_color, previous_via_color;
103 
104  /* get colors, and redraw bitmap button only on changes */
105  active_layer_color = GetBoard()->GetLayerColor(GetActiveLayer());
106 
107  if( previous_active_layer_color != active_layer_color )
108  {
109  previous_active_layer_color = active_layer_color;
110  change = true;
111  }
112 
113  Route_Layer_TOP_color =
114  g_ColorsSettings.GetLayerColor( GetScreen()->m_Route_Layer_TOP );
115 
116  if( previous_Route_Layer_TOP_color != Route_Layer_TOP_color )
117  {
118  previous_Route_Layer_TOP_color = Route_Layer_TOP_color;
119  change = true;
120  }
121 
122  Route_Layer_BOTTOM_color =
123  g_ColorsSettings.GetLayerColor( GetScreen()->m_Route_Layer_BOTTOM );
124 
125  if( previous_Route_Layer_BOTTOM_color != Route_Layer_BOTTOM_color )
126  {
127  previous_Route_Layer_BOTTOM_color = Route_Layer_BOTTOM_color;
128  change = true;
129  }
130 
131  int via_type = GetDesignSettings().m_CurrentViaType;
132  via_color = GetBoard()->GetVisibleElementColor(VIAS_VISIBLE+via_type);
133 
134  if( previous_via_color != via_color )
135  {
136  previous_via_color = via_color;
137  change = true;
138  }
139 
140  if( !change && (LayerPairBitmap != NULL) )
141  return;
142 
143  /* Create the bitmap and its Memory DC, if not already made */
144  if( LayerPairBitmap == NULL )
145  {
146  LayerPairBitmap = new wxBitmap( 24, 24 );
147  }
148 
149  /* Draw the icon, with colors according to the active layer and layer
150  * pairs for via command (change layer)
151  */
152  wxMemoryDC iconDC;
153  iconDC.SelectObject( *LayerPairBitmap );
154  wxPen pen;
155  int buttonColor = -1;
156 
157  for( ii = 0; ii < BM_LAYERICON_SIZE; ii++ )
158  {
159  for( jj = 0; jj < BM_LAYERICON_SIZE; jj++ )
160  {
161  if( s_BitmapLayerIcon[ii][jj] != buttonColor )
162  {
163  switch( s_BitmapLayerIcon[ii][jj] )
164  {
165  default:
166  case 0:
167  pen.SetColour( active_layer_color.ToColour() );
168  break;
169 
170  case 1:
171  pen.SetColour( Route_Layer_TOP_color.ToColour() );
172  break;
173 
174  case 2:
175  pen.SetColour( Route_Layer_BOTTOM_color.ToColour() );
176  break;
177 
178  case 3:
179  pen.SetColour( via_color.ToColour() );
180  break;
181  }
182 
183  buttonColor = s_BitmapLayerIcon[ii][jj];
184  iconDC.SetPen( pen );
185  }
186 
187  iconDC.DrawPoint( jj, ii );
188  }
189  }
190 
191  /* Deselect the Tool Bitmap from DC,
192  * in order to delete the MemoryDC safely without deleting the bitmap */
193  iconDC.SelectObject( wxNullBitmap );
194 
195  if( m_mainToolBar && ! first_call )
196  {
198  m_mainToolBar->Refresh();
199  }
200 }
201 
202 
204 {
205  wxString msg;
206 
207  if( m_mainToolBar )
208  return;
209 
210  wxWindowUpdateLocker dummy( this );
211 
212  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
213  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
214 
215  // Set up toolbar
216  if( Kiface().IsSingle() )
217  {
218  m_mainToolBar->AddTool( ID_NEW_BOARD, wxEmptyString, KiBitmap( new_pcb_xpm ),
219  _( "New board" ) );
220  m_mainToolBar->AddTool( ID_LOAD_FILE, wxEmptyString, KiBitmap( open_brd_file_xpm ),
221  _( "Open existing board" ) );
222  }
223 
224  m_mainToolBar->AddTool( ID_SAVE_BOARD, wxEmptyString, KiBitmap( save_xpm ),
225  _( "Save board" ) );
226 
227  m_mainToolBar->AddSeparator();
228  m_mainToolBar->AddTool( ID_SHEET_SET, wxEmptyString, KiBitmap( sheetset_xpm ),
229  _( "Page settings for paper size and texts" ) );
230 
231  m_mainToolBar->AddSeparator();
232  m_mainToolBar->AddTool( ID_OPEN_MODULE_EDITOR, wxEmptyString,
233  KiBitmap( module_editor_xpm ),
234  _( "Open footprint editor" ) );
235 
236  m_mainToolBar->AddTool( ID_OPEN_MODULE_VIEWER, wxEmptyString,
237  KiBitmap( modview_icon_xpm ),
238  _( "Open footprint viewer" ) );
239 
240  m_mainToolBar->AddSeparator();
242  m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiBitmap( undo_xpm ), msg );
244  m_mainToolBar->AddTool( wxID_REDO, wxEmptyString, KiBitmap( redo_xpm ), msg );
245 
246  m_mainToolBar->AddSeparator();
247  m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiBitmap( print_button_xpm ),
248  _( "Print board" ) );
249  m_mainToolBar->AddTool( ID_GEN_PLOT, wxEmptyString, KiBitmap( plot_xpm ),
250  _( "Plot (HPGL, PostScript, or GERBER format)" ) );
251 
252  m_mainToolBar->AddSeparator();
254  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiBitmap( zoom_in_xpm ), msg );
255 
257  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiBitmap( zoom_out_xpm ), msg );
258 
260  IS_COMMENT );
261  m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiBitmap( zoom_redraw_xpm ), msg );
262 
264  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ), msg );
265 
266  m_mainToolBar->AddSeparator();
268  m_mainToolBar->AddTool( ID_FIND_ITEMS, wxEmptyString, KiBitmap( find_xpm ), msg );
269 
270  m_mainToolBar->AddSeparator();
271  m_mainToolBar->AddTool( ID_GET_NETLIST, wxEmptyString, KiBitmap( netlist_xpm ),
272  _( "Read netlist" ) );
273  m_mainToolBar->AddTool( ID_DRC_CONTROL, wxEmptyString, KiBitmap( erc_xpm ),
274  _( "Perform design rules check" ) );
275 
276  m_mainToolBar->AddSeparator();
277 
278  if( m_SelLayerBox == NULL )
279  {
281  m_SelLayerBox->SetBoardFrame( this );
282  }
283 
284  ReCreateLayerBox( false );
285  m_mainToolBar->AddControl( m_SelLayerBox );
286 
287  PrepareLayerIndicator(); // Initialize the bitmap with current
288  // active layer colors for the next tool
289  m_mainToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, wxEmptyString,
291 
292  m_mainToolBar->AddSeparator();
293  m_mainToolBar->AddTool( ID_TOOLBARH_PCB_MODE_MODULE, wxEmptyString, KiBitmap( mode_module_xpm ),
294  _( "Mode footprint: manual and automatic movement and placement" ),
295  wxITEM_CHECK );
296  m_mainToolBar->AddTool( ID_TOOLBARH_PCB_MODE_TRACKS, wxEmptyString, KiBitmap( mode_track_xpm ),
297  _( "Mode track: autorouting" ), wxITEM_CHECK );
298 
299  // Fast call to FreeROUTE Web Bases router
300  m_mainToolBar->AddSeparator();
301  m_mainToolBar->AddTool( ID_TOOLBARH_PCB_FREEROUTE_ACCESS, wxEmptyString,
302  KiBitmap( web_support_xpm ),
303  _( "Fast access to the FreeROUTE external advanced router" ) );
304 
305  // Access to the scripting console
306 #if defined(KICAD_SCRIPTING_WXPYTHON)
307  if( IsWxPythonLoaded() )
308  {
309  m_mainToolBar->AddSeparator();
310 
311  m_mainToolBar->AddTool( ID_TOOLBARH_PCB_SCRIPTING_CONSOLE, wxEmptyString,
312  KiBitmap( py_script_xpm ),
313  _( "Show/Hide the Python Scripting console" ),
314  wxITEM_CHECK );
315  }
316 #endif
317 
318  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
319  m_mainToolBar->Realize();
320 }
321 
322 
324 {
325  if( m_optionsToolBar )
326  return;
327 
328  wxWindowUpdateLocker dummy( this );
329 
330  m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
331  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
332 
333  m_optionsToolBar->AddTool( ID_TB_OPTIONS_DRC_OFF, wxEmptyString, KiBitmap( drc_off_xpm ),
334  _( "Enable design rule checking" ), wxITEM_CHECK );
335  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, KiBitmap( grid_xpm ),
336  _( "Hide grid" ), wxITEM_CHECK );
337  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
338  KiBitmap( polar_coord_xpm ),
339  _( "Display polar coordinates" ), wxITEM_CHECK );
340  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
341  KiBitmap( unit_inch_xpm ),
342  _( "Set units to inches" ), wxITEM_CHECK );
343  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
344  KiBitmap( unit_mm_xpm ),
345  _( "Set units to millimeters" ), wxITEM_CHECK );
346 
347 #ifndef __APPLE__
348  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
349  KiBitmap( cursor_shape_xpm ),
350  _( "Change cursor shape" ), wxITEM_CHECK );
351 #endif // !__APPLE__
352 
353  m_optionsToolBar->AddSeparator();
354  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_RATSNEST, wxEmptyString,
355  KiBitmap( general_ratsnest_xpm ),
356  _( "Show board ratsnest" ), wxITEM_CHECK );
357 
358  m_optionsToolBar->AddSeparator();
359  m_optionsToolBar->AddTool( ID_TB_OPTIONS_AUTO_DEL_TRACK, wxEmptyString,
360  KiBitmap( auto_delete_track_xpm ),
361  _( "Enable automatic track deletion" ),
362  wxITEM_CHECK );
363 
364  m_optionsToolBar->AddSeparator();
365  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_ZONES, wxEmptyString, KiBitmap( show_zone_xpm ),
366  _( "Show filled areas in zones" ), wxITEM_CHECK );
367  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_ZONES_DISABLE, wxEmptyString,
368  KiBitmap( show_zone_disable_xpm ),
369  _( "Do not show filled areas in zones" ) , wxITEM_CHECK );
371  KiBitmap( show_zone_outline_only_xpm ),
372  _( "Show outlines of filled areas only in zones" ), wxITEM_CHECK );
373 
374  m_optionsToolBar->AddSeparator();
375  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString,
376  KiBitmap( pad_sketch_xpm ),
377  _( "Show pads in outline mode" ), wxITEM_CHECK );
378 
379  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, wxEmptyString,
380  KiBitmap( via_sketch_xpm ),
381  _( "Show vias in outline mode" ), wxITEM_CHECK );
382 
383  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, wxEmptyString,
384  KiBitmap( showtrack_xpm ),
385  _( "Show tracks in outline mode" ),
386  wxITEM_CHECK );
387 
389  KiBitmap( contrast_mode_xpm ),
390  _( "Enable high contrast display mode" ),
391  wxITEM_CHECK );
392 
393  // Tools to show/hide toolbars:
394  m_optionsToolBar->AddSeparator();
396  wxEmptyString,
397  KiBitmap( layers_manager_xpm ),
399  wxITEM_CHECK );
401  wxEmptyString,
402  KiBitmap( mw_toolbar_xpm ),
404  wxITEM_CHECK );
405 
406 
407  m_optionsToolBar->AddSeparator();
408  m_optionsToolBar->Realize();
409 }
410 
411 
413 {
414  if( m_drawToolBar )
415  return;
416 
417  wxWindowUpdateLocker dummy( this );
418 
419  m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
420  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
421 
422  // Set up toolbar
423  m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiBitmap( cursor_xpm ),
424  wxEmptyString, wxITEM_CHECK );
425 
426  m_drawToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiBitmap( zoom_area_xpm ),
427  _( "Zoom to selection" ), wxITEM_CHECK );
428 
429  m_drawToolBar->AddSeparator();
430 
431  m_drawToolBar->AddTool( ID_PCB_HIGHLIGHT_BUTT, wxEmptyString, KiBitmap( net_highlight_xpm ),
432  _( "Highlight net" ), wxITEM_CHECK );
433 
434  m_drawToolBar->AddTool( ID_PCB_SHOW_1_RATSNEST_BUTT, wxEmptyString,
435  KiBitmap( tool_ratsnest_xpm ),
436  _( "Display local ratsnest" ), wxITEM_CHECK );
437 
438  m_drawToolBar->AddSeparator();
439  m_drawToolBar->AddTool( ID_PCB_MODULE_BUTT, wxEmptyString, KiBitmap( module_xpm ),
440  _( "Add footprints" ), wxITEM_CHECK );
441 
442  m_drawToolBar->AddTool( ID_TRACK_BUTT, wxEmptyString, KiBitmap( add_tracks_xpm ),
443  _( "Add tracks and vias" ), wxITEM_CHECK );
444 
445  m_drawToolBar->AddTool( ID_PCB_ZONES_BUTT, wxEmptyString, KiBitmap( add_zone_xpm ),
446  _( "Add filled zones" ), wxITEM_CHECK );
447 
448  m_drawToolBar->AddTool( ID_PCB_KEEPOUT_AREA_BUTT, wxEmptyString,
449  KiBitmap( add_keepout_area_xpm ),
450  _( "Add keepout areas" ), wxITEM_CHECK );
451 
452  m_drawToolBar->AddSeparator();
453  m_drawToolBar->AddTool( ID_PCB_ADD_LINE_BUTT, wxEmptyString, KiBitmap( add_dashed_line_xpm ),
454  _( "Add graphic line or polygon" ), wxITEM_CHECK );
455 
456  m_drawToolBar->AddTool( ID_PCB_CIRCLE_BUTT, wxEmptyString, KiBitmap( add_circle_xpm ),
457  _( "Add graphic circle" ), wxITEM_CHECK );
458 
459  m_drawToolBar->AddTool( ID_PCB_ARC_BUTT, wxEmptyString, KiBitmap( add_arc_xpm ),
460  _( "Add graphic arc" ), wxITEM_CHECK );
461 
462  m_drawToolBar->AddTool( ID_PCB_ADD_TEXT_BUTT, wxEmptyString, KiBitmap( add_text_xpm ),
463  _( "Add text on copper layers or graphic text" ), wxITEM_CHECK );
464 
465  m_drawToolBar->AddSeparator();
466  m_drawToolBar->AddTool( ID_PCB_DIMENSION_BUTT, wxEmptyString, KiBitmap( add_dimension_xpm ),
467  _( "Add dimension" ), wxITEM_CHECK );
468 
469  m_drawToolBar->AddTool( ID_PCB_MIRE_BUTT, wxEmptyString, KiBitmap( add_mires_xpm ),
470  _( "Add layer alignment target" ), wxITEM_CHECK );
471 
472  m_drawToolBar->AddSeparator();
473  m_drawToolBar->AddTool( ID_PCB_DELETE_ITEM_BUTT, wxEmptyString, KiBitmap( delete_xpm ),
474  _( "Delete items" ), wxITEM_CHECK );
475 
476  m_drawToolBar->AddSeparator();
477  m_drawToolBar->AddTool( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxEmptyString,
478  KiBitmap( pcb_offset_xpm ),
479  _( "Place the origin point for drill and place files" ),
480  wxITEM_CHECK );
481 
482  m_drawToolBar->AddTool( ID_PCB_PLACE_GRID_COORD_BUTT, wxEmptyString,
483  KiBitmap( grid_select_axis_xpm ),
484  _( "Set the origin point for the grid" ),
485  wxITEM_CHECK );
486 
487  m_drawToolBar->AddTool( ID_PCB_MEASUREMENT_TOOL, wxEmptyString,
488  KiBitmap( measurement_xpm ),
489  _( "Measure distance between two points" ),
490  wxITEM_CHECK );
491 
492  m_drawToolBar->Realize();
493 }
494 
495 
496 /* Create the auxiliary vertical right toolbar, showing tools for microwave applications
497  */
499 {
500  if( m_microWaveToolBar )
501  return;
502 
503  wxWindowUpdateLocker dummy(this);
504 
505  m_microWaveToolBar = new wxAuiToolBar( this, ID_MICROWAVE_V_TOOLBAR, wxDefaultPosition,
506  wxDefaultSize,
507  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
508 
509  // Set up toolbar
510  m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_SELF_CMD, wxEmptyString,
511  KiBitmap( mw_add_line_xpm ),
512  _( "Create line of specified length for microwave applications" ),
513  wxITEM_CHECK );
514 
515  m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_GAP_CMD, wxEmptyString,
516  KiBitmap( mw_add_gap_xpm ),
517  _( "Create gap of specified length for microwave applications" ),
518  wxITEM_CHECK );
519 
520  m_microWaveToolBar->AddSeparator();
521 
522  m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_CMD, wxEmptyString,
523  KiBitmap( mw_add_stub_xpm ),
524  _( "Create stub of specified length for microwave applications" ),
525  wxITEM_CHECK );
526 
527  m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD, wxEmptyString,
528  KiBitmap( mw_add_stub_arc_xpm ),
529  _( "Create stub (arc) of specified length for microwave applications" ),
530  wxITEM_CHECK );
531 
533  KiBitmap( mw_add_shape_xpm ),
534  _( "Create a polynomial shape for microwave applications" ),
535  wxITEM_CHECK );
536 
537  m_microWaveToolBar->Realize();
538 }
539 
540 
542 {
543  wxWindowUpdateLocker dummy( this );
544 
545  if( m_auxiliaryToolBar )
546  {
549 
550  // combobox sizes can have changed: apply new best sizes
551  wxAuiToolBarItem* item = m_auxiliaryToolBar->FindTool( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH );
552  item->SetMinSize( m_SelTrackWidthBox->GetBestSize() );
554  item->SetMinSize( m_SelViaSizeBox->GetBestSize() );
555 
556  m_auxiliaryToolBar->Realize();
557  m_auimgr.Update();
558  return;
559  }
560 
561  m_auxiliaryToolBar = new wxAuiToolBar( this, ID_AUX_TOOLBAR, wxDefaultPosition, wxDefaultSize,
562  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
563 
564  /* Set up toolbar items */
565 
566  // Creates box to display and choose tracks widths:
567  m_SelTrackWidthBox = new wxChoice( m_auxiliaryToolBar,
569  wxDefaultPosition, wxDefaultSize,
570  0, NULL );
572  m_auxiliaryToolBar->AddControl( m_SelTrackWidthBox );
573 
574  // Creates box to display and choose vias diameters:
575  m_SelViaSizeBox = new wxChoice( m_auxiliaryToolBar,
577  wxDefaultPosition, wxDefaultSize,
578  0, NULL );
580  m_auxiliaryToolBar->AddControl( m_SelViaSizeBox );
581  m_auxiliaryToolBar->AddSeparator();
582 
583  // Creates box to display and choose strategy to handle tracks an vias sizes:
585  wxEmptyString,
586  KiBitmap( auto_track_width_xpm ),
587  _( "Auto track width: when starting on an existing track "
588  "use its width\notherwise, use current width setting" ),
589  wxITEM_CHECK );
590 
591  // Add the box to display and select the current grid size:
592  m_auxiliaryToolBar->AddSeparator();
593  m_gridSelectBox = new wxChoice( m_auxiliaryToolBar,
595  wxDefaultPosition, wxDefaultSize,
596  0, NULL );
598  m_auxiliaryToolBar->AddControl( m_gridSelectBox );
599 
600  // Add the box to display and select the current Zoom
601  m_auxiliaryToolBar->AddSeparator();
602  m_zoomSelectBox = new wxChoice( m_auxiliaryToolBar,
604  wxDefaultPosition, wxDefaultSize,
605  0, NULL );
607  m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
608 
609  // after adding the buttons to the toolbar, must call Realize()
610  m_auxiliaryToolBar->Realize();
611 }
612 
613 
615 {
616  if( m_SelTrackWidthBox == NULL )
617  return;
618 
619  wxString msg;
620  bool mmFirst = g_UserUnit != INCHES;
621 
622  m_SelTrackWidthBox->Clear();
623 
624  for( unsigned ii = 0; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
625  {
626  int size = GetDesignSettings().m_TrackWidthList[ii];
627 
628  double valueMils = To_User_Unit( INCHES, size ) * 1000;
629  double value_mm = To_User_Unit( MILLIMETRES, size );
630 
631  if( mmFirst )
632  msg.Printf( _( "Track: %.3f mm (%.2f mils)" ),
633  value_mm, valueMils );
634  else
635  msg.Printf( _( "Track: %.2f mils (%.3f mm)" ),
636  valueMils, value_mm );
637 
638  // Mark the netclass track width value (the first in list)
639  if( ii == 0 )
640  msg << wxT( " *" );
641 
642  m_SelTrackWidthBox->Append( msg );
643  }
644 
645  if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
647 
648  m_SelTrackWidthBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
649 }
650 
651 
653 {
654  if( m_SelViaSizeBox == NULL )
655  return;
656 
657  wxString msg;
658 
659  m_SelViaSizeBox->Clear();
660  bool mmFirst = g_UserUnit != INCHES;
661 
662  for( unsigned ii = 0; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
663  {
664  int diam = GetDesignSettings().m_ViasDimensionsList[ii].m_Diameter;
665 
666  double valueMils = To_User_Unit( INCHES, diam ) * 1000;
667  double value_mm = To_User_Unit( MILLIMETRES, diam );
668 
669  if( mmFirst )
670  msg.Printf( _( "Via: %.2f mm (%.1f mils)" ),
671  value_mm, valueMils );
672  else
673  msg.Printf( _( "Via: %.1f mils (%.2f mm)" ),
674  valueMils, value_mm );
675 
676  int hole = GetDesignSettings().m_ViasDimensionsList[ii].m_Drill;
677 
678  if( hole )
679  {
680  msg << wxT("/ ");
681  wxString hole_str;
682  valueMils = To_User_Unit( INCHES, hole ) * 1000;
683  value_mm = To_User_Unit( MILLIMETRES, hole );
684 
685  if( mmFirst )
686  hole_str.Printf( _( "%.2f mm (%.1f mils)" ),
687  value_mm, valueMils );
688  else
689  hole_str.Printf( _( "%.1f mils (%.2f mm)" ),
690  valueMils, value_mm );
691 
692  msg += hole_str;
693  }
694 
695  // Mark the netclass via size value (the first in list)
696  if( ii == 0 )
697  msg << wxT( " *" );
698 
699  m_SelViaSizeBox->Append( msg );
700  }
701 
702  if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )
704 
705  m_SelViaSizeBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
706 }
707 
708 
709 void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
710 {
711  if( m_SelLayerBox == NULL || m_mainToolBar == NULL )
712  return;
713 
714  m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
717 
718  if( aForceResizeToolbar )
719  {
720  // the layer box can have its size changed
721  // Update the aui manager, to take in account the new size
722  m_auimgr.Update();
723  }
724 }
725 
726 
727 void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
728 {
729  int id = event.GetId();
730  bool state = event.IsChecked();
732 
733  switch( id )
734  {
736  g_Drc_On = !state;
737 
738  if( GetToolId() == ID_TRACK_BUTT )
739  {
740  if( g_Drc_On )
741  m_canvas->SetCursor( wxCURSOR_PENCIL );
742  else
743  m_canvas->SetCursor( wxCURSOR_QUESTION_ARROW );
744  }
745  break;
746 
749  OnModify();
750 
751  if( state && (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
752  Compile_Ratsnest( NULL, true );
753 
754  m_canvas->Refresh();
755  break;
756 
758  g_AutoDeleteOldTrack = state;
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  DisplayError( this,
816  wxT( "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:1004
bool g_Drc_On
Definition: pcbnew.cpp:67
void SetElementVisibility(int aElement, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
Definition: pcbframe.cpp:944
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 LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
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
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Definition: draw_panel.cpp:326
void PrepareLayerIndicator()
Definition: tool_pcb.cpp:93
bool g_AutoDeleteOldTrack
Definition: pcbnew.cpp:68
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:498
Class BOARD to handle a board.
wxChoice * m_SelViaSizeBox
Definition: wxPcbStruct.h:240
COLOR4D GetLayerColor(LAYER_ID aLayer) const
Function GetLayerColor gets a layer color for any valid layer, including non-copper ones...
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:709
BOARD * GetBoard() const
Class to display a pcb layer list in a wxBitmapComboBox.
wxAuiManager m_auimgr
Definition: wxstruct.h:139
bool m_show_microwave_tools
Definition: wxPcbStruct.h:242
void SetBoardFrame(PCB_BASE_FRAME *aFrame)
void ReCreateHToolbar() override
Definition: tool_pcb.cpp:203
wxChoice * m_SelTrackWidthBox
Definition: wxPcbStruct.h:239
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:243
struct EDA_HOTKEY_CONFIG g_Board_Editor_Hokeys_Descr[]
bool IsWxPythonLoaded()
#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
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:727
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:412
bool m_ContrastModeDisplay
Definition: pcbstruct.h:85
#define BM_LAYERICON_SIZE
Definition: tool_pcb.cpp:61
Helper dialog and control classes.
static const char s_BitmapLayerIcon[BM_LAYERICON_SIZE][BM_LAYERICON_SIZE]
Definition: tool_pcb.cpp:62
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:323
COLORS_DESIGN_SETTINGS g_ColorsSettings
Definition: pcbnew.cpp:65
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:135
void Compile_Ratsnest(wxDC *aDC, bool aDisplayStatus)
Function Compile_Ratsnest Create the entire board ratsnest.
Definition: ratsnest.cpp:165
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:652
#define HELP_ZOOM_IN
#define HELP_SHOW_HIDE_LAYERMANAGER
COLOR4D GetVisibleElementColor(int aPCB_VISIBLE)
Function GetVisibleElementColor returns the color of a pcb visible element.
int GetToolId() const
Definition: draw_frame.h:406
static wxBitmap * LayerPairBitmap
Definition: tool_pcb.cpp:59
#define SEL_LAYER_HELP
Definition: tool_pcb.cpp:54
#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
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
Definition: wxPcbStruct.h:238
void updateZoomSelectBox()
void updateTraceWidthSelectBox()
Definition: tool_pcb.cpp:614
bool m_DisplayViaFill
Definition: pcbstruct.h:66
strings common to toolbars and menubar
#define HELP_FIND
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:69
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:541
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
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39