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_track.h>
48 #include <class_board.h>
49 #include <class_module.h>
50 #include <ws_proxy_view_item.h>
52 #include <ratsnest_viewitem.h>
54 #include <kicad_string.h>
55 #include <pcb_draw_panel_gal.h>
56 #include <functional>
58 #include <tool/tool_manager.h>
59 #include <tool/tool_dispatcher.h>
60 #include <tool/action_toolbar.h>
61 #include <tool/common_control.h>
62 #include <tool/common_tools.h>
63 #include <tool/zoom_tool.h>
64 #include <tools/selection_tool.h>
66 #include <tools/point_editor.h>
67 #include <tools/edit_tool.h>
68 #include <tools/global_edit_tool.h>
69 #include <tools/drawing_tool.h>
70 #include <tools/point_editor.h>
71 #include <tools/pcbnew_control.h>
74 #include <tools/placement_tool.h>
75 #include <tools/pad_tool.h>
76 #include <tools/microwave_tool.h>
78 #include <tools/zone_filler_tool.h>
79 #include <tools/pcb_actions.h>
80 #include <router/router_tool.h>
83 #include <gestfich.h>
84 #include <executable_names.h>
88 #include <wx/wupdlock.h>
89 #include <dialog_drc.h> // for DIALOG_DRC_WINDOW_NAME definition
90 
91 #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
92 #include <python_scripting.h>
93 #endif
94 
95 
96 using namespace std::placeholders;
97 
98 
99 BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
102 
105 
106  EVT_CLOSE( PCB_EDIT_FRAME::OnCloseWindow )
107  EVT_SIZE( PCB_EDIT_FRAME::OnSize )
108 
111 
112  // Menu Files:
114 
118 
124 
127 
128  EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit )
129  EVT_MENU( wxID_CLOSE, PCB_EDIT_FRAME::OnQuit )
130 
131  // menu Config
134 
135  // menu Postprocess
137 
138  // Horizontal toolbar
144 
145 
146 #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
147  EVT_TOOL( ID_TOOLBARH_PCB_ACTION_PLUGIN_REFRESH, PCB_EDIT_FRAME::OnActionPluginRefresh )
148 #endif
149 
150  // Tracks and vias sizes general options
153 
154  // User interface update event handlers.
159  PCB_EDIT_FRAME::OnUpdateSelectTrackWidth )
161  PCB_EDIT_FRAME::OnUpdateSelectViaSize )
162 
163  EVT_COMMAND( wxID_ANY, LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE, PCB_EDIT_FRAME::OnLayerColorChange )
164 END_EVENT_TABLE()
165 
166 
167 PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
168  PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_EDITOR, wxT( "Pcbnew" ), wxDefaultPosition,
170 {
171  m_showBorderAndTitleBlock = true; // true to display sheet references
172  m_SelTrackWidthBox = NULL;
173  m_SelViaSizeBox = NULL;
174  m_SelLayerBox = NULL;
175  m_show_microwave_tools = false;
176  m_show_layer_manager_tools = true;
177  m_hasAutoSave = true;
178  m_microWaveToolBar = NULL;
179  m_Layers = nullptr;
180  m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs
181 
182  // We don't know what state board was in when it was lasat saved, so we have to
183  // assume dirty
184  m_ZoneFillsDirty = true;
185 
186  m_rotationAngle = 900;
187  m_AboutTitle = "Pcbnew";
188 
189  // Create GAL canvas
190  auto canvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
191  GetGalDisplayOptions(),
193 
194  SetCanvas( canvas );
195 
196  SetBoard( new BOARD() );
197 
198  // Create the PCB_LAYER_WIDGET *after* SetBoard():
199  m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas() );
200 
201  wxIcon icon;
202  icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) );
203  SetIcon( icon );
204 
205  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
206  // initialize parameters in m_LayersManager
207  LoadSettings( config() );
208 
209  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
210  GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
211 
212  // PCB drawings start in the upper left corner.
213  GetScreen()->m_Center = false;
214 
215  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
216 
217  GetScreen()->AddGrid( m_UserGridSize, EDA_UNITS::UNSCALED, ID_POPUP_GRID_USER );
218  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
219 
220  setupTools();
221  ReCreateMenuBar();
222  ReCreateHToolbar();
223  ReCreateAuxiliaryToolbar();
224  ReCreateVToolbar();
225  ReCreateOptToolbar();
226  ReCreateMicrowaveVToolbar();
227 
228  m_auimgr.SetManagedWindow( this );
229 
230  // Horizontal items; layers 4 - 6
231  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
232  m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top().Layer(4) );
233  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
234 
235  // Vertical items; layers 1 - 3
236  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
237 
238  m_auimgr.AddPane( m_microWaveToolBar, EDA_PANE().VToolbar().Name( "MicrowaveToolbar" ).Right().Layer(1) );
239  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(2) );
240  m_auimgr.AddPane( m_Layers, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(3)
241  .Caption( _( "Layers Manager" ) ).PaneBorder( false )
242  .MinSize( 80, -1 ).BestSize( m_Layers->GetBestSize() ) );
243 
244  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
245 
246  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
247  m_auimgr.GetPane( "MicrowaveToolbar" ).Show( m_show_microwave_tools );
248 
249  m_Layers->ReFillRender(); // Update colors in Render after the config is read
250  ReFillLayerWidget(); // this is near end and after ReFillRender()
251  // because contents establish size
252  syncLayerWidgetLayer();
253 
254  m_auimgr.Update();
255  GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId );
256  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
257 
258  m_canvasType = LoadCanvasTypeSetting();
259 
260  // Nudge user to switch to OpenGL if they are on Cairo
261  if( m_firstRunDialogSetting < 1 )
262  {
263  if( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
264  {
265  wxString msg = _( "KiCad can use your graphics card to give you a smoother "
266  "and faster experience. This option is turned off by "
267  "default since it is not compatible with all computers.\n\n"
268  "Would you like to try enabling graphics acceleration?\n\n"
269  "If you'd like to choose later, select Accelerated Graphics "
270  "in the Preferences menu." );
271 
272  wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
273 
274  dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
275 
276  if( dlg.ShowModal() == wxID_YES )
277  {
278  // Save Cairo as default in case OpenGL crashes
279  saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
280 
281  // Switch to OpenGL, which will save the new setting if successful
282  GetToolManager()->RunAction( ACTIONS::acceleratedGraphics, true );
283 
284  // Switch back to Cairo if OpenGL is not supported
285  if( GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
286  GetToolManager()->RunAction( ACTIONS::standardGraphics, true );
287  }
288  else
289  {
290  // If they were on legacy, switch to Cairo
291  GetToolManager()->RunAction( ACTIONS::standardGraphics, true );
292  }
293  }
294 
295  m_firstRunDialogSetting = 1;
296  SaveSettings( config() );
297  }
298 
299  InitExitKey();
300 
301  GetCanvas()->SwitchBackend( m_canvasType );
302  GetCanvas()->GetView()->SetScale( GetZoomLevelCoeff() / GetScreen()->GetZoom() );
303  ActivateGalCanvas();
304 
305  // Default shutdown reason until a file is loaded
306  SetShutdownBlockReason( _( "New PCB file is unsaved" ) );
307 
308  // disable Export STEP item if kicad2step does not exist
309  wxString strK2S = Pgm().GetExecutablePath();
310 
311 #ifdef __WXMAC__
312  if (strK2S.find( "pcbnew.app" ) != wxNOT_FOUND )
313  {
314  // On macOS, we have standalone applications inside the main bundle, so we handle that here:
315  strK2S += "../../";
316  }
317 
318  strK2S += "Contents/MacOS/";
319 #endif
320 
321  wxFileName appK2S( strK2S, "kicad2step" );
322 
323  #ifdef _WIN32
324  appK2S.SetExt( "exe" );
325  #endif
326 
327 // if( !appK2S.FileExists() )
328  // GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
329 }
330 
331 
333 {
334  // Shutdown all running tools
335  if( m_toolManager )
336  m_toolManager->ShutdownAllTools();
337 }
338 
339 
341 {
343 
344  aBoard->GetConnectivity()->Build( aBoard );
345 
346  // reload the worksheet
347  SetPageSettings( aBoard->GetPageSettings() );
348 }
349 
350 
352 {
353  return m_Pcb;
354 }
355 
356 
357 int PCB_EDIT_FRAME::GetSeverity( int aErrorCode ) const
358 {
360 
361  return bds.m_DRCSeverities[ aErrorCode ];
362 }
363 
364 
365 void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
366 {
367  PCB_BASE_FRAME::SetPageSettings( aPageSettings );
368 
369  // Prepare worksheet template
370  KIGFX::WS_PROXY_VIEW_ITEM* worksheet;
371  worksheet = new KIGFX::WS_PROXY_VIEW_ITEM( IU_PER_MILS ,&m_Pcb->GetPageSettings(),
372  &m_Pcb->GetTitleBlock() );
373  worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );
374 
375  BASE_SCREEN* screen = GetScreen();
376 
377  if( screen != NULL )
378  {
379  worksheet->SetSheetNumber( screen->m_ScreenNumber );
380  worksheet->SetSheetCount( screen->m_NumberOfScreens );
381  }
382 
383  if( auto board = GetBoard() )
384  worksheet->SetFileName( TO_UTF8( board->GetFileName() ) );
385 
386  // PCB_DRAW_PANEL_GAL takes ownership of the worksheet
387  GetCanvas()->SetWorksheet( worksheet );
388 }
389 
390 
392 {
393  return GetScreen() && GetScreen()->IsModify() && GetBoard() && !GetBoard()->IsEmpty();
394 }
395 
396 
398 {
399  if( GetScreen() )
400  return GetScreen()->IsSave();
401 
402  return false;
403 }
404 
405 
407 {
408  // Create the manager and dispatcher & route draw panel events to the dispatcher
409  m_toolManager = new TOOL_MANAGER;
410  m_toolManager->SetEnvironment( m_Pcb, GetCanvas()->GetView(),
411  GetCanvas()->GetViewControls(), this );
412  m_actions = new PCB_ACTIONS();
413  m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
414 
415  // Register tools
416  m_toolManager->RegisterTool( new COMMON_CONTROL );
417  m_toolManager->RegisterTool( new COMMON_TOOLS );
418  m_toolManager->RegisterTool( new SELECTION_TOOL );
419  m_toolManager->RegisterTool( new ZOOM_TOOL );
420  m_toolManager->RegisterTool( new PCBNEW_PICKER_TOOL );
421  m_toolManager->RegisterTool( new ROUTER_TOOL );
422  m_toolManager->RegisterTool( new LENGTH_TUNER_TOOL );
423  m_toolManager->RegisterTool( new EDIT_TOOL );
424  m_toolManager->RegisterTool( new GLOBAL_EDIT_TOOL );
425  m_toolManager->RegisterTool( new PAD_TOOL );
426  m_toolManager->RegisterTool( new DRAWING_TOOL );
427  m_toolManager->RegisterTool( new POINT_EDITOR );
428  m_toolManager->RegisterTool( new PCBNEW_CONTROL );
429  m_toolManager->RegisterTool( new PCB_EDITOR_CONTROL );
430  m_toolManager->RegisterTool( new PCB_INSPECTION_TOOL );
431  m_toolManager->RegisterTool( new ALIGN_DISTRIBUTE_TOOL );
432  m_toolManager->RegisterTool( new MICROWAVE_TOOL );
433  m_toolManager->RegisterTool( new POSITION_RELATIVE_TOOL );
434  m_toolManager->RegisterTool( new ZONE_FILLER_TOOL );
435  m_toolManager->RegisterTool( new AUTOPLACE_TOOL );
436  m_toolManager->RegisterTool( new DRC );
437  m_toolManager->InitTools();
438 
439  // Run the selection tool, it is supposed to be always active
440  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
441 }
442 
443 
445 {
446  wxWindowUpdateLocker no_update( m_Layers );
447  m_Layers->ReFill();
448 
449  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_Layers );
450 
451  wxSize bestz = m_Layers->GetBestSize();
452 
453  lyrs.MinSize( bestz );
454  lyrs.BestSize( bestz );
455  lyrs.FloatingSize( bestz );
456 
457  if( lyrs.IsDocked() )
458  m_auimgr.Update();
459  else
460  m_Layers->SetSize( bestz );
461 }
462 
463 
464 void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event )
465 {
466  if( event.GetId() == wxID_EXIT )
467  Kiway().OnKiCadExit();
468 
469  if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
470  Close( false );
471 }
472 
473 
475 {
476  m_drcExclusions.clear();
477 
478  for( MARKER_PCB* marker : GetBoard()->Markers() )
479  {
480  if( marker->IsExcluded() )
481  m_drcExclusions.insert( marker->Serialize() );
482  }
483 }
484 
485 
487 {
488  for( MARKER_PCB* marker : GetBoard()->Markers() )
489  {
490  auto i = m_drcExclusions.find( marker->Serialize() );
491 
492  if( i != m_drcExclusions.end() )
493  {
494  marker->SetExcluded( true );
495  m_drcExclusions.erase( i );
496  }
497  }
498 
499  BOARD_COMMIT commit( this );
500 
501  for( const wxString& exclusionData : m_drcExclusions )
502  {
503  MARKER_PCB* marker = MARKER_PCB::Deserialize( exclusionData );
504  marker->SetExcluded( true );
505  commit.Add( marker );
506  }
507 
508  m_drcExclusions.clear();
509 
510  commit.Push( wxEmptyString, false, false );
511 }
512 
513 
514 void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
515 {
516  // Shutdown blocks must be determined and vetoed as early as possible
517  if( SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
518  && IsContentModified() )
519  {
520  aEvent.Veto();
521  return;
522  }
523 
524  // First close the DRC dialog. For some reason, if the board editor frame is destroyed
525  // when the DRC dialog currently open, Pcbnew crashes, at least on Windows.
526  DIALOG_DRC* open_dlg = static_cast<DIALOG_DRC*>(
527  wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME ) );
528 
529  if( open_dlg )
530  open_dlg->Close( true );
531 
532  // Save various DRC parameters, such as violation severities (which may have been
533  // edited via the DRC dialog as well as the Board Setup dialog), DRC exclusions, etc.
534  SaveProjectSettings();
535 
536  if( IsContentModified() )
537  {
538  wxFileName fileName = GetBoard()->GetFileName();
539  wxString msg = _( "Save changes to \"%s\" before closing?" );
540 
541  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
542  [&]()->bool { return Files_io_from_id( ID_SAVE_BOARD ); } ) )
543  {
544  aEvent.Veto();
545  return;
546  }
547  }
548 
549  // On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes
550  // when closing this frame if a footprint was selected, and the footprint editor called
551  // to edit this footprint, and when closing pcbnew if this footprint is still selected
552  // See https://bugs.launchpad.net/kicad/+bug/1655858
553  // I think this is certainly a OpenGL event fired after frame deletion, so this workaround
554  // avoid the crash (JPC)
555  GetCanvas()->SetEvtHandlerEnabled( false );
556 
557  GetCanvas()->StopDrawing();
558 
559  // Delete the auto save file if it exists.
560  wxFileName fn = GetBoard()->GetFileName();
561 
562  // Auto save file name is the normal file name prefixed with 'GetAutoSaveFilePrefix()'.
563  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
564 
565  // When the auto save feature does not have write access to the board file path, it falls
566  // back to a platform specific user temporary file path.
567  if( !fn.IsOk() || !fn.IsDirWritable() )
568  fn.SetPath( wxFileName::GetTempDir() );
569 
570  wxLogTrace( traceAutoSave, "Deleting auto save file <" + fn.GetFullPath() + ">" );
571 
572  // Remove the auto save file on a normal close of Pcbnew.
573  if( fn.FileExists() && !wxRemoveFile( fn.GetFullPath() ) )
574  {
575  wxString msg = wxString::Format( _( "The auto save file \"%s\" could not be removed!" ),
576  fn.GetFullPath() );
577  wxMessageBox( msg, Pgm().App().GetAppName(), wxOK | wxICON_ERROR, this );
578  }
579 
580  // Do not show the layer manager during closing to avoid flicker
581  // on some platforms (Windows) that generate useless redraw of items in
582  // the Layer Manger
583  if( m_show_layer_manager_tools )
584  m_auimgr.GetPane( "LayersManager" ).Show( false );
585 
586  // Delete board structs and undo/redo lists, to avoid crash on exit
587  // when deleting some structs (mainly in undo/redo lists) too late
588  Clear_Pcb( false, true );
589 
590  // do not show the window because ScreenPcb will be deleted and we do not
591  // want any paint event
592  Show( false );
593 
594  // Close frame:
595  aEvent.Skip();
596 }
597 
598 
600 {
602  ColorSettings()->SetColorContext( COLOR_CONTEXT::PCB );
603  GetCanvas()->UpdateColors();
604  GetCanvas()->Refresh();
605 }
606 
607 
608 void PCB_EDIT_FRAME::DoShowBoardSetupDialog( const wxString& aInitialPage,
609  const wxString& aInitialParentPage )
610 {
611  DIALOG_BOARD_SETUP dlg( this );
612 
613  if( !aInitialPage.IsEmpty() )
614  dlg.SetInitialPage( aInitialPage, aInitialParentPage );
615 
616  if( dlg.ShowQuasiModal() == wxID_OK )
617  {
618  SaveProjectSettings();
619 
621  ReCreateAuxiliaryToolbar();
622 
623  for( auto module : GetBoard()->Modules() )
624  GetCanvas()->GetView()->Update( module );
625 
626  GetCanvas()->Refresh();
627 
628  //this event causes the routing tool to reload its design rules information
630  toolEvent.SetHasPosition( false );
631  m_toolManager->ProcessEvent( toolEvent );
632 
633  OnModify();
634  }
635 }
636 
637 
639 {
641 
642  // TODO(JE) remove once color themes exist
643  COLOR_SETTINGS* cs = ColorSettings();
645  cs->Load();
646 
647  auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
648  wxASSERT( cfg );
649 
650  m_rotationAngle = cfg->m_RotationAngle;
651  g_DrawDefaultLineThickness = Millimeter2iu( cfg->m_PlotLineWidth );
652  m_show_microwave_tools = cfg->m_AuiPanels.show_microwave_tools;
653  m_show_layer_manager_tools = cfg->m_AuiPanels.show_layer_manager;
654  m_showPageLimits = cfg->m_ShowPageLimits;
655 }
656 
657 
659 {
661 
662  // TODO(JE) remove once color themes exist
663  COLOR_SETTINGS* cs = ColorSettings();
665  cs->Store();
666 
667  // Ensure pcbnew color settings get flushed to disk before context is changed
668  Pgm().GetSettingsManager().SaveColorSettings( cs, "board" );
669 
670  auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
671  wxASSERT( cfg );
672 
673  cfg->m_RotationAngle = m_rotationAngle;
674  cfg->m_PlotLineWidth = Iu2Millimeter( g_DrawDefaultLineThickness );
675  cfg->m_AuiPanels.show_microwave_tools = m_show_microwave_tools;
676  cfg->m_AuiPanels.show_layer_manager = m_show_layer_manager_tools;
677  cfg->m_ShowPageLimits = m_showPageLimits;
678 }
679 
680 
682 {
683  return ColorSettings()->GetColor( LAYER_GRID );
684 }
685 
686 
688 {
689 
690  ColorSettings()->SetColor( LAYER_GRID, aColor );
691  GetCanvas()->GetGAL()->SetGridColor( aColor );
692 }
693 
694 
696 {
698 
699  syncLayerWidgetLayer();
700 
701  m_toolManager->RunAction( PCB_ACTIONS::layerChanged ); // notify other tools
702  GetCanvas()->SetFocus(); // allow capture of hotkeys
703  GetCanvas()->SetHighContrastLayer( aLayer );
704  GetCanvas()->Refresh();
705 }
706 
707 
709 {
710  UpdateTitle();
711 
712  // Re-create layers manager based on layer info in board
713  ReFillLayerWidget();
714  ReCreateLayerBox();
715 
716  // Sync layer and item visibility
717  syncLayerVisibilities();
718  syncLayerWidgetLayer();
719  syncRenderStates();
720 
721  SetElementVisibility( LAYER_RATSNEST, GetDisplayOptions().m_ShowGlobalRatsnest );
722 
723  // Update the tracks / vias available sizes list:
724  ReCreateAuxiliaryToolbar();
725 
726  // Display the loaded board:
727  Zoom_Automatique( false );
728 
729  Refresh();
730 
731  SetMsgPanel( GetBoard() );
732  SetStatusText( wxEmptyString );
733 
734  SetShutdownBlockReason( _( "PCB file changes are unsaved" ) );
735 }
736 
737 
739 {
740  m_Layers->SelectLayer( GetActiveLayer() );
741  m_Layers->OnLayerSelected();
742 }
743 
744 
746 {
747  m_Layers->ReFillRender();
748 }
749 
750 
752 {
753  m_Layers->SyncLayerVisibilities();
754  GetCanvas()->SyncLayersVisibility( m_Pcb );
755 }
756 
757 
758 void PCB_EDIT_FRAME::OnUpdateLayerAlpha( wxUpdateUIEvent & )
759 {
760  m_Layers->SyncLayerAlphaIndicators();
761 }
762 
763 
765 {
766  return GetBoard()->IsElementVisible( aElement );
767 }
768 
769 
770 void PCB_EDIT_FRAME::SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState )
771 {
772  // Force the RATSNEST visible
773  if( aElement == LAYER_RATSNEST )
774  GetCanvas()->GetView()->SetLayerVisible( aElement, true );
775  else
776  GetCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
777 
778  GetBoard()->SetElementVisibility( aElement, aNewState );
779  m_Layers->SetRenderState( aElement, aNewState );
780 }
781 
782 
784 {
786 
788  m_Layers->SetRenderState( ii, true );
789 }
790 
791 
793 {
794  // call my base class
796 
797  // update the layer manager
798  m_Layers->Freeze();
799 
800  wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_Layers );
801  pane_info.Caption( _( "Visibles" ) );
802  m_auimgr.Update();
803 
804  m_Layers->SetLayersManagerTabsText();
805  ReFillLayerWidget();
806  // m_Layers->ReFillRender(); // syncRenderStates() does this
807 
808  // upate the layer widget to match board visibility states, both layers and render columns.
809  syncLayerVisibilities();
810  syncLayerWidgetLayer();
811  syncRenderStates();
812 
813  m_Layers->Thaw();
814 
815  // pcbnew-specific toolbars
816  ReCreateMicrowaveVToolbar();
817 }
818 
819 
821 {
822  if( m_lastPath[ aType ].IsEmpty() )
823  return wxEmptyString;
824 
825  wxFileName absoluteFileName = m_lastPath[ aType ];
826  wxFileName pcbFileName = GetBoard()->GetFileName();
827 
828  absoluteFileName.MakeAbsolute( pcbFileName.GetPath() );
829  return absoluteFileName.GetFullPath();
830 }
831 
832 
833 void PCB_EDIT_FRAME::SetLastPath( LAST_PATH_TYPE aType, const wxString& aLastPath )
834 {
835  wxFileName relativeFileName = aLastPath;
836  wxFileName pcbFileName = GetBoard()->GetFileName();
837 
838  relativeFileName.MakeRelativeTo( pcbFileName.GetPath() );
839 
840  if( relativeFileName.GetFullPath() != m_lastPath[ aType ] )
841  {
842  m_lastPath[ aType ] = relativeFileName.GetFullPath();
843  SaveProjectSettings();
844  }
845 }
846 
847 
849 {
851 
852  Update3DView( false );
853 
854  m_ZoneFillsDirty = true;
855 }
856 
857 
858 void PCB_EDIT_FRAME::ExportSVG( wxCommandEvent& event )
859 {
860  InvokeExportSVG( this, GetBoard() );
861 }
862 
863 
865 {
866  wxFileName fileName = GetBoard()->GetFileName();
867  wxString fileinfo;
868 
869  if( fileName.IsOk() && fileName.FileExists() )
870  fileinfo = fileName.IsFileWritable() ? wxString( wxEmptyString ) : _( " [Read Only]" );
871  else
872  fileinfo = _( " [Unsaved]" );
873 
874  SetTitle( wxString::Format( _( "Pcbnew" ) + wxT( " \u2014 %s%s" ),
875  fileName.GetFullPath(),
876  fileinfo ) );
877 }
878 
879 
881 {
882  // Update the layer manager and other widgets from the board setup
883  // (layer and items visibility, colors ...)
884 
885  // Rebuild list of nets (full ratsnest rebuild)
886  Compile_Ratsnest( true );
888 
889  // Update info shown by the horizontal toolbars
890  ReCreateLayerBox();
891 
892  // Update the layer manager
893  m_Layers->Freeze();
894  ReFillLayerWidget();
895  // m_Layers->ReFillRender(); // syncRenderStates() does this
896 
897  // upate the layer widget to match board visibility states, both layers and render columns.
898  syncLayerVisibilities();
899  syncLayerWidgetLayer();
900  syncRenderStates();
901 
902  m_Layers->Thaw();
903 }
904 
905 
906 #if defined( KICAD_SCRIPTING_WXPYTHON )
907 
908 void PCB_EDIT_FRAME::ScriptingConsoleEnableDisable()
909 {
910  wxWindow * pythonPanelFrame = findPythonConsole();
911  bool pythonPanelShown = true;
912 
913  if( pythonPanelFrame == NULL )
914  pythonPanelFrame = CreatePythonShellWindow( this, pythonConsoleNameId() );
915  else
916  pythonPanelShown = ! pythonPanelFrame->IsShown();
917 
918  if( pythonPanelFrame )
919  pythonPanelFrame->Show( pythonPanelShown );
920  else
921  wxMessageBox( wxT( "Error: unable to create the Python Console" ) );
922 }
923 #endif
924 
925 
926 void PCB_EDIT_FRAME::OnLayerColorChange( wxCommandEvent& aEvent )
927 {
928  ReCreateLayerBox();
929 }
930 
931 
933 {
934  // switches currently used canvas (Cairo / OpenGL).
935  PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
936 
937  GetCanvas()->GetGAL()->SetGridSize( VECTOR2D( GetScreen()->GetGridSize() ) );
938 
939  // The base class method *does not reinit* the layers manager. We must upate the
940  // layer widget to match board visibility states, both layers and render columns.
941  syncLayerVisibilities();
942  syncLayerWidgetLayer();
943  syncRenderStates();
944 }
945 
946 
948 {
949  PCB_PLOT_PARAMS plotSettings = GetPlotSettings();
950 
951  switch( aID )
952  {
953  case ID_GEN_PLOT_GERBER:
954  plotSettings.SetFormat( PLOT_FORMAT::GERBER );
955  break;
956  case ID_GEN_PLOT_DXF:
957  plotSettings.SetFormat( PLOT_FORMAT::DXF );
958  break;
959  case ID_GEN_PLOT_HPGL:
960  plotSettings.SetFormat( PLOT_FORMAT::HPGL );
961  break;
962  case ID_GEN_PLOT_PDF:
963  plotSettings.SetFormat( PLOT_FORMAT::PDF );
964  break;
965  case ID_GEN_PLOT_PS:
966  plotSettings.SetFormat( PLOT_FORMAT::POST );
967  break;
968  case ID_GEN_PLOT: /* keep the previous setup */ break;
969  default:
970  wxFAIL_MSG( "ToPlotter(): unexpected plot type" ); break;
971  break;
972  }
973 
974  SetPlotSettings( plotSettings );
975 
976  // Force rebuild the dialog if currently open because the old dialog can be not up to date
977  // if the board (or units) has changed
978  wxWindow* dlg = wxWindow::FindWindowByName( DLG_WINDOW_NAME );
979 
980  if( dlg )
981  dlg->Destroy();
982 
983  dlg = new DIALOG_PLOT( this );
984  dlg->Show( true );
985 }
986 
987 
988 bool PCB_EDIT_FRAME::SetCurrentNetClass( const wxString& aNetClassName )
989 {
990  bool change = GetDesignSettings().SetCurrentNetClass( aNetClassName );
991 
992  if( change )
993  ReCreateAuxiliaryToolbar();
994 
995  return change;
996 }
997 
998 
1000 {
1001  if( Kiface().IsSingle() )
1002  {
1003  DisplayError( this, _( "Cannot update the PCB because Pcbnew is opened in stand-alone "
1004  "mode. In order to create or update PCBs from schematics, you "
1005  "must launch the KiCad project manager and create a project." ) );
1006  return false;
1007  }
1008 
1009  // Update PCB requires a netlist. Therefore the schematic editor must be running
1010  // If this is not the case, open the schematic editor
1011  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
1012 
1013  if( !frame->IsShown() )
1014  {
1015  wxFileName schfn( Prj().GetProjectPath(), Prj().GetProjectName(), LegacySchematicFileExtension );
1016 
1017  frame->OpenProjectFiles( std::vector<wxString>( 1, schfn.GetFullPath() ) );
1018 
1019  // we show the schematic editor frame, because do not show is seen as
1020  // a not yet opened schematic by Kicad manager, which is not the case
1021  frame->Show( true );
1022 
1023  // bring ourselves back to the front
1024  Raise();
1025  }
1026 
1027  std::string payload;
1028 
1029  if( aMode == NO_ANNOTATION )
1030  payload = "no-annotate";
1031  else if( aMode == QUIET_ANNOTATION )
1032  payload = "quiet-annotate";
1033 
1034  Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_GET_NETLIST, payload, this );
1035 
1036  try
1037  {
1038  auto lineReader = new STRING_LINE_READER( payload, _( "Eeschema netlist" ) );
1039  KICAD_NETLIST_READER netlistReader( lineReader, &aNetlist );
1040  netlistReader.LoadNetlist();
1041  }
1042  catch( const IO_ERROR& )
1043  {
1044  assert( false ); // should never happen
1045  return false;
1046  }
1047 
1048  return true;
1049 }
1050 
1051 
1052 void PCB_EDIT_FRAME::DoUpdatePCBFromNetlist( NETLIST& aNetlist, bool aUseTimestamps )
1053 {
1054  BOARD_NETLIST_UPDATER updater( this, GetBoard() );
1055  updater.SetLookupByTimestamp( aUseTimestamps );
1056  updater.SetDeleteUnusedComponents( false );
1057  updater.SetReplaceFootprints( true );
1058  updater.SetDeleteSinglePadNets( false );
1059  updater.SetWarnPadNoNetInNetlist( false );
1060  updater.UpdateNetlist( aNetlist );
1061 }
1062 
1063 
1065 {
1066  wxString msg;
1067  wxFileName schfn( Prj().GetProjectPath(), Prj().GetProjectName(),
1069 
1070  if( !schfn.FileExists() )
1071  {
1072  msg.Printf( _( "Schematic file \"%s\" not found." ), schfn.GetFullPath() );
1073  wxMessageBox( msg, _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
1074  return;
1075  }
1076 
1077  if( Kiface().IsSingle() )
1078  {
1079  wxString filename = wxT( "\"" ) + schfn.GetFullPath( wxPATH_NATIVE ) + wxT( "\"" );
1080  ExecuteFile( this, EESCHEMA_EXE, filename );
1081  }
1082  else
1083  {
1084  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, false );
1085 
1086  // Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls
1087  // Kiway.Player( FRAME_SCH, true )
1088  // therefore, the schematic editor is sometimes running, but the schematic project
1089  // is not loaded, if the library editor was called, and the dialog field editor was used.
1090  // On linux, it happens the first time the schematic editor is launched, if
1091  // library editor was running, and the dialog field editor was open
1092  // On Windows, it happens always after the library editor was called,
1093  // and the dialog field editor was used
1094  if( !frame )
1095  {
1096  try
1097  {
1098  frame = Kiway().Player( FRAME_SCH, true );
1099  }
1100  catch( const IO_ERROR& err )
1101  {
1102  wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
1103  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
1104  return;
1105  }
1106  }
1107 
1108  if( !frame->IsShown() ) // the frame exists, (created by the dialog field editor)
1109  // but no project loaded.
1110  {
1111  frame->OpenProjectFiles( std::vector<wxString>( 1, schfn.GetFullPath() ) );
1112  frame->Show( true );
1113  }
1114 
1115  // On Windows, Raise() does not bring the window on screen, when iconized or not shown
1116  // On linux, Raise() brings the window on screen, but this code works fine
1117  if( frame->IsIconized() )
1118  {
1119  frame->Iconize( false );
1120  // If an iconized frame was created by Pcbnew, Iconize( false ) is not enough
1121  // to show the frame at its normal size: Maximize should be called.
1122  frame->Maximize( false );
1123  }
1124 
1125  frame->Raise();
1126  }
1127 }
1128 
1129 
1131 {
1132  // Reload Python plugins if they are newer than
1133  // the already loaded, and load new plugins
1134 #if defined(KICAD_SCRIPTING)
1135  //Reload plugin list: reload Python plugins if they are newer than
1136  // the already loaded, and load new plugins
1138 
1139  #if defined(KICAD_SCRIPTING_ACTION_MENU)
1140  // Action plugins can be modified, therefore the plugins menu
1141  // must be updated:
1142  ReCreateMenuBar();
1143  // Recreate top toolbar to add action plugin buttons
1144  ReCreateHToolbar();
1145  #endif
1146 #endif
1147 }
1148 
1149 
1151 {
1152  if( Module == NULL )
1153  return;
1154 
1156 
1157  int retvalue = dlg->ShowModal();
1158  /* retvalue =
1159  * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_UPDATE_FP if update footprint
1160  * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_EXCHANGE_FP if change footprint
1161  * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_MODEDIT for a goto editor command
1162  * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_EDIT_OK for normal edit
1163  */
1164 
1165  dlg->Close();
1166  dlg->Destroy();
1167 
1169  {
1170  // If something edited, push a refresh request
1171  GetCanvas()->Refresh();
1172  }
1174  {
1175  auto editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
1176 
1177  editor->Load_Module_From_BOARD( Module );
1178 
1179  editor->Show( true );
1180  editor->Raise(); // Iconize( false );
1181  }
1182 
1184  {
1185  auto editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
1186 
1187  editor->LoadModuleFromLibrary( Module->GetFPID() );
1188 
1189  editor->Show( true );
1190  editor->Raise(); // Iconize( false );
1191  }
1192 
1194  {
1195  InstallExchangeModuleFrame( Module, true, true );
1196  }
1197 
1199  {
1200  InstallExchangeModuleFrame( Module, false, true );
1201  }
1202 }
1203 
1204 
1206  bool selectedMode )
1207 {
1208  DIALOG_EXCHANGE_FOOTPRINTS dialog( this, aModule, updateMode, selectedMode );
1209 
1210  return dialog.ShowQuasiModal();
1211 }
1212 
1213 
1214 void PCB_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
1215 {
1216  PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged );
1217 
1218  ReCreateMicrowaveVToolbar();
1219 
1220  Layout();
1221  SendSizeEvent();
1222 }
1223 
1224 
1225 void PCB_EDIT_FRAME::LockModule( MODULE* aModule, bool aLocked )
1226 {
1227  const wxString ModulesMaskSelection = wxT( "*" );
1228  if( aModule )
1229  {
1230  aModule->SetLocked( aLocked );
1231  SetMsgPanel( aModule );
1232  OnModify();
1233  }
1234  else
1235  {
1236  for( auto mod : GetBoard()->Modules() )
1237  {
1238  if( WildCompareString( ModulesMaskSelection, mod->GetReference() ) )
1239  {
1240  mod->SetLocked( aLocked );
1241  OnModify();
1242  }
1243  }
1244  }
1245 }
1246 
1247 
1248 bool ExportBoardToHyperlynx( BOARD* aBoard, const wxFileName& aPath );
1249 
1250 
1251 void PCB_EDIT_FRAME::OnExportHyperlynx( wxCommandEvent& event )
1252 {
1253  wxString wildcard = wxT( "*.hyp" );
1254  wxFileName fn = GetBoard()->GetFileName();
1255 
1256  fn.SetExt( wxT("hyp") );
1257 
1258  wxFileDialog dlg( this, _( "Export Hyperlynx Layout" ), fn.GetPath(), fn.GetFullName(),
1259  wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1260 
1261  if( dlg.ShowModal() != wxID_OK )
1262  return;
1263 
1264  fn = dlg.GetPath();
1265 
1266  // always enforce filename extension, user may not have entered it.
1267  fn.SetExt( wxT( "hyp" ) );
1268 
1270 }
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
void syncRenderStates()
Function syncRenderStates updates the "Render" checkboxes in the layer widget according to current to...
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
LAST_PATH_TYPE
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
const PAGE_INFO & GetPageSettings() const
Definition: class_board.h:527
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:522
int m_ScreenNumber
Definition: base_screen.h:135
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:103
void clear()
Definition: commit.h:161
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.
std::map< int, int > m_DRCSeverities
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:512
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 SetColorContext(COLOR_CONTEXT aContext=COLOR_CONTEXT::PCB)
void SetGridColor(COLOR4D aColor) override
Function SetGridColor() , virtual.
const LIB_ID & GetFPID() const
Definition: class_module.h:219
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
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:218
bool UpdateNetlist(NETLIST &aNetlist)
Function UpdateNetlist()
void SetVisibleAlls()
Function SetVisibleAlls Set the status of all visible element categories and layers to VISIBLE.
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
int InstallExchangeModuleFrame(MODULE *aModule, bool updateMode, bool selectedMode)
Definitions for tracks, vias and zones.
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.
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:48
TOOL_MANAGER.
Definition: tool_manager.h:50
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:173
static TOOL_ACTION gridPreset
Definition: actions.h:134
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:75
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
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
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:341
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:49
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()
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:74
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:433
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.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:306
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)
Function SetActiveLayer will change the currently active layer to aLayer.
void SetFormat(PLOT_FORMAT aFormat)
PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board.
COMMON_CONTROL.
EDIT_TOOL.
Definition: edit_tool.h:67
Specialization of the wxAuiPaneInfo class for KiCad panels.
const std::string LegacySchematicFileExtension
virtual void Store()
Stores the current parameters into the JSON document represented by this object Note: this doesn't do...
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.
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:427
void OnSockRequest(wxSocketEvent &evt)
Definition: eda_dde.cpp:71
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
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:277
PCB_ACTIONS.
Definition: pcb_actions.h:62
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.
virtual 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:311
void DoShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString, const wxString &aInitialParentPage=wxEmptyString)
Function ShowBoardSetupDialog.
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:163
int GetSeverity(int aErrorCode) const override
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:133
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
PCB_EDIT_FRAME is the main frame for Pcbnew.
POINT_EDITOR.
Definition: point_editor.h:43
#define IU_PER_MILS
Definition: plotter.cpp:137
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, EDA_BASE_FRAME *aFrame)
Sets the work environment (model, view, view controls and the parent window).
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
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:136
Definition: id.h:87
void On3DShapeLibWizard(wxCommandEvent &event)
void OnUpdateSelectTrackWidth(wxUpdateUIEvent &aEvent)
#define PCB_EDIT_FRAME_NAME
void OnGridSettings(wxCommandEvent &aEvent) override
Module description (excepted pads)
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...
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
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...
bool IsEmpty() const
Definition: class_board.h:264
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
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
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.
KIWAY Kiway
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:40