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 <connectivity.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::Process_Special_Functions )
270 
271  // Tracks and vias sizes general options
274  PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
275 
276  // popup menus
277  EVT_MENU( ID_POPUP_PCB_DELETE_TRACKSEG, PCB_EDIT_FRAME::Process_Special_Functions )
279  PCB_EDIT_FRAME::Process_Special_Functions )
280 
281  // User interface update event handlers.
282  EVT_UPDATE_UI( ID_SAVE_BOARD, PCB_EDIT_FRAME::OnUpdateSave )
283  EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, PCB_EDIT_FRAME::OnUpdateLayerPair )
284  EVT_UPDATE_UI( ID_TOOLBARH_PCB_SELECT_LAYER, PCB_EDIT_FRAME::OnUpdateLayerSelectBox )
285  EVT_UPDATE_UI( ID_TB_OPTIONS_DRC_OFF, PCB_EDIT_FRAME::OnUpdateDrcEnable )
286  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_RATSNEST, PCB_EDIT_FRAME::OnUpdateShowBoardRatsnest )
287  EVT_UPDATE_UI( ID_TB_OPTIONS_AUTO_DEL_TRACK, PCB_EDIT_FRAME::OnUpdateAutoDeleteTrack )
288  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, PCB_EDIT_FRAME::OnUpdateViaDrawMode )
289  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, PCB_EDIT_FRAME::OnUpdateTraceDrawMode )
290  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE,
291  PCB_EDIT_FRAME::OnUpdateHighContrastDisplayMode )
292  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR,
293  PCB_EDIT_FRAME::OnUpdateShowLayerManager )
294  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE,
295  PCB_EDIT_FRAME::OnUpdateShowMicrowaveToolbar )
296  EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, PCB_EDIT_FRAME::OnUpdateVerticalToolbar )
297  EVT_UPDATE_UI( ID_ZOOM_SELECTION, PCB_EDIT_FRAME::OnUpdateVerticalToolbar )
298  EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, PCB_EDIT_FRAME::OnUpdateSelectTrackWidth )
299  EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH,
300  PCB_EDIT_FRAME::OnUpdateSelectAutoTrackWidth )
301  EVT_UPDATE_UI( ID_POPUP_PCB_SELECT_AUTO_WIDTH, PCB_EDIT_FRAME::OnUpdateSelectAutoTrackWidth )
303  PCB_EDIT_FRAME::OnUpdateSelectCustomTrackWidth )
304  EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_VIA_SIZE, PCB_EDIT_FRAME::OnUpdateSelectViaSize )
305  EVT_UPDATE_UI( ID_TOOLBARH_PCB_MODE_MODULE, PCB_EDIT_FRAME::OnUpdateAutoPlaceModulesMode )
306  EVT_UPDATE_UI( ID_TOOLBARH_PCB_MODE_TRACKS, PCB_EDIT_FRAME::OnUpdateAutoPlaceTracksMode )
308  PCB_EDIT_FRAME::OnUpdateSelectTrackWidth )
310  PCB_EDIT_FRAME::OnUpdateSelectViaSize )
311  EVT_UPDATE_UI_RANGE( ID_PCB_HIGHLIGHT_BUTT, ID_PCB_MEASUREMENT_TOOL,
312  PCB_EDIT_FRAME::OnUpdateVerticalToolbar )
313  EVT_UPDATE_UI_RANGE( ID_TB_OPTIONS_SHOW_ZONES, ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY,
314  PCB_EDIT_FRAME::OnUpdateZoneDisplayStyle )
315  EVT_UPDATE_UI_RANGE( ID_PCB_MUWAVE_START_CMD, ID_PCB_MUWAVE_END_CMD,
316  PCB_EDIT_FRAME::OnUpdateMuWaveToolbar )
317 
318  EVT_COMMAND( wxID_ANY, LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE, PCB_EDIT_FRAME::OnLayerColorChange )
319 END_EVENT_TABLE()
320 
321 
322 PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
323  PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB, wxT( "Pcbnew" ), wxDefaultPosition,
325 {
326  m_showBorderAndTitleBlock = true; // true to display sheet references
327  m_showAxis = false; // true to display X and Y axis
328  m_showOriginAxis = true;
329  m_showGridAxis = true;
330  m_SelTrackWidthBox = NULL;
331  m_SelViaSizeBox = NULL;
332  m_SelLayerBox = NULL;
333  m_show_microwave_tools = false;
334  m_show_layer_manager_tools = true;
335  m_hotkeysDescrList = g_Board_Editor_Hokeys_Descr;
336  m_hasAutoSave = true;
337  m_microWaveToolBar = NULL;
338 
339  m_rotationAngle = 900;
340 
341  // Create GAL canvas
342  EDA_DRAW_PANEL_GAL* galCanvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ),
343  m_FrameSize,
344  GetGalDisplayOptions(),
346 
347  SetGalCanvas( galCanvas );
348 
349  SetBoard( new BOARD() );
350 
351  // Create the PCB_LAYER_WIDGET *after* SetBoard():
352 
353  wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
354  int pointSize = font.GetPointSize();
355  int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
356 
357  // printf( "pointSize:%d 80%%:%d\n", pointSize, (pointSize*8)/10 );
358 
359  if( screenHeight <= 900 )
360  pointSize = (pointSize * 8) / 10;
361 
362  m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), pointSize );
363 
364  m_drc = new DRC( this ); // these 2 objects point to each other
365 
366  wxIcon icon;
367  icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) );
368  SetIcon( icon );
369 
370  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
371  // initialize parameters in m_LayersManager
372  LoadSettings( config() );
373 
374  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
375  GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
376 
377  // PCB drawings start in the upper left corner.
378  GetScreen()->m_Center = false;
379 
380  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
381 
382  GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
383  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
384 
385  if( m_canvas )
386  m_canvas->SetEnableBlockCommands( true );
387 
388  ReCreateMenuBar();
389  ReCreateHToolbar();
390  ReCreateAuxiliaryToolbar();
391  ReCreateVToolbar();
392  ReCreateOptToolbar();
393 
394  ReCreateMicrowaveVToolbar();
395 
396  m_auimgr.SetManagedWindow( this );
397 
398  EDA_PANEINFO horiz;
399  horiz.HorizontalToolbarPane();
400 
401  EDA_PANEINFO vert;
402  vert.VerticalToolbarPane();
403 
404  EDA_PANEINFO mesg;
405  mesg.MessageToolbarPane();
406 
407  // Create a wxAuiPaneInfo for the Layers Manager, not derived from the template.
408  // LAYER_WIDGET is floatable, but initially docked at far right
409  EDA_PANEINFO lyrs;
410  lyrs.LayersToolbarPane();
411  lyrs.MinSize( m_Layers->GetBestSize() ); // updated in ReFillLayerWidget
412  lyrs.BestSize( m_Layers->GetBestSize() );
413  lyrs.Caption( _( "Visibles" ) );
414  lyrs.TopDockable( false ).BottomDockable( false );
415 
416  if( m_mainToolBar ) // The main horizontal toolbar
417  {
418  m_auimgr.AddPane( m_mainToolBar,
419  wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) );
420  }
421 
422  if( m_auxiliaryToolBar ) // the auxiliary horizontal toolbar, that shows track and via sizes, zoom ...)
423  {
424  m_auimgr.AddPane( m_auxiliaryToolBar,
425  wxAuiPaneInfo( horiz ).Name( wxT( "m_auxiliaryToolBar" ) ).Top().Row( 1 ) );
426  }
427 
428  if( m_microWaveToolBar ) // The auxiliary vertical right toolbar (currently microwave tools)
429  m_auimgr.AddPane( m_microWaveToolBar,
430  wxAuiPaneInfo( vert ).Name( wxT( "m_microWaveToolBar" ) ).
431  Right().Layer( 1 ).Position(1).Hide() );
432 
433  if( m_drawToolBar ) // The main right vertical toolbar
434  m_auimgr.AddPane( m_drawToolBar,
435  wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right().Layer( 2 ) );
436 
437  // Add the layer manager ( most right side of pcbframe )
438  m_auimgr.AddPane( m_Layers, lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Layer( 3 ) );
439 
440  if( m_optionsToolBar ) // The left vertical toolbar (fast acces display options of Pcbnew)
441  {
442  m_auimgr.AddPane( m_optionsToolBar,
443  wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ).Left().Layer(1) );
444 
445  m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools );
446  m_auimgr.GetPane( wxT( "m_microWaveToolBar" ) ).Show( m_show_microwave_tools );
447  }
448 
449  if( m_canvas )
450  m_auimgr.AddPane( m_canvas,
451  wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
452 
453  if( GetGalCanvas() )
454  m_auimgr.AddPane( (wxWindow*) GetGalCanvas(),
455  wxAuiPaneInfo().Name( wxT( "DrawFrameGal" ) ).CentrePane().Hide() );
456 
457  if( m_messagePanel )
458  m_auimgr.AddPane( m_messagePanel,
459  wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) );
460 
461  ReFillLayerWidget(); // this is near end because contents establish size
462  m_Layers->ReFillRender(); // Update colors in Render after the config is read
463  syncLayerWidgetLayer();
464 
465  m_auimgr.Update();
466 
467  setupTools();
468 
469  Zoom_Automatique( false );
470 
471  EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = LoadCanvasTypeSetting();
472 
473  if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
474  {
475  if( GetGalCanvas()->SwitchBackend( canvasType ) )
476  UseGalCanvas( true );
477  }
478 
479  enableGALSpecificMenus();
480 
481  // disable Export STEP item if kicad2step does not exist
482  wxString strK2S = Pgm().GetExecutablePath();
483  #ifdef __WXMAC__
484  strK2S += "Contents/MacOS/";
485  #endif
486  wxFileName appK2S( strK2S, "kicad2step" );
487 
488  #ifdef _WIN32
489  appK2S.SetExt( "exe" );
490  #endif
491 
492  if( !appK2S.FileExists() )
493  GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
494 }
495 
496 
498 {
499  delete m_drc;
500 }
501 
502 
504 {
506 
507  if( IsGalCanvasActive() )
508  {
509  aBoard->GetConnectivity()->Build( aBoard );
510 
511  // reload the worksheet
512  SetPageSettings( aBoard->GetPageSettings() );
513  }
514 }
515 
516 
518 {
519  return m_Pcb;
520 }
521 
522 
523 void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
524 {
525  PCB_BASE_FRAME::SetPageSettings( aPageSettings );
526 
527  if( IsGalCanvasActive() )
528  {
529  PCB_DRAW_PANEL_GAL* drawPanel = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
530 
531  // Prepare worksheet template
532  KIGFX::WORKSHEET_VIEWITEM* worksheet;
533  worksheet = new KIGFX::WORKSHEET_VIEWITEM( &m_Pcb->GetPageSettings(),
534  &m_Pcb->GetTitleBlock() );
535  worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );
536 
537  BASE_SCREEN* screen = GetScreen();
538 
539  if( screen != NULL )
540  {
541  worksheet->SetSheetNumber( screen->m_ScreenNumber );
542  worksheet->SetSheetCount( screen->m_NumberOfScreens );
543  }
544 
545  // PCB_DRAW_PANEL_GAL takes ownership of the worksheet
546  drawPanel->SetWorksheet( worksheet );
547  }
548 }
549 
550 
552 {
553  if( GetScreen() )
554  return GetScreen()->IsSave();
555 
556  return false;
557 }
558 
559 
561 {
562  // Create the manager and dispatcher & route draw panel events to the dispatcher
563  m_toolManager = new TOOL_MANAGER;
564  m_toolManager->SetEnvironment( m_Pcb, GetGalCanvas()->GetView(),
565  GetGalCanvas()->GetViewControls(), this );
566  m_actions = new PCB_ACTIONS();
567  m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
568 
569  // Register tools
570  m_actions->RegisterAllTools( m_toolManager );
571  m_toolManager->InitTools();
572 
573  // Run the selection tool, it is supposed to be always active
574  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
575 }
576 
577 
579 {
580  m_Layers->ReFill();
581 
582  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_Layers );
583 
584  wxSize bestz = m_Layers->GetBestSize();
585 
586  lyrs.MinSize( bestz );
587  lyrs.BestSize( bestz );
588  lyrs.FloatingSize( bestz );
589 
590  if( lyrs.IsDocked() )
591  m_auimgr.Update();
592  else
593  m_Layers->SetSize( bestz );
594 }
595 
596 
597 void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event )
598 {
599  Close( false );
600 }
601 
602 
603 void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
604 {
605  m_canvas->SetAbortRequest( true );
606 
607  if( GetScreen()->IsModify() )
608  {
609  wxString msg = wxString::Format( _(
610  "Save the changes in\n"
611  "'%s'\n"
612  "before closing?" ),
613  GetChars( GetBoard()->GetFileName() )
614  );
615 
616  int ii = DisplayExitDialog( this, msg );
617  switch( ii )
618  {
619  case wxID_CANCEL:
620  Event.Veto();
621  return;
622 
623  case wxID_NO:
624  break;
625 
626  case wxID_YES:
627  // save the board. if the board has no name,
628  // the ID_SAVE_BOARD_AS will actually made
629  Files_io_from_id( ID_SAVE_BOARD );
630  break;
631  }
632  }
633 
634  if( IsGalCanvasActive() )
635  {
636  // On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes
637  // when closing this frame if a footprint was selected, and the footprint editor called
638  // to edit this footprint, and when closing pcbnew if this footprint is still selected
639  // See https://bugs.launchpad.net/kicad/+bug/1655858
640  // I think this is certainly a OpenGL event fired after frame deletion, so this workaround
641  // avoid the crash (JPC)
642  GetGalCanvas()->SetEvtHandlerEnabled( false );
643  }
644 
645  GetGalCanvas()->StopDrawing();
646 
647  // Delete the auto save file if it exists.
648  wxFileName fn = GetBoard()->GetFileName();
649 
650  // Auto save file name is the normal file name prefixed with '_autosave'.
651  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
652 
653  // When the auto save feature does not have write access to the board file path, it falls
654  // back to a platform specific user temporary file path.
655  if( !fn.IsOk() || !fn.IsDirWritable() )
656  fn.SetPath( wxFileName::GetTempDir() );
657 
658  wxLogTrace( traceAutoSave, "Deleting auto save file <" + fn.GetFullPath() + ">" );
659 
660  // Remove the auto save file on a normal close of Pcbnew.
661  if( fn.FileExists() && !wxRemoveFile( fn.GetFullPath() ) )
662  {
663  wxString msg = wxString::Format( _(
664  "The auto save file '%s' could not be removed!" ),
665  GetChars( fn.GetFullPath() )
666  );
667 
668  wxMessageBox( msg, Pgm().App().GetAppName(), wxOK | wxICON_ERROR, this );
669  }
670 
671  // Delete board structs and undo/redo lists, to avoid crash on exit
672  // when deleting some structs (mainly in undo/redo lists) too late
673  Clear_Pcb( false );
674 
675  // do not show the window because ScreenPcb will be deleted and we do not
676  // want any paint event
677  Show( false );
678 
679  Destroy();
680 }
681 
682 
683 void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
684 {
685  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
686 
687  if( draw3DFrame )
688  {
689  // Raising the window does not show the window on Windows if iconized.
690  // This should work on any platform.
691  if( draw3DFrame->IsIconized() )
692  draw3DFrame->Iconize( false );
693 
694  draw3DFrame->Raise();
695 
696  // Raising the window does not set the focus on Linux. This should work on any platform.
697  if( wxWindow::FindFocus() != draw3DFrame )
698  draw3DFrame->SetFocus();
699 
700  return;
701  }
702 
703  draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
704  draw3DFrame->SetDefaultFileName( GetBoard()->GetFileName() );
705  draw3DFrame->Raise(); // Needed with some Window Managers
706  draw3DFrame->Show( true );
707 }
708 
709 
710 void PCB_EDIT_FRAME::UseGalCanvas( bool aEnable )
711 {
712  if( !aEnable )
713  Compile_Ratsnest( NULL, true );
714 
716 
717  enableGALSpecificMenus();
718 
719  // Force colors to be legacy-compatible in case they were changed in GAL
720  if( !aEnable )
721  {
722  forceColorsToLegacy();
723  Refresh();
724  }
725 
726  // Re-create the layer manager to allow arbitrary colors when GAL is enabled
727  ReFillLayerWidget();
728  m_Layers->ReFillRender();
729 }
730 
731 
733 {
735 
736  for( unsigned i = 0; i < DIM( cds->m_LayersColors ); i++ )
737  {
738  COLOR4D c = cds->GetLayerColor( i );
739  c.SetToNearestLegacyColor();
740  c.a = 0.8;
741  cds->SetLayerColor( i, c );
742  }
743 }
744 
745 
747 {
748  // some menus are active only in GAL mode and do nothing in legacy mode.
749  // So enable or disable them, depending on the display mode
750 
751  if( GetMenuBar() )
752  {
753  // Enable / disable some menus which are usable only on GAL
754  pcbnew_ids id_list[] =
755  {
762  ID_MENU_PCB_FLIP_VIEW
763  };
764 
765  bool enbl = IsGalCanvasActive();
766 
767  for( unsigned ii = 0; ii < DIM( id_list ); ii++ )
768  {
769  if( GetMenuBar()->FindItem( id_list[ii] ) )
770  GetMenuBar()->FindItem( id_list[ii] )->Enable( enbl );
771  }
772  }
773 }
774 
775 
776 void PCB_EDIT_FRAME::ShowDesignRulesEditor( wxCommandEvent& event )
777 {
778  DIALOG_DESIGN_RULES dR_editor( this );
779  int returncode = dR_editor.ShowModal();
780 
781  if( returncode == wxID_OK ) // New rules, or others changes.
782  {
783  ReCreateLayerBox();
784  ReCreateAuxiliaryToolbar();
785  OnModify();
786  }
787 }
788 
789 
790 void PCB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
791 {
793 
794  wxConfigLoadSetups( aCfg, GetConfigurationSettings() );
795 
796  double dtmp;
797  aCfg->Read( PlotLineWidthEntry, &dtmp, 0.1 ); // stored in mm
798 
799  if( dtmp < 0.01 )
800  dtmp = 0.01;
801 
802  if( dtmp > 5.0 )
803  dtmp = 5.0;
804 
805  g_DrawDefaultLineThickness = Millimeter2iu( dtmp );
806 
807  aCfg->Read( MagneticPadsEntry, &g_MagneticPadOption );
809  aCfg->Read( ShowMicrowaveEntry, &m_show_microwave_tools );
810  aCfg->Read( ShowLayerManagerEntry, &m_show_layer_manager_tools );
811  aCfg->Read( ShowPageLimitsEntry, &m_showPageLimits );
812 }
813 
814 
815 void PCB_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
816 {
818 
819  wxConfigSaveSetups( aCfg, GetConfigurationSettings() );
820 
821  // This value is stored in mm )
822  aCfg->Write( PlotLineWidthEntry, MM_PER_IU * g_DrawDefaultLineThickness );
823  aCfg->Write( MagneticPadsEntry, (long) g_MagneticPadOption );
824  aCfg->Write( MagneticTracksEntry, (long) g_MagneticTrackOption );
825  aCfg->Write( ShowMicrowaveEntry, (long) m_show_microwave_tools );
826  aCfg->Write( ShowLayerManagerEntry, (long)m_show_layer_manager_tools );
827  aCfg->Write( ShowPageLimitsEntry, m_showPageLimits );
828 }
829 
830 
832 {
833  return IsElementVisible( LAYER_GRID );
834 }
835 
836 
838 {
839  SetElementVisibility( LAYER_GRID, aVisible );
840 }
841 
842 
844 {
846 }
847 
848 
850 {
851 
853 
854  if( IsGalCanvasActive() )
855  {
856  GetGalCanvas()->GetGAL()->SetGridColor( aColor );
857  }
858 }
859 
860 
862 {
863  int copperlayercnt = GetBoard()->GetCopperLayerCount( );
864  PCB_LAYER_ID currLayer = GetActiveLayer();
865 
866  if( !GetDesignSettings().m_MicroViasAllowed )
867  return false; // Obvious..
868 
869  if( copperlayercnt < 4 )
870  return false; // Only on multilayer boards..
871 
872  if( ( currLayer == B_Cu )
873  || ( currLayer == F_Cu )
874  || ( currLayer == copperlayercnt - 2 )
875  || ( currLayer == In1_Cu ) )
876  return true;
877 
878  return false;
879 }
880 
881 
883 {
885 
886  syncLayerWidgetLayer();
887 
888  if( IsGalCanvasActive() )
889  {
890  m_toolManager->RunAction( PCB_ACTIONS::layerChanged ); // notify other tools
891  GetGalCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
892 
893  GetGalCanvas()->SetHighContrastLayer( aLayer );
894  GetGalCanvas()->Refresh();
895  }
896 }
897 
898 
900 {
901  m_Layers->SelectLayer( GetActiveLayer() );
902  m_Layers->OnLayerSelected();
903 }
904 
905 
907 {
908  m_Layers->SyncRenderStates();
909 }
910 
911 
913 {
914  m_Layers->SyncLayerVisibilities();
915  static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( m_Pcb );
916 }
917 
918 
920 {
921  PCB_BASE_FRAME::unitsChangeRefresh(); // Update the grid size select box.
922 
923  ReCreateAuxiliaryToolbar();
924 }
925 
926 
928 {
929  return GetBoard()->IsElementVisible( aElement );
930 }
931 
932 
933 void PCB_EDIT_FRAME::SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState )
934 {
935  GetGalCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
936  GetBoard()->SetElementVisibility( aElement, aNewState );
937  m_Layers->SetRenderState( aElement, aNewState );
938 }
939 
940 
942 {
944 
946  m_Layers->SetRenderState( ii, true );
947 }
948 
949 
951 {
952  // call my base class
954 
955  m_Layers->SetLayersManagerTabsText();
956 
957  wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_Layers );
958 
959  pane_info.Caption( _( "Visibles" ) );
960  m_auimgr.Update();
961  ReFillLayerWidget();
962 }
963 
964 
966 {
967  wxFileName absoluteFileName = m_lastNetListRead;
968  wxFileName pcbFileName = GetBoard()->GetFileName();
969 
970  if( !absoluteFileName.MakeAbsolute( pcbFileName.GetPath() ) || !absoluteFileName.FileExists() )
971  {
972  absoluteFileName.Clear();
973  m_lastNetListRead = wxEmptyString;
974  }
975 
976  return absoluteFileName.GetFullPath();
977 }
978 
979 
980 void PCB_EDIT_FRAME::SetLastNetListRead( const wxString& aLastNetListRead )
981 {
982  wxFileName relativeFileName = aLastNetListRead;
983  wxFileName pcbFileName = GetBoard()->GetFileName();
984 
985  if( relativeFileName.MakeRelativeTo( pcbFileName.GetPath() )
986  && relativeFileName.GetFullPath() != aLastNetListRead )
987  {
988  m_lastNetListRead = relativeFileName.GetFullPath();
989  }
990 }
991 
992 
994 {
996 
997  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
998 
999  if( draw3DFrame )
1000  draw3DFrame->ReloadRequest();
1001 }
1002 
1003 
1004 void PCB_EDIT_FRAME::SVG_Print( wxCommandEvent& event )
1005 {
1006  PCB_PLOT_PARAMS tmp = GetPlotSettings();
1007 
1008  // we don't want dialogs knowing about complex wxFrame functions so
1009  // pass everything the dialog needs without reference to *this frame's class.
1010  if( InvokeSVGPrint( this, GetBoard(), &tmp ) )
1011  {
1012  if( tmp != GetPlotSettings() )
1013  {
1014  SetPlotSettings( tmp );
1015  OnModify();
1016  }
1017  }
1018 }
1019 
1020 
1022 {
1023  wxFileName fileName = GetBoard()->GetFileName();
1024  wxString fileinfo;
1025 
1026  if( fileName.IsOk() && fileName.FileExists() )
1027  {
1028  fileinfo = fileName.IsFileWritable()
1029  ? wxString( wxEmptyString )
1030  : _( " [Read Only]" );
1031  }
1032  else
1033  {
1034  fileinfo = _( " [new file]" );
1035  }
1036 
1037  wxString title;
1038  title.Printf( L"Pcbnew \u2014 %s%s",
1039  fileName.GetFullPath(),
1040  fileinfo );
1041 
1042  SetTitle( title );
1043 }
1044 
1045 
1046 #if defined( KICAD_SCRIPTING_WXPYTHON )
1047 
1048 void PCB_EDIT_FRAME::ScriptingConsoleEnableDisable( wxCommandEvent& aEvent )
1049 {
1050 
1051  wxWindow * pythonPanelFrame = findPythonConsole();
1052  bool pythonPanelShown = true;
1053 
1054  if( pythonPanelFrame == NULL )
1055  pythonPanelFrame = CreatePythonShellWindow( this, pythonConsoleNameId() );
1056  else
1057  pythonPanelShown = ! pythonPanelFrame->IsShown();
1058 
1059  if( pythonPanelFrame )
1060  pythonPanelFrame->Show( pythonPanelShown );
1061  else
1062  wxMessageBox( wxT( "Error: unable to create the Python Console" ) );
1063 }
1064 #endif
1065 
1066 
1067 void PCB_EDIT_FRAME::OnSelectAutoPlaceMode( wxCommandEvent& aEvent )
1068 {
1069  // Automatic placement of modules and tracks is a mutually exclusive operation so
1070  // clear the other tool if one of the two is selected.
1071  // Be careful: this event function is called both by the
1072  // ID_TOOLBARH_PCB_MODE_MODULE and the ID_TOOLBARH_PCB_MODE_TRACKS tool
1073  // Therefore we should avoid a race condition when deselecting one of these tools
1074  // inside this function (seems happen on some Linux/wxWidgets versions)
1075  // when the other tool is selected
1076 
1077  switch( aEvent.GetId() )
1078  {
1079  case ID_TOOLBARH_PCB_MODE_MODULE:
1080  if( aEvent.IsChecked() &&
1081  m_mainToolBar->GetToolToggled( ID_TOOLBARH_PCB_MODE_TRACKS ) )
1082  {
1083  m_mainToolBar->ToggleTool( ID_TOOLBARH_PCB_MODE_TRACKS, false );
1084  }
1085  break;
1086 
1087  case ID_TOOLBARH_PCB_MODE_TRACKS:
1088  if( aEvent.IsChecked() &&
1089  m_mainToolBar->GetToolToggled( ID_TOOLBARH_PCB_MODE_MODULE ) )
1090  {
1091  m_mainToolBar->ToggleTool( ID_TOOLBARH_PCB_MODE_MODULE, false );
1092  }
1093  break;
1094  }
1095 }
1096 
1097 
1098 void PCB_EDIT_FRAME::OnLayerColorChange( wxCommandEvent& aEvent )
1099 {
1100  ReCreateLayerBox();
1101 }
1102 
1103 
1104 void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event )
1105 {
1106  DIALOG_PLOT dlg( this );
1107 
1108  dlg.ShowModal();
1109 }
1110 
1111 
1112 bool PCB_EDIT_FRAME::SetCurrentNetClass( const wxString& aNetClassName )
1113 {
1114  bool change = GetDesignSettings().SetCurrentNetClass( aNetClassName );
1115 
1116  if( change )
1117  {
1118  ReCreateAuxiliaryToolbar();
1119  }
1120 
1121  return change;
1122 }
1123 
1124 
1125 void PCB_EDIT_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
1126 {
1127  Pgm().ConfigurePaths( this );
1128 }
1129 
1130 
1131 void PCB_EDIT_FRAME::OnUpdatePCBFromSch( wxCommandEvent& event )
1132 {
1133  if( Kiface().IsSingle() )
1134  {
1135  DisplayError( this, _( "Cannot update the PCB, because the Kicad is"
1136  " opened in stand-alone mode. In order to create/update"
1137  " PCBs from schematics, you need to launch Kicad shell"
1138  " and create a PCB project." ) );
1139  return;
1140  }
1141  else
1142  {
1143  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
1144  wxFileName schfn = Prj().AbsolutePath( Prj().GetProjectName() );
1145 
1146  schfn.SetExt( SchematicFileExtension );
1147 
1148  if( !frame->IsVisible() )
1149  {
1150  frame->OpenProjectFiles( std::vector<wxString>( 1, schfn.GetFullPath() ) );
1151  frame->Show( false );
1152  }
1153 
1155  }
1156 }
1157 
1158 
1159 void PCB_EDIT_FRAME::OnFlipPcbView( wxCommandEvent& evt )
1160 {
1161  auto view = GetGalCanvas()->GetView();
1162  view->SetMirror( evt.IsChecked(), false );
1163  view->RecacheAllItems();
1164  Refresh();
1165 }
1166 
1167 
1169 {
1170  // Reload Python plugins if they are newer than
1171  // the already loaded, and load new plugins
1172 #if defined(KICAD_SCRIPTING)
1173  //Reload plugin list: reload Python plugins if they are newer than
1174  // the already loaded, and load new plugins
1176 
1177  #if defined(KICAD_SCRIPTING_ACTION_MENU)
1178  // Action plugins can be modified, therefore the plugins menu
1179  // must be updated:
1180  RebuildActionPluginMenus();
1181  #endif
1182 #endif
1183 }
1184 
1185 
1187 {
1188  DIALOG_EXCHANGE_MODULE dialog( this, Module );
1189 
1190  return dialog.ShowQuasiModal();
1191 }
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:475
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: pcbframe.cpp:815
void syncRenderStates()
Function syncRenderStates updates the "Render" checkboxes in the layer widget according to current to...
Definition: pcbframe.cpp:906
void UpdateTitle()
Function UpdateTitle sets the main window title bar text.
Definition: pcbframe.cpp:1021
#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:993
void SetPageSettings(const PAGE_INFO &aPageSettings) override
>
Definition: pcbframe.cpp:523
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:933
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:899
void OnConfigurePaths(wxCommandEvent &aEvent)
Definition: pcbframe.cpp:1125
virtual void unitsChangeRefresh() override
Function unitsChangeRefresh is called when when the units setting has changed to allow for any derive...
Definition: pcbframe.cpp:919
int InstallExchangeModuleFrame(MODULE *ExchangeModuleModule)
Definition: pcbframe.cpp:1186
void UseGalCanvas(bool aEnable) override
>
Definition: pcbframe.cpp:710
void ToPlotter(wxCommandEvent &event)
Function ToPlotter Open a dialog frame to create plot and drill files relative to the current board...
Definition: pcbframe.cpp:1104
This file is part of the common library.
VTBL_ENTRY const wxString & GetExecutablePath() const
Definition: pgm_base.h:173
void SetLastNetListRead(const wxString &aNetListFile)
Set the last net list successfully read by the net list dialog box.
Definition: pcbframe.cpp:980
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:790
PROJECT & Prj()
Definition: kicad.cpp:293
void SVG_Print(wxCommandEvent &event)
Function SVG_Print shows the print SVG file dialog.
Definition: pcbframe.cpp:1004
Class BOARD to handle a board.
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::Process_Special_Functions PCB_EDIT_FRAME::Process_Special_Functions EVT_UPDATE_UI(ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, PCB_EDIT_FRAME::OnUpdateHighContrastDisplayMode) EVT_UPDATE_UI(ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR
static const wxString MagneticTracksEntry
Definition: pcbframe.cpp:92
int GetCopperLayerCount() const
Function GetCopperLayerCount.
void OnLayerColorChange(wxCommandEvent &aEvent)
Definition: pcbframe.cpp:1098
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
virtual COLOR4D GetGridColor() const override
Function GetGridColor() , virtual.
Definition: pcbframe.cpp:843
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:849
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:912
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::Process_Special_Functions PCB_EDIT_FRAME::Process_Special_Functions PCB_EDIT_FRAME::OnUpdateShowLayerManager PCB_EDIT_FRAME::OnUpdateSelectAutoTrackWidth PCB_EDIT_FRAME::OnUpdateSelectTrackWidth EVT_UPDATE_UI_RANGE(ID_POPUP_PCB_SELECT_VIASIZE1, ID_POPUP_PCB_SELECT_VIASIZE8, PCB_EDIT_FRAME::OnUpdateSelectViaSize) EVT_UPDATE_UI_RANGE(ID_PCB_HIGHLIGHT_BUTT
void OnCloseWindow(wxCloseEvent &Event) override
Definition: pcbframe.cpp:603
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:527
bool SetCurrentNetClass(const wxString &aNetClassName)
Function SetCurrentNetClass Must be called after a netclass selection (or after a netclass parameter ...
Definition: pcbframe.cpp:1112
void SetVisibleAlls()
Function SetVisibleAlls Set the status of all visible element categories and layers to VISIBLE...
Definition: pcbframe.cpp:941
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:466
virtual bool IsGridVisible() const override
Function IsGridVisible() , virtual.
Definition: pcbframe.cpp:831
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::Process_Special_Functions PCB_EDIT_FRAME::Process_Special_Functions PCB_EDIT_FRAME::OnUpdateShowLayerManager PCB_EDIT_FRAME::OnUpdateSelectAutoTrackWidth ID_POPUP_PCB_SELECT_WIDTH8
Definition: pcbframe.cpp:307
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:551
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:493
bool IsElementVisible(GAL_LAYER_ID aElement) const
Function IsElementVisible tests whether a given element category is visible.
Definition: pcbframe.cpp:927
static const wxString ShowLayerManagerEntry
Definition: pcbframe.cpp:94
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:517
void OnSelectOptionToolbar(wxCommandEvent &event)
Definition: tool_pcb.cpp:730
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:234
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 ...)
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_START_RANGE
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:564
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:497
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:950
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:597
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
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::Process_Special_Functions PCB_EDIT_FRAME::Process_Special_Functions PCB_EDIT_FRAME::OnUpdateShowLayerManager PCB_EDIT_FRAME::OnUpdateSelectAutoTrackWidth PCB_EDIT_FRAME::OnUpdateSelectTrackWidth PCB_EDIT_FRAME::OnUpdateVerticalToolbar ID_PCB_MUWAVE_END_CMD
Definition: pcbframe.cpp:315
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:683
const PAGE_INFO & GetPageSettings() const
Definition: class_board.h:548
void ShowDesignRulesEditor(wxCommandEvent &event)
Function ShowDesignRulesEditor displays the Design Rules Editor.
Definition: pcbframe.cpp:776
Class TOOL_DISPATCHER.
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 DIALOG_PLOT.
Definition: dialog_plot.h:37
void OnSelectAutoPlaceMode(wxCommandEvent &aEvent)
Definition: pcbframe.cpp:1067
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:746
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:965
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:259
EDA_PANEINFO & MessageToolbarPane()
Function MessageToolbarPane Change *this to a message pane for KiCad.
Definition: wxstruct.h:512
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:1131
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:503
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
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_END_RANGE
Definition: pcbframe.cpp:268
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:837
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
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:113
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:732
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::Process_Special_Functions ID_POPUP_GENERAL_END_RANGE
Definition: pcbframe.cpp:278
bool IsMicroViaAcceptable(void)
Function IsMicroViaAcceptable return true if a microvia can be placed on the board.
Definition: pcbframe.cpp:861
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:578
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:1168
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:1159
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:882
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:290
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 PCB_EDIT_FRAME::OnSelectOptionToolbar ID_PCB_MEASUREMENT_TOOL
Definition: pcbframe.cpp:262
void ReloadRequest()
Request reloading the 3D view.
void setupTools()
Definition: pcbframe.cpp:560
KIWAY Kiway
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39