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( LAYER_VIAS + 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_generic_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  IS_COMMENT );
255  m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiBitmap( zoom_redraw_xpm ), msg );
256 
258  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiBitmap( zoom_in_xpm ), msg );
259 
261  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiBitmap( zoom_out_xpm ), msg );
262 
264  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ), msg );
265 
266  m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiBitmap( zoom_area_xpm ),
267  _( "Zoom to selection" ), wxITEM_CHECK );
268 
269  m_mainToolBar->AddSeparator();
271  m_mainToolBar->AddTool( ID_FIND_ITEMS, wxEmptyString, KiBitmap( find_xpm ), msg );
272 
273  m_mainToolBar->AddSeparator();
274  m_mainToolBar->AddTool( ID_GET_NETLIST, wxEmptyString, KiBitmap( netlist_xpm ),
275  _( "Read netlist" ) );
276  m_mainToolBar->AddTool( ID_DRC_CONTROL, wxEmptyString, KiBitmap( erc_xpm ),
277  _( "Perform design rules check" ) );
278 
279  m_mainToolBar->AddSeparator();
280 
281  if( m_SelLayerBox == NULL )
282  {
284  m_SelLayerBox->SetBoardFrame( this );
285  }
286 
287  ReCreateLayerBox( false );
288  m_mainToolBar->AddControl( m_SelLayerBox );
289 
290  PrepareLayerIndicator(); // Initialize the bitmap with current
291  // active layer colors for the next tool
292  m_mainToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, wxEmptyString,
294 
295  m_mainToolBar->AddSeparator();
296  m_mainToolBar->AddTool( ID_TOOLBARH_PCB_MODE_MODULE, wxEmptyString, KiBitmap( mode_module_xpm ),
297  _( "Mode footprint: manual and automatic movement and placement" ),
298  wxITEM_CHECK );
299  m_mainToolBar->AddTool( ID_TOOLBARH_PCB_MODE_TRACKS, wxEmptyString, KiBitmap( mode_track_xpm ),
300  _( "Mode track: autorouting" ), wxITEM_CHECK );
301 
302  // Fast call to FreeROUTE Web Bases router
303  m_mainToolBar->AddSeparator();
304  m_mainToolBar->AddTool( ID_TOOLBARH_PCB_FREEROUTE_ACCESS, wxEmptyString,
305  KiBitmap( web_support_xpm ),
306  _( "Fast access to the FreeROUTE external advanced router" ) );
307 
308  // Access to the scripting console
309 #if defined(KICAD_SCRIPTING_WXPYTHON)
310  if( IsWxPythonLoaded() )
311  {
312  m_mainToolBar->AddSeparator();
313 
314  m_mainToolBar->AddTool( ID_TOOLBARH_PCB_SCRIPTING_CONSOLE, wxEmptyString,
315  KiBitmap( py_script_xpm ),
316  _( "Show/Hide the Python Scripting console" ),
317  wxITEM_CHECK );
318  }
319 #endif
320 
321  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
322  m_mainToolBar->Realize();
323 }
324 
325 
327 {
328  if( m_optionsToolBar )
329  return;
330 
331  wxWindowUpdateLocker dummy( this );
332 
333  m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
334  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
335 
336  m_optionsToolBar->AddTool( ID_TB_OPTIONS_DRC_OFF, wxEmptyString, KiBitmap( drc_off_xpm ),
337  _( "Enable design rule checking" ), wxITEM_CHECK );
338  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, KiBitmap( grid_xpm ),
339  _( "Hide grid" ), wxITEM_CHECK );
340  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
341  KiBitmap( polar_coord_xpm ),
342  _( "Display polar coordinates" ), wxITEM_CHECK );
343  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
344  KiBitmap( unit_inch_xpm ),
345  _( "Set units to inches" ), wxITEM_CHECK );
346  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
347  KiBitmap( unit_mm_xpm ),
348  _( "Set units to millimeters" ), wxITEM_CHECK );
349 
350 #ifndef __APPLE__
351  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
352  KiBitmap( cursor_shape_xpm ),
353  _( "Change cursor shape" ), wxITEM_CHECK );
354 #endif // !__APPLE__
355 
356  m_optionsToolBar->AddSeparator();
357  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_RATSNEST, wxEmptyString,
358  KiBitmap( general_ratsnest_xpm ),
359  _( "Show board ratsnest" ), wxITEM_CHECK );
360 
361  m_optionsToolBar->AddSeparator();
362  m_optionsToolBar->AddTool( ID_TB_OPTIONS_AUTO_DEL_TRACK, wxEmptyString,
363  KiBitmap( auto_delete_track_xpm ),
364  _( "Enable automatic track deletion" ),
365  wxITEM_CHECK );
366 
367  m_optionsToolBar->AddSeparator();
368  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_ZONES, wxEmptyString, KiBitmap( show_zone_xpm ),
369  _( "Show filled areas in zones" ), wxITEM_CHECK );
370  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_ZONES_DISABLE, wxEmptyString,
371  KiBitmap( show_zone_disable_xpm ),
372  _( "Do not show filled areas in zones" ) , wxITEM_CHECK );
374  KiBitmap( show_zone_outline_only_xpm ),
375  _( "Show outlines of filled areas only in zones" ), wxITEM_CHECK );
376 
377  m_optionsToolBar->AddSeparator();
378  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString,
379  KiBitmap( pad_sketch_xpm ),
380  _( "Show pads in outline mode" ), wxITEM_CHECK );
381 
382  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, wxEmptyString,
383  KiBitmap( via_sketch_xpm ),
384  _( "Show vias in outline mode" ), wxITEM_CHECK );
385 
386  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, wxEmptyString,
387  KiBitmap( showtrack_xpm ),
388  _( "Show tracks in outline mode" ),
389  wxITEM_CHECK );
390 
392  KiBitmap( contrast_mode_xpm ),
393  _( "Enable high contrast display mode" ),
394  wxITEM_CHECK );
395 
396  // Tools to show/hide toolbars:
397  m_optionsToolBar->AddSeparator();
399  wxEmptyString,
400  KiBitmap( layers_manager_xpm ),
402  wxITEM_CHECK );
404  wxEmptyString,
405  KiBitmap( mw_toolbar_xpm ),
407  wxITEM_CHECK );
408 
409 
410  m_optionsToolBar->AddSeparator();
411  m_optionsToolBar->Realize();
412 }
413 
414 
416 {
417  if( m_drawToolBar )
418  return;
419 
420  wxWindowUpdateLocker dummy( this );
421 
422  m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
423  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
424 
425  // Set up toolbar
426  m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiBitmap( cursor_xpm ),
427  wxEmptyString, 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  _( "Route tracks" ), wxITEM_CHECK );
444 
445  m_drawToolBar->AddTool( ID_PCB_DRAW_VIA_BUTT, wxEmptyString, KiBitmap( add_via_xpm ),
446  _( "Add vias" ), wxITEM_CHECK );
447 
448  m_drawToolBar->AddTool( ID_PCB_ZONES_BUTT, wxEmptyString, KiBitmap( add_zone_xpm ),
449  _( "Add filled zones" ), wxITEM_CHECK );
450 
451  m_drawToolBar->AddTool( ID_PCB_KEEPOUT_AREA_BUTT, wxEmptyString,
452  KiBitmap( add_keepout_area_xpm ),
453  _( "Add keepout areas" ), wxITEM_CHECK );
454 
455  m_drawToolBar->AddSeparator();
456  m_drawToolBar->AddTool( ID_PCB_ADD_LINE_BUTT, wxEmptyString, KiBitmap( add_dashed_line_xpm ),
457  _( "Add graphic line or polygon" ), 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_TEXT_BUTT, wxEmptyString, KiBitmap( text_xpm ),
466  _( "Add text on copper layers or graphic text" ), wxITEM_CHECK );
467 
468  m_drawToolBar->AddSeparator();
469  m_drawToolBar->AddTool( ID_PCB_DIMENSION_BUTT, wxEmptyString, KiBitmap( add_dimension_xpm ),
470  _( "Add dimension" ), wxITEM_CHECK );
471 
472  m_drawToolBar->AddTool( ID_PCB_MIRE_BUTT, wxEmptyString, KiBitmap( add_mires_xpm ),
473  _( "Add layer alignment target" ), wxITEM_CHECK );
474 
475  m_drawToolBar->AddSeparator();
476  m_drawToolBar->AddTool( ID_PCB_DELETE_ITEM_BUTT, wxEmptyString, KiBitmap( delete_xpm ),
477  _( "Delete items" ), wxITEM_CHECK );
478 
479  m_drawToolBar->AddSeparator();
480  m_drawToolBar->AddTool( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxEmptyString,
481  KiBitmap( pcb_offset_xpm ),
482  _( "Place the origin point for drill and place files" ),
483  wxITEM_CHECK );
484 
485  m_drawToolBar->AddTool( ID_PCB_PLACE_GRID_COORD_BUTT, wxEmptyString,
486  KiBitmap( grid_select_axis_xpm ),
487  _( "Set the origin point for the grid" ),
488  wxITEM_CHECK );
489 
490  m_drawToolBar->AddTool( ID_PCB_MEASUREMENT_TOOL, wxEmptyString,
491  KiBitmap( measurement_xpm ),
492  _( "Measure distance" ),
493  wxITEM_CHECK );
494 
495  m_drawToolBar->Realize();
496 }
497 
498 
499 /* Create the auxiliary vertical right toolbar, showing tools for microwave applications
500  */
502 {
503  if( m_microWaveToolBar )
504  return;
505 
506  wxWindowUpdateLocker dummy(this);
507 
508  m_microWaveToolBar = new wxAuiToolBar( this, ID_MICROWAVE_V_TOOLBAR, wxDefaultPosition,
509  wxDefaultSize,
510  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
511 
512  // Set up toolbar
513  m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_SELF_CMD, wxEmptyString,
514  KiBitmap( mw_add_line_xpm ),
515  _( "Create line of specified length for microwave applications" ),
516  wxITEM_CHECK );
517 
518  m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_GAP_CMD, wxEmptyString,
519  KiBitmap( mw_add_gap_xpm ),
520  _( "Create gap of specified length for microwave applications" ),
521  wxITEM_CHECK );
522 
523  m_microWaveToolBar->AddSeparator();
524 
525  m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_CMD, wxEmptyString,
526  KiBitmap( mw_add_stub_xpm ),
527  _( "Create stub of specified length for microwave applications" ),
528  wxITEM_CHECK );
529 
530  m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD, wxEmptyString,
531  KiBitmap( mw_add_stub_arc_xpm ),
532  _( "Create stub (arc) of specified length for microwave applications" ),
533  wxITEM_CHECK );
534 
536  KiBitmap( mw_add_shape_xpm ),
537  _( "Create a polynomial shape for microwave applications" ),
538  wxITEM_CHECK );
539 
540  m_microWaveToolBar->Realize();
541 }
542 
543 
545 {
546  wxWindowUpdateLocker dummy( this );
547 
548  if( m_auxiliaryToolBar )
549  {
552 
553  // combobox sizes can have changed: apply new best sizes
554  wxAuiToolBarItem* item = m_auxiliaryToolBar->FindTool( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH );
555  item->SetMinSize( m_SelTrackWidthBox->GetBestSize() );
557  item->SetMinSize( m_SelViaSizeBox->GetBestSize() );
558 
559  m_auxiliaryToolBar->Realize();
560  m_auimgr.Update();
561  return;
562  }
563 
564  m_auxiliaryToolBar = new wxAuiToolBar( this, ID_AUX_TOOLBAR, wxDefaultPosition, wxDefaultSize,
565  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
566 
567  /* Set up toolbar items */
568 
569  // Creates box to display and choose tracks widths:
570  m_SelTrackWidthBox = new wxChoice( m_auxiliaryToolBar,
572  wxDefaultPosition, wxDefaultSize,
573  0, NULL );
575  m_auxiliaryToolBar->AddControl( m_SelTrackWidthBox );
576 
577  // Creates box to display and choose vias diameters:
578  m_SelViaSizeBox = new wxChoice( m_auxiliaryToolBar,
580  wxDefaultPosition, wxDefaultSize,
581  0, NULL );
583  m_auxiliaryToolBar->AddControl( m_SelViaSizeBox );
584  m_auxiliaryToolBar->AddSeparator();
585 
586  // Creates box to display and choose strategy to handle tracks an vias sizes:
588  wxEmptyString,
589  KiBitmap( auto_track_width_xpm ),
590  _( "Auto track width: when starting on an existing track "
591  "use its width\notherwise, use current width setting" ),
592  wxITEM_CHECK );
593 
594  // Add the box to display and select the current grid size:
595  m_auxiliaryToolBar->AddSeparator();
596  m_gridSelectBox = new wxChoice( m_auxiliaryToolBar,
598  wxDefaultPosition, wxDefaultSize,
599  0, NULL );
601  m_auxiliaryToolBar->AddControl( m_gridSelectBox );
602 
603  // Add the box to display and select the current Zoom
604  m_auxiliaryToolBar->AddSeparator();
605  m_zoomSelectBox = new wxChoice( m_auxiliaryToolBar,
607  wxDefaultPosition, wxDefaultSize,
608  0, NULL );
610  m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
611 
612  // after adding the buttons to the toolbar, must call Realize()
613  m_auxiliaryToolBar->Realize();
614 }
615 
616 
618 {
619  if( m_SelTrackWidthBox == NULL )
620  return;
621 
622  wxString msg;
623  bool mmFirst = g_UserUnit != INCHES;
624 
625  m_SelTrackWidthBox->Clear();
626 
627  for( unsigned ii = 0; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
628  {
629  int size = GetDesignSettings().m_TrackWidthList[ii];
630 
631  double valueMils = To_User_Unit( INCHES, size ) * 1000;
632  double value_mm = To_User_Unit( MILLIMETRES, size );
633 
634  if( mmFirst )
635  msg.Printf( _( "Track: %.3f mm (%.2f mils)" ),
636  value_mm, valueMils );
637  else
638  msg.Printf( _( "Track: %.2f mils (%.3f mm)" ),
639  valueMils, value_mm );
640 
641  // Mark the netclass track width value (the first in list)
642  if( ii == 0 )
643  msg << wxT( " *" );
644 
645  m_SelTrackWidthBox->Append( msg );
646  }
647 
648  if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
650 
651  m_SelTrackWidthBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
652 }
653 
654 
656 {
657  if( m_SelViaSizeBox == NULL )
658  return;
659 
660  wxString msg;
661 
662  m_SelViaSizeBox->Clear();
663  bool mmFirst = g_UserUnit != INCHES;
664 
665  for( unsigned ii = 0; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
666  {
667  int diam = GetDesignSettings().m_ViasDimensionsList[ii].m_Diameter;
668 
669  double valueMils = To_User_Unit( INCHES, diam ) * 1000;
670  double value_mm = To_User_Unit( MILLIMETRES, diam );
671 
672  if( mmFirst )
673  msg.Printf( _( "Via: %.2f mm (%.1f mils)" ),
674  value_mm, valueMils );
675  else
676  msg.Printf( _( "Via: %.1f mils (%.2f mm)" ),
677  valueMils, value_mm );
678 
679  int hole = GetDesignSettings().m_ViasDimensionsList[ii].m_Drill;
680 
681  if( hole )
682  {
683  msg << wxT("/ ");
684  wxString hole_str;
685  valueMils = To_User_Unit( INCHES, hole ) * 1000;
686  value_mm = To_User_Unit( MILLIMETRES, hole );
687 
688  if( mmFirst )
689  hole_str.Printf( _( "%.2f mm (%.1f mils)" ),
690  value_mm, valueMils );
691  else
692  hole_str.Printf( _( "%.1f mils (%.2f mm)" ),
693  valueMils, value_mm );
694 
695  msg += hole_str;
696  }
697 
698  // Mark the netclass via size value (the first in list)
699  if( ii == 0 )
700  msg << wxT( " *" );
701 
702  m_SelViaSizeBox->Append( msg );
703  }
704 
705  if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )
707 
708  m_SelViaSizeBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
709 }
710 
711 
712 void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
713 {
714  if( m_SelLayerBox == NULL || m_mainToolBar == NULL )
715  return;
716 
717  m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
720 
721  if( aForceResizeToolbar )
722  {
723  // the layer box can have its size changed
724  // Update the aui manager, to take in account the new size
725  m_auimgr.Update();
726  }
727 }
728 
729 
730 void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
731 {
732  int id = event.GetId();
733  bool state = event.IsChecked();
735 
736  switch( id )
737  {
739  g_Drc_On = !state;
740 
741  if( GetToolId() == ID_TRACK_BUTT )
742  {
743  if( g_Drc_On )
744  m_canvas->SetCursor( wxCURSOR_PENCIL );
745  else
746  m_canvas->SetCursor( wxCURSOR_QUESTION_ARROW );
747  }
748  break;
749 
752  OnModify();
753  Compile_Ratsnest( NULL, true );
754 
755  m_canvas->Refresh();
756  break;
757 
759  g_AutoDeleteOldTrack = state;
760  break;
761 
763  displ_opts->m_DisplayZonesMode = 0;
764  m_canvas->Refresh();
765  break;
766 
768  displ_opts->m_DisplayZonesMode = 1;
769  m_canvas->Refresh();
770  break;
771 
773  displ_opts->m_DisplayZonesMode = 2;
774  m_canvas->Refresh();
775  break;
776 
778  displ_opts->m_DisplayViaFill = !state;
779  m_canvas->Refresh();
780  break;
781 
783  displ_opts->m_DisplayPcbTrackFill = !state;
784  m_canvas->Refresh();
785  break;
786 
788  {
789  displ_opts->m_ContrastModeDisplay = state;
790  m_canvas->Refresh();
791  break;
792  }
793 
795  m_show_microwave_tools = state;
796  m_auimgr.GetPane( wxT( "m_microWaveToolBar" ) ).Show( m_show_microwave_tools );
797  m_auimgr.Update();
798 
799  GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_MUWAVE_TOOLBAR,
801  _( "Hide Microwa&ve Toolbar" ): _( "Show Microwa&ve Toolbar" ));
802  break;
803 
805  // show auxiliary Vertical layers and visibility manager toolbar
807  m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools );
808  m_auimgr.Update();
809 
810  GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER,
812  _( "Hide &Layers Manager" ) : _( "Show &Layers Manager" ) );
813  break;
814 
815  default:
816  DisplayError( this,
817  wxT( "PCB_EDIT_FRAME::OnSelectOptionToolbar error \n (event not handled!)" ) );
818  break;
819  }
820 }
COLOR4D GetLayerColor(PCB_LAYER_ID aLayer) const
Function GetLayerColor gets a layer color for any valid layer, including non-copper ones...
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:993
bool g_Drc_On
Definition: pcbnew.cpp:70
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
Definition: pcbframe.cpp:933
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:93
bool g_AutoDeleteOldTrack
Definition: pcbnew.cpp:71
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:501
Class BOARD to handle a board.
wxChoice * m_SelViaSizeBox
Definition: wxPcbStruct.h:240
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:712
BOARD * GetBoard() const
Class to display a pcb layer list in a wxBitmapComboBox.
COLOR4D GetVisibleElementColor(GAL_LAYER_ID LAYER_aPCB)
Function GetVisibleElementColor returns the color of a pcb visible element.
wxAuiManager m_auimgr
Definition: wxstruct.h:140
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:730
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:415
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:326
COLORS_DESIGN_SETTINGS g_ColorsSettings
Definition: pcbnew.cpp:68
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
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:57
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:655
#define HELP_ZOOM_IN
#define HELP_SHOW_HIDE_LAYERMANAGER
int GetToolId() const
Definition: draw_frame.h:419
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
static const char * text_xpm[]
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
Definition: wxPcbStruct.h:238
void updateZoomSelectBox()
void updateTraceWidthSelectBox()
Definition: tool_pcb.cpp:617
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
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:544
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