KiCad PCB EDA Suite
pcb_edit_frame.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
7  * Copyright (C) 2013-2020 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software: you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as published by the
11  * Free Software Foundation, either version 3 of the License, or (at your
12  * option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include <fctsys.h>
24 #include <kiface_i.h>
25 #include <kiway.h>
26 #include <pgm_base.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_id.h>
33 #include <pcbnew_settings.h>
34 #include <pcb_layer_box_selector.h>
35 #include <pcb_layer_widget.h>
36 #include <footprint_edit_frame.h>
37 #include <dialog_plot.h>
40 #include <dialog_board_setup.h>
41 #include <convert_to_biu.h>
42 #include <invoke_pcb_dialog.h>
43 #include <class_board.h>
44 #include <class_module.h>
45 #include <ws_proxy_view_item.h>
48 #include <pcb_draw_panel_gal.h>
49 #include <functional>
50 #include <project/project_file.h>
52 #include <project/net_settings.h>
55 #include <tool/tool_manager.h>
56 #include <tool/tool_dispatcher.h>
57 #include <tool/action_toolbar.h>
58 #include <tool/common_control.h>
59 #include <tool/common_tools.h>
60 #include <tool/selection.h>
61 #include <tool/zoom_tool.h>
62 #include <tools/selection_tool.h>
64 #include <tools/point_editor.h>
65 #include <tools/edit_tool.h>
66 #include <tools/drc_tool.h>
67 #include <tools/global_edit_tool.h>
68 #include <tools/convert_tool.h>
69 #include <tools/drawing_tool.h>
70 #include <tools/pcbnew_control.h>
74 #include <tools/pcb_viewer_tools.h>
76 #include <tools/placement_tool.h>
77 #include <tools/pad_tool.h>
80 #include <tools/zone_filler_tool.h>
81 #include <tools/pcb_actions.h>
82 #include <router/router_tool.h>
85 #include <gestfich.h>
86 #include <executable_names.h>
90 #include <wx/wupdlock.h>
91 #include <dialog_drc.h> // for DIALOG_DRC_WINDOW_NAME definition
95 #include <kiplatform/app.h>
96 
97 
98 #include <widgets/infobar.h>
99 
100 #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
101 #include <python_scripting.h>
102 #endif
103 
104 
105 using namespace std::placeholders;
106 
107 
108 BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
111 
114 
115  EVT_SIZE( PCB_EDIT_FRAME::OnSize )
116 
118 
119  // Menu Files:
121 
125 
131 
134 
135  EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit )
136  EVT_MENU( wxID_CLOSE, PCB_EDIT_FRAME::OnQuit )
137 
138  // menu Config
141 
142  // menu Postprocess
144 
145  // Horizontal toolbar
151 
152 
153 #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
154  EVT_TOOL( ID_TOOLBARH_PCB_ACTION_PLUGIN_REFRESH, PCB_EDIT_FRAME::OnActionPluginRefresh )
155  EVT_TOOL( ID_TOOLBARH_PCB_ACTION_PLUGIN_SHOW_FOLDER, PCB_EDIT_FRAME::OnActionPluginShowFolder )
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 
189  // We don't know what state board was in when it was lasat saved, so we have to
190  // assume dirty
191  m_ZoneFillsDirty = true;
192 
193  m_rotationAngle = 900;
194  m_AboutTitle = "Pcbnew";
195 
196  // Create GAL canvas
197  auto canvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
198  GetGalDisplayOptions(),
200 
201  SetCanvas( canvas );
202 
203  SetBoard( new BOARD() );
204 
205  wxIcon icon;
206  icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) );
207  SetIcon( icon );
208 
209  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
210  // initialize parameters in m_LayersManager
211  LoadSettings( config() );
212 
213  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
214 
215  // PCB drawings start in the upper left corner.
216  GetScreen()->m_Center = false;
217 
218  setupTools();
219  ReCreateMenuBar();
220  ReCreateHToolbar();
221  ReCreateAuxiliaryToolbar();
222  ReCreateVToolbar();
223  ReCreateOptToolbar();
224  ReCreateMicrowaveVToolbar();
225 
226  // We call this after the toolbars have been created to ensure the layer widget button handler
227  // doesn't cause problems
228  setupUIConditions();
229 
230  m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
231 
232  // Create the infobar
233  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
234 
235  m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas() );
236 
237  m_auimgr.SetManagedWindow( this );
238  m_auimgr.SetFlags( wxAUI_MGR_DEFAULT | wxAUI_MGR_LIVE_RESIZE );
239 
240  // Horizontal items; layers 4 - 6
241  m_auimgr.AddPane( m_mainToolBar,
242  EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
243  m_auimgr.AddPane( m_auxiliaryToolBar,
244  EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top().Layer(5) );
245  m_auimgr.AddPane( m_messagePanel,
246  EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
247  m_auimgr.AddPane( m_infoBar,
248  EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
249 
250  // Vertical items; layers 1 - 3
251  m_auimgr.AddPane( m_optionsToolBar,
252  EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
253 
254  m_auimgr.AddPane( m_microWaveToolBar,
255  EDA_PANE().VToolbar().Name( "MicrowaveToolbar" ).Right().Layer(2) );
256  m_auimgr.AddPane( m_drawToolBar,
257  EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(3) );
258 
259  m_auimgr.AddPane( m_appearancePanel,
260  EDA_PANE().Name( "LayersManager" ).Right().Layer( 4 )
261  .Caption( _( "Appearance" ) ).PaneBorder( false )
262  .MinSize( 180, -1 ).BestSize( 180, -1 ) );
263 
264  m_auimgr.AddPane( m_selectionFilterPanel,
265  EDA_PANE().Name( "SelectionFilter" ).Right().Layer( 4 )
266  .Caption( _( "Selection Filter" ) ).PaneBorder( false ).Position( 2 )
267  .MinSize( 180, -1 ).BestSize( 180, -1 ) );
268 
269  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
270 
271  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
272  m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
273  m_auimgr.GetPane( "MicrowaveToolbar" ).Show( m_show_microwave_tools );
274 
275  // The selection filter doesn't need to grow in the vertical direction when docked
276  m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
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  m_canvasType = LoadCanvasTypeSetting();
314 
315  // Nudge user to switch to OpenGL if they are on Cairo
316  if( m_firstRunDialogSetting < 1 )
317  {
318  if( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
319  {
320  wxString msg = _( "KiCad can use your graphics card to give you a smoother "
321  "and faster experience. This option is turned off by "
322  "default since it is not compatible with all computers.\n\n"
323  "Would you like to try enabling graphics acceleration?\n\n"
324  "If you'd like to choose later, select Accelerated Graphics "
325  "in the Preferences menu." );
326 
327  wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
328 
329  dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
330 
331  if( dlg.ShowModal() == wxID_YES )
332  {
333  // Save Cairo as default in case OpenGL crashes
334  saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
335 
336  // Switch to OpenGL, which will save the new setting if successful
337  GetToolManager()->RunAction( ACTIONS::acceleratedGraphics, true );
338 
339  // Switch back to Cairo if OpenGL is not supported
340  if( GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
341  GetToolManager()->RunAction( ACTIONS::standardGraphics, true );
342  }
343  else
344  {
345  // If they were on legacy, switch to Cairo
346  GetToolManager()->RunAction( ACTIONS::standardGraphics, true );
347  }
348  }
349 
350  m_firstRunDialogSetting = 1;
351  SaveSettings( config() );
352  }
353 
354  InitExitKey();
355 
356  // Ensure the Python interpreter is up to date with its environment variables
357  PythonSyncEnvironmentVariables();
358  PythonSyncProjectName();
359 
360  GetCanvas()->SwitchBackend( m_canvasType );
361  ActivateGalCanvas();
362 
363  // Default shutdown reason until a file is loaded
364  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New PCB file is unsaved" ) );
365 
366  // disable Export STEP item if kicad2step does not exist
367  wxString strK2S = Pgm().GetExecutablePath();
368 
369 #ifdef __WXMAC__
370  if( strK2S.Find( "pcbnew.app" ) != wxNOT_FOUND )
371  {
372  // On macOS, we have standalone applications inside the main bundle, so we handle that here:
373  strK2S += "../../";
374  }
375 
376  strK2S += "Contents/MacOS/";
377 #endif
378 
379  wxFileName appK2S( strK2S, "kicad2step" );
380 
381  #ifdef _WIN32
382  appK2S.SetExt( "exe" );
383  #endif
384 
385  // Ensure the window is on top
386  Raise();
387 
388 // if( !appK2S.FileExists() )
389  // GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
390 }
391 
392 
394 {
395  // Close modeless dialogs
396  wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
397 
398  if( open_dlg )
399  open_dlg->Close( true );
400 
401  // Shutdown all running tools
402  if( m_toolManager )
403  m_toolManager->ShutdownAllTools();
404 
405  if( GetBoard() )
406  GetBoard()->RemoveListener( m_appearancePanel );
407 
408  delete m_selectionFilterPanel;
409  delete m_appearancePanel;
410 }
411 
412 
414 {
415  if( m_Pcb )
416  m_Pcb->ClearProject();
417 
419 
420  aBoard->SetProject( &Prj() );
421  aBoard->GetConnectivity()->Build( aBoard );
422 
423  // reload the worksheet
424  SetPageSettings( aBoard->GetPageSettings() );
425 }
426 
427 
429 {
430  return m_Pcb;
431 }
432 
433 
434 void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
435 {
436  PCB_BASE_FRAME::SetPageSettings( aPageSettings );
437 
438  // Prepare worksheet template
439  KIGFX::WS_PROXY_VIEW_ITEM* worksheet;
440  worksheet = new KIGFX::WS_PROXY_VIEW_ITEM( IU_PER_MILS ,&m_Pcb->GetPageSettings(),
441  m_Pcb->GetProject(), &m_Pcb->GetTitleBlock() );
442  worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );
443 
444  BASE_SCREEN* screen = GetScreen();
445 
446  if( screen != NULL )
447  {
448  worksheet->SetSheetNumber( screen->m_ScreenNumber );
449  worksheet->SetSheetCount( screen->m_NumberOfScreens );
450  }
451 
452  if( auto board = GetBoard() )
453  worksheet->SetFileName( TO_UTF8( board->GetFileName() ) );
454 
455  // PCB_DRAW_PANEL_GAL takes ownership of the worksheet
456  GetCanvas()->SetWorksheet( worksheet );
457 }
458 
459 
461 {
462  return GetScreen() && GetScreen()->IsModify();
463 }
464 
465 
467 {
468  if( GetScreen() )
469  return GetScreen()->IsSave();
470 
471  return false;
472 }
473 
474 
476 {
477  return m_toolManager->GetTool<SELECTION_TOOL>()->GetSelection();
478 }
479 
480 
482 {
483  // Create the manager and dispatcher & route draw panel events to the dispatcher
484  m_toolManager = new TOOL_MANAGER;
485  m_toolManager->SetEnvironment( m_Pcb, GetCanvas()->GetView(),
486  GetCanvas()->GetViewControls(), config(), this );
487  m_actions = new PCB_ACTIONS();
488  m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
489 
490  // Register tools
491  m_toolManager->RegisterTool( new COMMON_CONTROL );
492  m_toolManager->RegisterTool( new COMMON_TOOLS );
493  m_toolManager->RegisterTool( new SELECTION_TOOL );
494  m_toolManager->RegisterTool( new ZOOM_TOOL );
495  m_toolManager->RegisterTool( new PCBNEW_PICKER_TOOL );
496  m_toolManager->RegisterTool( new ROUTER_TOOL );
497  m_toolManager->RegisterTool( new LENGTH_TUNER_TOOL );
498  m_toolManager->RegisterTool( new EDIT_TOOL );
499  m_toolManager->RegisterTool( new GLOBAL_EDIT_TOOL );
500  m_toolManager->RegisterTool( new PAD_TOOL );
501  m_toolManager->RegisterTool( new DRAWING_TOOL );
502  m_toolManager->RegisterTool( new POINT_EDITOR );
503  m_toolManager->RegisterTool( new PCBNEW_CONTROL );
504  m_toolManager->RegisterTool( new PCB_EDITOR_CONTROL );
505  m_toolManager->RegisterTool( new PCB_INSPECTION_TOOL );
506  m_toolManager->RegisterTool( new PCB_REANNOTATE_TOOL );
507  m_toolManager->RegisterTool( new ALIGN_DISTRIBUTE_TOOL );
508  m_toolManager->RegisterTool( new MICROWAVE_TOOL );
509  m_toolManager->RegisterTool( new POSITION_RELATIVE_TOOL );
510  m_toolManager->RegisterTool( new ZONE_FILLER_TOOL );
511  m_toolManager->RegisterTool( new AUTOPLACE_TOOL );
512  m_toolManager->RegisterTool( new DRC_TOOL );
513  m_toolManager->RegisterTool( new PCB_VIEWER_TOOLS );
514  m_toolManager->RegisterTool( new CONVERT_TOOL );
515  m_toolManager->InitTools();
516 
517  // Run the selection tool, it is supposed to be always active
518  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
519 }
520 
521 
523 {
525 
526  ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
527  PCB_EDITOR_CONDITIONS cond( this );
528 
529  wxASSERT( mgr );
530 
531 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
532 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
533 
535  mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
536  mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
537 
545 
550  mgr->SetConditions( ACTIONS::selectAll, ENABLE( cond.HasItems() ) );
553 
560 
561 
562 #if defined( KICAD_SCRIPTING_WXPYTHON )
563  auto pythonConsoleCond =
564  [] ( const SELECTION& )
565  {
566  if( IsWxPythonLoaded() )
567  {
568  wxWindow* console = PCB_EDIT_FRAME::findPythonConsole();
569  return console && console->IsShown();
570  }
571 
572  return false;
573  };
574 
575  mgr->SetConditions( PCB_ACTIONS::showPythonConsole, CHECK( pythonConsoleCond ) );
576 #endif
577 
578 
579  auto enableBoardSetupCondition =
580  [this] ( const SELECTION& )
581  {
582  if( DRC_TOOL* tool = m_toolManager->GetTool<DRC_TOOL>() )
583  return !tool->IsDRCDialogShown();
584 
585  return true;
586  };
587 
588  auto boardFlippedCond =
589  [this]( const SELECTION& )
590  {
591  return GetCanvas()->GetView()->IsMirroredX();
592  };
593 
594  auto layerManagerCond =
595  [this] ( const SELECTION& )
596  {
597  return LayerManagerShown();
598  };
599 
600  auto microwaveToolbarCond =
601  [this] ( const SELECTION& )
602  {
603  return MicrowaveToolbarShown();
604  };
605 
606  auto highContrastCond =
607  [this] ( const SELECTION& )
608  {
609  return GetDisplayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
610  };
611 
612  auto globalRatsnestCond =
613  [this] (const SELECTION& )
614  {
615  return GetDisplayOptions().m_ShowGlobalRatsnest;
616  };
617 
618  auto curvedRatsnestCond =
619  [this] (const SELECTION& )
620  {
621  return GetDisplayOptions().m_DisplayRatsnestLinesCurved;
622  };
623 
624  mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
625  mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
626  mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) );
627  mgr->SetConditions( PCB_ACTIONS::showMicrowaveToolbar, CHECK( microwaveToolbarCond ) );
628  mgr->SetConditions( PCB_ACTIONS::showRatsnest, CHECK( globalRatsnestCond ) );
629  mgr->SetConditions( PCB_ACTIONS::ratsnestLineMode, CHECK( curvedRatsnestCond ) );
630  mgr->SetConditions( PCB_ACTIONS::boardSetup , ENABLE( enableBoardSetupCondition ) );
631 
632 
633  auto isHighlightMode =
634  [this]( const SELECTION& )
635  {
636  ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
637  return tool->GetRouterMode() == PNS::RM_MarkObstacles;
638  };
639 
640  auto isShoveMode =
641  [this]( const SELECTION& )
642  {
643  ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
644  return tool->GetRouterMode() == PNS::RM_Shove;
645  };
646 
647  auto isWalkaroundMode =
648  [this]( const SELECTION& )
649  {
650  ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
651  return tool->GetRouterMode() == PNS::RM_Walkaround;
652  };
653 
654  mgr->SetConditions( PCB_ACTIONS::routerHighlightMode, CHECK( isHighlightMode ) );
655  mgr->SetConditions( PCB_ACTIONS::routerShoveMode, CHECK( isShoveMode ) );
656  mgr->SetConditions( PCB_ACTIONS::routerWalkaroundMode, CHECK( isWalkaroundMode ) );
657 
658  auto haveNetCond =
659  [] ( const SELECTION& aSel )
660  {
661  for( EDA_ITEM* item : aSel )
662  {
663  if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
664  {
665  if( bci->GetNetCode() > 0 )
666  return true;
667  }
668  }
669 
670  return false;
671  };
672 
673  mgr->SetConditions( PCB_ACTIONS::showNet, ENABLE( haveNetCond ) );
674  mgr->SetConditions( PCB_ACTIONS::hideNet, ENABLE( haveNetCond ) );
675  mgr->SetConditions( PCB_ACTIONS::highlightNet, ENABLE( haveNetCond ) );
676 
685 
686 
687  SELECTION_CONDITION singleZoneCond = SELECTION_CONDITIONS::Count( 1 ) &&
689 
693 
694  mgr->SetConditions( PCB_ACTIONS::zoneDuplicate, ENABLE( singleZoneCond ) );
695  mgr->SetConditions( PCB_ACTIONS::drawZoneCutout, ENABLE( singleZoneCond ) );
696  mgr->SetConditions( PCB_ACTIONS::drawSimilarZone, ENABLE( singleZoneCond ) );
697  mgr->SetConditions( PCB_ACTIONS::zoneMerge, ENABLE( zoneMergeCond ) );
700 
701  // The layer indicator is special, so we register a callback directly that will regenerate the
702  // bitmap instead of using the conditions system
703  auto layerIndicatorUpdate =
704  [this] ( wxUpdateUIEvent& )
705  {
706  PrepareLayerIndicator();
707  };
708 
709  Bind( wxEVT_UPDATE_UI, layerIndicatorUpdate, PCB_ACTIONS::selectLayerPair.GetUIId() );
710 
711 
712 #define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
713 
714  // These tools can be used at any time to inspect the board
720 
721 
722  auto isDrcRunning =
723  [this] ( const SELECTION& )
724  {
725  DRC_TOOL* tool = m_toolManager->GetTool<DRC_TOOL>();
726  return !tool->IsDRCRunning();
727  };
728 
729 #define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, ACTION_CONDITIONS().Check( cond.CurrentTool( action ) ).Enable( isDrcRunning ) )
730 
731  // These tools edit the board, so they must be disabled during some operations
751 
757 
758 #undef CURRENT_TOOL
759 #undef CURRENT_EDIT_TOOL
760 #undef ENABLE
761 #undef CHECK
762 }
763 
764 
765 void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event )
766 {
767  if( event.GetId() == wxID_EXIT )
768  Kiway().OnKiCadExit();
769 
770  if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
771  Close( false );
772 }
773 
774 
776 {
778  bds.m_DrcExclusions.clear();
779 
780  for( MARKER_PCB* marker : GetBoard()->Markers() )
781  {
782  if( marker->IsExcluded() )
783  bds.m_DrcExclusions.insert( marker->Serialize() );
784  }
785 }
786 
787 
789 {
791 
792  for( MARKER_PCB* marker : GetBoard()->Markers() )
793  {
794  auto i = bds.m_DrcExclusions.find( marker->Serialize() );
795 
796  if( i != bds.m_DrcExclusions.end() )
797  {
798  marker->SetExcluded( true );
799  bds.m_DrcExclusions.erase( i );
800  }
801  }
802 
803  BOARD_COMMIT commit( this );
804 
805  for( const wxString& exclusionData : bds.m_DrcExclusions )
806  {
807  MARKER_PCB* marker = MARKER_PCB::Deserialize( exclusionData );
808 
809  if( marker )
810  {
811  marker->SetExcluded( true );
812  commit.Add( marker );
813  }
814  }
815 
816  bds.m_DrcExclusions.clear();
817 
818  commit.Push( wxEmptyString, false, false );
819 }
820 
821 
822 bool PCB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
823 {
824  // Shutdown blocks must be determined and vetoed as early as possible
825  if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
826  && IsContentModified() )
827  {
828  return false;
829  }
830 
831  if( IsContentModified() )
832  {
833  wxFileName fileName = GetBoard()->GetFileName();
834  wxString msg = _( "Save changes to \"%s\" before closing?" );
835 
836  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
837  [&]() -> bool
838  {
839  return Files_io_from_id( ID_SAVE_BOARD );
840  } ) )
841  {
842  return false;
843  }
844  }
845 
846  // Close modeless dialogs. They're trouble when they get destroyed after the frame and/or
847  // board.
848  wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
849 
850  if( open_dlg )
851  open_dlg->Close( true );
852 
853  return true;
854 }
855 
857 {
858  // On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes
859  // when closing this frame if a footprint was selected, and the footprint editor called
860  // to edit this footprint, and when closing pcbnew if this footprint is still selected
861  // See https://bugs.launchpad.net/kicad/+bug/1655858
862  // I think this is certainly a OpenGL event fired after frame deletion, so this workaround
863  // avoid the crash (JPC)
864  GetCanvas()->SetEvtHandlerEnabled( false );
865 
866  GetCanvas()->StopDrawing();
867 
868  // Delete the auto save file if it exists.
869  wxFileName fn = GetBoard()->GetFileName();
870 
871  // Auto save file name is the normal file name prefixed with 'GetAutoSaveFilePrefix()'.
872  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
873 
874  // When the auto save feature does not have write access to the board file path, it falls
875  // back to a platform specific user temporary file path.
876  if( !fn.IsOk() || !fn.IsDirWritable() )
877  fn.SetPath( wxFileName::GetTempDir() );
878 
879  wxLogTrace( traceAutoSave, "Deleting auto save file <" + fn.GetFullPath() + ">" );
880 
881  // Remove the auto save file on a normal close of Pcbnew.
882  if( fn.FileExists() && !wxRemoveFile( fn.GetFullPath() ) )
883  {
884  wxString msg = wxString::Format( _( "The auto save file \"%s\" could not be removed!" ),
885  fn.GetFullPath() );
886  wxMessageBox( msg, Pgm().App().GetAppName(), wxOK | wxICON_ERROR, this );
887  }
888 
889  // Make sure local settings are persisted
890  SaveProjectSettings();
891 
892  // Do not show the layer manager during closing to avoid flicker
893  // on some platforms (Windows) that generate useless redraw of items in
894  // the Layer Manger
895  if( m_show_layer_manager_tools )
896  m_auimgr.GetPane( "LayersManager" ).Show( false );
897 
898  // Unlink the old project if needed
899  GetBoard()->ClearProject();
900 
901  // Delete board structs and undo/redo lists, to avoid crash on exit
902  // when deleting some structs (mainly in undo/redo lists) too late
903  Clear_Pcb( false, true );
904 
905  // do not show the window because ScreenPcb will be deleted and we do not
906  // want any paint event
907  Show( false );
908 
910 }
911 
912 
914 {
916  GetCanvas()->UpdateColors();
917  GetCanvas()->Refresh();
918 }
919 
920 
921 void PCB_EDIT_FRAME::ShowBoardSetupDialog( const wxString& aInitialPage, const wxString& aErrorMsg,
922  int aErrorCtrlId, int aErrorLine, int aErrorCol )
923 {
924  // Make sure everything's up-to-date
926 
927  DIALOG_BOARD_SETUP dlg( this );
928 
929  if( !aInitialPage.IsEmpty() )
930  dlg.SetInitialPage( aInitialPage, wxEmptyString );
931 
932  if( !aErrorMsg.IsEmpty() )
933  dlg.SetError( aErrorMsg, aInitialPage, aErrorCtrlId, aErrorLine, aErrorCol );
934 
935  if( dlg.ShowQuasiModal() == wxID_OK )
936  {
938 
941  SaveProjectSettings();
942 
944  ReCreateAuxiliaryToolbar();
945 
946  Kiway().CommonSettingsChanged( false, true );
947  GetCanvas()->Refresh();
948 
949  m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
950 
951  //this event causes the routing tool to reload its design rules information
953  toolEvent.SetHasPosition( false );
954  m_toolManager->ProcessEvent( toolEvent );
955 
956  OnModify();
957  }
958 
959  GetCanvas()->SetFocus();
960 }
961 
962 
964 {
966 
967  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
968  wxASSERT( cfg );
969 
970  if( cfg )
971  {
972  m_rotationAngle = cfg->m_RotationAngle;
974  m_show_microwave_tools = cfg->m_AuiPanels.show_microwave_tools;
975  m_show_layer_manager_tools = cfg->m_AuiPanels.show_layer_manager;
976  m_showPageLimits = cfg->m_ShowPageLimits;
977  }
978 }
979 
980 
982 {
984 
985  auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
986  wxASSERT( cfg );
987 
988  if( cfg )
989  {
990  cfg->m_RotationAngle = m_rotationAngle;
991  cfg->m_PlotLineWidth = Iu2Millimeter( g_DrawDefaultLineThickness );
992  cfg->m_AuiPanels.show_microwave_tools = m_show_microwave_tools;
993  cfg->m_AuiPanels.show_layer_manager = m_show_layer_manager_tools;
994  cfg->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
995  cfg->m_AuiPanels.appearance_panel_tab = m_appearancePanel->GetTabIndex();
996  cfg->m_ShowPageLimits = m_showPageLimits;
997  }
998 }
999 
1000 
1002 {
1003  return GetColorSettings()->GetColor( LAYER_GRID );
1004 }
1005 
1006 
1008 {
1009 
1010  GetColorSettings()->SetColor( LAYER_GRID, aColor );
1011  GetCanvas()->GetGAL()->SetGridColor( aColor );
1012 }
1013 
1014 
1016 {
1018 
1019  m_appearancePanel->OnLayerChanged();
1020 
1021  m_toolManager->RunAction( PCB_ACTIONS::layerChanged ); // notify other tools
1022  GetCanvas()->SetFocus(); // allow capture of hotkeys
1023  GetCanvas()->SetHighContrastLayer( aLayer );
1024  GetCanvas()->Refresh();
1025 }
1026 
1027 
1029 {
1030  UpdateTitle();
1031 
1032  wxFileName fn = GetBoard()->GetFileName();
1033  m_infoBar->Dismiss();
1034 
1035  // Display a warning that the file is read only
1036  if( fn.FileExists() && !fn.IsFileWritable() )
1037  {
1038  m_infoBar->RemoveAllButtons();
1039  m_infoBar->AddCloseButton();
1040  m_infoBar->ShowMessage( "Board file is read only.", wxICON_WARNING );
1041  }
1042 
1043  ReCreateLayerBox();
1044 
1045  // Sync layer and item visibility
1046  GetCanvas()->SyncLayersVisibility( m_Pcb );
1047 
1048  SetElementVisibility( LAYER_RATSNEST, GetDisplayOptions().m_ShowGlobalRatsnest );
1049 
1050  m_appearancePanel->OnBoardChanged();
1051 
1052  // Apply saved display state to the appearance panel after it has been set up
1053  PROJECT_LOCAL_SETTINGS& localSettings = Prj().GetLocalSettings();
1054 
1055  m_appearancePanel->ApplyLayerPreset( localSettings.m_ActiveLayerPreset );
1056 
1057  if( GetBoard()->GetDesignSettings().IsLayerEnabled( localSettings.m_ActiveLayer ) )
1058  SetActiveLayer( localSettings.m_ActiveLayer );
1059 
1060  // Updates any auto dimensions and the auxiliary toolbar tracks/via sizes
1061  unitsChangeRefresh();
1062 
1063  // Display the loaded board:
1064  Zoom_Automatique( false );
1065 
1066  Refresh();
1067 
1068  SetMsgPanel( GetBoard() );
1069  SetStatusText( wxEmptyString );
1070 
1071  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "PCB file changes are unsaved" ) );
1072 }
1073 
1074 
1076 {
1077  m_appearancePanel->UpdateDisplayOptions();
1078 }
1079 
1080 
1081 void PCB_EDIT_FRAME::OnUpdateLayerAlpha( wxUpdateUIEvent & )
1082 {
1083  m_appearancePanel->OnLayerAlphaChanged();
1084 }
1085 
1086 
1088 {
1089  return GetBoard()->IsElementVisible( aElement );
1090 }
1091 
1092 
1093 void PCB_EDIT_FRAME::SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState )
1094 {
1095  // Force the RATSNEST visible
1096  if( aElement == LAYER_RATSNEST )
1097  GetCanvas()->GetView()->SetLayerVisible( aElement, true );
1098  else
1099  GetCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
1100 
1101  GetBoard()->SetElementVisibility( aElement, aNewState );
1102 }
1103 
1104 
1106 {
1107  // call my base class
1109 
1110  wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_appearancePanel );
1111  pane_info.Caption( _( "Appearance" ) );
1112  m_auimgr.Update();
1113 
1114  m_appearancePanel->OnBoardChanged();
1115 
1116  // pcbnew-specific toolbars
1117  ReCreateMicrowaveVToolbar();
1118 }
1119 
1120 
1122 {
1123  PROJECT_FILE& project = Prj().GetProjectFile();
1124 
1125  if( project.m_PcbLastPath[ aType ].IsEmpty() )
1126  return wxEmptyString;
1127 
1128  wxFileName absoluteFileName = project.m_PcbLastPath[ aType ];
1129  wxFileName pcbFileName = GetBoard()->GetFileName();
1130 
1131  absoluteFileName.MakeAbsolute( pcbFileName.GetPath() );
1132  return absoluteFileName.GetFullPath();
1133 }
1134 
1135 
1136 void PCB_EDIT_FRAME::SetLastPath( LAST_PATH_TYPE aType, const wxString& aLastPath )
1137 {
1138  PROJECT_FILE& project = Prj().GetProjectFile();
1139 
1140  wxFileName relativeFileName = aLastPath;
1141  wxFileName pcbFileName = GetBoard()->GetFileName();
1142 
1143  relativeFileName.MakeRelativeTo( pcbFileName.GetPath() );
1144 
1145  if( relativeFileName.GetFullPath() != project.m_PcbLastPath[ aType ] )
1146  {
1147  project.m_PcbLastPath[ aType ] = relativeFileName.GetFullPath();
1148  SaveProjectSettings();
1149  }
1150 }
1151 
1152 
1154 {
1156 
1157  Update3DView( false );
1158 
1159  m_ZoneFillsDirty = true;
1160 }
1161 
1162 
1163 void PCB_EDIT_FRAME::ExportSVG( wxCommandEvent& event )
1164 {
1165  InvokeExportSVG( this, GetBoard() );
1166 }
1167 
1168 
1170 {
1171  wxFileName fileName = GetBoard()->GetFileName();
1172  wxString fileinfo;
1173 
1174  if( fileName.IsOk() && fileName.FileExists() )
1175  fileinfo = fileName.IsFileWritable() ? wxString( wxEmptyString ) : _( " [Read Only]" );
1176  else
1177  fileinfo = _( " [Unsaved]" );
1178 
1179  SetTitle( wxString::Format( wxT( "%s%s \u2014 " ) + _( "Pcbnew" ),
1180  fileName.GetName(),
1181  fileinfo ) );
1182 }
1183 
1184 
1186 {
1187  // Update the layer manager and other widgets from the board setup
1188  // (layer and items visibility, colors ...)
1189 
1190  // Rebuild list of nets (full ratsnest rebuild)
1192  Compile_Ratsnest( true );
1193 
1194  // Update info shown by the horizontal toolbars
1195  ReCreateLayerBox();
1196 
1197  LSET activeLayers = GetBoard()->GetEnabledLayers();
1198 
1199  if( !activeLayers.test( GetActiveLayer() ) )
1200  SetActiveLayer( activeLayers.Seq().front() );
1201 
1202  m_SelLayerBox->SetLayerSelection( GetActiveLayer() );
1203 
1205 
1206  layerEnum.Choices().Clear();
1207  layerEnum.Undefined( UNDEFINED_LAYER );
1208 
1209  for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
1210  layerEnum.Map( *seq, GetBoard()->GetLayerName( *seq ) );
1211 
1212  // Sync visibility with canvas
1213  KIGFX::VIEW* view = GetCanvas()->GetView();
1214 
1215  for( PCB_LAYER_ID layer : GetBoard()->GetVisibleLayers().Seq() )
1216  view->SetLayerVisible( layer, true );
1217 
1218  // Stackup and/or color theme may have changed
1219  m_appearancePanel->OnBoardChanged();
1220 }
1221 
1222 
1223 #if defined( KICAD_SCRIPTING_WXPYTHON )
1224 
1225 void PCB_EDIT_FRAME::ScriptingConsoleEnableDisable()
1226 {
1227  wxWindow * pythonPanelFrame = findPythonConsole();
1228  bool pythonPanelShown = true;
1229 
1230  if( pythonPanelFrame == NULL )
1231  pythonPanelFrame = CreatePythonShellWindow( this, pythonConsoleNameId() );
1232  else
1233  pythonPanelShown = ! pythonPanelFrame->IsShown();
1234 
1235  if( pythonPanelFrame )
1236  pythonPanelFrame->Show( pythonPanelShown );
1237  else
1238  wxMessageBox( wxT( "Error: unable to create the Python Console" ) );
1239 }
1240 #endif
1241 
1242 
1243 void PCB_EDIT_FRAME::OnLayerColorChange( wxCommandEvent& aEvent )
1244 {
1245  ReCreateLayerBox();
1246 }
1247 
1248 
1250 {
1251  // switches currently used canvas (Cairo / OpenGL).
1252  PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
1253 }
1254 
1255 
1257 {
1258  PCB_PLOT_PARAMS plotSettings = GetPlotSettings();
1259 
1260  switch( aID )
1261  {
1262  case ID_GEN_PLOT_GERBER:
1263  plotSettings.SetFormat( PLOT_FORMAT::GERBER );
1264  break;
1265  case ID_GEN_PLOT_DXF:
1266  plotSettings.SetFormat( PLOT_FORMAT::DXF );
1267  break;
1268  case ID_GEN_PLOT_HPGL:
1269  plotSettings.SetFormat( PLOT_FORMAT::HPGL );
1270  break;
1271  case ID_GEN_PLOT_PDF:
1272  plotSettings.SetFormat( PLOT_FORMAT::PDF );
1273  break;
1274  case ID_GEN_PLOT_PS:
1275  plotSettings.SetFormat( PLOT_FORMAT::POST );
1276  break;
1277  case ID_GEN_PLOT: /* keep the previous setup */ break;
1278  default:
1279  wxFAIL_MSG( "ToPlotter(): unexpected plot type" ); break;
1280  break;
1281  }
1282 
1283  SetPlotSettings( plotSettings );
1284 
1285  // Force rebuild the dialog if currently open because the old dialog can be not up to date
1286  // if the board (or units) has changed
1287  wxWindow* dlg = wxWindow::FindWindowByName( DLG_WINDOW_NAME );
1288 
1289  if( dlg )
1290  dlg->Destroy();
1291 
1292  dlg = new DIALOG_PLOT( this );
1293  dlg->Show( true );
1294 }
1295 
1296 
1297 bool PCB_EDIT_FRAME::SetCurrentNetClass( const wxString& aNetClassName )
1298 {
1299  bool change = GetDesignSettings().SetCurrentNetClass( aNetClassName );
1300 
1301  if( change )
1302  ReCreateAuxiliaryToolbar();
1303 
1304  return change;
1305 }
1306 
1307 
1309 {
1310  if( Kiface().IsSingle() )
1311  return false;
1312 
1313  // Update PCB requires a netlist. Therefore the schematic editor must be running
1314  // If this is not the case, open the schematic editor
1315  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
1316 
1317  if( !frame->IsShown() )
1318  {
1319  wxFileName fn( Prj().GetProjectPath(), Prj().GetProjectName(),
1321 
1322  // Maybe the file hasn't been converted to the new s-expression file format so
1323  // see if the legacy schematic file is still in play.
1324  if( !fn.FileExists() )
1325  {
1326  fn.SetExt( LegacySchematicFileExtension );
1327 
1328  if( !fn.FileExists() )
1329  {
1330  DisplayError( this, _( "The schematic for this board cannot be found." ) );
1331  return false;
1332  }
1333  }
1334 
1335  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1336 
1337  // we show the schematic editor frame, because do not show is seen as
1338  // a not yet opened schematic by Kicad manager, which is not the case
1339  frame->Show( true );
1340 
1341  // bring ourselves back to the front
1342  Raise();
1343  }
1344 
1345  return true; //Success!
1346 }
1347 
1348 
1349 //
1350 // Sends a Netlist packet to eeSchema.
1351 // The reply is in aNetlist so it is destroyed by this
1352 //
1353 bool PCB_EDIT_FRAME::ReannotateSchematic( std::string& aNetlist )
1354 {
1355  Kiway().ExpressMail( FRAME_SCH, MAIL_REANNOTATE, aNetlist, this );
1356  return true;
1357 }
1358 
1359 
1361 {
1362  if( !TestStandalone( )) {
1363  DisplayError( this, _( "Cannot update the PCB because Pcbnew is opened in stand-alone "
1364  "mode. In order to create or update PCBs from schematics, you "
1365  "must launch the KiCad project manager and create a project." ) );
1366  return false; //Not in standalone mode
1367  }
1368 
1369  Raise(); //Show
1370  std::string payload;
1371 
1372  if( aMode == NO_ANNOTATION )
1373  payload = "no-annotate";
1374  else if( aMode == QUIET_ANNOTATION )
1375  payload = "quiet-annotate";
1376 
1377  Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_GET_NETLIST, payload, this );
1378 
1379  try
1380  {
1381  auto lineReader = new STRING_LINE_READER( payload, _( "Eeschema netlist" ) );
1382  KICAD_NETLIST_READER netlistReader( lineReader, &aNetlist );
1383  netlistReader.LoadNetlist();
1384  }
1385  catch( const IO_ERROR& )
1386  {
1387  assert( false ); // should never happen
1388  return false;
1389  }
1390 
1391  return true;
1392 }
1393 
1394 
1395 void PCB_EDIT_FRAME::DoUpdatePCBFromNetlist( NETLIST& aNetlist, bool aUseTimestamps )
1396 {
1397  BOARD_NETLIST_UPDATER updater( this, GetBoard() );
1398  updater.SetLookupByTimestamp( aUseTimestamps );
1399  updater.SetDeleteUnusedComponents( false );
1400  updater.SetReplaceFootprints( true );
1401  updater.SetDeleteSinglePadNets( false );
1402  updater.SetWarnPadNoNetInNetlist( false );
1403  updater.UpdateNetlist( aNetlist );
1404 }
1405 
1406 
1408 {
1409  wxString msg;
1410  wxFileName schfn( Prj().GetProjectPath(), Prj().GetProjectName(),
1412 
1413  if( !schfn.FileExists() )
1414  {
1415  msg.Printf( _( "Schematic file \"%s\" not found." ), schfn.GetFullPath() );
1416  wxMessageBox( msg, _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
1417  return;
1418  }
1419 
1420  if( Kiface().IsSingle() )
1421  {
1422  wxString filename = wxT( "\"" ) + schfn.GetFullPath( wxPATH_NATIVE ) + wxT( "\"" );
1423  ExecuteFile( this, EESCHEMA_EXE, filename );
1424  }
1425  else
1426  {
1427  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, false );
1428 
1429  // Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls
1430  // Kiway.Player( FRAME_SCH, true )
1431  // therefore, the schematic editor is sometimes running, but the schematic project
1432  // is not loaded, if the library editor was called, and the dialog field editor was used.
1433  // On linux, it happens the first time the schematic editor is launched, if
1434  // library editor was running, and the dialog field editor was open
1435  // On Windows, it happens always after the library editor was called,
1436  // and the dialog field editor was used
1437  if( !frame )
1438  {
1439  try
1440  {
1441  frame = Kiway().Player( FRAME_SCH, true );
1442  }
1443  catch( const IO_ERROR& err )
1444  {
1445  wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
1446  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
1447  return;
1448  }
1449  }
1450 
1451  if( !frame->IsShown() ) // the frame exists, (created by the dialog field editor)
1452  // but no project loaded.
1453  {
1454  frame->OpenProjectFiles( std::vector<wxString>( 1, schfn.GetFullPath() ) );
1455  frame->Show( true );
1456  }
1457 
1458  // On Windows, Raise() does not bring the window on screen, when iconized or not shown
1459  // On linux, Raise() brings the window on screen, but this code works fine
1460  if( frame->IsIconized() )
1461  {
1462  frame->Iconize( false );
1463  // If an iconized frame was created by Pcbnew, Iconize( false ) is not enough
1464  // to show the frame at its normal size: Maximize should be called.
1465  frame->Maximize( false );
1466  }
1467 
1468  frame->Raise();
1469  }
1470 }
1471 
1472 
1474 {
1475  // Reload Python plugins if they are newer than the already loaded, and load new plugins
1476 #if defined(KICAD_SCRIPTING)
1477  // Reload plugin list: reload Python plugins if they are newer than the already loaded,
1478  // and load new plugins
1480 
1481 #if defined(KICAD_SCRIPTING_ACTION_MENU)
1482  // Action plugins can be modified, therefore the plugins menu must be updated:
1483  ReCreateMenuBar();
1484  // Recreate top toolbar to add action plugin buttons
1485  ReCreateHToolbar();
1486 #endif
1487 #endif
1488 }
1489 
1490 
1492 {
1493 #if defined(KICAD_SCRIPTING)
1494 #ifdef __WXMAC__
1495  wxString msg;
1496 
1497  // Quote in case there are spaces in the path.
1498  msg.Printf( "open \"%s\"", PyPluginsPath( true ) );
1499 
1500  system( msg.c_str() );
1501 #else
1502  wxString pypath( PyPluginsPath( true ) );
1503 
1504  // Quote in case there are spaces in the path.
1505  AddDelimiterString( pypath );
1506 
1507  wxLaunchDefaultApplication( pypath );
1508 #endif
1509 #endif
1510 }
1511 
1512 
1514 {
1515 #if defined( KICAD_SCRIPTING )
1516  const ENV_VAR_MAP& vars = Pgm().GetLocalEnvVariables();
1517 
1518  for( auto& var : vars )
1519  pcbnewUpdatePythonEnvVar( var.first, var.second.GetValue() );
1520 #endif
1521 }
1522 
1523 
1525 {
1526 #if defined( KICAD_SCRIPTING )
1527  wxString evValue;
1528  wxGetEnv( PROJECT_VAR_NAME, &evValue );
1529  pcbnewUpdatePythonEnvVar( wxString( PROJECT_VAR_NAME ).ToStdString(), evValue );
1530 #endif
1531 }
1532 
1533 
1535 {
1536  if( Module == NULL )
1537  return;
1538 
1540 
1541  int retvalue = dlg->ShowModal();
1542  /* retvalue =
1543  * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_UPDATE_FP if update footprint
1544  * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_EXCHANGE_FP if change footprint
1545  * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_MODEDIT for a goto editor command
1546  * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_EDIT_OK for normal edit
1547  */
1548 
1549  dlg->Close();
1550  dlg->Destroy();
1551 
1553  {
1554  // If something edited, push a refresh request
1555  GetCanvas()->Refresh();
1556  }
1558  {
1559  auto editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
1560 
1561  editor->Load_Module_From_BOARD( Module );
1562 
1563  editor->Show( true );
1564  editor->Raise(); // Iconize( false );
1565  }
1566 
1568  {
1569  auto editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
1570 
1571  editor->LoadModuleFromLibrary( Module->GetFPID() );
1572 
1573  editor->Show( true );
1574  editor->Raise(); // Iconize( false );
1575  }
1576 
1578  {
1579  InstallExchangeModuleFrame( Module, true, true );
1580  }
1581 
1583  {
1584  InstallExchangeModuleFrame( Module, false, true );
1585  }
1586 }
1587 
1588 
1590  bool selectedMode )
1591 {
1592  DIALOG_EXCHANGE_FOOTPRINTS dialog( this, aModule, updateMode, selectedMode );
1593 
1594  return dialog.ShowQuasiModal();
1595 }
1596 
1597 
1598 void PCB_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1599 {
1600  PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1601 
1602  GetAppearancePanel()->OnColorThemeChanged();
1603  ReCreateMicrowaveVToolbar();
1604 
1605  if( aTextVarsChanged )
1606  GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
1607 
1608  // Update the environment variables in the Python interpreter
1609  if( aEnvVarsChanged )
1610  PythonSyncEnvironmentVariables();
1611 
1612  Layout();
1613  SendSizeEvent();
1614 }
1615 
1616 
1618 {
1619  PythonSyncProjectName();
1620 }
1621 
1622 
1623 void PCB_EDIT_FRAME::LockModule( MODULE* aModule, bool aLocked )
1624 {
1625  const wxString ModulesMaskSelection = wxT( "*" );
1626  if( aModule )
1627  {
1628  aModule->SetLocked( aLocked );
1629  SetMsgPanel( aModule );
1630  OnModify();
1631  }
1632  else
1633  {
1634  for( auto mod : GetBoard()->Modules() )
1635  {
1636  if( WildCompareString( ModulesMaskSelection, mod->GetReference() ) )
1637  {
1638  mod->SetLocked( aLocked );
1639  OnModify();
1640  }
1641  }
1642  }
1643 }
1644 
1645 
1646 bool ExportBoardToHyperlynx( BOARD* aBoard, const wxFileName& aPath );
1647 
1648 
1649 void PCB_EDIT_FRAME::OnExportHyperlynx( wxCommandEvent& event )
1650 {
1651  wxString wildcard = wxT( "*.hyp" );
1652  wxFileName fn = GetBoard()->GetFileName();
1653 
1654  fn.SetExt( wxT("hyp") );
1655 
1656  wxFileDialog dlg( this, _( "Export Hyperlynx Layout" ), fn.GetPath(), fn.GetFullName(),
1657  wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1658 
1659  if( dlg.ShowModal() != wxID_OK )
1660  return;
1661 
1662  fn = dlg.GetPath();
1663 
1664  // always enforce filename extension, user may not have entered it.
1665  fn.SetExt( wxT( "hyp" ) );
1666 
1668 }
1669 
1670 
1672 {
1673  return GetBoard()->GetFileName();
1674 }
1675 
1676 
1678 {
1679  return m_auimgr.GetPane( "LayersManager" ).IsShown();
1680 }
1681 
1682 
1684 {
1685  return m_auimgr.GetPane( "MicrowaveToolbar" ).IsShown();
1686 }
1687 
1688 
1689 void PCB_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
1690 {
1691  if( IsShown() )
1692  {
1693  // We only need this until the frame is done resizing and the final client size is
1694  // established.
1695  Unbind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this );
1696  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
1697  }
1698 
1699  // Skip() is called in the base class.
1700  EDA_DRAW_FRAME::OnSize( aEvent );
1701 }
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
void UpdateTitle()
Function UpdateTitle sets the main window title bar text.
POSITION_RELATIVE_TOOL.
static TOOL_ACTION drawLine
Definition: pcb_actions.h:139
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
Filled polygons are shown.
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:146
void BuildListOfNets()
Definition: class_board.h:692
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:155
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
#define CURRENT_EDIT_TOOL(action)
void SetPageSettings(const PAGE_INFO &aPageSettings) override
void RecreateCmpFileFromBoard(wxCommandEvent &aEvent)
Function RecreateBOMFileFromBoard Recreates a .cmp file from the current loaded board this is the sam...
KiCad executable names.
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:59
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
const PAGE_INFO & GetPageSettings() const
Definition: class_board.h:552
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:585
int m_ScreenNumber
Definition: base_screen.h:79
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
PNS::PNS_MODE GetRouterMode()
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:126
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
static const KICAD_T Tracks[]
A scan list for only TRACKS.
Definition: collectors.h:313
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.
void LockModule(MODULE *aModule, bool aLocked)
Model changes (required full reload)
Definition: tool_base.h:82
static TOOL_ACTION drawSimilarZone
Definition: pcb_actions.h:153
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:419
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:143
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:435
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:147
static TOOL_ACTION microwaveCreateStubArc
Definition: pcb_actions.h:394
void OnSockRequestServer(wxSocketEvent &evt)
Definition: eda_dde.cpp:103
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
void SetInitialPage(const wxString &aPage, const wxString &aParentPage=wxEmptyString)
void doCloseWindow() override
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:227
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.
static bool Idle(const SELECTION &aSelection)
Tests if there no items selected or being edited.
ENUM_MAP & Undefined(T aValue)
Definition: property.h:531
PROJECT & Prj()
Definition: kicad.cpp:318
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:233
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
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
#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:145
void OnLayerColorChange(wxCommandEvent &aEvent)
static constexpr GAL_TYPE GAL_FALLBACK
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:232
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:147
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
static ENUM_MAP< T > & Instance()
Definition: property.h:517
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.
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:140
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:162
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
Definition: pcb_actions.h:194
static TOOL_ACTION microwaveCreateLine
Definition: pcb_actions.h:398
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:331
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:537
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:329
void SetGridColor(COLOR4D aColor) override
Function SetGridColor() , virtual.
const LIB_ID & GetFPID() const
Definition: class_module.h:228
SELECTION_CONDITION RedoAvailable()
Creates a functor that tests if there are any items in the redo queue.
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
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:557
static TOOL_ACTION localRatsnestTool
Definition: pcb_actions.h:439
wxString m_PcbLastPath[LAST_PATH_SIZE]
MRU path storage.
Definition: project_file.h:160
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...
bool MicrowaveToolbarShown()
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.
Item needs to be redrawn.
Definition: view_item.h:63
bool SetCurrentNetClass(const wxString &aNetClassName)
Function SetCurrentNetClass Must be called after a netclass selection (or after a netclass parameter ...
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Function Seq returns an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:380
const wxString & GetFileName() const
Definition: class_board.h:244
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 TOOL_ACTION imperialUnits
Definition: actions.h:142
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:144
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:290
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.
int InstallExchangeModuleFrame(MODULE *aModule, bool updateMode, bool selectedMode)
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.
Only the zone outline is shown.
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.
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:100
static TOOL_ACTION highlightNetTool
Definition: pcb_actions.h:432
TOOL_MANAGER.
Definition: tool_manager.h:51
void SynchronizeNetsAndNetClasses()
Function SynchronizeNetsAndNetClasses copies NETCLASS info to each NET, based on NET membership in a ...
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
void OnClearFileHistory(wxCommandEvent &aEvent)
static TOOL_ACTION measureTool
Definition: actions.h:150
class MODULE, a footprint
Definition: typeinfo.h:89
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)
Function SetSheetCount() Changes 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.
const wxString EESCHEMA_EXE
LSET is a set of PCB_LAYER_IDs.
void SetExcluded(bool aExcluded)
Definition: marker_base.h:110
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:343
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.
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 char Default[]
the name of the default NETCLASS
Definition: netclass.h:80
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.
GAL not used (the legacy wxDC engine is used)
int ShowQuasiModal()
VTBL_ENTRY PROJECT_FILE & GetProjectFile() const
Definition: project.h:141
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:43
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:488
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:294
static TOOL_ACTION togglePolarCoords
Definition: actions.h:145
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:345
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:277
#define DIALOG_DRC_WINDOW_NAME
Definition: dialog_drc.h:43
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:226
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:141
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:390
wxLogTrace helper definitions.
static LSET AllLayersMask()
Definition: lset.cpp:756
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:388
static TOOL_ACTION drawVia
Definition: pcb_actions.h:150
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:40
#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...
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:152
COMMON_CONTROL.
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:196
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:154
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
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...
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:300
COMMON_TOOLS.
Definition: common_tools.h:38
void ClearProject()
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
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:392
static TOOL_ACTION zoneUnfill
Definition: pcb_actions.h:292
BOARD * GetBoard()
static TOOL_ACTION pasteSpecial
Definition: actions.h:72
#define CHECK(x)
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:229
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:142
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:230
void SetProject(PROJECT *aProject)
Links a board to a given project.
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:297
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:437
static TOOL_ACTION metricUnits
Definition: actions.h:143
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:68
void OnSockRequest(wxSocketEvent &evt)
Definition: eda_dde.cpp:71
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:396
LAYER_WIDGET is abstract and is used to manage a list of layers, with the notion of a "current" layer...
Definition: layer_widget.h:79
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:277
PCB_ACTIONS.
Definition: pcb_actions.h:51
void OnFileHistory(wxCommandEvent &event)
static TOOL_ACTION showNet
Definition: pcb_actions.h:436
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:148
static TOOL_ACTION showMicrowaveToolbar
Definition: pcb_actions.h:330
bool SetCurrentNetClass(const wxString &aNetClassName)
Function SetCurrentNetClass Must be called after a netclass selection (or after a netclass parameter ...
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:151
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:430
void SetLocked(bool isLocked) override
Function SetLocked sets the MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition: class_module.h:321
#define CURRENT_TOOL(action)
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:201
void Process_Special_Functions(wxCommandEvent &event)
Definition: pcbnew/edit.cpp:50
void DoUpdatePCBFromNetlist(NETLIST &aNetlist, bool aUseTimestamps)
Function DoUpdatePCBFromNetlist An automated version of UpdatePCBFromNetlist which skips the UI dialo...
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
PCB_EDIT_FRAME::OnUpdateSelectTrackWidth EVT_UPDATE_UI_RANGE(ID_POPUP_PCB_SELECT_VIASIZE1, ID_POPUP_PCB_SELECT_VIASIZE8, PCB_EDIT_FRAME::OnUpdateSelectViaSize) PCB_EDIT_FRAME
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:178
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:173
#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)
static MARKER_PCB * Deserialize(const wxString &data)
FETCH_NETLIST_MODE
Function FetchNetlistFromSchematic.
static TOOL_ACTION acceleratedGraphics
Definition: actions.h:161
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
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
#define IU_PER_MILS
Definition: plotter.cpp:138
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: base_struct.h:159
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:513
Definition: id.h:97
int m_NumberOfScreens
Definition: base_screen.h:80
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 On3DShapeLibWizard(wxCommandEvent &event)
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:279
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:61
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:523
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:254
ID_POPUP_PCB_SELECT_WIDTH8
wxString GetCurrentFileName() const override
Get the full filename + path of the currently opened file in the frame.
void SetSheetNumber(int aSheetNumber)
Function SetSheetNumber() Changes the sheet number displayed in the title block.
int ExecuteFile(wxWindow *frame, const wxString &ExecFile, const wxString &param, wxProcess *callback)
Function ExecuteFile calls the executable file ExecFile with the command line parameters param.
Definition: gestfich.cpp:164
Class that groups generic conditions for PCB editor states.
static constexpr int Millimeter2iu(double mm)
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:195
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 PCB_LAYE...
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString, const wxString &aErrorMsg=wxEmptyString, int aErrorCtrlId=-1, int aErrorLine=-1, int aErrorCol=-1)
Function ShowBoardSetupDialog.
static TOOL_ACTION paste
Definition: actions.h:71
void InstallFootprintPropertiesDialog(MODULE *Module)
bool FetchNetlistFromSchematic(NETLIST &aNetlist, FETCH_NETLIST_MODE aMode)
static TOOL_ACTION drawZone
Definition: pcb_actions.h:149
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:228
static TOOL_ACTION selectionTool
Definition: actions.h:149
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:99
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:231