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