KiCad PCB EDA Suite
pcbframe.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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2013-2016 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 2013-2017 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 <pgm_base.h>
35 #include <class_drawpanel.h>
36 #include <confirm.h>
37 #include <wxPcbStruct.h>
38 #include <collectors.h>
39 #include <build_version.h>
40 #include <macros.h>
42 #include <msgpanel.h>
43 #include <fp_lib_table.h>
44 #include <bitmaps.h>
45 
46 #include <pcbnew.h>
47 #include <pcbnew_id.h>
48 #include <drc_stuff.h>
49 #include <layer_widget.h>
50 #include <dialog_design_rules.h>
51 #include <class_pcb_layer_widget.h>
52 #include <hotkeys.h>
53 #include <pcbnew_config.h>
54 #include <module_editor_frame.h>
55 #include <dialog_helpers.h>
56 #include <dialog_plot.h>
58 #include <convert_to_biu.h>
59 #include <view/view.h>
60 #include <view/view_controls.h>
61 #include <pcb_painter.h>
62 #include <invoke_pcb_dialog.h>
63 
64 #include <class_track.h>
65 #include <class_board.h>
66 #include <class_module.h>
67 #include <worksheet_viewitem.h>
68 #include <ratsnest_data.h>
69 #include <ratsnest_viewitem.h>
70 
71 #include <tool/tool_manager.h>
72 #include <tool/tool_dispatcher.h>
73 #include <tools/pcb_actions.h>
74 
76 
77 #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
78 #include <python_scripting.h>
79 #endif
80 
81 #include <pcb_draw_panel_gal.h>
83 #include <functional>
84 
85 using namespace std::placeholders;
86 
89 
90 static const wxString PlotLineWidthEntry = "PlotLineWidth_mm";
91 static const wxString MagneticPadsEntry = "PcbMagPadOpt";
92 static const wxString MagneticTracksEntry = "PcbMagTrackOpt";
93 static const wxString ShowMicrowaveEntry = "ShowMicrowaveTools";
94 static const wxString ShowLayerManagerEntry = "ShowLayerManagerTools";
95 static const wxString ShowPageLimitsEntry = "ShowPageLimits";
96 
98 
99 
100 BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
101  EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV, PCB_EDIT_FRAME::OnSockRequestServer )
102  EVT_SOCKET( ID_EDA_SOCKET_EVENT, PCB_EDIT_FRAME::OnSockRequest )
103 
104  EVT_CHOICE( ID_ON_ZOOM_SELECT, PCB_EDIT_FRAME::OnSelectZoom )
105  EVT_CHOICE( ID_ON_GRID_SELECT, PCB_EDIT_FRAME::OnSelectGrid )
106 
107  EVT_CLOSE( PCB_EDIT_FRAME::OnCloseWindow )
108  EVT_SIZE( PCB_EDIT_FRAME::OnSize )
109 
110  EVT_TOOL( ID_LOAD_FILE, PCB_EDIT_FRAME::Files_io )
113  EVT_TOOL( ID_NEW_BOARD, PCB_EDIT_FRAME::Files_io )
115  EVT_TOOL( ID_OPEN_MODULE_EDITOR, PCB_EDIT_FRAME::Process_Special_Functions )
116  EVT_TOOL( ID_OPEN_MODULE_VIEWER, PCB_EDIT_FRAME::Process_Special_Functions )
117 
118  // Menu Files:
119  EVT_MENU( ID_MAIN_MENUBAR, PCB_EDIT_FRAME::Process_Special_Functions )
121 
126  EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, PCB_EDIT_FRAME::OnFileHistory )
127 
128  EVT_MENU( ID_GEN_PLOT, PCB_EDIT_FRAME::ToPlotter )
129 
130  EVT_MENU( ID_GEN_EXPORT_SPECCTRA, PCB_EDIT_FRAME::ExportToSpecctra )
136 
137  EVT_MENU( ID_GEN_IMPORT_SPECCTRA_SESSION,PCB_EDIT_FRAME::ImportSpecctraSession )
138  EVT_MENU( ID_GEN_IMPORT_SPECCTRA_DESIGN, PCB_EDIT_FRAME::ImportSpecctraDesign )
139  EVT_MENU( ID_GEN_IMPORT_DXF_FILE, PCB_EDIT_FRAME::Process_Special_Functions )
140 
141  EVT_MENU( ID_MENU_ARCHIVE_MODULES_IN_LIBRARY, PCB_EDIT_FRAME::Process_Special_Functions )
143 
144  EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit )
145 
146  // menu Config
147  EVT_MENU( ID_PCB_DRAWINGS_WIDTHS_SETUP, PCB_EDIT_FRAME::OnConfigurePcbOptions )
148  EVT_MENU( ID_PCB_LIB_TABLE_EDIT, PCB_EDIT_FRAME::Process_Config )
149  EVT_MENU( ID_PCB_LIB_WIZARD, PCB_EDIT_FRAME::Process_Config )
152  EVT_MENU( ID_CONFIG_SAVE, PCB_EDIT_FRAME::Process_Config )
153  EVT_MENU( ID_CONFIG_READ, PCB_EDIT_FRAME::Process_Config )
155  PCB_EDIT_FRAME::Process_Config )
158  EVT_MENU( wxID_PREFERENCES, PCB_EDIT_FRAME::Process_Config )
159  EVT_MENU( ID_PCB_LAYERS_SETUP, PCB_EDIT_FRAME::Process_Config )
160  EVT_MENU( ID_PCB_MASK_CLEARANCE, PCB_EDIT_FRAME::Process_Config )
161  EVT_MENU( ID_PCB_PAD_SETUP, PCB_EDIT_FRAME::Process_Config )
162  EVT_MENU( ID_CONFIG_SAVE, PCB_EDIT_FRAME::Process_Config )
163  EVT_MENU( ID_CONFIG_READ, PCB_EDIT_FRAME::Process_Config )
164  EVT_MENU( ID_PCB_DISPLAY_OPTIONS_SETUP, PCB_EDIT_FRAME::InstallDisplayOptionsDialog )
165  EVT_MENU( ID_PCB_USER_GRID_SETUP, PCB_EDIT_FRAME::Process_Special_Functions )
166 
167  // menu Postprocess
168  EVT_MENU( ID_PCB_GEN_POS_MODULES_FILE, PCB_EDIT_FRAME::GenFootprintsPositionFile )
169  EVT_MENU( ID_PCB_GEN_DRILL_FILE, PCB_EDIT_FRAME::InstallDrillFrame )
171  EVT_MENU( ID_PCB_GEN_CMP_FILE, PCB_EDIT_FRAME::RecreateCmpFileFromBoard )
172  EVT_MENU( ID_PCB_GEN_BOM_FILE_FROM_BOARD, PCB_EDIT_FRAME::RecreateBOMFileFromBoard )
173 
174  // menu Miscellaneous
175  EVT_MENU( ID_MENU_LIST_NETS, PCB_EDIT_FRAME::ListNetsAndSelect )
176  EVT_MENU( ID_PCB_EDIT_ALL_VIAS_AND_TRACK_SIZE, PCB_EDIT_FRAME::Process_Special_Functions )
177  EVT_MENU( ID_PCB_GLOBAL_DELETE, PCB_EDIT_FRAME::Process_Special_Functions )
178  EVT_MENU( ID_MENU_PCB_CLEAN, PCB_EDIT_FRAME::Process_Special_Functions )
179  EVT_MENU( ID_MENU_PCB_SWAP_LAYERS, PCB_EDIT_FRAME::Process_Special_Functions )
181  PCB_EDIT_FRAME::OnResetModuleTextSizes )
182 
183  // Menu Help
184  EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
185  EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp )
186  EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute )
187  EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout )
188 
189  // Menu 3D Frame
191 
192  // Switching canvases
196 
197  // Menu Get Design Rules Editor
199 
200  // Horizontal toolbar
201  EVT_TOOL( ID_RUN_LIBRARY, PCB_EDIT_FRAME::Process_Special_Functions )
202  EVT_TOOL( ID_SHEET_SET, EDA_DRAW_FRAME::Process_PageSettings )
203  EVT_TOOL( wxID_CUT, PCB_EDIT_FRAME::Process_Special_Functions )
204  EVT_TOOL( wxID_COPY, PCB_EDIT_FRAME::Process_Special_Functions )
205  EVT_TOOL( wxID_PASTE, PCB_EDIT_FRAME::Process_Special_Functions )
206  EVT_TOOL( wxID_UNDO, PCB_BASE_EDIT_FRAME::RestoreCopyFromUndoList )
207  EVT_TOOL( wxID_REDO, PCB_BASE_EDIT_FRAME::RestoreCopyFromRedoList )
208  EVT_TOOL( wxID_PRINT, PCB_EDIT_FRAME::ToPrinter )
210  EVT_TOOL( ID_GEN_PLOT, PCB_EDIT_FRAME::Process_Special_Functions )
211  EVT_TOOL( ID_FIND_ITEMS, PCB_EDIT_FRAME::Process_Special_Functions )
212  EVT_TOOL( ID_GET_NETLIST, PCB_EDIT_FRAME::Process_Special_Functions )
213  EVT_TOOL( ID_DRC_CONTROL, PCB_EDIT_FRAME::Process_Special_Functions )
214  EVT_TOOL( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, PCB_EDIT_FRAME::Process_Special_Functions )
215  EVT_TOOL( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
216  EVT_COMBOBOX( ID_TOOLBARH_PCB_SELECT_LAYER, PCB_EDIT_FRAME::Process_Special_Functions )
217  EVT_CHOICE( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
218  EVT_CHOICE( ID_AUX_TOOLBAR_PCB_VIA_SIZE, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
219  EVT_TOOL( ID_TOOLBARH_PCB_MODE_MODULE, PCB_EDIT_FRAME::OnSelectAutoPlaceMode )
220  EVT_TOOL( ID_TOOLBARH_PCB_MODE_TRACKS, PCB_EDIT_FRAME::OnSelectAutoPlaceMode )
221  EVT_TOOL( ID_TOOLBARH_PCB_FREEROUTE_ACCESS, PCB_EDIT_FRAME::Access_to_External_Tool )
222 
223 
224 #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
225  EVT_TOOL( ID_TOOLBARH_PCB_ACTION_PLUGIN_REFRESH, PCB_EDIT_FRAME::OnActionPluginRefresh )
226 #endif
227 
228 #if defined( KICAD_SCRIPTING_WXPYTHON )
229  // has meaning only with KICAD_SCRIPTING_WXPYTHON enabled
230  EVT_TOOL( ID_TOOLBARH_PCB_SCRIPTING_CONSOLE, PCB_EDIT_FRAME::ScriptingConsoleEnableDisable )
232  PCB_EDIT_FRAME::OnUpdateScriptingConsoleState )
233 #endif
234 
235  // Option toolbar
239  PCB_EDIT_FRAME::OnSelectOptionToolbar )
241  PCB_EDIT_FRAME::OnSelectOptionToolbar )
243  PCB_EDIT_FRAME::OnSelectOptionToolbar )
245  PCB_EDIT_FRAME::OnSelectOptionToolbar )
247  PCB_EDIT_FRAME::OnSelectOptionToolbar )
249  PCB_EDIT_FRAME::OnSelectOptionToolbar )
250 
251  EVT_TOOL( ID_UPDATE_PCB_FROM_SCH, PCB_EDIT_FRAME::OnUpdatePCBFromSch )
252 
254  PCB_EDIT_FRAME::OnSelectOptionToolbar )
255 
257  PCB_EDIT_FRAME::OnSelectOptionToolbar )
258 
259  // Vertical main toolbar:
261  EVT_TOOL( ID_ZOOM_SELECTION, PCB_EDIT_FRAME::OnSelectTool )
263  PCB_EDIT_FRAME::OnSelectTool )
264 
266  PCB_EDIT_FRAME::ProcessMuWaveFunctions )
267 
269  PCB_EDIT_FRAME::OnPlaceOrRouteFootprints )
270 
272  PCB_EDIT_FRAME::Process_Special_Functions )
273 
274  // Tracks and vias sizes general options
277  PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
278 
279  // popup menus
280  EVT_MENU( ID_POPUP_PCB_DELETE_TRACKSEG, PCB_EDIT_FRAME::Process_Special_Functions )
282  PCB_EDIT_FRAME::Process_Special_Functions )
283 
284  // User interface update event handlers.
285  EVT_UPDATE_UI( ID_SAVE_BOARD, PCB_EDIT_FRAME::OnUpdateSave )
286  EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, PCB_EDIT_FRAME::OnUpdateLayerPair )
287  EVT_UPDATE_UI( ID_TOOLBARH_PCB_SELECT_LAYER, PCB_EDIT_FRAME::OnUpdateLayerSelectBox )
288  EVT_UPDATE_UI( ID_TB_OPTIONS_DRC_OFF, PCB_EDIT_FRAME::OnUpdateDrcEnable )
289  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_RATSNEST, PCB_EDIT_FRAME::OnUpdateShowBoardRatsnest )
290  EVT_UPDATE_UI( ID_TB_OPTIONS_AUTO_DEL_TRACK, PCB_EDIT_FRAME::OnUpdateAutoDeleteTrack )
291  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, PCB_EDIT_FRAME::OnUpdateViaDrawMode )
292  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, PCB_EDIT_FRAME::OnUpdateTraceDrawMode )
293  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE,
294  PCB_EDIT_FRAME::OnUpdateHighContrastDisplayMode )
295  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR,
296  PCB_EDIT_FRAME::OnUpdateShowLayerManager )
297  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE,
298  PCB_EDIT_FRAME::OnUpdateShowMicrowaveToolbar )
299  EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, PCB_EDIT_FRAME::OnUpdateVerticalToolbar )
300  EVT_UPDATE_UI( ID_ZOOM_SELECTION, PCB_EDIT_FRAME::OnUpdateVerticalToolbar )
301  EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, PCB_EDIT_FRAME::OnUpdateSelectTrackWidth )
302  EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH,
303  PCB_EDIT_FRAME::OnUpdateSelectAutoTrackWidth )
304  EVT_UPDATE_UI( ID_POPUP_PCB_SELECT_AUTO_WIDTH, PCB_EDIT_FRAME::OnUpdateSelectAutoTrackWidth )
306  PCB_EDIT_FRAME::OnUpdateSelectCustomTrackWidth )
307  EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_VIA_SIZE, PCB_EDIT_FRAME::OnUpdateSelectViaSize )
308  EVT_UPDATE_UI( ID_TOOLBARH_PCB_MODE_MODULE, PCB_EDIT_FRAME::OnUpdateAutoPlaceModulesMode )
309  EVT_UPDATE_UI( ID_TOOLBARH_PCB_MODE_TRACKS, PCB_EDIT_FRAME::OnUpdateAutoPlaceTracksMode )
311  PCB_EDIT_FRAME::OnUpdateSelectTrackWidth )
313  PCB_EDIT_FRAME::OnUpdateSelectViaSize )
314  EVT_UPDATE_UI_RANGE( ID_PCB_HIGHLIGHT_BUTT, ID_PCB_MEASUREMENT_TOOL,
315  PCB_EDIT_FRAME::OnUpdateVerticalToolbar )
316  EVT_UPDATE_UI_RANGE( ID_TB_OPTIONS_SHOW_ZONES, ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY,
317  PCB_EDIT_FRAME::OnUpdateZoneDisplayStyle )
318  EVT_UPDATE_UI_RANGE( ID_PCB_MUWAVE_START_CMD, ID_PCB_MUWAVE_END_CMD,
319  PCB_EDIT_FRAME::OnUpdateMuWaveToolbar )
320 
321  EVT_COMMAND( wxID_ANY, LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE, PCB_EDIT_FRAME::OnLayerColorChange )
322 END_EVENT_TABLE()
323 
324 
325 PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
326  PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB, wxT( "Pcbnew" ), wxDefaultPosition,
328 {
329  m_showBorderAndTitleBlock = true; // true to display sheet references
330  m_showAxis = false; // true to display X and Y axis
331  m_showOriginAxis = true;
332  m_showGridAxis = true;
333  m_SelTrackWidthBox = NULL;
334  m_SelViaSizeBox = NULL;
335  m_SelLayerBox = NULL;
336  m_show_microwave_tools = false;
337  m_show_layer_manager_tools = true;
338  m_hotkeysDescrList = g_Board_Editor_Hokeys_Descr;
339  m_hasAutoSave = true;
340  m_microWaveToolBar = NULL;
341 
342  m_rotationAngle = 900;
343 
344  // Create GAL canvas
345  EDA_DRAW_PANEL_GAL* galCanvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ),
346  m_FrameSize,
347  GetGalDisplayOptions(),
349 
350  SetGalCanvas( galCanvas );
351 
352  SetBoard( new BOARD() );
353 
354  // Create the PCB_LAYER_WIDGET *after* SetBoard():
355 
356  wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
357  int pointSize = font.GetPointSize();
358  int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
359 
360  // printf( "pointSize:%d 80%%:%d\n", pointSize, (pointSize*8)/10 );
361 
362  if( screenHeight <= 900 )
363  pointSize = (pointSize * 8) / 10;
364 
365  m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), pointSize );
366 
367  m_drc = new DRC( this ); // these 2 objects point to each other
368 
369  wxIcon icon;
370  icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) );
371  SetIcon( icon );
372 
373  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
374  // initialize parameters in m_LayersManager
375  LoadSettings( config() );
376 
377  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
378  GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
379 
380  // PCB drawings start in the upper left corner.
381  GetScreen()->m_Center = false;
382 
383  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
384 
385  GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
386  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
387 
388  if( m_canvas )
389  m_canvas->SetEnableBlockCommands( true );
390 
391  ReCreateMenuBar();
392  ReCreateHToolbar();
393  ReCreateAuxiliaryToolbar();
394  ReCreateVToolbar();
395  ReCreateOptToolbar();
396 
397  ReCreateMicrowaveVToolbar();
398 
399  m_auimgr.SetManagedWindow( this );
400 
401  EDA_PANEINFO horiz;
402  horiz.HorizontalToolbarPane();
403 
404  EDA_PANEINFO vert;
405  vert.VerticalToolbarPane();
406 
407  EDA_PANEINFO mesg;
408  mesg.MessageToolbarPane();
409 
410  // Create a wxAuiPaneInfo for the Layers Manager, not derived from the template.
411  // LAYER_WIDGET is floatable, but initially docked at far right
412  EDA_PANEINFO lyrs;
413  lyrs.LayersToolbarPane();
414  lyrs.MinSize( m_Layers->GetBestSize() ); // updated in ReFillLayerWidget
415  lyrs.BestSize( m_Layers->GetBestSize() );
416  lyrs.Caption( _( "Visibles" ) );
417  lyrs.TopDockable( false ).BottomDockable( false );
418 
419  if( m_mainToolBar ) // The main horizontal toolbar
420  {
421  m_auimgr.AddPane( m_mainToolBar,
422  wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) );
423  }
424 
425  if( m_auxiliaryToolBar ) // the auxiliary horizontal toolbar, that shows track and via sizes, zoom ...)
426  {
427  m_auimgr.AddPane( m_auxiliaryToolBar,
428  wxAuiPaneInfo( horiz ).Name( wxT( "m_auxiliaryToolBar" ) ).Top().Row( 1 ) );
429  }
430 
431  if( m_microWaveToolBar ) // The auxiliary vertical right toolbar (currently microwave tools)
432  m_auimgr.AddPane( m_microWaveToolBar,
433  wxAuiPaneInfo( vert ).Name( wxT( "m_microWaveToolBar" ) ).
434  Right().Layer( 1 ).Position(1).Hide() );
435 
436  if( m_drawToolBar ) // The main right vertical toolbar
437  m_auimgr.AddPane( m_drawToolBar,
438  wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right().Layer( 2 ) );
439 
440  // Add the layer manager ( most right side of pcbframe )
441  m_auimgr.AddPane( m_Layers, lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Layer( 3 ) );
442 
443  if( m_optionsToolBar ) // The left vertical toolbar (fast acces display options of Pcbnew)
444  {
445  m_auimgr.AddPane( m_optionsToolBar,
446  wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ).Left().Layer(1) );
447 
448  m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools );
449  m_auimgr.GetPane( wxT( "m_microWaveToolBar" ) ).Show( m_show_microwave_tools );
450  }
451 
452  if( m_canvas )
453  m_auimgr.AddPane( m_canvas,
454  wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
455 
456  if( GetGalCanvas() )
457  m_auimgr.AddPane( (wxWindow*) GetGalCanvas(),
458  wxAuiPaneInfo().Name( wxT( "DrawFrameGal" ) ).CentrePane().Hide() );
459 
460  if( m_messagePanel )
461  m_auimgr.AddPane( m_messagePanel,
462  wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) );
463 
464  ReFillLayerWidget(); // this is near end because contents establish size
465  m_Layers->ReFillRender(); // Update colors in Render after the config is read
466  syncLayerWidgetLayer();
467 
468  m_auimgr.Update();
469 
470  setupTools();
471 
472  Zoom_Automatique( false );
473 
474  EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = LoadCanvasTypeSetting();
475 
476  if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
477  {
478  if( GetGalCanvas()->SwitchBackend( canvasType ) )
479  UseGalCanvas( true );
480  }
481 
482  enableGALSpecificMenus();
483 
484  // disable Export STEP item if kicad2step does not exist
485  wxString strK2S = Pgm().GetExecutablePath();
486  #ifdef __WXMAC__
487  strK2S += "Contents/MacOS/";
488  #endif
489  wxFileName appK2S( strK2S, "kicad2step" );
490 
491  #ifdef _WIN32
492  appK2S.SetExt( "exe" );
493  #endif
494 
495  if( !appK2S.FileExists() )
496  GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
497 }
498 
499 
501 {
502  delete m_drc;
503 }
504 
505 
507 {
509 
510  if( IsGalCanvasActive() )
511  {
512  aBoard->GetRatsnest()->ProcessBoard();
513 
514  // reload the worksheet
515  SetPageSettings( aBoard->GetPageSettings() );
516  }
517 }
518 
519 
521 {
522  return m_Pcb;
523 }
524 
525 
526 void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
527 {
528  PCB_BASE_FRAME::SetPageSettings( aPageSettings );
529 
530  if( IsGalCanvasActive() )
531  {
532  PCB_DRAW_PANEL_GAL* drawPanel = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
533 
534  // Prepare worksheet template
535  KIGFX::WORKSHEET_VIEWITEM* worksheet;
536  worksheet = new KIGFX::WORKSHEET_VIEWITEM( &m_Pcb->GetPageSettings(),
537  &m_Pcb->GetTitleBlock() );
538  worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );
539 
540  BASE_SCREEN* screen = GetScreen();
541 
542  if( screen != NULL )
543  {
544  worksheet->SetSheetNumber( screen->m_ScreenNumber );
545  worksheet->SetSheetCount( screen->m_NumberOfScreens );
546  }
547 
548  // PCB_DRAW_PANEL_GAL takes ownership of the worksheet
549  drawPanel->SetWorksheet( worksheet );
550  }
551 }
552 
553 
555 {
556  if( GetScreen() )
557  return GetScreen()->IsSave();
558 
559  return false;
560 }
561 
562 
564 {
565  // Create the manager and dispatcher & route draw panel events to the dispatcher
566  m_toolManager = new TOOL_MANAGER;
567  m_toolManager->SetEnvironment( m_Pcb, GetGalCanvas()->GetView(),
568  GetGalCanvas()->GetViewControls(), this );
569  m_actions = new PCB_ACTIONS();
570  m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
571 
572  // Register tools
573  m_actions->RegisterAllTools( m_toolManager );
574  m_toolManager->InitTools();
575 
576  // Run the selection tool, it is supposed to be always active
577  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
578 }
579 
580 
582 {
583  m_Layers->ReFill();
584 
585  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_Layers );
586 
587  wxSize bestz = m_Layers->GetBestSize();
588 
589  lyrs.MinSize( bestz );
590  lyrs.BestSize( bestz );
591  lyrs.FloatingSize( bestz );
592 
593  if( lyrs.IsDocked() )
594  m_auimgr.Update();
595  else
596  m_Layers->SetSize( bestz );
597 }
598 
599 
600 void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event )
601 {
602  Close( false );
603 }
604 
605 
606 void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
607 {
608  m_canvas->SetAbortRequest( true );
609 
610  if( GetScreen()->IsModify() )
611  {
612  wxString msg = wxString::Format( _(
613  "Save the changes in\n"
614  "'%s'\n"
615  "before closing?" ),
616  GetChars( GetBoard()->GetFileName() )
617  );
618 
619  int ii = DisplayExitDialog( this, msg );
620  switch( ii )
621  {
622  case wxID_CANCEL:
623  Event.Veto();
624  return;
625 
626  case wxID_NO:
627  break;
628 
629  case wxID_YES:
630  // save the board. if the board has no name,
631  // the ID_SAVE_BOARD_AS will actually made
632  Files_io_from_id( ID_SAVE_BOARD );
633  break;
634  }
635  }
636 
637  if( IsGalCanvasActive() )
638  {
639  // On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes
640  // when closing this frame if a footprint was selected, and the footprint editor called
641  // to edit this footprint, and when closing pcbnew if this footprint is still selected
642  // See https://bugs.launchpad.net/kicad/+bug/1655858
643  // I think this is certainly a OpenGL event fired after frame deletion, so this workaround
644  // avoid the crash (JPC)
645  GetGalCanvas()->SetEvtHandlerEnabled( false );
646  }
647 
648  GetGalCanvas()->StopDrawing();
649 
650  // Delete the auto save file if it exists.
651  wxFileName fn = GetBoard()->GetFileName();
652 
653  // Auto save file name is the normal file name prefixed with '_autosave'.
654  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
655 
656  // When the auto save feature does not have write access to the board file path, it falls
657  // back to a platform specific user temporary file path.
658  if( !fn.IsOk() || !fn.IsDirWritable() )
659  fn.SetPath( wxFileName::GetTempDir() );
660 
661  wxLogTrace( traceAutoSave, "Deleting auto save file <" + fn.GetFullPath() + ">" );
662 
663  // Remove the auto save file on a normal close of Pcbnew.
664  if( fn.FileExists() && !wxRemoveFile( fn.GetFullPath() ) )
665  {
666  wxString msg = wxString::Format( _(
667  "The auto save file '%s' could not be removed!" ),
668  GetChars( fn.GetFullPath() )
669  );
670 
671  wxMessageBox( msg, Pgm().App().GetAppName(), wxOK | wxICON_ERROR, this );
672  }
673 
674  // Delete board structs and undo/redo lists, to avoid crash on exit
675  // when deleting some structs (mainly in undo/redo lists) too late
676  Clear_Pcb( false );
677 
678  // do not show the window because ScreenPcb will be deleted and we do not
679  // want any paint event
680  Show( false );
681 
682  Destroy();
683 }
684 
685 
686 void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
687 {
688  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
689 
690  if( draw3DFrame )
691  {
692  // Raising the window does not show the window on Windows if iconized.
693  // This should work on any platform.
694  if( draw3DFrame->IsIconized() )
695  draw3DFrame->Iconize( false );
696 
697  draw3DFrame->Raise();
698 
699  // Raising the window does not set the focus on Linux. This should work on any platform.
700  if( wxWindow::FindFocus() != draw3DFrame )
701  draw3DFrame->SetFocus();
702 
703  return;
704  }
705 
706  draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
707  draw3DFrame->SetDefaultFileName( GetBoard()->GetFileName() );
708  draw3DFrame->Raise(); // Needed with some Window Managers
709  draw3DFrame->Show( true );
710 }
711 
712 
713 void PCB_EDIT_FRAME::UseGalCanvas( bool aEnable )
714 {
715  if( !aEnable )
716  Compile_Ratsnest( NULL, true );
717 
719 
720  enableGALSpecificMenus();
721 
722  // Force colors to be legacy-compatible in case they were changed in GAL
723  if( !aEnable )
724  {
725  forceColorsToLegacy();
726  Refresh();
727  }
728 
729  // Re-create the layer manager to allow arbitrary colors when GAL is enabled
730  ReFillLayerWidget();
731  m_Layers->ReFillRender();
732 }
733 
734 
736 {
738 
739  for( unsigned i = 0; i < DIM( cds->m_LayersColors ); i++ )
740  {
741  COLOR4D c = cds->GetLayerColor( i );
742  c.SetToNearestLegacyColor();
743  c.a = 0.8;
744  cds->SetLayerColor( i, c );
745  }
746 }
747 
748 
750 {
751  // some menus are active only in GAL mode and do nothing in legacy mode.
752  // So enable or disable them, depending on the display mode
753 
754  if( GetMenuBar() )
755  {
756  // Enable / disable some menus which are usable only on GAL
757  pcbnew_ids id_list[] =
758  {
765  ID_MENU_PCB_FLIP_VIEW
766  };
767 
768  bool enbl = IsGalCanvasActive();
769 
770  for( unsigned ii = 0; ii < DIM( id_list ); ii++ )
771  {
772  if( GetMenuBar()->FindItem( id_list[ii] ) )
773  GetMenuBar()->FindItem( id_list[ii] )->Enable( enbl );
774  }
775  }
776 }
777 
778 
779 void PCB_EDIT_FRAME::ShowDesignRulesEditor( wxCommandEvent& event )
780 {
781  DIALOG_DESIGN_RULES dR_editor( this );
782  int returncode = dR_editor.ShowModal();
783 
784  if( returncode == wxID_OK ) // New rules, or others changes.
785  {
786  ReCreateLayerBox();
787  ReCreateAuxiliaryToolbar();
788  OnModify();
789  }
790 }
791 
792 
793 void PCB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
794 {
796 
797  wxConfigLoadSetups( aCfg, GetConfigurationSettings() );
798 
799  double dtmp;
800  aCfg->Read( PlotLineWidthEntry, &dtmp, 0.1 ); // stored in mm
801 
802  if( dtmp < 0.01 )
803  dtmp = 0.01;
804 
805  if( dtmp > 5.0 )
806  dtmp = 5.0;
807 
808  g_DrawDefaultLineThickness = Millimeter2iu( dtmp );
809 
810  aCfg->Read( MagneticPadsEntry, &g_MagneticPadOption );
812  aCfg->Read( ShowMicrowaveEntry, &m_show_microwave_tools );
813  aCfg->Read( ShowLayerManagerEntry, &m_show_layer_manager_tools );
814  aCfg->Read( ShowPageLimitsEntry, &m_showPageLimits );
815 }
816 
817 
818 void PCB_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
819 {
821 
822  wxConfigSaveSetups( aCfg, GetConfigurationSettings() );
823 
824  // This value is stored in mm )
825  aCfg->Write( PlotLineWidthEntry, MM_PER_IU * g_DrawDefaultLineThickness );
826  aCfg->Write( MagneticPadsEntry, (long) g_MagneticPadOption );
827  aCfg->Write( MagneticTracksEntry, (long) g_MagneticTrackOption );
828  aCfg->Write( ShowMicrowaveEntry, (long) m_show_microwave_tools );
829  aCfg->Write( ShowLayerManagerEntry, (long)m_show_layer_manager_tools );
830  aCfg->Write( ShowPageLimitsEntry, m_showPageLimits );
831 }
832 
833 
835 {
836  return IsElementVisible( LAYER_GRID );
837 }
838 
839 
841 {
842  SetElementVisibility( LAYER_GRID, aVisible );
843 }
844 
845 
847 {
849 }
850 
851 
853 {
854 
856 
857  if( IsGalCanvasActive() )
858  {
859  GetGalCanvas()->GetGAL()->SetGridColor( aColor );
860  }
861 }
862 
863 
865 {
866  int copperlayercnt = GetBoard()->GetCopperLayerCount( );
867  PCB_LAYER_ID currLayer = GetActiveLayer();
868 
869  if( !GetDesignSettings().m_MicroViasAllowed )
870  return false; // Obvious..
871 
872  if( copperlayercnt < 4 )
873  return false; // Only on multilayer boards..
874 
875  if( ( currLayer == B_Cu )
876  || ( currLayer == F_Cu )
877  || ( currLayer == copperlayercnt - 2 )
878  || ( currLayer == In1_Cu ) )
879  return true;
880 
881  return false;
882 }
883 
884 
886 {
888 
889  syncLayerWidgetLayer();
890 
891  if( IsGalCanvasActive() )
892  {
893  m_toolManager->RunAction( PCB_ACTIONS::layerChanged ); // notify other tools
894  GetGalCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
895 
896  GetGalCanvas()->SetHighContrastLayer( aLayer );
897  GetGalCanvas()->Refresh();
898  }
899 }
900 
901 
903 {
904  m_Layers->SelectLayer( GetActiveLayer() );
905  m_Layers->OnLayerSelected();
906 }
907 
908 
910 {
911  m_Layers->SyncRenderStates();
912 }
913 
914 
916 {
917  m_Layers->SyncLayerVisibilities();
918  static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( m_Pcb );
919 }
920 
921 
923 {
924  PCB_BASE_FRAME::unitsChangeRefresh(); // Update the grid size select box.
925 
926  ReCreateAuxiliaryToolbar();
927 }
928 
929 
931 {
932  return GetBoard()->IsElementVisible( aElement );
933 }
934 
935 
936 void PCB_EDIT_FRAME::SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState )
937 {
938  GetGalCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
939  GetBoard()->SetElementVisibility( aElement, aNewState );
940  m_Layers->SetRenderState( aElement, aNewState );
941 }
942 
943 
945 {
947 
949  m_Layers->SetRenderState( ii, true );
950 }
951 
952 
954 {
955  // call my base class
957 
958  m_Layers->SetLayersManagerTabsText();
959 
960  wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_Layers );
961 
962  pane_info.Caption( _( "Visibles" ) );
963  m_auimgr.Update();
964  ReFillLayerWidget();
965 }
966 
967 
969 {
970  wxFileName absoluteFileName = m_lastNetListRead;
971  wxFileName pcbFileName = GetBoard()->GetFileName();
972 
973  if( !absoluteFileName.MakeAbsolute( pcbFileName.GetPath() ) || !absoluteFileName.FileExists() )
974  {
975  absoluteFileName.Clear();
976  m_lastNetListRead = wxEmptyString;
977  }
978 
979  return absoluteFileName.GetFullPath();
980 }
981 
982 
983 void PCB_EDIT_FRAME::SetLastNetListRead( const wxString& aLastNetListRead )
984 {
985  wxFileName relativeFileName = aLastNetListRead;
986  wxFileName pcbFileName = GetBoard()->GetFileName();
987 
988  if( relativeFileName.MakeRelativeTo( pcbFileName.GetPath() )
989  && relativeFileName.GetFullPath() != aLastNetListRead )
990  {
991  m_lastNetListRead = relativeFileName.GetFullPath();
992  }
993 }
994 
995 
997 {
999 
1000  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
1001 
1002  if( draw3DFrame )
1003  draw3DFrame->ReloadRequest();
1004 }
1005 
1006 
1007 void PCB_EDIT_FRAME::SVG_Print( wxCommandEvent& event )
1008 {
1009  PCB_PLOT_PARAMS tmp = GetPlotSettings();
1010 
1011  // we don't want dialogs knowing about complex wxFrame functions so
1012  // pass everything the dialog needs without reference to *this frame's class.
1013  if( InvokeSVGPrint( this, GetBoard(), &tmp ) )
1014  {
1015  if( tmp != GetPlotSettings() )
1016  {
1017  SetPlotSettings( tmp );
1018  OnModify();
1019  }
1020  }
1021 }
1022 
1023 
1025 {
1026  wxFileName fileName = GetBoard()->GetFileName();
1027  wxString fileinfo;
1028 
1029  if( fileName.IsOk() && fileName.FileExists() )
1030  {
1031  fileinfo = fileName.IsFileWritable()
1032  ? wxString( wxEmptyString )
1033  : _( " [Read Only]" );
1034  }
1035  else
1036  {
1037  fileinfo = _( " [new file]" );
1038  }
1039 
1040  wxString title;
1041  title.Printf( L"Pcbnew \u2014 %s%s",
1042  fileName.GetFullPath(),
1043  fileinfo );
1044 
1045  SetTitle( title );
1046 }
1047 
1048 
1049 #if defined( KICAD_SCRIPTING_WXPYTHON )
1050 
1051 void PCB_EDIT_FRAME::ScriptingConsoleEnableDisable( wxCommandEvent& aEvent )
1052 {
1053 
1054  wxWindow * pythonPanelFrame = findPythonConsole();
1055  bool pythonPanelShown = true;
1056 
1057  if( pythonPanelFrame == NULL )
1058  pythonPanelFrame = CreatePythonShellWindow( this, pythonConsoleNameId() );
1059  else
1060  pythonPanelShown = ! pythonPanelFrame->IsShown();
1061 
1062  if( pythonPanelFrame )
1063  pythonPanelFrame->Show( pythonPanelShown );
1064  else
1065  wxMessageBox( wxT( "Error: unable to create the Python Console" ) );
1066 }
1067 #endif
1068 
1069 
1070 void PCB_EDIT_FRAME::OnSelectAutoPlaceMode( wxCommandEvent& aEvent )
1071 {
1072  // Automatic placement of modules and tracks is a mutually exclusive operation so
1073  // clear the other tool if one of the two is selected.
1074  // Be careful: this event function is called both by the
1075  // ID_TOOLBARH_PCB_MODE_MODULE and the ID_TOOLBARH_PCB_MODE_TRACKS tool
1076  // Therefore we should avoid a race condition when deselecting one of these tools
1077  // inside this function (seems happen on some Linux/wxWidgets versions)
1078  // when the other tool is selected
1079 
1080  switch( aEvent.GetId() )
1081  {
1082  case ID_TOOLBARH_PCB_MODE_MODULE:
1083  if( aEvent.IsChecked() &&
1084  m_mainToolBar->GetToolToggled( ID_TOOLBARH_PCB_MODE_TRACKS ) )
1085  {
1086  m_mainToolBar->ToggleTool( ID_TOOLBARH_PCB_MODE_TRACKS, false );
1087  }
1088  break;
1089 
1090  case ID_TOOLBARH_PCB_MODE_TRACKS:
1091  if( aEvent.IsChecked() &&
1092  m_mainToolBar->GetToolToggled( ID_TOOLBARH_PCB_MODE_MODULE ) )
1093  {
1094  m_mainToolBar->ToggleTool( ID_TOOLBARH_PCB_MODE_MODULE, false );
1095  }
1096  break;
1097  }
1098 }
1099 
1100 
1101 void PCB_EDIT_FRAME::OnLayerColorChange( wxCommandEvent& aEvent )
1102 {
1103  ReCreateLayerBox();
1104 }
1105 
1106 
1107 void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event )
1108 {
1109  DIALOG_PLOT dlg( this );
1110 
1111  dlg.ShowModal();
1112 }
1113 
1114 
1115 bool PCB_EDIT_FRAME::SetCurrentNetClass( const wxString& aNetClassName )
1116 {
1117  bool change = GetDesignSettings().SetCurrentNetClass( aNetClassName );
1118 
1119  if( change )
1120  {
1121  ReCreateAuxiliaryToolbar();
1122  }
1123 
1124  return change;
1125 }
1126 
1127 
1128 void PCB_EDIT_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
1129 {
1130  Pgm().ConfigurePaths( this );
1131 }
1132 
1133 
1134 void PCB_EDIT_FRAME::OnUpdatePCBFromSch( wxCommandEvent& event )
1135 {
1136  if( Kiface().IsSingle() )
1137  {
1138  DisplayError( this, _( "Cannot update the PCB, because the Kicad is"
1139  " opened in stand-alone mode. In order to create/update"
1140  " PCBs from schematics, you need to launch Kicad shell"
1141  " and create a PCB project." ) );
1142  return;
1143  }
1144  else
1145  {
1146  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
1147  wxFileName schfn = Prj().AbsolutePath( Prj().GetProjectName() );
1148 
1149  schfn.SetExt( SchematicFileExtension );
1150 
1151  if( !frame->IsVisible() )
1152  {
1153  frame->OpenProjectFiles( std::vector<wxString>( 1, schfn.GetFullPath() ) );
1154  frame->Show( false );
1155  }
1156 
1158  }
1159 }
1160 
1161 
1162 void PCB_EDIT_FRAME::OnFlipPcbView( wxCommandEvent& evt )
1163 {
1164  auto view = GetGalCanvas()->GetView();
1165  view->SetMirror( evt.IsChecked(), false );
1166  view->RecacheAllItems();
1167  Refresh();
1168 }
1169 
1170 
1172 {
1173  // Reload Python plugins if they are newer than
1174  // the already loaded, and load new plugins
1175 #if defined(KICAD_SCRIPTING)
1176  //Reload plugin list: reload Python plugins if they are newer than
1177  // the already loaded, and load new plugins
1179 
1180  #if defined(KICAD_SCRIPTING_ACTION_MENU)
1181  // Action plugins can be modified, therefore the plugins menu
1182  // must be updated:
1183  RebuildActionPluginMenus();
1184  #endif
1185 #endif
1186 }
1187 
1188 
1190 {
1191  DIALOG_EXCHANGE_MODULE dialog( this, Module );
1192 
1193  return dialog.ShowQuasiModal();
1194 }
void SetWorksheet(KIGFX::WORKSHEET_VIEWITEM *aWorksheet)
Function SetWorksheet Sets (or updates) worksheet used by the draw panel.
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:474
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: pcbframe.cpp:818
void syncRenderStates()
Function syncRenderStates updates the "Render" checkboxes in the layer widget according to current to...
Definition: pcbframe.cpp:909
void UpdateTitle()
Function UpdateTitle sets the main window title bar text.
Definition: pcbframe.cpp:1024
#define DIM(x)
of elements in an array
Definition: macros.h:98
#define KICAD_DEFAULT_DRAWFRAME_STYLE
Definition: wxstruct.h:55
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:996
PCB_EDIT_FRAME::OnResetModuleTextSizes PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectTool PCB_EDIT_FRAME::OnPlaceOrRouteFootprints ID_POPUP_PCB_SELECT_WIDTH_END_RANGE
Definition: pcbframe.cpp:276
void SetPageSettings(const PAGE_INFO &aPageSettings) override
>
Definition: pcbframe.cpp:526
Definition of class FOOTPRINT_EDIT_FRAME.
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:111
bool IsElementVisible(GAL_LAYER_ID LAYER_aPCB) const
Function IsElementVisible tests whether a given element category is visible.
const wxChar traceAutoSave[]
Custom trace mask to enable and disable auto save tracing.
Definition: basicframe.cpp:53
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
Definition: pcbframe.cpp:936
Class that draws missing connections on a PCB.
virtual void unitsChangeRefresh() override
Function unitsChangeRefresh is called when when the units setting has changed to allow for any derive...
void syncLayerWidgetLayer()
Function syncLayerWidgetLayer updates the currently layer "selection" within the PCB_LAYER_WIDGET.
Definition: pcbframe.cpp:902
void OnConfigurePaths(wxCommandEvent &aEvent)
Definition: pcbframe.cpp:1128
virtual void unitsChangeRefresh() override
Function unitsChangeRefresh is called when when the units setting has changed to allow for any derive...
Definition: pcbframe.cpp:922
int InstallExchangeModuleFrame(MODULE *ExchangeModuleModule)
Definition: pcbframe.cpp:1189
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
void UseGalCanvas(bool aEnable) override
>
Definition: pcbframe.cpp:713
void ToPlotter(wxCommandEvent &event)
Function ToPlotter Open a dialog frame to create plot and drill files relative to the current board...
Definition: pcbframe.cpp:1107
This file is part of the common library.
PCB_EDIT_FRAME::OnResetModuleTextSizes PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectTool PCB_EDIT_FRAME::OnPlaceOrRouteFootprints PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event PCB_EDIT_FRAME::OnUpdateHighContrastDisplayMode EVT_UPDATE_UI(ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR, PCB_EDIT_FRAME::OnUpdateShowLayerManager) EVT_UPDATE_UI(ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE
VTBL_ENTRY const wxString & GetExecutablePath() const
Definition: pgm_base.h:173
PCB_EDIT_FRAME::OnResetModuleTextSizes PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectTool PCB_EDIT_FRAME::OnPlaceOrRouteFootprints PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event PCB_EDIT_FRAME::OnUpdateHighContrastDisplayMode PCB_EDIT_FRAME::OnUpdateShowMicrowaveToolbar PCB_EDIT_FRAME::OnUpdateSelectCustomTrackWidth EVT_UPDATE_UI_RANGE(ID_POPUP_PCB_SELECT_WIDTH1, ID_POPUP_PCB_SELECT_WIDTH8, PCB_EDIT_FRAME::OnUpdateSelectTrackWidth) EVT_UPDATE_UI_RANGE(ID_POPUP_PCB_SELECT_VIASIZE1
void SetLastNetListRead(const wxString &aNetListFile)
Set the last net list successfully read by the net list dialog box.
Definition: pcbframe.cpp:983
Class PCB_LAYER_WIDGET is here to implement the abstract functions of LAYER_WIDGET so they may be tie...
static const wxString ShowPageLimitsEntry
Definition: pcbframe.cpp:95
VIEW_CONTROLS class definition.
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
Definition: pcbframe.cpp:793
PROJECT & Prj()
Definition: kicad.cpp:293
void SVG_Print(wxCommandEvent &event)
Function SVG_Print shows the print SVG file dialog.
Definition: pcbframe.cpp:1007
PCB_EDIT_FRAME::OnResetModuleTextSizes PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectTool EVT_TOOL_RANGE(ID_PCB_MUWAVE_START_CMD, ID_PCB_MUWAVE_END_CMD, PCB_EDIT_FRAME::ProcessMuWaveFunctions) EVT_MENU_RANGE(ID_POPUP_PCB_AUTOPLACE_START_RANGE
Class BOARD to handle a board.
Class that computes missing connections on a PCB.
static const wxString MagneticTracksEntry
Definition: pcbframe.cpp:92
int GetCopperLayerCount() const
Function GetCopperLayerCount.
void OnLayerColorChange(wxCommandEvent &aEvent)
Definition: pcbframe.cpp:1101
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences ID_POPUP_PCB_END_RANGE
PCB_EDIT_FRAME::OnResetModuleTextSizes PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectTool PCB_EDIT_FRAME::OnPlaceOrRouteFootprints PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event PCB_EDIT_FRAME::OnUpdateHighContrastDisplayMode PCB_EDIT_FRAME::OnUpdateShowMicrowaveToolbar PCB_EDIT_FRAME::OnUpdateSelectCustomTrackWidth ID_POPUP_PCB_SELECT_VIASIZE8
Definition: pcbframe.cpp:312
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
virtual COLOR4D GetGridColor() const override
Function GetGridColor() , virtual.
Definition: pcbframe.cpp:846
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
void SetVisibleAlls()
Function SetVisibleAlls changes the bit-mask of visible element categories and layers.
static const wxString MagneticPadsEntry
Definition: pcbframe.cpp:91
void SetLayerColor(LAYER_NUM aLayer, COLOR4D aColor)
Function SetLayerColor sets the color for aLayer which is one of the layer indices given in pcbstruct...
virtual void SetGridColor(COLOR4D aColor) override
Function SetGridColor() , virtual.
Definition: pcbframe.cpp:852
COLOR4D GetVisibleElementColor(GAL_LAYER_ID LAYER_aPCB)
Function GetVisibleElementColor returns the color of a pcb visible element.
EVT_MENU_RANGE(ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END, PCB_EDIT_FRAME::Process_Config) EVT_MENU(ID_MENU_PCB_RESET_TEXTMODULE_FIELDS_SIZES
This is the end of the layers used for visibility bitmasks in Pcbnew There can be at most 32 layers a...
void syncLayerVisibilities()
Function syncLayerVisibilities updates each "Layer" checkbox in the layer widget according to each la...
Definition: pcbframe.cpp:915
void OnCloseWindow(wxCloseEvent &Event) override
Definition: pcbframe.cpp:606
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:53
EDA_PANEINFO & LayersToolbarPane()
Function LayersToolbarPane Change *this to a layers toolbar for KiCad.
Definition: wxstruct.h:526
bool SetCurrentNetClass(const wxString &aNetClassName)
Function SetCurrentNetClass Must be called after a netclass selection (or after a netclass parameter ...
Definition: pcbframe.cpp:1115
void SetVisibleAlls()
Function SetVisibleAlls Set the status of all visible element categories and layers to VISIBLE...
Definition: pcbframe.cpp:944
PCB_EDIT_FRAME::OnResetModuleTextSizes EVT_TOOL(ID_TB_OPTIONS_DRC_OFF, PCB_EDIT_FRAME::OnSelectOptionToolbar) EVT_TOOL(ID_TB_OPTIONS_SHOW_RATSNEST
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:465
virtual bool IsGridVisible() const override
Function IsGridVisible() , virtual.
Definition: pcbframe.cpp:834
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
Functions relatives to tracks, vias and segments used to fill zones.
VTBL_ENTRY bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList...
Definition: kiway_player.h:170
Pcbnew hotkeys.
static const wxString PlotLineWidthEntry
Definition: pcbframe.cpp:90
void UseGalCanvas(bool aEnable) override
>
This file contains miscellaneous commonly used macros and functions.
virtual bool isAutoSaveRequired() const override
Function isautoSaveRequired returns true if the board has been modified.
Definition: pcbframe.cpp:554
EVT_MENU(ID_SELECT_PREFERED_PDF_BROWSER_NAME, KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser) EVT_MENU_RANGE(ID_PREFERENCES_HOTKEY_START
bool InvokeSVGPrint(wxTopLevelWindow *aCaller, BOARD *aBoard, PCB_PLOT_PARAMS *aSettings)
Function InvokeSVGPrint shows the SVG print dialog.
struct EDA_HOTKEY_CONFIG g_Board_Editor_Hokeys_Descr[]
VTBL_ENTRY void ConfigurePaths(wxWindow *aParent=NULL)
Function ConfigurePaths.
Definition: pgm_base.cpp:897
Class that handles properties and drawing of worksheet layout.
Class TOOL_MANAGER.
Definition: tool_manager.h:49
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
EDA_PANEINFO & VerticalToolbarPane()
Function VerticalToolbarPane Change *this to a vertical toolbar for KiCad.
Definition: wxstruct.h:492
bool IsElementVisible(GAL_LAYER_ID aElement) const
Function IsElementVisible tests whether a given element category is visible.
Definition: pcbframe.cpp:930
static const wxString ShowLayerManagerEntry
Definition: pcbframe.cpp:94
PCB_EDIT_FRAME::OnResetModuleTextSizes PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectTool ID_POPUP_PCB_AUTOPLACE_END_RANGE
Definition: pcbframe.cpp:268
PCB_LAYER_ID
A quick note on layer IDs:
double a
Alpha component.
Definition: color4d.h:284
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, KIWAY_PLAYER *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:302
COLOR4D m_LayersColors[LAYER_ID_COUNT]
Layer colors (tracks and graphic items)
void SetSheetName(const std::string &aSheetName)
Function SetSheetName() Sets the sheet name displayed in the title block.
BOARD_ITEM_CONTAINER * GetModel() const override
>
Definition: pcbframe.cpp:520
void OnSelectOptionToolbar(wxCommandEvent &event)
Definition: tool_pcb.cpp:727
void Refresh()
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, wxWindow *aFrame)
Sets the work environment (model, view, view controls and the parent window).
const wxString & GetFileName() const
Definition: class_board.h:237
int ShowQuasiModal()
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
void ProcessBoard()
Function ProcessBoard() Prepares data for computing (computes a list of current nodes and connections...
VTBL_ENTRY const wxString AbsolutePath(const wxString &aFileName) const
Function AbsolutePath fixes up aFileName if it is relative to the project's directory to be an absolu...
Definition: project.cpp:371
COLORS_DESIGN_SETTINGS * GetColorsSettings() const
Function GetColorSettings.
Definition: class_board.h:561
void SetElementVisibility(GAL_LAYER_ID LAYER_aPCB, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
virtual ~PCB_EDIT_FRAME()
Definition: pcbframe.cpp:500
ID_PREFERENCES_HOTKEY_END
The common library.
Helper dialog and control classes.
void ShowChangedLanguage() override
Function ShowChangedLanguage redraws the menus and what not in current language.
Definition: pcbframe.cpp:953
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:257
void SetSheetNumber(int aSheetNumber)
Function SetSheetNumber() Changes the sheet number displayed in the title block.
Configuration parameters for Pcbnew.
void OnQuit(wxCommandEvent &event)
Definition: pcbframe.cpp:600
int g_DrawDefaultLineThickness
Default line thickness in internal units used to draw or plot items using a default thickness line va...
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
Function SetActiveLayer will change the currently active layer to aLayer.
static const wxString ShowMicrowaveEntry
Definition: pcbframe.cpp:93
ID_POPUP_GRID_USER
Definition: draw_frame.cpp:105
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Class PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board...
void Show3D_Frame(wxCommandEvent &event) override
Function Show3D_Frame displays the 3D view of current printed circuit board.
Definition: pcbframe.cpp:686
const PAGE_INFO & GetPageSettings() const
Definition: class_board.h:545
RN_DATA * GetRatsnest() const
Function GetRatsnest() returns list of missing connections between components/tracks.
Definition: class_board.h:287
void ShowDesignRulesEditor(wxCommandEvent &event)
Function ShowDesignRulesEditor displays the Design Rules Editor.
Definition: pcbframe.cpp:779
Class TOOL_DISPATCHER.
Class DIALOG_PLOT.
Definition: dialog_plot.h:37
void OnSelectAutoPlaceMode(wxCommandEvent &aEvent)
Definition: pcbframe.cpp:1070
const wxString SchematicFileExtension
BOARD * GetBoard()
void enableGALSpecificMenus()
an helper function to enable some menus only active when the display is switched to GAL mode and whic...
Definition: pcbframe.cpp:749
void PythonPluginsReloadBase()
Helper function PythonPluginsReloadBase Reload Python plugins if they are newer than the already load...
Definition: pcbnew.cpp:299
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
Class LAYER_WIDGET is abstract and is used to manage a list of layers, with the notion of a "current"...
Definition: layer_widget.h:76
wxString GetLastNetListRead()
Get the last net list read with the net list dialog box.
Definition: pcbframe.cpp:968
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:245
EDA_PANEINFO & MessageToolbarPane()
Function MessageToolbarPane Change *this to a message pane for KiCad.
Definition: wxstruct.h:511
int DisplayExitDialog(wxWindow *parent, const wxString &aMessage)
Function DisplayExitDialog displays a dialog with 3 buttons: Save and Exit Cancel Exit without save...
Definition: confirm.cpp:58
Class PCB_ACTIONS.
Definition: pcb_actions.h:42
void OnUpdatePCBFromSch(wxCommandEvent &event)
Definition: pcbframe.cpp:1134
void wxConfigSaveSetups(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
Function wxConfigSaveSetups writes aList of PARAM_CFG_ARRAY elements to save configuration values to ...
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
see class PGM_BASE
void SetBoard(BOARD *aBoard) override
>
Definition: pcbframe.cpp:506
Declaration of the eda_3d_viewer class.
int g_MagneticTrackOption
Definition: pcbnew.cpp:81
void SetVisibleElementColor(GAL_LAYER_ID LAYER_aPCB, COLOR4D aColor)
Common, abstract interface for edit frames.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
virtual void SetGridVisibility(bool aVisible) override
Function SetGridVisibility() , virtual It may be overloaded by derived classes if you want to store/r...
Definition: pcbframe.cpp:840
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
pcbnew_ids
Definition: pcbnew_id.h:16
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
VTBL_ENTRY void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, const std::string &aPayload, wxWindow *aSource=NULL)
Function ExpressMail send aPayload to aDestination from aSource.
Definition: kiway.cpp:387
Class DRC is the Design Rule Checker, and performs all the DRC tests.
Definition: drc_stuff.h:158
virtual void SetBoard(BOARD *aBoard) override
>
void SetSheetCount(int aSheetCount)
Function SetSheetCount() Changes the sheets count number displayed in the title block.
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
Definition: wxstruct.h:112
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
virtual void SetPageSettings(const PAGE_INFO &aPageSettings) override
Class COLORS_DESIGN_SETTINGS is a list of color settings for designs in Eeschema, Pcbnew and GerbView...
Definition: id.h:96
void forceColorsToLegacy()
Helper function to coerce all colors to legacy-compatible when switching from GAL to legacy canvas...
Definition: pcbframe.cpp:735
LIB_EDIT_FRAME::Process_Config ID_POPUP_GENERAL_END_RANGE
bool IsMicroViaAcceptable(void)
Function IsMicroViaAcceptable return true if a microvia can be placed on the board.
Definition: pcbframe.cpp:864
Class EDA_3D_VIEWER Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard...
Definition: eda_3d_viewer.h:50
Module description (excepted pads)
Abstract interface for BOARD_ITEMs capable of storing other items inside.
void ReFillLayerWidget()
Function ReFillLayerWidget changes out all the layers in m_Layers and may be called upon loading a ne...
Definition: pcbframe.cpp:581
int g_MagneticPadOption
Definition: pcbnew.cpp:80
#define PCB_EDIT_FRAME_NAME
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
Definition: wxPcbStruct.h:78
Message panel definition file.
void SetDefaultFileName(const wxString &aFn)
Function SetDefaultFileName Set the default file name (eg: to be suggested to a screenshot) ...
Definition: eda_3d_viewer.h:93
void PythonPluginsReload()
Reload the Python plugins if they are newer than the already loaded, and load new plugins if any Do n...
Definition: pcbframe.cpp:1171
void wxConfigLoadSetups(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
Function wxConfigLoadSetups uses aList of PARAM_CFG_ARRAY elements to load configuration values from ...
void OnFlipPcbView(wxCommandEvent &event)
Definition: pcbframe.cpp:1162
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 void ShowChangedLanguage()
Function ShowChangedLanguage redraws the menus and what not in current language.
Definition: basicframe.cpp:242
virtual void SetActiveLayer(PCB_LAYER_ID aLayer) override
Function SetActiveLayer will change the currently active layer to aLayer and also update the PCB_LAYE...
Definition: pcbframe.cpp:885
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
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 ReloadRequest()
Request reloading the 3D view.
void setupTools()
Definition: pcbframe.cpp:563
KIWAY Kiway
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39