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 <kiface_i.h>
24 #include <kiway.h>
25 #include <pgm_base.h>
26 #include <pcb_edit_frame.h>
28 #include <fp_lib_table.h>
29 #include <bitmaps.h>
30 #include <trace_helpers.h>
31 #include <pcbnew_id.h>
32 #include <pcbnew_settings.h>
33 #include <pcb_layer_box_selector.h>
34 #include <footprint_edit_frame.h>
35 #include <dialog_plot.h>
38 #include <dialog_board_setup.h>
39 #include <convert_to_biu.h>
40 #include <invoke_pcb_dialog.h>
41 #include <board.h>
42 #include <footprint.h>
46 #include <pcb_draw_panel_gal.h>
47 #include <functional>
48 #include <project/project_file.h>
50 #include <project/net_settings.h>
53 #include <tool/tool_manager.h>
54 #include <tool/tool_dispatcher.h>
55 #include <tool/action_toolbar.h>
56 #include <tool/common_control.h>
57 #include <tool/common_tools.h>
58 #include <tool/selection.h>
59 #include <tool/zoom_tool.h>
60 #include <tools/selection_tool.h>
62 #include <tools/point_editor.h>
63 #include <tools/edit_tool.h>
64 #include <tools/group_tool.h>
65 #include <tools/drc_tool.h>
66 #include <tools/global_edit_tool.h>
67 #include <tools/convert_tool.h>
68 #include <tools/drawing_tool.h>
69 #include <tools/pcbnew_control.h>
73 #include <tools/pcb_viewer_tools.h>
75 #include <tools/placement_tool.h>
76 #include <tools/pad_tool.h>
79 #include <tools/zone_filler_tool.h>
80 #include <tools/pcb_actions.h>
81 #include <router/router_tool.h>
84 #include <gestfich.h>
85 #include <executable_names.h>
89 #include <wx/wupdlock.h>
90 #include <dialog_drc.h> // for DIALOG_DRC_WINDOW_NAME definition
94 #include <kiplatform/app.h>
95 
96 
97 #include <widgets/infobar.h>
98 
99 #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
100 #include <python_scripting.h>
101 #endif
102 
103 
104 using namespace std::placeholders;
105 
106 
107 BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
110 
113 
114  EVT_SIZE( PCB_EDIT_FRAME::OnSize )
115 
117 
118  // Menu Files:
120 
124 
130 
133 
134  EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit )
135  EVT_MENU( wxID_CLOSE, PCB_EDIT_FRAME::OnQuit )
136 
137  // menu Config
139 
140  // menu Postprocess
142 
143  // Horizontal toolbar
149 
150 
151 #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
152  EVT_TOOL( ID_TOOLBARH_PCB_ACTION_PLUGIN_REFRESH, PCB_EDIT_FRAME::OnActionPluginRefresh )
153  EVT_TOOL( ID_TOOLBARH_PCB_ACTION_PLUGIN_SHOW_FOLDER, PCB_EDIT_FRAME::OnActionPluginShowFolder )
154 #endif
155 
156  // Tracks and vias sizes general options
159 
160  // User interface update event handlers.
166  PCB_EDIT_FRAME::OnUpdateSelectTrackWidth )
168  PCB_EDIT_FRAME::OnUpdateSelectViaSize )
169 END_EVENT_TABLE()
170 
171 
172 PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
173  PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_EDITOR, wxT( "Pcbnew" ), wxDefaultPosition,
175 {
176  m_maximizeByDefault = true;
177  m_showBorderAndTitleBlock = true; // true to display sheet references
178  m_SelTrackWidthBox = NULL;
179  m_SelViaSizeBox = NULL;
180  m_SelLayerBox = NULL;
181  m_show_layer_manager_tools = true;
182  m_hasAutoSave = true;
183 
184  // We don't know what state board was in when it was lasat saved, so we have to
185  // assume dirty
186  m_ZoneFillsDirty = true;
187 
188  m_rotationAngle = 900;
189  m_aboutTitle = "Pcbnew";
190 
191  // Create GAL canvas
192  auto canvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
193  GetGalDisplayOptions(),
195 
196  SetCanvas( canvas );
197 
198  SetBoard( new BOARD() );
199 
200  wxIcon icon;
201  icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) );
202  SetIcon( icon );
203 
204  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
205  // initialize parameters in m_LayersManager
206  LoadSettings( config() );
207 
208  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
209 
210  // PCB drawings start in the upper left corner.
211  GetScreen()->m_Center = false;
212 
213  setupTools();
214  setupUIConditions();
215 
216  ReCreateMenuBar();
217  ReCreateHToolbar();
218  ReCreateAuxiliaryToolbar();
219  ReCreateVToolbar();
220  ReCreateOptToolbar();
221 
222  m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
223 
224  // Create the infobar
225  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
226 
227  m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas() );
228 
229  m_auimgr.SetManagedWindow( this );
230 
231  unsigned int auiFlags = wxAUI_MGR_DEFAULT;
232 #if !defined( _WIN32 )
233  // Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds of graphical glitches
234  auiFlags |= wxAUI_MGR_LIVE_RESIZE;
235 #endif
236  m_auimgr.SetFlags( auiFlags );
237 
238  // Horizontal items; layers 4 - 6
239  m_auimgr.AddPane( m_mainToolBar,
240  EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
241  m_auimgr.AddPane( m_auxiliaryToolBar,
242  EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top().Layer(5) );
243  m_auimgr.AddPane( m_messagePanel,
244  EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
245  m_auimgr.AddPane( m_infoBar,
246  EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
247 
248  // Vertical items; layers 1 - 3
249  m_auimgr.AddPane( m_optionsToolBar,
250  EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
251 
252  m_auimgr.AddPane( m_drawToolBar,
253  EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(3) );
254 
255  m_auimgr.AddPane( m_appearancePanel,
256  EDA_PANE().Name( "LayersManager" ).Right().Layer( 4 )
257  .Caption( _( "Appearance" ) ).PaneBorder( false )
258  .MinSize( 180, -1 ).BestSize( 180, -1 ) );
259 
260  m_auimgr.AddPane( m_selectionFilterPanel,
261  EDA_PANE().Name( "SelectionFilter" ).Right().Layer( 4 )
262  .Caption( _( "Selection Filter" ) ).PaneBorder( false ).Position( 2 )
263  .MinSize( 180, -1 ).BestSize( 180, -1 ) );
264 
265  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
266 
267  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
268  m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
269 
270  // The selection filter doesn't need to grow in the vertical direction when docked
271  m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
272 
273  m_auimgr.GetArtProvider()->SetColour( wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR,
274  wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) );
275  m_auimgr.GetArtProvider()->SetColour( wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR,
276  wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) );
277 
278  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
279  // hidding it.
280  m_auimgr.Update();
281 
282  if( PCBNEW_SETTINGS* settings = dynamic_cast<PCBNEW_SETTINGS*>( config() ) )
283  {
284  if( settings->m_AuiPanels.right_panel_width > 0 )
285  {
286  wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
287 
288  // wxAUI hack: force width by setting MinSize() and then Fixed()
289  // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
290  layersManager.MinSize( settings->m_AuiPanels.right_panel_width, -1 );
291  layersManager.Fixed();
292  m_auimgr.Update();
293 
294  // now make it resizable again
295  layersManager.MinSize( 180, -1 );
296  layersManager.Resizable();
297  m_auimgr.Update();
298  }
299 
300  m_appearancePanel->SetTabIndex( settings->m_AuiPanels.appearance_panel_tab );
301  }
302 
303  // We don't want the infobar displayed right away
304  m_auimgr.GetPane( "InfoBar" ).Hide();
305  m_auimgr.Update();
306 
307  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
308 
309  // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
310  // to calculate the wrong zoom size. See PCB_EDIT_FRAME::onSize().
311  Bind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this );
312 
313  resolveCanvasType();
314 
315  initExitKey();
316  setupUnits( config() );
317 
318  // Ensure the Python interpreter is up to date with its environment variables
319  PythonSyncEnvironmentVariables();
320  PythonSyncProjectName();
321 
322  GetCanvas()->SwitchBackend( m_canvasType );
323  ActivateGalCanvas();
324 
325  // Default shutdown reason until a file is loaded
326  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New PCB file is unsaved" ) );
327 
328  // disable Export STEP item if kicad2step does not exist
329  wxString strK2S = Pgm().GetExecutablePath();
330 
331 #ifdef __WXMAC__
332  if( strK2S.Find( "pcbnew.app" ) != wxNOT_FOUND )
333  {
334  // On macOS, we have standalone applications inside the main bundle, so we handle that here:
335  strK2S += "../../";
336  }
337 
338  strK2S += "Contents/MacOS/";
339 #endif
340 
341  wxFileName appK2S( strK2S, "kicad2step" );
342 
343  #ifdef _WIN32
344  appK2S.SetExt( "exe" );
345  #endif
346 
347  // Ensure the window is on top
348  Raise();
349 
350 // if( !appK2S.FileExists() )
351  // GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
352 }
353 
354 
356 {
357  // Close modeless dialogs
358  wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
359 
360  if( open_dlg )
361  open_dlg->Close( true );
362 
363  // Shutdown all running tools
364  if( m_toolManager )
365  m_toolManager->ShutdownAllTools();
366 
367  if( GetBoard() )
368  GetBoard()->RemoveListener( m_appearancePanel );
369 
370  delete m_selectionFilterPanel;
371  delete m_appearancePanel;
372 }
373 
374 
376 {
377  if( m_pcb )
378  m_pcb->ClearProject();
379 
381 
382  aBoard->SetProject( &Prj() );
383  aBoard->GetConnectivity()->Build( aBoard );
384 
385  // reload the worksheet
386  SetPageSettings( aBoard->GetPageSettings() );
387 }
388 
389 
391 {
392  return m_pcb;
393 }
394 
395 
396 void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
397 {
398  PCB_BASE_FRAME::SetPageSettings( aPageSettings );
399 
400  // Prepare worksheet template
401  KIGFX::WS_PROXY_VIEW_ITEM* worksheet;
402  worksheet = new KIGFX::WS_PROXY_VIEW_ITEM( IU_PER_MILS, &m_pcb->GetPageSettings(),
403  m_pcb->GetProject(), &m_pcb->GetTitleBlock() );
404  worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );
405 
406  BASE_SCREEN* screen = GetScreen();
407 
408  if( screen != NULL )
409  {
410  worksheet->SetPageNumber( TO_UTF8( screen->GetPageNumber() ) );
411  worksheet->SetSheetCount( screen->GetPageCount() );
412  }
413 
414  if( auto board = GetBoard() )
415  worksheet->SetFileName( TO_UTF8( board->GetFileName() ) );
416 
417  // PCB_DRAW_PANEL_GAL takes ownership of the worksheet
418  GetCanvas()->SetWorksheet( worksheet );
419 }
420 
421 
423 {
424  return GetScreen() && GetScreen()->IsModify();
425 }
426 
427 
429 {
430  if( GetScreen() )
431  return GetScreen()->IsSave();
432 
433  return false;
434 }
435 
436 
438 {
439  return m_toolManager->GetTool<SELECTION_TOOL>()->GetSelection();
440 }
441 
442 
444 {
445  // Create the manager and dispatcher & route draw panel events to the dispatcher
446  m_toolManager = new TOOL_MANAGER;
447  m_toolManager->SetEnvironment( m_pcb, GetCanvas()->GetView(),
448  GetCanvas()->GetViewControls(), config(), this );
449  m_actions = new PCB_ACTIONS();
450  m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
451 
452  // Register tools
453  m_toolManager->RegisterTool( new COMMON_CONTROL );
454  m_toolManager->RegisterTool( new COMMON_TOOLS );
455  m_toolManager->RegisterTool( new SELECTION_TOOL );
456  m_toolManager->RegisterTool( new ZOOM_TOOL );
457  m_toolManager->RegisterTool( new PCBNEW_PICKER_TOOL );
458  m_toolManager->RegisterTool( new ROUTER_TOOL );
459  m_toolManager->RegisterTool( new LENGTH_TUNER_TOOL );
460  m_toolManager->RegisterTool( new EDIT_TOOL );
461  m_toolManager->RegisterTool( new GLOBAL_EDIT_TOOL );
462  m_toolManager->RegisterTool( new PAD_TOOL );
463  m_toolManager->RegisterTool( new DRAWING_TOOL );
464  m_toolManager->RegisterTool( new POINT_EDITOR );
465  m_toolManager->RegisterTool( new PCBNEW_CONTROL );
466  m_toolManager->RegisterTool( new PCB_EDITOR_CONTROL );
467  m_toolManager->RegisterTool( new PCB_INSPECTION_TOOL );
468  m_toolManager->RegisterTool( new PCB_REANNOTATE_TOOL );
469  m_toolManager->RegisterTool( new ALIGN_DISTRIBUTE_TOOL );
470  m_toolManager->RegisterTool( new MICROWAVE_TOOL );
471  m_toolManager->RegisterTool( new POSITION_RELATIVE_TOOL );
472  m_toolManager->RegisterTool( new ZONE_FILLER_TOOL );
473  m_toolManager->RegisterTool( new AUTOPLACE_TOOL );
474  m_toolManager->RegisterTool( new DRC_TOOL );
475  m_toolManager->RegisterTool( new PCB_VIEWER_TOOLS );
476  m_toolManager->RegisterTool( new CONVERT_TOOL );
477  m_toolManager->RegisterTool( new GROUP_TOOL );
478  m_toolManager->InitTools();
479 
480  // Run the selection tool, it is supposed to be always active
481  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
482 }
483 
484 
486 {
488 
489  ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
490  PCB_EDITOR_CONDITIONS cond( this );
491 
492  wxASSERT( mgr );
493 
494 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
495 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
496 
498  mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
499  mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
500 
509 
514  mgr->SetConditions( ACTIONS::selectAll, ENABLE( cond.HasItems() ) );
517 
524 
525 
526 #if defined( KICAD_SCRIPTING_WXPYTHON )
527  auto pythonConsoleCond =
528  [] ( const SELECTION& )
529  {
530  if( IsWxPythonLoaded() )
531  {
532  wxWindow* console = PCB_EDIT_FRAME::findPythonConsole();
533  return console && console->IsShown();
534  }
535 
536  return false;
537  };
538 
539  mgr->SetConditions( PCB_ACTIONS::showPythonConsole, CHECK( pythonConsoleCond ) );
540 #endif
541 
542 
543  auto enableBoardSetupCondition =
544  [this] ( const SELECTION& )
545  {
546  if( DRC_TOOL* tool = m_toolManager->GetTool<DRC_TOOL>() )
547  return !tool->IsDRCDialogShown();
548 
549  return true;
550  };
551 
552  auto boardFlippedCond =
553  [this]( const SELECTION& )
554  {
555  return GetCanvas()->GetView()->IsMirroredX();
556  };
557 
558  auto layerManagerCond =
559  [this] ( const SELECTION& )
560  {
561  return LayerManagerShown();
562  };
563 
564  auto highContrastCond =
565  [this] ( const SELECTION& )
566  {
567  return GetDisplayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
568  };
569 
570  auto globalRatsnestCond =
571  [this] (const SELECTION& )
572  {
573  return GetDisplayOptions().m_ShowGlobalRatsnest;
574  };
575 
576  auto curvedRatsnestCond =
577  [this] (const SELECTION& )
578  {
579  return GetDisplayOptions().m_DisplayRatsnestLinesCurved;
580  };
581 
582  mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
583  mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
584  mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) );
585  mgr->SetConditions( PCB_ACTIONS::showRatsnest, CHECK( globalRatsnestCond ) );
586  mgr->SetConditions( PCB_ACTIONS::ratsnestLineMode, CHECK( curvedRatsnestCond ) );
587  mgr->SetConditions( PCB_ACTIONS::boardSetup , ENABLE( enableBoardSetupCondition ) );
588 
589 
590  auto isHighlightMode =
591  [this]( const SELECTION& )
592  {
593  ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
594  return tool->GetRouterMode() == PNS::RM_MarkObstacles;
595  };
596 
597  auto isShoveMode =
598  [this]( const SELECTION& )
599  {
600  ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
601  return tool->GetRouterMode() == PNS::RM_Shove;
602  };
603 
604  auto isWalkaroundMode =
605  [this]( const SELECTION& )
606  {
607  ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
608  return tool->GetRouterMode() == PNS::RM_Walkaround;
609  };
610 
611  mgr->SetConditions( PCB_ACTIONS::routerHighlightMode, CHECK( isHighlightMode ) );
612  mgr->SetConditions( PCB_ACTIONS::routerShoveMode, CHECK( isShoveMode ) );
613  mgr->SetConditions( PCB_ACTIONS::routerWalkaroundMode, CHECK( isWalkaroundMode ) );
614 
615  auto haveNetCond =
616  [] ( const SELECTION& aSel )
617  {
618  for( EDA_ITEM* item : aSel )
619  {
620  if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
621  {
622  if( bci->GetNetCode() > 0 )
623  return true;
624  }
625  }
626 
627  return false;
628  };
629 
630  mgr->SetConditions( PCB_ACTIONS::showNet, ENABLE( haveNetCond ) );
631  mgr->SetConditions( PCB_ACTIONS::hideNet, ENABLE( haveNetCond ) );
632  mgr->SetConditions( PCB_ACTIONS::highlightNet, ENABLE( haveNetCond ) );
633 
642 
643 
644  SELECTION_CONDITION singleZoneCond = SELECTION_CONDITIONS::Count( 1 ) &&
646 
650 
651  mgr->SetConditions( PCB_ACTIONS::zoneDuplicate, ENABLE( singleZoneCond ) );
652  mgr->SetConditions( PCB_ACTIONS::drawZoneCutout, ENABLE( singleZoneCond ) );
653  mgr->SetConditions( PCB_ACTIONS::drawSimilarZone, ENABLE( singleZoneCond ) );
654  mgr->SetConditions( PCB_ACTIONS::zoneMerge, ENABLE( zoneMergeCond ) );
657 
658 
659 #define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
660 
661  // These tools can be used at any time to inspect the board
667 
668 
669  auto isDrcRunning =
670  [this] ( const SELECTION& )
671  {
672  DRC_TOOL* tool = m_toolManager->GetTool<DRC_TOOL>();
673  return !tool->IsDRCRunning();
674  };
675 
676 #define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, ACTION_CONDITIONS().Check( cond.CurrentTool( action ) ).Enable( isDrcRunning ) )
677 
678  // These tools edit the board, so they must be disabled during some operations
699 
705 
706 #undef CURRENT_TOOL
707 #undef CURRENT_EDIT_TOOL
708 #undef ENABLE
709 #undef CHECK
710 }
711 
712 
713 void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event )
714 {
715  if( event.GetId() == wxID_EXIT )
716  Kiway().OnKiCadExit();
717 
718  if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
719  Close( false );
720 }
721 
722 
724 {
726  bds.m_DrcExclusions.clear();
727 
728  for( PCB_MARKER* marker : GetBoard()->Markers() )
729  {
730  if( marker->IsExcluded() )
731  bds.m_DrcExclusions.insert( marker->Serialize() );
732  }
733 }
734 
735 
737 {
738  BOARD_COMMIT commit( this );
739 
740  for( PCB_MARKER* marker : GetBoard()->ResolveDRCExclusions() )
741  commit.Add( marker );
742 
743  commit.Push( wxEmptyString, false, false );
744 
745  for( PCB_MARKER* marker : GetBoard()->Markers() )
746  {
747  if( marker->IsExcluded() )
748  {
749  GetCanvas()->GetView()->Remove( marker );
750  GetCanvas()->GetView()->Add( marker );
751  }
752  }
753 }
754 
755 
756 bool PCB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
757 {
758  // Shutdown blocks must be determined and vetoed as early as possible
759  if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
760  && IsContentModified() )
761  {
762  return false;
763  }
764 
765  if( IsContentModified() )
766  {
767  wxFileName fileName = GetBoard()->GetFileName();
768  wxString msg = _( "Save changes to \"%s\" before closing?" );
769 
770  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
771  [&]() -> bool
772  {
773  return Files_io_from_id( ID_SAVE_BOARD );
774  } ) )
775  {
776  return false;
777  }
778  }
779 
780  // Close modeless dialogs. They're trouble when they get destroyed after the frame and/or
781  // board.
782  wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
783 
784  if( open_dlg )
785  open_dlg->Close( true );
786 
787  return true;
788 }
789 
790 
792 {
793  // On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes
794  // when closing this frame if a footprint was selected, and the footprint editor called
795  // to edit this footprint, and when closing pcbnew if this footprint is still selected
796  // See https://bugs.launchpad.net/kicad/+bug/1655858
797  // I think this is certainly a OpenGL event fired after frame deletion, so this workaround
798  // avoid the crash (JPC)
799  GetCanvas()->SetEvtHandlerEnabled( false );
800 
801  GetCanvas()->StopDrawing();
802 
803  // Delete the auto save file if it exists.
804  wxFileName fn = GetBoard()->GetFileName();
805 
806  // Auto save file name is the normal file name prefixed with 'GetAutoSaveFilePrefix()'.
807  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
808 
809  // When the auto save feature does not have write access to the board file path, it falls
810  // back to a platform specific user temporary file path.
811  if( !fn.IsOk() || !fn.IsDirWritable() )
812  fn.SetPath( wxFileName::GetTempDir() );
813 
814  wxLogTrace( traceAutoSave, "Deleting auto save file <" + fn.GetFullPath() + ">" );
815 
816  // Remove the auto save file on a normal close of Pcbnew.
817  if( fn.FileExists() && !wxRemoveFile( fn.GetFullPath() ) )
818  {
819  wxString msg = wxString::Format( _( "The auto save file \"%s\" could not be removed!" ),
820  fn.GetFullPath() );
821  wxMessageBox( msg, Pgm().App().GetAppName(), wxOK | wxICON_ERROR, this );
822  }
823 
824  // Make sure local settings are persisted
825  SaveProjectSettings();
826 
827  // Do not show the layer manager during closing to avoid flicker
828  // on some platforms (Windows) that generate useless redraw of items in
829  // the Layer Manger
830  if( m_show_layer_manager_tools )
831  m_auimgr.GetPane( "LayersManager" ).Show( false );
832 
833  // Unlink the old project if needed
834  GetBoard()->ClearProject();
835 
836  // Delete board structs and undo/redo lists, to avoid crash on exit
837  // when deleting some structs (mainly in undo/redo lists) too late
838  Clear_Pcb( false, true );
839 
840  // do not show the window because ScreenPcb will be deleted and we do not
841  // want any paint event
842  Show( false );
843 
845 }
846 
847 
849 {
851  GetCanvas()->UpdateColors();
852  GetCanvas()->Refresh();
853 }
854 
855 
856 void PCB_EDIT_FRAME::ShowBoardSetupDialog( const wxString& aInitialPage )
857 {
858  // Make sure everything's up-to-date
860 
861  DIALOG_BOARD_SETUP dlg( this );
862 
863  if( !aInitialPage.IsEmpty() )
864  dlg.SetInitialPage( aInitialPage, wxEmptyString );
865 
866  if( dlg.ShowQuasiModal() == wxID_OK )
867  {
869 
871  SaveProjectSettings();
872 
874  ReCreateAuxiliaryToolbar();
875 
876  Kiway().CommonSettingsChanged( false, true );
877  GetCanvas()->Refresh();
878 
879  m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
880 
881  //this event causes the routing tool to reload its design rules information
883  toolEvent.SetHasPosition( false );
884  m_toolManager->ProcessEvent( toolEvent );
885  }
886 
887  GetCanvas()->SetFocus();
888 }
889 
890 
892 {
894 
895  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
896  wxASSERT( cfg );
897 
898  if( cfg )
899  {
900  m_rotationAngle = cfg->m_RotationAngle;
902  m_show_layer_manager_tools = cfg->m_AuiPanels.show_layer_manager;
903  m_showPageLimits = cfg->m_ShowPageLimits;
904  }
905 }
906 
907 
909 {
911 
912  auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
913  wxASSERT( cfg );
914 
915  if( cfg )
916  {
917  cfg->m_RotationAngle = m_rotationAngle;
918  cfg->m_PlotLineWidth = Iu2Millimeter( g_DrawDefaultLineThickness );
919  cfg->m_AuiPanels.show_layer_manager = m_show_layer_manager_tools;
920  cfg->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
921  cfg->m_AuiPanels.appearance_panel_tab = m_appearancePanel->GetTabIndex();
922  cfg->m_ShowPageLimits = m_showPageLimits;
923  }
924 
925  GetSettingsManager()->SaveColorSettings( GetColorSettings(), "board" );
926 }
927 
928 
930 {
931  return GetColorSettings()->GetColor( LAYER_GRID );
932 }
933 
934 
936 {
937 
938  GetColorSettings()->SetColor( LAYER_GRID, aColor );
939  GetCanvas()->GetGAL()->SetGridColor( aColor );
940 }
941 
942 
944 {
945  PCB_LAYER_ID oldLayer = GetActiveLayer();
946 
947  if( oldLayer == aLayer )
948  return;
949 
951 
952  m_appearancePanel->OnLayerChanged();
953 
954  m_toolManager->RunAction( PCB_ACTIONS::layerChanged ); // notify other tools
955  GetCanvas()->SetFocus(); // allow capture of hotkeys
956  GetCanvas()->SetHighContrastLayer( aLayer );
957 
958  // Vias on a restricted layer set must be redrawn when the active layer is changed
959  GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
960  []( KIGFX::VIEW_ITEM* aItem ) -> bool
961  {
962  if( VIA* via = dynamic_cast<VIA*>( aItem ) )
963  {
964  return ( via->GetViaType() == VIATYPE::BLIND_BURIED ||
965  via->GetViaType() == VIATYPE::MICROVIA );
966  }
967 
968  return false;
969  } );
970 
971  // Clearances could be layer-dependent so redraw them when the active layer is changed
972 
973  if( GetDisplayOptions().m_DisplayPadIsol )
974  {
975  GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
976  [&]( KIGFX::VIEW_ITEM* aItem ) -> bool
977  {
978  if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
979  {
980  // Round-corner rects are expensive to draw, but are mostly found on
981  // SMD pads which only need redrawing on an active-to-not-active
982  // switch.
983  if( pad->GetAttribute() == PAD_ATTRIB_SMD )
984  {
985  if( ( oldLayer == F_Cu || aLayer == F_Cu ) && pad->IsOnLayer( F_Cu ) )
986  return true;
987 
988  if( ( oldLayer == B_Cu || aLayer == B_Cu ) && pad->IsOnLayer( B_Cu ) )
989  return true;
990  }
991 
992  return true;
993  }
994 
995  return false;
996  } );
997  }
998 
999  if( GetDisplayOptions().m_ShowTrackClearanceMode )
1000  {
1001  GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
1002  [&]( KIGFX::VIEW_ITEM* aItem ) -> bool
1003  {
1004  if( TRACK* track = dynamic_cast<TRACK*>( aItem ) )
1005  {
1006  // Tracks aren't particularly expensive to draw, but it's an easy
1007  // check.
1008  return track->IsOnLayer( oldLayer ) || track->IsOnLayer( aLayer );
1009  }
1010 
1011  return false;
1012  } );
1013  }
1014 
1015  GetCanvas()->Refresh();
1016 }
1017 
1018 
1020 {
1021  DRC_TOOL* drcTool = m_toolManager->GetTool<DRC_TOOL>();
1022  drcTool->Reset( TOOL_BASE::MODEL_RELOAD );
1023 
1024  UpdateTitle();
1025 
1026  wxFileName fn = GetBoard()->GetFileName();
1027  m_infoBar->Dismiss();
1028 
1029  // Display a warning that the file is read only
1030  if( fn.FileExists() && !fn.IsFileWritable() )
1031  {
1032  m_infoBar->RemoveAllButtons();
1033  m_infoBar->AddCloseButton();
1034  m_infoBar->ShowMessage( "Board file is read only.", wxICON_WARNING );
1035  }
1036 
1037  ReCreateLayerBox();
1038 
1039  // Sync layer and item visibility
1040  GetCanvas()->SyncLayersVisibility( m_pcb );
1041 
1042  SetElementVisibility( LAYER_RATSNEST, GetDisplayOptions().m_ShowGlobalRatsnest );
1043 
1044  m_appearancePanel->OnBoardChanged();
1045 
1046  // Apply saved display state to the appearance panel after it has been set up
1047  PROJECT_LOCAL_SETTINGS& localSettings = Prj().GetLocalSettings();
1048 
1049  m_appearancePanel->ApplyLayerPreset( localSettings.m_ActiveLayerPreset );
1050 
1051  if( GetBoard()->GetDesignSettings().IsLayerEnabled( localSettings.m_ActiveLayer ) )
1052  SetActiveLayer( localSettings.m_ActiveLayer );
1053 
1054  // Updates any auto dimensions and the auxiliary toolbar tracks/via sizes
1055  unitsChangeRefresh();
1056 
1057  // Display the loaded board:
1058  Zoom_Automatique( false );
1059 
1060  Refresh();
1061 
1062  SetMsgPanel( GetBoard() );
1063  SetStatusText( wxEmptyString );
1064 
1065  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "PCB file changes are unsaved" ) );
1066 }
1067 
1068 
1070 {
1071  m_appearancePanel->UpdateDisplayOptions();
1072 }
1073 
1074 
1075 void PCB_EDIT_FRAME::OnUpdateLayerAlpha( wxUpdateUIEvent & )
1076 {
1077  m_appearancePanel->OnLayerAlphaChanged();
1078 }
1079 
1080 
1082 {
1083  return GetBoard()->IsElementVisible( aElement );
1084 }
1085 
1086 
1087 void PCB_EDIT_FRAME::SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState )
1088 {
1089  // Force the RATSNEST visible
1090  if( aElement == LAYER_RATSNEST )
1091  GetCanvas()->GetView()->SetLayerVisible( aElement, true );
1092  else
1093  GetCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
1094 
1095  GetBoard()->SetElementVisibility( aElement, aNewState );
1096 }
1097 
1098 
1100 {
1101  // call my base class
1103 
1104  wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_appearancePanel );
1105  pane_info.Caption( _( "Appearance" ) );
1106  m_auimgr.Update();
1107 
1108  m_appearancePanel->OnBoardChanged();
1109 }
1110 
1111 
1113 {
1114  PROJECT_FILE& project = Prj().GetProjectFile();
1115 
1116  if( project.m_PcbLastPath[ aType ].IsEmpty() )
1117  return wxEmptyString;
1118 
1119  wxFileName absoluteFileName = project.m_PcbLastPath[ aType ];
1120  wxFileName pcbFileName = GetBoard()->GetFileName();
1121 
1122  absoluteFileName.MakeAbsolute( pcbFileName.GetPath() );
1123  return absoluteFileName.GetFullPath();
1124 }
1125 
1126 
1127 void PCB_EDIT_FRAME::SetLastPath( LAST_PATH_TYPE aType, const wxString& aLastPath )
1128 {
1129  PROJECT_FILE& project = Prj().GetProjectFile();
1130 
1131  wxFileName relativeFileName = aLastPath;
1132  wxFileName pcbFileName = GetBoard()->GetFileName();
1133 
1134  relativeFileName.MakeRelativeTo( pcbFileName.GetPath() );
1135 
1136  if( relativeFileName.GetFullPath() != project.m_PcbLastPath[ aType ] )
1137  {
1138  project.m_PcbLastPath[ aType ] = relativeFileName.GetFullPath();
1139  SaveProjectSettings();
1140  }
1141 }
1142 
1143 
1145 {
1147 
1148  Update3DView( false );
1149 
1150  m_ZoneFillsDirty = true;
1151 }
1152 
1153 
1154 void PCB_EDIT_FRAME::ExportSVG( wxCommandEvent& event )
1155 {
1156  InvokeExportSVG( this, GetBoard() );
1157 }
1158 
1159 
1161 {
1162  wxFileName fileName = GetBoard()->GetFileName();
1163  wxString fileinfo;
1164 
1165  if( fileName.IsOk() && fileName.FileExists() )
1166  fileinfo = fileName.IsFileWritable() ? wxString( wxEmptyString ) : wxS( " " ) + _( "[Read Only]" );
1167  else
1168  fileinfo = wxS( " " ) + _( "[Unsaved]" );
1169 
1170  SetTitle( wxString::Format( wxT( "%s%s \u2014 " ) + _( "Pcbnew" ),
1171  fileName.GetName(),
1172  fileinfo ) );
1173 }
1174 
1175 
1177 {
1178  // Update the layer manager and other widgets from the board setup
1179  // (layer and items visibility, colors ...)
1180 
1181  // Rebuild list of nets (full ratsnest rebuild)
1183  Compile_Ratsnest( true );
1184 
1185  // Update info shown by the horizontal toolbars
1186  ReCreateLayerBox();
1187 
1188  LSET activeLayers = GetBoard()->GetEnabledLayers();
1189 
1190  if( !activeLayers.test( GetActiveLayer() ) )
1191  SetActiveLayer( activeLayers.Seq().front() );
1192 
1193  m_SelLayerBox->SetLayerSelection( GetActiveLayer() );
1194 
1196 
1197  layerEnum.Choices().Clear();
1198  layerEnum.Undefined( UNDEFINED_LAYER );
1199 
1200  for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
1201  {
1202  // Canonical name
1203  layerEnum.Map( *seq, LSET::Name( *seq ) );
1204  // User name
1205  layerEnum.Map( *seq, GetBoard()->GetLayerName( *seq ) );
1206  }
1207 
1208  // Sync visibility with canvas
1209  KIGFX::VIEW* view = GetCanvas()->GetView();
1210  LSET visible = GetBoard()->GetVisibleLayers();
1211 
1212  for( PCB_LAYER_ID layer : LSET::AllLayersMask().Seq() )
1213  view->SetLayerVisible( layer, visible.Contains( layer ) );
1214 
1215  // Stackup and/or color theme may have changed
1216  m_appearancePanel->OnBoardChanged();
1217 }
1218 
1219 
1220 #if defined( KICAD_SCRIPTING_WXPYTHON )
1221 
1222 void PCB_EDIT_FRAME::ScriptingConsoleEnableDisable()
1223 {
1224  wxWindow * pythonPanelFrame = findPythonConsole();
1225  bool pythonPanelShown = true;
1226 
1227  if( pythonPanelFrame == NULL )
1228  pythonPanelFrame = CreatePythonShellWindow( this, pythonConsoleNameId() );
1229  else
1230  pythonPanelShown = ! pythonPanelFrame->IsShown();
1231 
1232  if( pythonPanelFrame )
1233  pythonPanelFrame->Show( pythonPanelShown );
1234  else
1235  wxMessageBox( wxT( "Error: unable to create the Python Console" ) );
1236 }
1237 #endif
1238 
1239 
1241 {
1242  // switches currently used canvas (Cairo / OpenGL).
1243  PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
1244 }
1245 
1246 
1248 {
1249  PCB_PLOT_PARAMS plotSettings = GetPlotSettings();
1250 
1251  switch( aID )
1252  {
1253  case ID_GEN_PLOT_GERBER:
1254  plotSettings.SetFormat( PLOT_FORMAT::GERBER );
1255  break;
1256  case ID_GEN_PLOT_DXF:
1257  plotSettings.SetFormat( PLOT_FORMAT::DXF );
1258  break;
1259  case ID_GEN_PLOT_HPGL:
1260  plotSettings.SetFormat( PLOT_FORMAT::HPGL );
1261  break;
1262  case ID_GEN_PLOT_PDF:
1263  plotSettings.SetFormat( PLOT_FORMAT::PDF );
1264  break;
1265  case ID_GEN_PLOT_PS:
1266  plotSettings.SetFormat( PLOT_FORMAT::POST );
1267  break;
1268  case ID_GEN_PLOT: /* keep the previous setup */ break;
1269  default:
1270  wxFAIL_MSG( "ToPlotter(): unexpected plot type" ); break;
1271  break;
1272  }
1273 
1274  SetPlotSettings( plotSettings );
1275 
1276  // Force rebuild the dialog if currently open because the old dialog can be not up to date
1277  // if the board (or units) has changed
1278  wxWindow* dlg = wxWindow::FindWindowByName( DLG_WINDOW_NAME );
1279 
1280  if( dlg )
1281  dlg->Destroy();
1282 
1283  dlg = new DIALOG_PLOT( this );
1284  dlg->Show( true );
1285 }
1286 
1287 
1289 {
1290  if( Kiface().IsSingle() )
1291  return false;
1292 
1293  // Update PCB requires a netlist. Therefore the schematic editor must be running
1294  // If this is not the case, open the schematic editor
1295  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
1296 
1297  if( !frame->IsShown() )
1298  {
1299  wxFileName fn( Prj().GetProjectPath(), Prj().GetProjectName(),
1301 
1302  // Maybe the file hasn't been converted to the new s-expression file format so
1303  // see if the legacy schematic file is still in play.
1304  if( !fn.FileExists() )
1305  {
1306  fn.SetExt( LegacySchematicFileExtension );
1307 
1308  if( !fn.FileExists() )
1309  {
1310  DisplayError( this, _( "The schematic for this board cannot be found." ) );
1311  return false;
1312  }
1313  }
1314 
1315  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1316 
1317  // we show the schematic editor frame, because do not show is seen as
1318  // a not yet opened schematic by Kicad manager, which is not the case
1319  frame->Show( true );
1320 
1321  // bring ourselves back to the front
1322  Raise();
1323  }
1324 
1325  return true; //Success!
1326 }
1327 
1328 
1329 //
1330 // Sends a Netlist packet to eeSchema.
1331 // The reply is in aNetlist so it is destroyed by this
1332 //
1333 bool PCB_EDIT_FRAME::ReannotateSchematic( std::string& aNetlist )
1334 {
1335  Kiway().ExpressMail( FRAME_SCH, MAIL_REANNOTATE, aNetlist, this );
1336  return true;
1337 }
1338 
1339 
1341 {
1342  if( !TestStandalone() )
1343  {
1344  DisplayError( this, _( "Cannot update the PCB because Pcbnew is opened in stand-alone "
1345  "mode. In order to create or update PCBs from schematics, you "
1346  "must launch the KiCad project manager and create a project." ) );
1347  return false; //Not in standalone mode
1348  }
1349 
1350  Raise(); //Show
1351  std::string payload;
1352 
1353  if( aMode == NO_ANNOTATION )
1354  payload = "no-annotate";
1355  else if( aMode == QUIET_ANNOTATION )
1356  payload = "quiet-annotate";
1357 
1358  Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_GET_NETLIST, payload, this );
1359 
1360  try
1361  {
1362  auto lineReader = new STRING_LINE_READER( payload, _( "Eeschema netlist" ) );
1363  KICAD_NETLIST_READER netlistReader( lineReader, &aNetlist );
1364  netlistReader.LoadNetlist();
1365  }
1366  catch( const IO_ERROR& )
1367  {
1368  assert( false ); // should never happen
1369  return false;
1370  }
1371 
1372  return true;
1373 }
1374 
1375 
1376 void PCB_EDIT_FRAME::DoUpdatePCBFromNetlist( NETLIST& aNetlist, bool aUseTimestamps )
1377 {
1378  BOARD_NETLIST_UPDATER updater( this, GetBoard() );
1379  updater.SetLookupByTimestamp( aUseTimestamps );
1380  updater.SetDeleteUnusedComponents( false );
1381  updater.SetReplaceFootprints( true );
1382  updater.SetDeleteSinglePadNets( false );
1383  updater.SetWarnPadNoNetInNetlist( false );
1384  updater.UpdateNetlist( aNetlist );
1385 }
1386 
1387 
1389 {
1390  wxString msg;
1391  wxFileName schematic( Prj().GetProjectPath(), Prj().GetProjectName(), "kicad_sch" );
1392 
1393  if( !schematic.FileExists() )
1394  {
1395  wxFileName legacySchematic( Prj().GetProjectPath(), Prj().GetProjectName(), "sch" );
1396 
1397  if( legacySchematic.FileExists() )
1398  {
1399  schematic = legacySchematic;
1400  }
1401  else
1402  {
1403  msg.Printf( _( "Schematic file \"%s\" not found." ), schematic.GetFullPath() );
1404  wxMessageBox( msg, _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
1405  return;
1406  }
1407  }
1408 
1409  if( Kiface().IsSingle() )
1410  {
1411  wxString filename = wxT( "\"" ) + schematic.GetFullPath( wxPATH_NATIVE ) + wxT( "\"" );
1412  ExecuteFile( this, EESCHEMA_EXE, filename );
1413  }
1414  else
1415  {
1416  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, false );
1417 
1418  // Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls
1419  // Kiway.Player( FRAME_SCH, true )
1420  // therefore, the schematic editor is sometimes running, but the schematic project
1421  // is not loaded, if the library editor was called, and the dialog field editor was used.
1422  // On linux, it happens the first time the schematic editor is launched, if
1423  // library editor was running, and the dialog field editor was open
1424  // On Windows, it happens always after the library editor was called,
1425  // and the dialog field editor was used
1426  if( !frame )
1427  {
1428  try
1429  {
1430  frame = Kiway().Player( FRAME_SCH, true );
1431  }
1432  catch( const IO_ERROR& err )
1433  {
1434  wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
1435  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
1436  return;
1437  }
1438  }
1439 
1440  if( !frame->IsShown() ) // the frame exists, (created by the dialog field editor)
1441  // but no project loaded.
1442  {
1443  frame->OpenProjectFiles( std::vector<wxString>( 1, schematic.GetFullPath() ) );
1444  frame->Show( true );
1445  }
1446 
1447  // On Windows, Raise() does not bring the window on screen, when iconized or not shown
1448  // On linux, Raise() brings the window on screen, but this code works fine
1449  if( frame->IsIconized() )
1450  {
1451  frame->Iconize( false );
1452  // If an iconized frame was created by Pcbnew, Iconize( false ) is not enough
1453  // to show the frame at its normal size: Maximize should be called.
1454  frame->Maximize( false );
1455  }
1456 
1457  frame->Raise();
1458  }
1459 }
1460 
1461 
1463 {
1464  // Reload Python plugins if they are newer than the already loaded, and load new plugins
1465 #if defined(KICAD_SCRIPTING)
1466  // Reload plugin list: reload Python plugins if they are newer than the already loaded,
1467  // and load new plugins
1469 
1470 #if defined(KICAD_SCRIPTING_ACTION_MENU)
1471  // Action plugins can be modified, therefore the plugins menu must be updated:
1472  ReCreateMenuBar();
1473  // Recreate top toolbar to add action plugin buttons
1474  ReCreateHToolbar();
1475 #endif
1476 #endif
1477 }
1478 
1479 
1481 {
1482 #if defined(KICAD_SCRIPTING)
1483 #ifdef __WXMAC__
1484  wxString msg;
1485 
1486  // Quote in case there are spaces in the path.
1487  msg.Printf( "open \"%s\"", PyPluginsPath( true ) );
1488 
1489  system( msg.c_str() );
1490 #else
1491  wxString pypath( PyPluginsPath( true ) );
1492 
1493  // Quote in case there are spaces in the path.
1494  AddDelimiterString( pypath );
1495 
1496  wxLaunchDefaultApplication( pypath );
1497 #endif
1498 #endif
1499 }
1500 
1501 
1503 {
1504 #if defined( KICAD_SCRIPTING )
1505  const ENV_VAR_MAP& vars = Pgm().GetLocalEnvVariables();
1506 
1507  // Set the environment variables for python scripts
1508  // note: the strint will be encoded UTF8 for python env
1509  for( auto& var : vars )
1510  pcbnewUpdatePythonEnvVar( var.first, var.second.GetValue() );
1511 
1512  // Because the env vars can de modifed by the python scripts (rewritten in UTF8),
1513  // regenerate them (in unicode) for our normal environment
1514  for( auto& var : vars )
1515  wxSetEnv( var.first, var.second.GetValue() );
1516 #endif
1517 }
1518 
1519 
1521 {
1522 #if defined( KICAD_SCRIPTING )
1523  wxString evValue;
1524  wxGetEnv( PROJECT_VAR_NAME, &evValue );
1525  pcbnewUpdatePythonEnvVar( wxString( PROJECT_VAR_NAME ).ToStdString(), evValue );
1526 
1527  // Because PROJECT_VAR_NAME can be modifed by the python scripts (rewritten in UTF8),
1528  // regenerate it (in unicode) for our normal environment
1529  wxSetEnv( PROJECT_VAR_NAME, evValue );
1530 #endif
1531 }
1532 
1533 
1535 {
1536  if( aFootprint == NULL )
1537  return;
1538 
1539  DIALOG_FOOTPRINT_PROPERTIES* dlg = new DIALOG_FOOTPRINT_PROPERTIES( this, aFootprint );
1540 
1541  int retvalue = dlg->ShowModal();
1542  /*
1543  * retvalue =
1544  * FP_PROPS_UPDATE_FP to show Update Footprints dialog
1545  * FP_PROPS_CHANGE_FP to show Chanage Footprints dialog
1546  * FP_PROPS_OK for normal edit
1547  * FP_PROPS_EDIT_BOARD_FP to load board footprint into Footprint Editor
1548  * FP_PROPS_EDIT_LIBRARY_FP to load library footprint into Footprint Editor
1549  */
1550 
1551  dlg->Close();
1552  dlg->Destroy();
1553 
1555  {
1556  // If something edited, push a refresh request
1557  GetCanvas()->Refresh();
1558  }
1560  {
1561  auto editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
1562 
1563  editor->LoadFootprintFromBoard( aFootprint );
1564 
1565  editor->Show( true );
1566  editor->Raise(); // Iconize( false );
1567  }
1568 
1570  {
1571  auto editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
1572 
1573  editor->LoadFootprintFromLibrary( aFootprint->GetFPID() );
1574 
1575  editor->Show( true );
1576  editor->Raise(); // Iconize( false );
1577  }
1578 
1580  {
1581  ShowExchangeFootprintsDialog( aFootprint, true, true );
1582  }
1583 
1585  {
1586  ShowExchangeFootprintsDialog( aFootprint, false, true );
1587  }
1588 }
1589 
1590 
1591 int PCB_EDIT_FRAME::ShowExchangeFootprintsDialog( FOOTPRINT* aFootprint, bool aUpdateMode,
1592  bool aSelectedMode )
1593 {
1594  DIALOG_EXCHANGE_FOOTPRINTS dialog( this, aFootprint, aUpdateMode, aSelectedMode );
1595 
1596  return dialog.ShowQuasiModal();
1597 }
1598 
1599 
1600 void PCB_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1601 {
1602  PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1603 
1604  GetAppearancePanel()->OnColorThemeChanged();
1605 
1606  // Update the environment variables in the Python interpreter
1607  if( aEnvVarsChanged )
1608  PythonSyncEnvironmentVariables();
1609 
1610  Layout();
1611  SendSizeEvent();
1612 }
1613 
1614 
1616 {
1617  PythonSyncProjectName();
1618 }
1619 
1620 
1621 bool ExportBoardToHyperlynx( BOARD* aBoard, const wxFileName& aPath );
1622 
1623 
1624 void PCB_EDIT_FRAME::OnExportHyperlynx( wxCommandEvent& event )
1625 {
1626  wxString wildcard = wxT( "*.hyp" );
1627  wxFileName fn = GetBoard()->GetFileName();
1628 
1629  fn.SetExt( wxT("hyp") );
1630 
1631  wxFileDialog dlg( this, _( "Export Hyperlynx Layout" ), fn.GetPath(), fn.GetFullName(),
1632  wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1633 
1634  if( dlg.ShowModal() != wxID_OK )
1635  return;
1636 
1637  fn = dlg.GetPath();
1638 
1639  // always enforce filename extension, user may not have entered it.
1640  fn.SetExt( wxT( "hyp" ) );
1641 
1643 }
1644 
1645 
1647 {
1648  return GetBoard()->GetFileName();
1649 }
1650 
1651 
1653 {
1654  return m_auimgr.GetPane( "LayersManager" ).IsShown();
1655 }
1656 
1657 
1658 void PCB_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
1659 {
1660  if( IsShown() )
1661  {
1662  // We only need this until the frame is done resizing and the final client size is
1663  // established.
1664  Unbind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this );
1665  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
1666  }
1667 
1668  // Skip() is called in the base class.
1669  EDA_DRAW_FRAME::OnSize( aEvent );
1670 }
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:240
void UpdateTitle()
Function UpdateTitle sets the main window title bar text.
POSITION_RELATIVE_TOOL.
static TOOL_ACTION drawLine
Definition: pcb_actions.h:145
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:120
Filled polygons are shown.
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:152
void BuildListOfNets()
Definition: board.h:700
void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
static TOOL_ACTION placeModule
Definition: pcb_actions.h:161
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:202
#define CURRENT_EDIT_TOOL(action)
Definition: track.h:354
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:61
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
const PAGE_INFO & GetPageSettings() const
Definition: board.h:574
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:587
PNS::PNS_MODE GetRouterMode()
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:503
static const KICAD_T Tracks[]
A scan list for only TRACKs.
Definition: collectors.h:299
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.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
This file is part of the common library TODO brief description.
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
Model changes (required full reload)
Definition: tool_base.h:82
static TOOL_ACTION drawSimilarZone
Definition: pcb_actions.h:159
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:429
SELECTION_CONDITION HasItems()
Creates a functor that tests if there are items in the board.
static TOOL_ACTION doDelete
Definition: actions.h:75
static TOOL_ACTION drawArc
Definition: pcb_actions.h:149
SELECTION_CONDITION TrackFillDisplay()
Creates a functor that tests if the frame fills vias.
void ToPlotter(int aID)
Function ToPlotter Open a dialog frame to create plot and drill files relative to the current board.
static TOOL_ACTION hideNet
Definition: pcb_actions.h:447
SELECTION_CONDITION FullscreenCursor()
Creates a functor testing if the cursor is full screen in a frame.
BOARD_NETLIST_UPDATER updates the BOARD with a new netlist.
Definition: id.h:88
static SELECTION_CONDITION MoreThan(int aNumber)
Creates a functor that tests if the number of selected items is greater than the value given as param...
VTBL_ENTRY PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition: project.h:149
static TOOL_ACTION microwaveCreateStubArc
Definition: pcb_actions.h:407
void OnSockRequestServer(wxSocketEvent &evt)
Definition: eda_dde.cpp:102
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
void SetInitialPage(const wxString &aPage, const wxString &aParentPage=wxEmptyString)
void doCloseWindow() override
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:239
static TOOL_ACTION zoomTool
Definition: actions.h:97
void pcbnewUpdatePythonEnvVar(const wxString &aVar, const wxString &aValue)
Set an environment variable in the current Python interpreter.
EVT_UPDATE_UI(ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
static bool Idle(const SELECTION &aSelection)
Tests if there no items selected or being edited.
ENUM_MAP & Undefined(T aValue)
Definition: property.h:532
PROJECT & Prj()
Definition: kicad.cpp:328
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Creates a functor that tests if the selected items are only of given types.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:245
SELECTION_TOOL.
void ActivateGalCanvas() override
MICROWAVE_TOOL.
void OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
void SetSheetName(const std::string &aSheetName)
Set the sheet name displayed in the title block.
void SetDeleteSinglePadNets(bool aEnabled)
Enables "delete single pad nets" option
Ignore collisions, mark obstacles
void OnExportSTEP(wxCommandEvent &event)
Function OnExportSTEP Exports the current BOARD to a STEP assembly.
void ResolveDRCExclusions()
Update markers to match recorded exclusions.
static TOOL_ACTION selectNet
Selects all connections belonging to a single net.
Definition: pcb_actions.h:80
bool Contains(PCB_LAYER_ID aLayer)
See if the layer set contains a PCB layer.
#define PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
Definition: project.h:38
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:151
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:81
static constexpr GAL_TYPE GAL_FALLBACK
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:244
PAD_TOOL.
Definition: pad_tool.h:37
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:153
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
static TOOL_ACTION millimetersUnits
Definition: actions.h:144
static ENUM_MAP< T > & Instance()
Definition: property.h:519
The project local settings are things that are attached to a particular project, but also might be pa...
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
int GetPageCount() const
Definition: base_screen.h:137
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings Returns a bit-mask of all t...
Definition: board.cpp:451
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:146
static TOOL_ACTION selectConnection
Selects tracks between junctions or expands an existing selection to pads or the entire connection.
Definition: pcb_actions.h:77
void SetWarnPadNoNetInNetlist(bool aEnabled)
Enables warning option if a connectable pad is not found in netlist connectable = pad with a name and...
#define ENABLE(x)
static TOOL_ACTION standardGraphics
Definition: actions.h:164
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
Definition: pcb_actions.h:200
static TOOL_ACTION microwaveCreateLine
Definition: pcb_actions.h:411
BOARD_NETLIST_UPDATER class definition.
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
NET_SETTINGS & NetSettings()
Definition: project_file.h:92
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:342
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:559
SELECTION_CONDITION CanvasType(EDA_DRAW_PANEL_GAL::GAL_TYPE aType)
Creates a functor testing if the specified canvas is active in the frame.
void ExportToGenCAD(wxCommandEvent &event)
Function ExportToGenCAD creates a file in GenCAD 1.4 format from the current board.
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:341
void SetGridColor(COLOR4D aColor) override
Function SetGridColor() , virtual.
SELECTION_CONDITION RedoAvailable()
Creates a functor that tests if there are any items in the redo queue.
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings Returns a bit-mask of all t...
Definition: board.cpp:437
PCB_LAYER_ID m_ActiveLayer
The current (active) board layer for editing.
ACTION_MANAGER.
void SetLookupByTimestamp(bool aEnabled)
Enables component lookup by timestamp instead of reference
wxPGChoices & Choices()
Definition: property.h:558
static TOOL_ACTION localRatsnestTool
Definition: pcb_actions.h:451
wxString m_PcbLastPath[LAST_PATH_SIZE]
MRU path storage.
Definition: project_file.h:160
VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:85
static SELECTION_CONDITION Count(int aNumber)
Creates a functor that tests if the number of selected items is equal to the value given as parameter...
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.
int ShowExchangeFootprintsDialog(FOOTPRINT *aFootprint, bool aUpdateMode, bool aSelectedMode)
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
const wxString & GetFileName() const
Definition: board.h:278
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
bool UpdateNetlist(NETLIST &aNetlist)
Function UpdateNetlist()
static wxWindow * findPythonConsole()
static SELECTION_CONDITION SameLayer()
Function SameLayer Creates a functor that tests if selection contains items that belong exclusively t...
static bool NotEmpty(const SELECTION &aSelection)
Tests if there are any items selected.
static TOOL_ACTION placeText
Definition: pcb_actions.h:150
PROJECT_FILE is the backing store for a PROJECT, in JSON format.
Definition: project_file.h:62
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:302
SELECTION_CONDITION PadFillDisplay()
Creates a functor that tests if the frame fills the pads.
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
PCBNEW_CONTROL.
const wxString & GetPageNumber() const
Definition: base_screen.cpp:79
void ShowFootprintPropertiesDialog(FOOTPRINT *aFootprint)
Only the zone outline is shown.
void SetFileName(const std::string &aFileName)
Set the file name displayed in the title block.
bool isAutoSaveRequired() const override
Function isautoSaveRequired returns true if the board has been modified.
void doCloseWindow() override
bool TestStandalone(void)
Test if standalone mode.
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:51
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:95
static TOOL_ACTION highlightNetTool
Definition: pcb_actions.h:444
TOOL_MANAGER.
Definition: tool_manager.h:51
void SynchronizeNetsAndNetClasses()
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1379
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
Definition: drc_tool.cpp:53
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:82
void OnClearFileHistory(wxCommandEvent &aEvent)
static TOOL_ACTION measureTool
Definition: actions.h:152
static TOOL_ACTION copy
Definition: actions.h:70
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)
Change the sheets count number displayed in the title block.
PCB_LAYER_ID
A quick note on layer IDs:
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.
Item is being added to the view.
Definition: view_item.h:62
const wxString EESCHEMA_EXE
LSET is a set of PCB_LAYER_IDs.
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString)
Function ShowBoardSetupDialog.
void ProjectChanged() override
Notification event that the project has changed.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
NETLIST stores all of information read from a netlist along with the flags used to update the NETLIST...
Definition: pcb_netlist.h:194
SELECTION_CONDITION GridVisible()
Creates a functor testing if the grid is visible in a frame.
#define NULL
bool IsSingle() const
Function IsSingle is this KIFACE_I running under single_top?
Definition: kiface_i.h:117
bool IsContentModified() override
Get if the current board has been modified but not saved.
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:345
BOARD_ITEM_CONTAINER * GetModel() const override
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Creates a functor that tests if the frame has the specified units.
void RemoveListener(BOARD_LISTENER *aListener)
Remove the specified listener.
Definition: board.cpp:1941
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
Definition: pgm_base.h:117
wxString m_ActiveLayerPreset
The name of a LAYER_PRESET that is currently activated (or blank if none)
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:82
DRAWING_TOOL.
Definition: drawing_tool.h:50
static TOOL_ACTION toggleGrid
Definition: actions.h:138
void onBoardLoaded()
Updates the state of the GUI after a new board is loaded or created.
int ShowQuasiModal()
VTBL_ENTRY PROJECT_FILE & GetProjectFile() const
Definition: project.h:143
PAGE_INFO describes the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
static TOOL_ACTION inchesUnits
Definition: actions.h:142
void SetPageNumber(const std::string &aPageNumber)
Changes the page number displayed in the title block.
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
void ResolveNetClassAssignments(bool aRebuildFromScratch=false)
Explodes the list of netclass assignments to include atomic members of composite labels (buses).
static TOOL_ACTION save
Definition: actions.h:54
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.
wxString PyPluginsPath(bool aUserPath)
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:306
static TOOL_ACTION togglePolarCoords
Definition: actions.h:147
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:382
virtual ~PCB_EDIT_FRAME()
void SetReplaceFootprints(bool aEnabled)
Enables replacing footprints with new ones
static TOOL_ACTION cut
Definition: actions.h:69
Definition of file extensions used in Kicad.
static const KICAD_T Zones[]
A scan list for zones outlines only.
Definition: collectors.h:273
void OnUpdateSelectAutoWidth(wxUpdateUIEvent &aEvent)
#define DIALOG_DRC_WINDOW_NAME
Definition: dialog_drc.h:41
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:238
PCB_INSPECTION_TOOL.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
COLOR4D GetGridColor() override
Function GetGridColor() , virtual.
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:147
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
static TOOL_ACTION microwaveCreateGap
Definition: pcb_actions.h:403
wxLogTrace helper definitions.
static LSET AllLayersMask()
Definition: lset.cpp:787
void AddDelimiterString(wxString &string)
Function AddDelimiterString Add un " to the start and the end of string (if not already done).
Definition: gestfich.cpp:42
virtual void OnSize(wxSizeEvent &event)
Recalculate the size of toolbars and display panel when the frame size changes.
void SetLayerVisible(int aLayer, bool aVisible=true)
Function SetLayerVisible() Controls the visibility of a particular layer.
Definition: view.h:385
static TOOL_ACTION drawVia
Definition: pcb_actions.h:156
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:40
const LIB_ID & GetFPID() const
Definition: footprint.h:208
#define KICAD_DEFAULT_DRAWFRAME_STYLE
std::function< bool(const SELECTION &)> SELECTION_CONDITION
Functor type that checks a specific condition for selected items.
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
Definition: board.cpp:133
void OnQuit(wxCommandEvent &event)
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
void PythonPluginsShowFolder()
Open the plugins folder in the default system file browser.
void PythonSyncEnvironmentVariables()
Synchronize the environment variables from KiCad's environment into the Python interpreter.
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
void SetFormat(PLOT_FORMAT aFormat)
PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board.
static TOOL_ACTION drawZoneCutout
Definition: pcb_actions.h:158
COMMON_CONTROL.
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:202
LAST_PATH_TYPE
For storing PcbNew MRU paths of various types.
Definition: project_file.h:44
EDIT_TOOL.
Definition: edit_tool.h:74
static TOOL_ACTION placeTarget
Definition: pcb_actions.h:160
SELECTION_CONDITION ZoneDisplayMode(ZONE_DISPLAY_MODE aMode)
Creates a functor that tests the current zone display mode in the frame.
Specialization of the wxAuiPaneInfo class for KiCad panels.
const std::string LegacySchematicFileExtension
SETTINGS_MANAGER * GetSettingsManager()
SELECTION_CONDITION PolarCoordinates()
Creates a functor testing if polar coordinates are current being used.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
static TOOL_ACTION milsUnits
Definition: actions.h:143
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:312
COMMON_TOOLS.
Definition: common_tools.h:38
void ClearProject()
Definition: board.cpp:165
bool IsDRCRunning() const
Check to see if the DRC engine is running the tests.
Definition: drc_tool.h:106
DIALOG_PLOT is the dialog to set the plot options, and create plot files in various formats.
Definition: dialog_plot.h:40
class FOOTPRINT, a footprint
Definition: typeinfo.h:89
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
SELECTION_CONDITION ContentModified()
Creates a functor that tests if the content of the frame is modified.
SELECTION_CONDITION NoActiveTool()
Creates a functor testing if there are no tools active in the frame.
static TOOL_ACTION microwaveCreateStub
Definition: pcb_actions.h:405
static TOOL_ACTION zoneUnfill
Definition: pcb_actions.h:304
BOARD * GetBoard()
static TOOL_ACTION pasteSpecial
Definition: actions.h:72
#define CHECK(x)
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:241
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:497
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:148
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:242
void SetProject(PROJECT *aProject)
Links a board to a given project.
Definition: board.cpp:139
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:309
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:439
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:70
void OnSockRequest(wxSocketEvent &evt)
Definition: eda_dde.cpp:70
static TOOL_ACTION redo
Definition: actions.h:68
virtual void OnModify()
Function OnModify Must be called after a change in order to set the "modify" flag of the current scre...
static TOOL_ACTION microwaveCreateFunctionShape
Definition: pcb_actions.h:409
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:289
PCB_ACTIONS.
Definition: pcb_actions.h:51
void OnFileHistory(wxCommandEvent &event)
static TOOL_ACTION showNet
Definition: pcb_actions.h:448
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:154
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:157
PCB_EDITOR_CONTROL.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
see class PGM_BASE
void OnUpdateLayerAlpha(wxUpdateUIEvent &aEvent) override
Update the UI to reflect changes to the current layer's transparency.
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
void SetBoard(BOARD *aBoard) override
Declaration of the eda_3d_viewer class.
void PythonSyncProjectName()
Synchronize the project name from KiCad's environment into the Python interpreter.
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:442
#define CURRENT_TOOL(action)
Common, abstract interface for edit frames.
void Process_Special_Functions(wxCommandEvent &event)
Definition: pcbnew/edit.cpp:47
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
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:186
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Sets the work environment (model, view, view controls and the parent window).
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void Files_io(wxCommandEvent &event)
Function Files_io.
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:179
#define _(s)
Definition: 3d_actions.cpp:33
SELECTION_CONDITION UndoAvailable()
Creates a functor that tests if there are any items in the undo queue.
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:163
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Creates a functor that tests if the selected items are only of given type.
const std::string KiCadSchematicFileExtension
PCB_EDIT_FRAME is the main frame for Pcbnew.
AUI_PANELS m_AuiPanels
POINT_EDITOR.
Definition: point_editor.h:43
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely saves a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
#define IU_PER_MILS
Definition: plotter.cpp:137
SELECTION_CONDITION ViaFillDisplay()
Creates a functor that tests if the frame fills vias.
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
PCB_VIEWER_TOOLS.
static TOOL_ACTION deselectNet
Removes all connections belonging to a single net from the active selection.
Definition: pcb_actions.h:83
bool InvokeExportSVG(PCB_EDIT_FRAME *aCaller, BOARD *aBoard)
Function InvokeExportSVG shows the Export SVG dialog.
virtual void SetPageSettings(const PAGE_INFO &aPageSettings) override
bool ReannotateSchematic(std::string &aNetlist)
Sends a command to Eeschema to re-annotate the schematic.
VTBL_ENTRY void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged)
Function CommonSettingsChanged Calls CommonSettingsChanged() on all KIWAY_PLAYERs.
Definition: kiway.cpp:515
Definition: id.h:97
static TOOL_ACTION deleteTool
Definition: actions.h:76
void onSize(wxSizeEvent &aEvent)
Definition: id.h:87
static SELECTION_CONDITION SameNet(bool aAllowUnconnected=false)
Function SameNet Creates a functor that tests if selection contains items belonging to the same net o...
void OnUpdateSelectTrackWidth(wxUpdateUIEvent &aEvent)
static TOOL_ACTION undo
Definition: actions.h:67
#define PCB_EDIT_FRAME_NAME
void OnGridSettings(wxCommandEvent &event)
bool IsWxPythonLoaded()
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:100
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:291
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnSelectDisplayMode EVT_CHOICE(ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice) EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER
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...
static TOOL_ACTION gridSetOrigin
Definition: actions.h:135
const BITMAP_OPAQUE icon_pcbnew_xpm[1]
Definition: icon_pcbnew.cpp:49
VIEW.
Definition: view.h:63
bool IsElementVisible(GAL_LAYER_ID aElement) const
Function IsElementVisible tests whether a given element category is visible.
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:525
Definition: pad.h:59
std::set< wxString > m_DrcExclusions
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:255
ID_POPUP_PCB_SELECT_WIDTH8
wxString GetCurrentFileName() const override
Get the full filename + path of the currently opened file in the frame.
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:165
Class that groups generic conditions for PCB editor states.
static constexpr int Millimeter2iu(double mm)
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:201
static TOOL_ACTION highContrastMode
Definition: actions.h:101
void PythonPluginsReload()
Reload the Python plugins if they are newer than the already loaded, and load new plugins if any.
void OnDisplayOptionsChanged() override
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
static TOOL_ACTION selectAll
Definition: actions.h:73
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Function SetActiveLayer will change the currently active layer to aLayer and also update the APPEARAN...
static TOOL_ACTION paste
Definition: actions.h:71
bool FetchNetlistFromSchematic(NETLIST &aNetlist, FETCH_NETLIST_MODE aMode)
static TOOL_ACTION drawZone
Definition: pcb_actions.h:155
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
#define DLG_WINDOW_NAME
static TOOL_ACTION duplicate
Definition: actions.h:74
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:240
Definition: track.h:83
static TOOL_ACTION selectionTool
Definition: actions.h:151
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.
Outlines of filled polygons are shown.
void SetLastPath(LAST_PATH_TYPE aType, const wxString &aLastPath)
Set the path of the last file successfully read.
AUTOPLACE_TOOL.
static TOOL_ACTION selectSameSheet
Selects all components on the same sheet as the selected footprint.
Definition: pcb_actions.h:89
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
KIWAY Kiway
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:243
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:182