KiCad PCB EDA Suite
pcb_edit_frame.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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
7  * Copyright (C) 2013-2020 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software: you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as published by the
11  * Free Software Foundation, either version 3 of the License, or (at your
12  * option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include <fctsys.h>
24 #include <kiface_i.h>
25 #include <pgm_base.h>
26 #include <confirm.h>
27 #include <pcb_edit_frame.h>
29 #include <fp_lib_table.h>
30 #include <bitmaps.h>
31 #include <trace_helpers.h>
32 #include <pcbnew.h>
33 #include <pcbnew_id.h>
34 #include <drc/drc.h>
35 #include <pcbnew_settings.h>
36 #include <layer_widget.h>
37 #include <pcb_layer_widget.h>
38 #include <footprint_edit_frame.h>
39 #include <dialog_plot.h>
42 #include <dialog_board_setup.h>
43 #include <convert_to_biu.h>
44 #include <view/view_controls.h>
45 #include <pcb_painter.h>
46 #include <invoke_pcb_dialog.h>
47 #include <class_board.h>
48 #include <class_module.h>
49 #include <ws_proxy_view_item.h>
52 #include <kicad_string.h>
53 #include <pcb_draw_panel_gal.h>
54 #include <functional>
55 #include <project/project_file.h>
57 #include <tool/tool_manager.h>
58 #include <tool/tool_dispatcher.h>
59 #include <tool/action_toolbar.h>
60 #include <tool/common_control.h>
61 #include <tool/common_tools.h>
62 #include <tool/zoom_tool.h>
63 #include <tools/selection_tool.h>
65 #include <tools/point_editor.h>
66 #include <tools/edit_tool.h>
67 #include <tools/global_edit_tool.h>
68 #include <tools/drawing_tool.h>
69 #include <tools/pcbnew_control.h>
72 #include <tools/pcb_viewer_tools.h>
73 #include <tools/placement_tool.h>
74 #include <tools/pad_tool.h>
77 #include <tools/zone_filler_tool.h>
78 #include <tools/pcb_actions.h>
79 #include <router/router_tool.h>
82 #include <gestfich.h>
83 #include <executable_names.h>
87 #include <wx/wupdlock.h>
88 #include <dialog_drc.h> // for DIALOG_DRC_WINDOW_NAME definition
91 
92 #include <widgets/infobar.h>
93 
94 #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
95 #include <python_scripting.h>
96 #endif
97 
98 
99 using namespace std::placeholders;
100 
101 
102 BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
105 
108 
109  EVT_CLOSE( PCB_EDIT_FRAME::OnCloseWindow )
110  EVT_SIZE( PCB_EDIT_FRAME::OnSize )
111 
113 
114  // Menu Files:
116 
120 
126 
129 
130  EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit )
131  EVT_MENU( wxID_CLOSE, PCB_EDIT_FRAME::OnQuit )
132 
133  // menu Config
136 
137  // menu Postprocess
139 
140  // Horizontal toolbar
146 
147 
148 #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
149  EVT_TOOL( ID_TOOLBARH_PCB_ACTION_PLUGIN_REFRESH, PCB_EDIT_FRAME::OnActionPluginRefresh )
150 #endif
151 
152  // Tracks and vias sizes general options
155 
156  // User interface update event handlers.
161  PCB_EDIT_FRAME::OnUpdateSelectTrackWidth )
163  PCB_EDIT_FRAME::OnUpdateSelectViaSize )
164 
165  EVT_COMMAND( wxID_ANY, LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE, PCB_EDIT_FRAME::OnLayerColorChange )
166 END_EVENT_TABLE()
167 
168 
169 PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
170  PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_EDITOR, wxT( "Pcbnew" ), wxDefaultPosition,
172 {
173  m_showBorderAndTitleBlock = true; // true to display sheet references
174  m_SelTrackWidthBox = NULL;
175  m_SelViaSizeBox = NULL;
176  m_SelLayerBox = NULL;
177  m_show_microwave_tools = false;
178  m_show_layer_manager_tools = true;
179  m_hasAutoSave = true;
180  m_microWaveToolBar = NULL;
181  m_Layers = nullptr;
182 
183  // We don't know what state board was in when it was lasat saved, so we have to
184  // assume dirty
185  m_ZoneFillsDirty = true;
186 
187  m_rotationAngle = 900;
188  m_AboutTitle = "Pcbnew";
189 
190  // Create GAL canvas
191  auto canvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
192  GetGalDisplayOptions(),
194 
195  SetCanvas( canvas );
196 
197  SetBoard( new BOARD() );
198 
199  // Create the PCB_LAYER_WIDGET *after* SetBoard():
200  m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas() );
201 
202  wxIcon icon;
203  icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) );
204  SetIcon( icon );
205 
206  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
207  // initialize parameters in m_LayersManager
208  LoadSettings( config() );
209 
210  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
211  GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
212 
213  // PCB drawings start in the upper left corner.
214  GetScreen()->m_Center = false;
215 
216  setupTools();
217  ReCreateMenuBar();
218  ReCreateHToolbar();
219  ReCreateAuxiliaryToolbar();
220  ReCreateVToolbar();
221  ReCreateOptToolbar();
222  ReCreateMicrowaveVToolbar();
223 
224  m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
225 
226  // Create the infobar
227  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
228 
229  m_auimgr.SetManagedWindow( this );
230  m_auimgr.SetFlags( wxAUI_MGR_LIVE_RESIZE );
231 
232  // Horizontal items; layers 4 - 6
233  m_auimgr.AddPane( m_mainToolBar,
234  EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
235  m_auimgr.AddPane( m_auxiliaryToolBar,
236  EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top().Layer(5) );
237  m_auimgr.AddPane( m_messagePanel,
238  EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
239  m_auimgr.AddPane( m_infoBar,
240  EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
241 
242  // Vertical items; layers 1 - 3
243  m_auimgr.AddPane( m_optionsToolBar,
244  EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
245 
246  m_auimgr.AddPane( m_microWaveToolBar,
247  EDA_PANE().VToolbar().Name( "MicrowaveToolbar" ).Right().Layer(2) );
248  m_auimgr.AddPane( m_drawToolBar,
249  EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(3) );
250  m_auimgr.AddPane( m_Layers,
251  EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(4)
252  .Caption( _( "Layers Manager" ) ).PaneBorder( false )
253  .MinSize( 80, -1 ).BestSize( m_Layers->GetBestSize() ).Maximize() );
254  m_auimgr.AddPane( m_selectionFilterPanel,
255  EDA_PANE().Palette().Name( "SelectionFilter" ).Right().Layer( 4 )
256  .Caption( _( "Selection Filter" ) ).PaneBorder( false ).Position( 2 )
257  .MinSize( 160, -1 ).BestSize( m_selectionFilterPanel->GetBestSize() ) );
258 
259  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
260 
261  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
262  m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
263  m_auimgr.GetPane( "MicrowaveToolbar" ).Show( m_show_microwave_tools );
264 
265  m_Layers->ReFillRender(); // Update colors in Render after the config is read
266  ReFillLayerWidget(); // this is near end and after ReFillRender()
267  // because contents establish size
268  syncLayerWidgetLayer();
269 
270  // The selection filter doesn't need to grow in the vertical direction when docked
271  m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
272 
273  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
274  // hidding it.
275  m_auimgr.Update();
276 
277  // We don't want the infobar displayed right away
278  m_auimgr.GetPane( "InfoBar" ).Hide();
279  m_auimgr.Update();
280 
281  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
282 
283  m_canvasType = LoadCanvasTypeSetting();
284 
285  // Nudge user to switch to OpenGL if they are on Cairo
286  if( m_firstRunDialogSetting < 1 )
287  {
288  if( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
289  {
290  wxString msg = _( "KiCad can use your graphics card to give you a smoother "
291  "and faster experience. This option is turned off by "
292  "default since it is not compatible with all computers.\n\n"
293  "Would you like to try enabling graphics acceleration?\n\n"
294  "If you'd like to choose later, select Accelerated Graphics "
295  "in the Preferences menu." );
296 
297  wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
298 
299  dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
300 
301  if( dlg.ShowModal() == wxID_YES )
302  {
303  // Save Cairo as default in case OpenGL crashes
304  saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
305 
306  // Switch to OpenGL, which will save the new setting if successful
307  GetToolManager()->RunAction( ACTIONS::acceleratedGraphics, true );
308 
309  // Switch back to Cairo if OpenGL is not supported
310  if( GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
311  GetToolManager()->RunAction( ACTIONS::standardGraphics, true );
312  }
313  else
314  {
315  // If they were on legacy, switch to Cairo
316  GetToolManager()->RunAction( ACTIONS::standardGraphics, true );
317  }
318  }
319 
320  m_firstRunDialogSetting = 1;
321  SaveSettings( config() );
322  }
323 
324  InitExitKey();
325 
326  GetCanvas()->SwitchBackend( m_canvasType );
327  ActivateGalCanvas();
328 
329  // Default shutdown reason until a file is loaded
330  SetShutdownBlockReason( _( "New PCB file is unsaved" ) );
331 
332  // disable Export STEP item if kicad2step does not exist
333  wxString strK2S = Pgm().GetExecutablePath();
334 
335 #ifdef __WXMAC__
336  if (strK2S.find( "pcbnew.app" ) != wxNOT_FOUND )
337  {
338  // On macOS, we have standalone applications inside the main bundle, so we handle that here:
339  strK2S += "../../";
340  }
341 
342  strK2S += "Contents/MacOS/";
343 #endif
344 
345  wxFileName appK2S( strK2S, "kicad2step" );
346 
347  #ifdef _WIN32
348  appK2S.SetExt( "exe" );
349  #endif
350 
351  // Ensure the window is on top
352  Raise();
353 
354 // if( !appK2S.FileExists() )
355  // GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
356 }
357 
358 
360 {
361  // Shutdown all running tools
362  if( m_toolManager )
363  m_toolManager->ShutdownAllTools();
364 
365  delete m_selectionFilterPanel;
366  delete m_Layers;
367 }
368 
369 
371 {
372  if( m_Pcb )
373  m_Pcb->ClearProject();
374 
376 
377  aBoard->SetProject( &Prj() );
378  aBoard->GetConnectivity()->Build( aBoard );
379 
380  // reload the worksheet
381  SetPageSettings( aBoard->GetPageSettings() );
382 }
383 
384 
386 {
387  return m_Pcb;
388 }
389 
390 
391 void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
392 {
393  PCB_BASE_FRAME::SetPageSettings( aPageSettings );
394 
395  // Prepare worksheet template
396  KIGFX::WS_PROXY_VIEW_ITEM* worksheet;
397  worksheet = new KIGFX::WS_PROXY_VIEW_ITEM( IU_PER_MILS ,&m_Pcb->GetPageSettings(),
398  m_Pcb->GetProject(), &m_Pcb->GetTitleBlock() );
399  worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );
400 
401  BASE_SCREEN* screen = GetScreen();
402 
403  if( screen != NULL )
404  {
405  worksheet->SetSheetNumber( screen->m_ScreenNumber );
406  worksheet->SetSheetCount( screen->m_NumberOfScreens );
407  }
408 
409  if( auto board = GetBoard() )
410  worksheet->SetFileName( TO_UTF8( board->GetFileName() ) );
411 
412  // PCB_DRAW_PANEL_GAL takes ownership of the worksheet
413  GetCanvas()->SetWorksheet( worksheet );
414 }
415 
416 
418 {
419  return GetScreen() && GetScreen()->IsModify() && GetBoard() && !GetBoard()->IsEmpty();
420 }
421 
422 
424 {
425  if( GetScreen() )
426  return GetScreen()->IsSave();
427 
428  return false;
429 }
430 
431 
433 {
434  // Create the manager and dispatcher & route draw panel events to the dispatcher
435  m_toolManager = new TOOL_MANAGER;
436  m_toolManager->SetEnvironment( m_Pcb, GetCanvas()->GetView(),
437  GetCanvas()->GetViewControls(), config(), this );
438  m_actions = new PCB_ACTIONS();
439  m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
440 
441  // Register tools
442  m_toolManager->RegisterTool( new COMMON_CONTROL );
443  m_toolManager->RegisterTool( new COMMON_TOOLS );
444  m_toolManager->RegisterTool( new SELECTION_TOOL );
445  m_toolManager->RegisterTool( new ZOOM_TOOL );
446  m_toolManager->RegisterTool( new PCBNEW_PICKER_TOOL );
447  m_toolManager->RegisterTool( new ROUTER_TOOL );
448  m_toolManager->RegisterTool( new LENGTH_TUNER_TOOL );
449  m_toolManager->RegisterTool( new EDIT_TOOL );
450  m_toolManager->RegisterTool( new GLOBAL_EDIT_TOOL );
451  m_toolManager->RegisterTool( new PAD_TOOL );
452  m_toolManager->RegisterTool( new DRAWING_TOOL );
453  m_toolManager->RegisterTool( new POINT_EDITOR );
454  m_toolManager->RegisterTool( new PCBNEW_CONTROL );
455  m_toolManager->RegisterTool( new PCB_EDITOR_CONTROL );
456  m_toolManager->RegisterTool( new PCB_INSPECTION_TOOL );
457  m_toolManager->RegisterTool( new ALIGN_DISTRIBUTE_TOOL );
458  m_toolManager->RegisterTool( new MICROWAVE_TOOL );
459  m_toolManager->RegisterTool( new POSITION_RELATIVE_TOOL );
460  m_toolManager->RegisterTool( new ZONE_FILLER_TOOL );
461  m_toolManager->RegisterTool( new AUTOPLACE_TOOL );
462  m_toolManager->RegisterTool( new DRC );
463  m_toolManager->RegisterTool( new PCB_VIEWER_TOOLS );
464  m_toolManager->InitTools();
465 
466  // Run the selection tool, it is supposed to be always active
467  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
468 }
469 
470 
472 {
473  wxWindowUpdateLocker no_update( m_Layers );
474  m_Layers->ReFill();
475 
476  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_Layers );
477 
478  wxSize bestz = m_Layers->GetBestSize();
479 
480  lyrs.MinSize( bestz );
481  lyrs.BestSize( bestz );
482  lyrs.FloatingSize( bestz );
483 
484  if( lyrs.IsDocked() )
485  m_auimgr.Update();
486  else
487  m_Layers->SetSize( bestz );
488 }
489 
490 
491 void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event )
492 {
493  if( event.GetId() == wxID_EXIT )
494  Kiway().OnKiCadExit();
495 
496  if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
497  Close( false );
498 }
499 
500 
502 {
504  bds.m_DrcExclusions.clear();
505 
506  for( MARKER_PCB* marker : GetBoard()->Markers() )
507  {
508  if( marker->IsExcluded() )
509  bds.m_DrcExclusions.insert( marker->Serialize() );
510  }
511 }
512 
513 
515 {
517 
518  for( MARKER_PCB* marker : GetBoard()->Markers() )
519  {
520  auto i = bds.m_DrcExclusions.find( marker->Serialize() );
521 
522  if( i != bds.m_DrcExclusions.end() )
523  {
524  marker->SetExcluded( true );
525  bds.m_DrcExclusions.erase( i );
526  }
527  }
528 
529  BOARD_COMMIT commit( this );
530 
531  for( const wxString& exclusionData : bds.m_DrcExclusions )
532  {
533  MARKER_PCB* marker = MARKER_PCB::Deserialize( exclusionData );
534  marker->SetExcluded( true );
535  commit.Add( marker );
536  }
537 
538  bds.m_DrcExclusions.clear();
539 
540  commit.Push( wxEmptyString, false, false );
541 }
542 
543 
544 void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
545 {
546  // Shutdown blocks must be determined and vetoed as early as possible
547  if( SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
548  && IsContentModified() )
549  {
550  aEvent.Veto();
551  return;
552  }
553 
554  // First close the DRC dialog. For some reason, if the board editor frame is destroyed
555  // when the DRC dialog currently open, Pcbnew crashes, at least on Windows.
556  DIALOG_DRC* open_dlg = static_cast<DIALOG_DRC*>(
557  wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME ) );
558 
559  if( open_dlg )
560  open_dlg->Close( true );
561 
562  if( IsContentModified() )
563  {
564  wxFileName fileName = GetBoard()->GetFileName();
565  wxString msg = _( "Save changes to \"%s\" before closing?" );
566 
567  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
568  [&]()->bool { return Files_io_from_id( ID_SAVE_BOARD ); } ) )
569  {
570  aEvent.Veto();
571  return;
572  }
573  }
574 
575  // On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes
576  // when closing this frame if a footprint was selected, and the footprint editor called
577  // to edit this footprint, and when closing pcbnew if this footprint is still selected
578  // See https://bugs.launchpad.net/kicad/+bug/1655858
579  // I think this is certainly a OpenGL event fired after frame deletion, so this workaround
580  // avoid the crash (JPC)
581  GetCanvas()->SetEvtHandlerEnabled( false );
582 
583  GetCanvas()->StopDrawing();
584 
585  // Delete the auto save file if it exists.
586  wxFileName fn = GetBoard()->GetFileName();
587 
588  // Auto save file name is the normal file name prefixed with 'GetAutoSaveFilePrefix()'.
589  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
590 
591  // When the auto save feature does not have write access to the board file path, it falls
592  // back to a platform specific user temporary file path.
593  if( !fn.IsOk() || !fn.IsDirWritable() )
594  fn.SetPath( wxFileName::GetTempDir() );
595 
596  wxLogTrace( traceAutoSave, "Deleting auto save file <" + fn.GetFullPath() + ">" );
597 
598  // Remove the auto save file on a normal close of Pcbnew.
599  if( fn.FileExists() && !wxRemoveFile( fn.GetFullPath() ) )
600  {
601  wxString msg = wxString::Format( _( "The auto save file \"%s\" could not be removed!" ),
602  fn.GetFullPath() );
603  wxMessageBox( msg, Pgm().App().GetAppName(), wxOK | wxICON_ERROR, this );
604  }
605 
606  // Do not show the layer manager during closing to avoid flicker
607  // on some platforms (Windows) that generate useless redraw of items in
608  // the Layer Manger
609  if( m_show_layer_manager_tools )
610  m_auimgr.GetPane( "LayersManager" ).Show( false );
611 
612  // Delete board structs and undo/redo lists, to avoid crash on exit
613  // when deleting some structs (mainly in undo/redo lists) too late
614  Clear_Pcb( false, true );
615 
616  // do not show the window because ScreenPcb will be deleted and we do not
617  // want any paint event
618  Show( false );
619 
620  // Close frame:
621  aEvent.Skip();
622 }
623 
624 
626 {
628  GetCanvas()->UpdateColors();
629  GetCanvas()->Refresh();
630 }
631 
632 
633 void PCB_EDIT_FRAME::ShowBoardSetupDialog( const wxString& aInitialPage, const wxString& aErrorMsg,
634  int aErrorCtrlId, int aErrorLine, int aErrorCol )
635 {
636  DIALOG_BOARD_SETUP dlg( this );
637 
638  if( !aInitialPage.IsEmpty() )
639  dlg.SetInitialPage( aInitialPage, wxEmptyString );
640 
641  if( !aErrorMsg.IsEmpty() )
642  dlg.SetError( aErrorMsg, aInitialPage, aErrorCtrlId, aErrorLine, aErrorCol );
643 
644  if( dlg.ShowQuasiModal() == wxID_OK )
645  {
646  SaveProjectSettings();
647 
649  ReCreateAuxiliaryToolbar();
650 
651  for( auto module : GetBoard()->Modules() )
652  GetCanvas()->GetView()->Update( module );
653 
654  GetCanvas()->Refresh();
655 
656  //this event causes the routing tool to reload its design rules information
658  toolEvent.SetHasPosition( false );
659  m_toolManager->ProcessEvent( toolEvent );
660 
661  OnModify();
662  }
663 }
664 
665 
667 {
669 
670  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
671  wxASSERT( cfg );
672 
673  if( cfg )
674  {
675  m_rotationAngle = cfg->m_RotationAngle;
676  g_DrawDefaultLineThickness = Millimeter2iu( cfg->m_PlotLineWidth );
677  m_show_microwave_tools = cfg->m_AuiPanels.show_microwave_tools;
678  m_show_layer_manager_tools = cfg->m_AuiPanels.show_layer_manager;
679  m_showPageLimits = cfg->m_ShowPageLimits;
680  }
681 }
682 
683 
685 {
687 
688  auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
689  wxASSERT( cfg );
690 
691  if( cfg )
692  {
693  cfg->m_RotationAngle = m_rotationAngle;
694  cfg->m_PlotLineWidth = Iu2Millimeter( g_DrawDefaultLineThickness );
695  cfg->m_AuiPanels.show_microwave_tools = m_show_microwave_tools;
696  cfg->m_AuiPanels.show_layer_manager = m_show_layer_manager_tools;
697  cfg->m_ShowPageLimits = m_showPageLimits;
698  }
699 }
700 
701 
703 {
704  return GetColorSettings()->GetColor( LAYER_GRID );
705 }
706 
707 
709 {
710 
711  GetColorSettings()->SetColor( LAYER_GRID, aColor );
712  GetCanvas()->GetGAL()->SetGridColor( aColor );
713 }
714 
715 
717 {
719 
720  syncLayerWidgetLayer();
721 
722  m_toolManager->RunAction( PCB_ACTIONS::layerChanged ); // notify other tools
723  GetCanvas()->SetFocus(); // allow capture of hotkeys
724  GetCanvas()->SetHighContrastLayer( aLayer );
725  GetCanvas()->Refresh();
726 }
727 
728 
730 {
731  UpdateTitle();
732 
733  wxFileName fn = GetBoard()->GetFileName();
734  m_infoBar->Dismiss();
735 
736  // Display a warning that the file is read only
737  if( fn.FileExists() && !fn.IsFileWritable() )
738  {
739  m_infoBar->RemoveAllButtons();
740  m_infoBar->AddCloseButton();
741  m_infoBar->ShowMessage( "Board file is read only.", wxICON_WARNING );
742  }
743 
744  // Re-create layers manager based on layer info in board
745  ReFillLayerWidget();
746  ReCreateLayerBox();
747 
748  // Sync layer and item visibility
749  syncLayerVisibilities();
750  syncLayerWidgetLayer();
751  SyncRenderStates();
752 
753  SetElementVisibility( LAYER_RATSNEST, GetDisplayOptions().m_ShowGlobalRatsnest );
754 
755  // Update the tracks / vias available sizes list:
756  ReCreateAuxiliaryToolbar();
757 
758  // Display the loaded board:
759  Zoom_Automatique( false );
760 
761  Refresh();
762 
763  SetMsgPanel( GetBoard() );
764  SetStatusText( wxEmptyString );
765 
766  m_toolManager->GetTool<DRC>()->LoadRules();
767 
768  SetShutdownBlockReason( _( "PCB file changes are unsaved" ) );
769 }
770 
771 
773 {
774  m_Layers->SelectLayer( GetActiveLayer() );
775  m_Layers->OnLayerSelected();
776 }
777 
778 
780 {
781  m_Layers->ReFillRender();
782 }
783 
784 
786 {
787  m_Layers->SyncLayerVisibilities();
788  GetCanvas()->SyncLayersVisibility( m_Pcb );
789 }
790 
791 
792 void PCB_EDIT_FRAME::OnUpdateLayerAlpha( wxUpdateUIEvent & )
793 {
794  m_Layers->SyncLayerAlphaIndicators();
795 }
796 
797 
799 {
800  return GetBoard()->IsElementVisible( aElement );
801 }
802 
803 
804 void PCB_EDIT_FRAME::SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState )
805 {
806  // Force the RATSNEST visible
807  if( aElement == LAYER_RATSNEST )
808  GetCanvas()->GetView()->SetLayerVisible( aElement, true );
809  else
810  GetCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
811 
812  GetBoard()->SetElementVisibility( aElement, aNewState );
813  m_Layers->SetRenderState( aElement, aNewState );
814 }
815 
816 
818 {
820 
822  m_Layers->SetRenderState( ii, true );
823 }
824 
825 
827 {
828  // call my base class
830 
831  // update the layer manager
832  m_Layers->Freeze();
833 
834  wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_Layers );
835  pane_info.Caption( _( "Visibles" ) );
836  m_auimgr.Update();
837 
838  m_Layers->SetLayersManagerTabsText();
839  ReFillLayerWidget();
840  // m_Layers->ReFillRender(); // SyncRenderStates() does this
841 
842  // upate the layer widget to match board visibility states, both layers and render columns.
843  syncLayerVisibilities();
844  syncLayerWidgetLayer();
845  SyncRenderStates();
846 
847  m_Layers->Thaw();
848 
849  // pcbnew-specific toolbars
850  ReCreateMicrowaveVToolbar();
851 }
852 
853 
855 {
856  PROJECT_FILE& project = Prj().GetProjectFile();
857 
858  if( project.m_PcbLastPath[ aType ].IsEmpty() )
859  return wxEmptyString;
860 
861  wxFileName absoluteFileName = project.m_PcbLastPath[ aType ];
862  wxFileName pcbFileName = GetBoard()->GetFileName();
863 
864  absoluteFileName.MakeAbsolute( pcbFileName.GetPath() );
865  return absoluteFileName.GetFullPath();
866 }
867 
868 
869 void PCB_EDIT_FRAME::SetLastPath( LAST_PATH_TYPE aType, const wxString& aLastPath )
870 {
871  PROJECT_FILE& project = Prj().GetProjectFile();
872 
873  wxFileName relativeFileName = aLastPath;
874  wxFileName pcbFileName = GetBoard()->GetFileName();
875 
876  relativeFileName.MakeRelativeTo( pcbFileName.GetPath() );
877 
878  if( relativeFileName.GetFullPath() != project.m_PcbLastPath[ aType ] )
879  {
880  project.m_PcbLastPath[ aType ] = relativeFileName.GetFullPath();
881  SaveProjectSettings();
882  }
883 }
884 
885 
887 {
889 
890  Update3DView( false );
891 
892  m_ZoneFillsDirty = true;
893 }
894 
895 
896 void PCB_EDIT_FRAME::ExportSVG( wxCommandEvent& event )
897 {
898  InvokeExportSVG( this, GetBoard() );
899 }
900 
901 
903 {
904  wxFileName fileName = GetBoard()->GetFileName();
905  wxString fileinfo;
906 
907  if( fileName.IsOk() && fileName.FileExists() )
908  fileinfo = fileName.IsFileWritable() ? wxString( wxEmptyString ) : _( " [Read Only]" );
909  else
910  fileinfo = _( " [Unsaved]" );
911 
912  SetTitle( wxString::Format( _( "Pcbnew" ) + wxT( " \u2014 %s%s" ),
913  fileName.GetFullPath(),
914  fileinfo ) );
915 }
916 
917 
919 {
920  // Update the layer manager and other widgets from the board setup
921  // (layer and items visibility, colors ...)
922 
923  // Rebuild list of nets (full ratsnest rebuild)
925  Compile_Ratsnest( true );
926 
927  // Update info shown by the horizontal toolbars
928  ReCreateLayerBox();
929 
930  // Update the layer manager
931  m_Layers->Freeze();
932  ReFillLayerWidget();
933  // m_Layers->ReFillRender(); // SyncRenderStates() does this
934 
935  // upate the layer widget to match board visibility states, both layers and render columns.
936  syncLayerVisibilities();
937  syncLayerWidgetLayer();
938  SyncRenderStates();
939 
940  m_Layers->Thaw();
941 }
942 
943 
944 #if defined( KICAD_SCRIPTING_WXPYTHON )
945 
946 void PCB_EDIT_FRAME::ScriptingConsoleEnableDisable()
947 {
948  wxWindow * pythonPanelFrame = findPythonConsole();
949  bool pythonPanelShown = true;
950 
951  if( pythonPanelFrame == NULL )
952  pythonPanelFrame = CreatePythonShellWindow( this, pythonConsoleNameId() );
953  else
954  pythonPanelShown = ! pythonPanelFrame->IsShown();
955 
956  if( pythonPanelFrame )
957  pythonPanelFrame->Show( pythonPanelShown );
958  else
959  wxMessageBox( wxT( "Error: unable to create the Python Console" ) );
960 }
961 #endif
962 
963 
964 void PCB_EDIT_FRAME::OnLayerColorChange( wxCommandEvent& aEvent )
965 {
966  ReCreateLayerBox();
967 }
968 
969 
971 {
972  // switches currently used canvas (Cairo / OpenGL).
973  PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
974 
975  // The base class method *does not* reinitialize the layers manager. We must upate the
976  // layer widget to match board visibility states, both layers and render columns.
977  syncLayerVisibilities();
978  syncLayerWidgetLayer();
979  SyncRenderStates();
980 }
981 
982 
984 {
985  PCB_PLOT_PARAMS plotSettings = GetPlotSettings();
986 
987  switch( aID )
988  {
989  case ID_GEN_PLOT_GERBER:
990  plotSettings.SetFormat( PLOT_FORMAT::GERBER );
991  break;
992  case ID_GEN_PLOT_DXF:
993  plotSettings.SetFormat( PLOT_FORMAT::DXF );
994  break;
995  case ID_GEN_PLOT_HPGL:
996  plotSettings.SetFormat( PLOT_FORMAT::HPGL );
997  break;
998  case ID_GEN_PLOT_PDF:
999  plotSettings.SetFormat( PLOT_FORMAT::PDF );
1000  break;
1001  case ID_GEN_PLOT_PS:
1002  plotSettings.SetFormat( PLOT_FORMAT::POST );
1003  break;
1004  case ID_GEN_PLOT: /* keep the previous setup */ break;
1005  default:
1006  wxFAIL_MSG( "ToPlotter(): unexpected plot type" ); break;
1007  break;
1008  }
1009 
1010  SetPlotSettings( plotSettings );
1011 
1012  // Force rebuild the dialog if currently open because the old dialog can be not up to date
1013  // if the board (or units) has changed
1014  wxWindow* dlg = wxWindow::FindWindowByName( DLG_WINDOW_NAME );
1015 
1016  if( dlg )
1017  dlg->Destroy();
1018 
1019  dlg = new DIALOG_PLOT( this );
1020  dlg->Show( true );
1021 }
1022 
1023 
1024 bool PCB_EDIT_FRAME::SetCurrentNetClass( const wxString& aNetClassName )
1025 {
1026  bool change = GetDesignSettings().SetCurrentNetClass( aNetClassName );
1027 
1028  if( change )
1029  ReCreateAuxiliaryToolbar();
1030 
1031  return change;
1032 }
1033 
1034 
1036 {
1037  if( Kiface().IsSingle() )
1038  {
1039  DisplayError( this, _( "Cannot update the PCB because Pcbnew is opened in stand-alone "
1040  "mode. In order to create or update PCBs from schematics, you "
1041  "must launch the KiCad project manager and create a project." ) );
1042  return false;
1043  }
1044 
1045  // Update PCB requires a netlist. Therefore the schematic editor must be running
1046  // If this is not the case, open the schematic editor
1047  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
1048 
1049  if( !frame->IsShown() )
1050  {
1051  wxFileName fn( Prj().GetProjectPath(), Prj().GetProjectName(),
1053 
1054  // Maybe the file hasn't been converted to the new s-expression file format so
1055  // see if the legacy schematic file is still in play.
1056  if( !fn.FileExists() )
1057  {
1058  fn.SetExt( LegacySchematicFileExtension );
1059 
1060  if( !fn.FileExists() )
1061  {
1062  DisplayError( this, _( "The schematic for this board cannot be found." ) );
1063  return false;
1064  }
1065  }
1066 
1067  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1068 
1069  // we show the schematic editor frame, because do not show is seen as
1070  // a not yet opened schematic by Kicad manager, which is not the case
1071  frame->Show( true );
1072 
1073  // bring ourselves back to the front
1074  Raise();
1075  }
1076 
1077  std::string payload;
1078 
1079  if( aMode == NO_ANNOTATION )
1080  payload = "no-annotate";
1081  else if( aMode == QUIET_ANNOTATION )
1082  payload = "quiet-annotate";
1083 
1084  Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_GET_NETLIST, payload, this );
1085 
1086  try
1087  {
1088  auto lineReader = new STRING_LINE_READER( payload, _( "Eeschema netlist" ) );
1089  KICAD_NETLIST_READER netlistReader( lineReader, &aNetlist );
1090  netlistReader.LoadNetlist();
1091  }
1092  catch( const IO_ERROR& )
1093  {
1094  assert( false ); // should never happen
1095  return false;
1096  }
1097 
1098  return true;
1099 }
1100 
1101 
1102 void PCB_EDIT_FRAME::DoUpdatePCBFromNetlist( NETLIST& aNetlist, bool aUseTimestamps )
1103 {
1104  BOARD_NETLIST_UPDATER updater( this, GetBoard() );
1105  updater.SetLookupByTimestamp( aUseTimestamps );
1106  updater.SetDeleteUnusedComponents( false );
1107  updater.SetReplaceFootprints( true );
1108  updater.SetDeleteSinglePadNets( false );
1109  updater.SetWarnPadNoNetInNetlist( false );
1110  updater.UpdateNetlist( aNetlist );
1111 }
1112 
1113 
1115 {
1116  wxString msg;
1117  wxFileName schfn( Prj().GetProjectPath(), Prj().GetProjectName(),
1119 
1120  if( !schfn.FileExists() )
1121  {
1122  msg.Printf( _( "Schematic file \"%s\" not found." ), schfn.GetFullPath() );
1123  wxMessageBox( msg, _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
1124  return;
1125  }
1126 
1127  if( Kiface().IsSingle() )
1128  {
1129  wxString filename = wxT( "\"" ) + schfn.GetFullPath( wxPATH_NATIVE ) + wxT( "\"" );
1130  ExecuteFile( this, EESCHEMA_EXE, filename );
1131  }
1132  else
1133  {
1134  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, false );
1135 
1136  // Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls
1137  // Kiway.Player( FRAME_SCH, true )
1138  // therefore, the schematic editor is sometimes running, but the schematic project
1139  // is not loaded, if the library editor was called, and the dialog field editor was used.
1140  // On linux, it happens the first time the schematic editor is launched, if
1141  // library editor was running, and the dialog field editor was open
1142  // On Windows, it happens always after the library editor was called,
1143  // and the dialog field editor was used
1144  if( !frame )
1145  {
1146  try
1147  {
1148  frame = Kiway().Player( FRAME_SCH, true );
1149  }
1150  catch( const IO_ERROR& err )
1151  {
1152  wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
1153  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
1154  return;
1155  }
1156  }
1157 
1158  if( !frame->IsShown() ) // the frame exists, (created by the dialog field editor)
1159  // but no project loaded.
1160  {
1161  frame->OpenProjectFiles( std::vector<wxString>( 1, schfn.GetFullPath() ) );
1162  frame->Show( true );
1163  }
1164 
1165  // On Windows, Raise() does not bring the window on screen, when iconized or not shown
1166  // On linux, Raise() brings the window on screen, but this code works fine
1167  if( frame->IsIconized() )
1168  {
1169  frame->Iconize( false );
1170  // If an iconized frame was created by Pcbnew, Iconize( false ) is not enough
1171  // to show the frame at its normal size: Maximize should be called.
1172  frame->Maximize( false );
1173  }
1174 
1175  frame->Raise();
1176  }
1177 }
1178 
1179 
1181 {
1182  // Reload Python plugins if they are newer than
1183  // the already loaded, and load new plugins
1184 #if defined(KICAD_SCRIPTING)
1185  //Reload plugin list: reload Python plugins if they are newer than
1186  // the already loaded, and load new plugins
1188 
1189  #if defined(KICAD_SCRIPTING_ACTION_MENU)
1190  // Action plugins can be modified, therefore the plugins menu
1191  // must be updated:
1192  ReCreateMenuBar();
1193  // Recreate top toolbar to add action plugin buttons
1194  ReCreateHToolbar();
1195  #endif
1196 #endif
1197 }
1198 
1199 
1201 {
1202  if( Module == NULL )
1203  return;
1204 
1206 
1207  int retvalue = dlg->ShowModal();
1208  /* retvalue =
1209  * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_UPDATE_FP if update footprint
1210  * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_EXCHANGE_FP if change footprint
1211  * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_MODEDIT for a goto editor command
1212  * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_EDIT_OK for normal edit
1213  */
1214 
1215  dlg->Close();
1216  dlg->Destroy();
1217 
1219  {
1220  // If something edited, push a refresh request
1221  GetCanvas()->Refresh();
1222  }
1224  {
1225  auto editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
1226 
1227  editor->Load_Module_From_BOARD( Module );
1228 
1229  editor->Show( true );
1230  editor->Raise(); // Iconize( false );
1231  }
1232 
1234  {
1235  auto editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
1236 
1237  editor->LoadModuleFromLibrary( Module->GetFPID() );
1238 
1239  editor->Show( true );
1240  editor->Raise(); // Iconize( false );
1241  }
1242 
1244  {
1245  InstallExchangeModuleFrame( Module, true, true );
1246  }
1247 
1249  {
1250  InstallExchangeModuleFrame( Module, false, true );
1251  }
1252 }
1253 
1254 
1256  bool selectedMode )
1257 {
1258  DIALOG_EXCHANGE_FOOTPRINTS dialog( this, aModule, updateMode, selectedMode );
1259 
1260  return dialog.ShowQuasiModal();
1261 }
1262 
1263 
1264 void PCB_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
1265 {
1266  PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged );
1267 
1268  ReCreateMicrowaveVToolbar();
1269 
1270  Layout();
1271  SendSizeEvent();
1272 }
1273 
1274 
1275 void PCB_EDIT_FRAME::LockModule( MODULE* aModule, bool aLocked )
1276 {
1277  const wxString ModulesMaskSelection = wxT( "*" );
1278  if( aModule )
1279  {
1280  aModule->SetLocked( aLocked );
1281  SetMsgPanel( aModule );
1282  OnModify();
1283  }
1284  else
1285  {
1286  for( auto mod : GetBoard()->Modules() )
1287  {
1288  if( WildCompareString( ModulesMaskSelection, mod->GetReference() ) )
1289  {
1290  mod->SetLocked( aLocked );
1291  OnModify();
1292  }
1293  }
1294  }
1295 }
1296 
1297 
1298 bool ExportBoardToHyperlynx( BOARD* aBoard, const wxFileName& aPath );
1299 
1300 
1301 void PCB_EDIT_FRAME::OnExportHyperlynx( wxCommandEvent& event )
1302 {
1303  wxString wildcard = wxT( "*.hyp" );
1304  wxFileName fn = GetBoard()->GetFileName();
1305 
1306  fn.SetExt( wxT("hyp") );
1307 
1308  wxFileDialog dlg( this, _( "Export Hyperlynx Layout" ), fn.GetPath(), fn.GetFullName(),
1309  wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1310 
1311  if( dlg.ShowModal() != wxID_OK )
1312  return;
1313 
1314  fn = dlg.GetPath();
1315 
1316  // always enforce filename extension, user may not have entered it.
1317  fn.SetExt( wxT( "hyp" ) );
1318 
1320 }
1321 
1322 
1324 {
1325  return GetBoard()->GetFileName();
1326 }
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
void UpdateTitle()
Function UpdateTitle sets the main window title bar text.
POSITION_RELATIVE_TOOL.
virtual 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:118
void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:201
void SetPageSettings(const PAGE_INFO &aPageSettings) override
void RecreateCmpFileFromBoard(wxCommandEvent &aEvent)
Function RecreateBOMFileFromBoard Recreates a .cmp file from the current loaded board this is the sam...
KiCad executable names.
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:59
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
const PAGE_INFO & GetPageSettings() const
Definition: class_board.h:572
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
void OnExportIDF3(wxCommandEvent &event)
Function OnExportIDF3 will export the current BOARD to a IDFv3 board and lib files.
Class that draws missing connections on a PCB.
void OnKiCadExit()
Definition: kiway.cpp:523
int m_ScreenNumber
Definition: base_screen.h:85
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
void syncLayerWidgetLayer()
Function syncLayerWidgetLayer updates the currently layer "selection" within the PCB_LAYER_WIDGET.
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
void ActivateGalCanvas() override
void OnExportHyperlynx(wxCommandEvent &event)
Function OnExportHyperlynx will export the current BOARD to a Hyperlynx HYP file.
KICAD_NETLIST_READER read the new s-expression based KiCad netlist format.
This file is part of the common library TODO brief description.
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
void LockModule(MODULE *aModule, bool aLocked)
Fetch a netlist from schematics.
Definition: mail_type.h:46
This file is part of the common library.
void ToPlotter(int aID)
Function ToPlotter Open a dialog frame to create plot and drill files relative to the current board.
BOARD_NETLIST_UPDATER updates the BOARD with a new netlist.
Definition: id.h:88
void OnSockRequestServer(wxSocketEvent &evt)
Definition: eda_dde.cpp:103
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
PCB_LAYER_WIDGET is here to implement the abstract functions of LAYER_WIDGET so they may be tied into...
void SetInitialPage(const wxString &aPage, const wxString &aParentPage=wxEmptyString)
VIEW_CONTROLS class definition.
PROJECT & Prj()
Definition: kicad.cpp:317
SELECTION_TOOL.
void ActivateGalCanvas() override
MICROWAVE_TOOL.
void OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
void SetSheetName(const std::string &aSheetName)
Function SetSheetName() Sets the sheet name displayed in the title block.
void SetDeleteSinglePadNets(bool aEnabled)
Enables "delete single pad nets" option
void OnExportSTEP(wxCommandEvent &event)
Function OnExportSTEP Exports the current BOARD to a STEP assembly.
void ResolveDRCExclusions()
Update markers to match recorded exclusions.
void CommonSettingsChanged(bool aEnvVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void OnLayerColorChange(wxCommandEvent &aEvent)
PAD_TOOL.
Definition: pad_tool.h:37
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
void SetWarnPadNoNetInNetlist(bool aEnabled)
Enables warning option if a connectable pad is not found in netlist connectable = pad with a name and...
static TOOL_ACTION standardGraphics
Definition: actions.h:159
BOARD_NETLIST_UPDATER class definition.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:551
void ExportToGenCAD(wxCommandEvent &event)
Function ExportToGenCAD creates a file in GenCAD 1.4 format from the current board.
void SetVisibleAlls()
Function SetVisibleAlls changes the bit-mask of visible element categories and layers.
void SetGridColor(COLOR4D aColor) override
Function SetGridColor() , virtual.
const LIB_ID & GetFPID() const
Definition: class_module.h:215
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
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...
void SetLookupByTimestamp(bool aEnabled)
Enables component lookup by timestamp instead of reference
wxString m_PcbLastPath[LAST_PATH_SIZE]
MRU path storage.
Definition: project_file.h:170
void RecordDRCExclusions()
Scan existing markers and record data from any that are Excluded.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void OnCloseWindow(wxCloseEvent &Event) override
bool SetCurrentNetClass(const wxString &aNetClassName)
Function SetCurrentNetClass Must be called after a netclass selection (or after a netclass parameter ...
const wxString & GetFileName() const
Definition: class_board.h:255
bool UpdateNetlist(NETLIST &aNetlist)
Function UpdateNetlist()
void SetVisibleAlls()
Function SetVisibleAlls Set the status of all visible element categories and layers to VISIBLE.
PROJECT_FILE is the backing store for a PROJECT, in JSON format.
Definition: project_file.h:61
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
int InstallExchangeModuleFrame(MODULE *aModule, bool updateMode, bool selectedMode)
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
PCBNEW_CONTROL.
void SetFileName(const std::string &aFileName)
Function SetFileName() Sets the file name displayed in the title block.
bool isAutoSaveRequired() const override
Function isautoSaveRequired returns true if the board has been modified.
TOOL_MANAGER.
Definition: tool_manager.h:51
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
void OnClearFileHistory(wxCommandEvent &aEvent)
EVT_MENU_RANGE(ID_POPUP_PCB_SELECT_WIDTH_START_RANGE, ID_POPUP_PCB_SELECT_WIDTH_END_RANGE, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event) EVT_UPDATE_UI_RANGE(ID_POPUP_PCB_SELECT_WIDTH1
virtual void LoadNetlist() override
Function LoadNetlist loads the contents of the netlist file into aNetlist.
void SetSheetCount(int aSheetCount)
Function SetSheetCount() Changes the sheets count number displayed in the title block.
PCB_LAYER_ID
A quick note on layer IDs:
void CommonSettingsChanged(bool aEnvVarsChanged) override
Called after the preferences dialog is run.
void Tracks_and_Vias_Size_Event(wxCommandEvent &event)
ZONE_FILLER_TOOL.
Action belongs to a particular tool (i.e. a part of a pop-up menu)
Definition: tool_event.h:146
bool ExportBoardToHyperlynx(BOARD *aBoard, const wxFileName &aPath)
Generic tool for picking a point.
const wxString EESCHEMA_EXE
void SetExcluded(bool aExcluded)
Definition: marker_base.h:109
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:91
NETLIST stores all of information read from a netlist along with the flags used to update the NETLIST...
Definition: pcb_netlist.h:212
#define NULL
bool IsSingle() const
Function IsSingle is this KIFACE_I running under single_top?
Definition: kiface_i.h:117
bool IsContentModified() override
Get if the current board has been modified but not saved.
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:342
BOARD_ITEM_CONTAINER * GetModel() const override
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
DRAWING_TOOL.
Definition: drawing_tool.h:50
void onBoardLoaded()
Updates the state of the GUI after a new board is loaded or created.
GAL not used (the legacy wxDC engine is used)
int ShowQuasiModal()
VTBL_ENTRY PROJECT_FILE & GetProjectFile() const
Definition: project.h:129
PAGE_INFO describes the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:44
bool WildCompareString(const wxString &pattern, const wxString &string_to_tst, bool case_sensitive)
Compare a string against wild card (* and ?) pattern using the usual rules.
Definition: string.cpp:467
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
TOOL_EVENT.
Definition: tool_event.h:171
int g_DrawDefaultLineThickness
Default line thickness in internal units used to draw or plot items using a default thickness line va...
void ExportSVG(wxCommandEvent &event)
Function SVG_Print Shows the Export to SVG file dialog.
void SyncRenderStates()
Updates the "Render" colors and checkboxes in the layer widget according to current toggle values det...
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:355
virtual ~PCB_EDIT_FRAME()
void SetReplaceFootprints(bool aEnabled)
Enables replacing footprints with new ones
Definition of file extensions used in Kicad.
#define DIALOG_DRC_WINDOW_NAME
Definition: dialog_drc.h:44
PCB_INSPECTION_TOOL.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
COLOR4D GetGridColor() override
Function GetGridColor() , virtual.
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
wxLogTrace helper definitions.
virtual void OnSize(wxSizeEvent &event)
Recalculate the size of toolbars and display panel when the frame size changes.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
void OnQuit(wxCommandEvent &event)
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
void SetFormat(PLOT_FORMAT aFormat)
PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board.
COMMON_CONTROL.
LAST_PATH_TYPE
For storing PcbNew MRU paths of various types.
Definition: project_file.h:43
EDIT_TOOL.
Definition: edit_tool.h:67
Specialization of the wxAuiPaneInfo class for KiCad panels.
const std::string LegacySchematicFileExtension
COMMON_TOOLS.
Definition: common_tools.h:38
TOOL_DISPATCHER.
DIALOG_PLOT is the dialog to set the plot options, and create plot files in various formats.
Definition: dialog_plot.h:40
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
BOARD * GetBoard()
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
void SetProject(PROJECT *aProject)
Links a board to a given project.
VTBL_ENTRY void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=NULL)
Function ExpressMail send aPayload to aDestination from aSource.
Definition: kiway.cpp:428
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:68
void OnSockRequest(wxSocketEvent &evt)
Definition: eda_dde.cpp:71
virtual void OnModify()
Function OnModify Must be called after a change in order to set the "modify" flag of the current scre...
LAYER_WIDGET is abstract and is used to manage a list of layers, with the notion of a "current" layer...
Definition: layer_widget.h:79
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:272
PCB_ACTIONS.
Definition: pcb_actions.h:51
void OnFileHistory(wxCommandEvent &event)
PCB_EDITOR_CONTROL.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
see class PGM_BASE
void OnUpdateLayerAlpha(wxUpdateUIEvent &aEvent) override
Update the UI to reflect changes to the current layer's transparency.
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
void SetBoard(BOARD *aBoard) override
Declaration of the eda_3d_viewer class.
void SetLocked(bool isLocked) override
Function SetLocked sets the MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition: class_module.h:307
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
void Process_Special_Functions(wxCommandEvent &event)
Definition: pcbnew/edit.cpp:50
void DoUpdatePCBFromNetlist(NETLIST &aNetlist, bool aUseTimestamps)
Function DoUpdatePCBFromNetlist An automated version of UpdatePCBFromNetlist which skips the UI dialo...
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
PCB_EDIT_FRAME::OnUpdateSelectTrackWidth EVT_UPDATE_UI_RANGE(ID_POPUP_PCB_SELECT_VIASIZE1, ID_POPUP_PCB_SELECT_VIASIZE8, PCB_EDIT_FRAME::OnUpdateSelectViaSize) PCB_EDIT_FRAME
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Sets the work environment (model, view, view controls and the parent window).
void Files_io(wxCommandEvent &event)
Function Files_io.
#define _(s)
Definition: 3d_actions.cpp:33
Design Rule Checker object that performs all the DRC tests.
Definition: drc.h:105
virtual void SetBoard(BOARD *aBoard) override
void OnExportVRML(wxCommandEvent &event)
Function OnExportVRML will export the current BOARD to a VRML file.
void SetDeleteUnusedComponents(bool aEnabled)
Enables removing unused components
void OnUpdateSelectViaSize(wxUpdateUIEvent &aEvent)
static MARKER_PCB * Deserialize(const wxString &data)
FETCH_NETLIST_MODE
Function FetchNetlistFromSchematic.
static TOOL_ACTION acceleratedGraphics
Definition: actions.h:158
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnToggleShowLayerManager GERBVIEW_FRAME::OnSelectHighlightChoice EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, GERBVIEW_FRAME::OnUpdateLayerSelectBox) EVT_UPDATE_UI_RANGE(ID_TB_OPTIONS_SHOW_GBR_MODE_0
const std::string KiCadSchematicFileExtension
PCB_EDIT_FRAME is the main frame for Pcbnew.
AUI_PANELS m_AuiPanels
POINT_EDITOR.
Definition: point_editor.h:43
#define IU_PER_MILS
Definition: plotter.cpp:138
#define TO_UTF8(wxstring)
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
PCB_VIEWER_TOOLS.
bool InvokeExportSVG(PCB_EDIT_FRAME *aCaller, BOARD *aBoard)
Function InvokeExportSVG shows the Export SVG dialog.
virtual void SetPageSettings(const PAGE_INFO &aPageSettings) override
Definition: id.h:97
int m_NumberOfScreens
Definition: base_screen.h:86
Definition: id.h:87
void On3DShapeLibWizard(wxCommandEvent &event)
void OnUpdateSelectTrackWidth(wxUpdateUIEvent &aEvent)
#define PCB_EDIT_FRAME_NAME
void OnGridSettings(wxCommandEvent &event)
Abstract interface for BOARD_ITEMs capable of storing other items inside.
void PythonPluginsReloadBase()
Helper function PythonPluginsReloadBase Reload Python plugins if they are newer than the already load...
const BITMAP_OPAQUE icon_pcbnew_xpm[1]
Definition: icon_pcbnew.cpp:49
bool IsElementVisible(GAL_LAYER_ID aElement) const
Function IsElementVisible tests whether a given element category is visible.
void ReFillLayerWidget()
Function ReFillLayerWidget changes out all the layers in m_Layers and may be called upon loading a ne...
std::set< wxString > m_DrcExclusions
Excluded DRC items.
void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
switches currently used canvas (Cairo / OpenGL).
STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254
ID_POPUP_PCB_SELECT_WIDTH8
wxString GetCurrentFileName() const override
Get the full filename + path of the currently opened file in the frame.
void SetSheetNumber(int aSheetNumber)
Function SetSheetNumber() Changes the sheet number displayed in the title block.
int ExecuteFile(wxWindow *frame, const wxString &ExecFile, const wxString &param, wxProcess *callback)
Function ExecuteFile calls the executable file ExecFile with the command line parameters param.
Definition: gestfich.cpp:174
void PythonPluginsReload()
Reload the Python plugins if they are newer than the already loaded, and load new plugins if any Do n...
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Function SetActiveLayer will change the currently active layer to aLayer and also update the PCB_LAYE...
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString, const wxString &aErrorMsg=wxEmptyString, int aErrorCtrlId=-1, int aErrorLine=-1, int aErrorCol=-1)
Function ShowBoardSetupDialog.
bool IsEmpty() const
Definition: class_board.h:311
void InstallFootprintPropertiesDialog(MODULE *Module)
bool FetchNetlistFromSchematic(NETLIST &aNetlist, FETCH_NETLIST_MODE aMode)
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
#define DLG_WINDOW_NAME
void SetHasPosition(bool aHasPosition)
Definition: tool_event.h:261
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
void SetLastPath(LAST_PATH_TYPE aType, const wxString &aLastPath)
Set the path of the last file successfully read.
AUTOPLACE_TOOL.
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
KIWAY Kiway
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99