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-2021 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 <advanced_config.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 <confirm.h>
32 #include <trace_helpers.h>
33 #include <pcbnew_id.h>
34 #include <pcbnew_settings.h>
35 #include <pcb_layer_box_selector.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 <board.h>
44 #include <board_design_settings.h>
45 #include <footprint.h>
49 #include <pcb_draw_panel_gal.h>
50 #include <functional>
51 #include <pcb_painter.h>
52 #include <project/project_file.h>
54 #include <project/net_settings.h>
55 #include <python_scripting.h>
58 #include <tool/tool_manager.h>
59 #include <tool/tool_dispatcher.h>
60 #include <tool/action_toolbar.h>
61 #include <tool/common_control.h>
62 #include <tool/common_tools.h>
63 #include <tool/selection.h>
64 #include <tool/zoom_tool.h>
66 #include <tools/pcb_picker_tool.h>
67 #include <tools/pcb_point_editor.h>
68 #include <tools/edit_tool.h>
69 #include <tools/group_tool.h>
70 #include <tools/drc_tool.h>
71 #include <tools/global_edit_tool.h>
72 #include <tools/convert_tool.h>
73 #include <tools/drawing_tool.h>
74 #include <tools/pcb_control.h>
78 #include <tools/pcb_viewer_tools.h>
80 #include <tools/placement_tool.h>
81 #include <tools/pad_tool.h>
84 #include <tools/zone_filler_tool.h>
85 #include <tools/pcb_actions.h>
86 #include <router/router_tool.h>
90 #include <gestfich.h>
91 #include <executable_names.h>
95 #include <wx/socket.h>
96 #include <wx/wupdlock.h>
97 #include <dialog_drc.h> // for DIALOG_DRC_WINDOW_NAME definition
100 #include <widgets/infobar.h>
102 #include <kiplatform/app.h>
103 
104 #include <action_plugin.h>
105 #include "../scripting/python_scripting.h"
106 
107 #include <wx/filedlg.h>
108 
109 
110 using namespace std::placeholders;
111 
112 
113 BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
116 
119 
120  EVT_SIZE( PCB_EDIT_FRAME::OnSize )
121 
123 
124  // Menu Files:
126 
130 
136 
139 
140  EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit )
141  EVT_MENU( wxID_CLOSE, PCB_EDIT_FRAME::OnQuit )
142 
143  // menu Config
145 
146  // menu Postprocess
148 
149  // Horizontal toolbar
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( "PCB Editor" ), wxDefaultPosition,
175  m_exportNetlistAction( nullptr )
176 {
177  m_maximizeByDefault = true;
178  m_showBorderAndTitleBlock = true; // true to display sheet references
179  m_SelTrackWidthBox = nullptr;
180  m_SelViaSizeBox = nullptr;
181  m_SelLayerBox = nullptr;
182  m_show_layer_manager_tools = true;
183  m_hasAutoSave = true;
184 
185  // We don't know what state board was in when it was last saved, so we have to
186  // assume dirty
187  m_ZoneFillsDirty = true;
188 
189  m_rotationAngle = 900;
190  m_aboutTitle = _( "KiCad PCB Editor" );
191 
192  // Must be created before the menus are created.
193  if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist )
194  m_exportNetlistAction = new TOOL_ACTION( "pcbnew.EditorControl.exportNetlist",
195  AS_GLOBAL, 0, "", _( "Netlist..." ),
196  _( "Export netlist used to update schematics" ) );
197 
198  // Create GAL canvas
199  auto canvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
200  GetGalDisplayOptions(),
202 
203  SetCanvas( canvas );
204 
205  SetBoard( new BOARD() );
206 
207  wxIcon icon;
208  wxIconBundle icon_bundle;
209 
210  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew ) );
211  icon_bundle.AddIcon( icon );
212  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew_32 ) );
213  icon_bundle.AddIcon( icon );
214  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew_16 ) );
215  icon_bundle.AddIcon( icon );
216 
217  SetIcons( icon_bundle );
218 
219  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
220  // initialize parameters in m_LayersManager
221  LoadSettings( config() );
222 
223  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
224 
225  // PCB drawings start in the upper left corner.
226  GetScreen()->m_Center = false;
227 
228  setupTools();
229  setupUIConditions();
230 
231  ReCreateMenuBar();
232  ReCreateHToolbar();
233  ReCreateAuxiliaryToolbar();
234  ReCreateVToolbar();
235  ReCreateOptToolbar();
236 
237  m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
238 
239  m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas() );
240 
241  m_auimgr.SetManagedWindow( this );
242 
243  CreateInfoBar();
244 
245  unsigned int auiFlags = wxAUI_MGR_DEFAULT;
246 #if !defined( _WIN32 )
247  // Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds
248  // of graphical glitches.
249  auiFlags |= wxAUI_MGR_LIVE_RESIZE;
250 #endif
251  m_auimgr.SetFlags( auiFlags );
252 
253  // Rows; layers 4 - 6
254  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
255  .Top().Layer( 6 ) );
256  m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" )
257  .Top().Layer( 5 ) );
258  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
259  .Bottom().Layer( 6 ) );
260 
261  // Columns; layers 1 - 3
262  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
263  .Left().Layer( 3 ) );
264 
265  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
266  .Right().Layer( 3 ) );
267 
268  m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( "LayersManager" )
269  .Right().Layer( 4 )
270  .Caption( _( "Appearance" ) ).PaneBorder( false )
271  .MinSize( 180, -1 ).BestSize( 180, -1 ) );
272 
273  m_auimgr.AddPane( m_selectionFilterPanel, EDA_PANE().Name( "SelectionFilter" )
274  .Right().Layer( 4 ).Position( 2 )
275  .Caption( _( "Selection Filter" ) ).PaneBorder( false )
276  .MinSize( 180, -1 ).BestSize( 180, -1 ) );
277 
278  // Center
279  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
280  .Center() );
281 
282  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
283  m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
284 
285  // The selection filter doesn't need to grow in the vertical direction when docked
286  m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
287 
288  FinishAUIInitialization();
289 
290  if( PCBNEW_SETTINGS* settings = dynamic_cast<PCBNEW_SETTINGS*>( config() ) )
291  {
292  if( settings->m_AuiPanels.right_panel_width > 0 )
293  {
294  wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
295 
296  // wxAUI hack: force width by setting MinSize() and then Fixed()
297  // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
298  layersManager.MinSize( settings->m_AuiPanels.right_panel_width, -1 );
299  layersManager.Fixed();
300  m_auimgr.Update();
301 
302  // now make it resizable again
303  layersManager.MinSize( 180, -1 );
304  layersManager.Resizable();
305  m_auimgr.Update();
306  }
307 
308  m_appearancePanel->SetTabIndex( settings->m_AuiPanels.appearance_panel_tab );
309  }
310 
311  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
312 
313  // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
314  // to calculate the wrong zoom size. See PCB_EDIT_FRAME::onSize().
315  Bind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this );
316 
317  resolveCanvasType();
318 
319  setupUnits( config() );
320 
321  // Ensure the Python interpreter is up to date with its environment variables
322  PythonSyncEnvironmentVariables();
323  PythonSyncProjectName();
324 
325  GetCanvas()->SwitchBackend( m_canvasType );
326  ActivateGalCanvas();
327 
328  // Default shutdown reason until a file is loaded
329  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New PCB file is unsaved" ) );
330 
331  // disable Export STEP item if kicad2step does not exist
332  wxString strK2S = Pgm().GetExecutablePath();
333 
334 #ifdef __WXMAC__
335  if( strK2S.Find( "pcbnew.app" ) != wxNOT_FOUND )
336  {
337  // On macOS, we have standalone applications inside the main bundle, so we handle that here:
338  strK2S += "../../";
339  }
340 
341  strK2S += "Contents/MacOS/";
342 #endif
343 
344  wxFileName appK2S( strK2S, "kicad2step" );
345 
346  #ifdef _WIN32
347  appK2S.SetExt( "exe" );
348  #endif
349 
350  // Ensure the window is on top
351  Raise();
352 
353 // if( !appK2S.FileExists() )
354  // GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
355 
356  // AUI doesn't refresh properly on wxMac after changes in eb7dc6dd, so force it to
357 #ifdef __WXMAC__
358  if( Kiface().IsSingle() )
359  {
360  CallAfter( [&]()
361  {
362  m_appearancePanel->OnBoardChanged();
363  } );
364  }
365 #endif
366 
367  // Register a call to update the toolbar sizes. It can't be done immediately because
368  // it seems to require some sizes calculated that aren't yet (at least on GTK).
369  CallAfter( [&]()
370  {
371  // Ensure the controls on the toolbars all are correctly sized
372  UpdateToolbarControlSizes();
373  } );
374 }
375 
376 
378 {
379  // Close modeless dialogs
380  wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
381 
382  if( open_dlg )
383  open_dlg->Close( true );
384 
385  // Shutdown all running tools
386  if( m_toolManager )
387  m_toolManager->ShutdownAllTools();
388 
389  if( GetBoard() )
390  GetBoard()->RemoveListener( m_appearancePanel );
391 
392  delete m_selectionFilterPanel;
393  delete m_appearancePanel;
394  delete m_exportNetlistAction;
395 }
396 
397 
399 {
400  if( m_pcb )
401  m_pcb->ClearProject();
402 
404 
405  aBoard->SetProject( &Prj() );
406  aBoard->GetConnectivity()->Build( aBoard );
407 
408  // reload the drawing-sheet
409  SetPageSettings( aBoard->GetPageSettings() );
410 }
411 
412 
414 {
415  return m_pcb;
416 }
417 
418 
419 void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
420 {
421  PCB_BASE_FRAME::SetPageSettings( aPageSettings );
422 
423  // Prepare drawing-sheet template
425  &m_pcb->GetPageSettings(),
426  m_pcb->GetProject(),
427  &m_pcb->GetTitleBlock() );
428  drawingSheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );
429 
430  BASE_SCREEN* screen = GetScreen();
431 
432  if( screen != nullptr )
433  {
434  drawingSheet->SetPageNumber(TO_UTF8( screen->GetPageNumber() ) );
435  drawingSheet->SetSheetCount( screen->GetPageCount() );
436  }
437 
438  if( BOARD* board = GetBoard() )
439  drawingSheet->SetFileName( TO_UTF8( board->GetFileName() ) );
440 
441  // PCB_DRAW_PANEL_GAL takes ownership of the drawing-sheet
442  GetCanvas()->SetDrawingSheet( drawingSheet );
443 }
444 
445 
447 {
448  return GetScreen() && GetScreen()->IsContentModified();
449 }
450 
451 
453 {
454  if( GetScreen() )
455  return GetScreen()->IsContentModified();
456 
457  return false;
458 }
459 
460 
462 {
463  return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
464 }
465 
466 
468 {
469  // Create the manager and dispatcher & route draw panel events to the dispatcher
470  m_toolManager = new TOOL_MANAGER;
471  m_toolManager->SetEnvironment( m_pcb, GetCanvas()->GetView(),
472  GetCanvas()->GetViewControls(), config(), this );
473  m_actions = new PCB_ACTIONS();
474  m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
475 
476  // Register tools
477  m_toolManager->RegisterTool( new COMMON_CONTROL );
478  m_toolManager->RegisterTool( new COMMON_TOOLS );
479  m_toolManager->RegisterTool( new PCB_SELECTION_TOOL );
480  m_toolManager->RegisterTool( new ZOOM_TOOL );
481  m_toolManager->RegisterTool( new PCB_PICKER_TOOL );
482  m_toolManager->RegisterTool( new ROUTER_TOOL );
483  m_toolManager->RegisterTool( new LENGTH_TUNER_TOOL );
484  m_toolManager->RegisterTool( new EDIT_TOOL );
485  m_toolManager->RegisterTool( new GLOBAL_EDIT_TOOL );
486  m_toolManager->RegisterTool( new PAD_TOOL );
487  m_toolManager->RegisterTool( new DRAWING_TOOL );
488  m_toolManager->RegisterTool( new PCB_POINT_EDITOR );
489  m_toolManager->RegisterTool( new PCB_CONTROL );
490  m_toolManager->RegisterTool( new BOARD_EDITOR_CONTROL );
491  m_toolManager->RegisterTool( new BOARD_INSPECTION_TOOL );
492  m_toolManager->RegisterTool( new BOARD_REANNOTATE_TOOL );
493  m_toolManager->RegisterTool( new ALIGN_DISTRIBUTE_TOOL );
494  m_toolManager->RegisterTool( new MICROWAVE_TOOL );
495  m_toolManager->RegisterTool( new POSITION_RELATIVE_TOOL );
496  m_toolManager->RegisterTool( new ZONE_FILLER_TOOL );
497  m_toolManager->RegisterTool( new AUTOPLACE_TOOL );
498  m_toolManager->RegisterTool( new DRC_TOOL );
499  m_toolManager->RegisterTool( new PCB_VIEWER_TOOLS );
500  m_toolManager->RegisterTool( new CONVERT_TOOL );
501  m_toolManager->RegisterTool( new GROUP_TOOL );
502  m_toolManager->RegisterTool( new SCRIPTING_TOOL );
503  m_toolManager->InitTools();
504 
505  // Run the selection tool, it is supposed to be always active
506  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
507 }
508 
509 
511 {
513 
514  ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
515  PCB_EDITOR_CONDITIONS cond( this );
516 
517  wxASSERT( mgr );
518 
519 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
520 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
521 
523  mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
524  mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
525 
532 
533  mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
534  mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );
539  mgr->SetConditions( ACTIONS::selectAll, ENABLE( cond.HasItems() ) );
540  mgr->SetConditions( ACTIONS::doDelete, ENABLE( cond.HasItems() ) );
541  mgr->SetConditions( ACTIONS::duplicate, ENABLE( cond.HasItems() ) );
542 
547  mgr->SetConditions( PCB_ACTIONS::lock, ENABLE( cond.HasItems() ) );
549 
553 
554  if( SCRIPTING::IsWxAvailable() )
556 
557  auto enableZoneControlConition =
558  [this] ( const SELECTION& )
559  {
561  && GetDisplayOptions().m_ZoneOpacity > 0.0;
562  };
563 
565  ENABLE( enableZoneControlConition ).Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FILLED ) ) );
567  ENABLE( enableZoneControlConition ).Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE ) ) );
569  ENABLE( enableZoneControlConition ).Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS ) ) );
571  ENABLE( enableZoneControlConition ).Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ) ) );
572 
573  auto enableBoardSetupCondition =
574  [this] ( const SELECTION& )
575  {
576  if( DRC_TOOL* tool = m_toolManager->GetTool<DRC_TOOL>() )
577  return !tool->IsDRCDialogShown();
578 
579  return true;
580  };
581 
582  auto boardFlippedCond =
583  [this]( const SELECTION& )
584  {
585  return GetCanvas()->GetView()->IsMirroredX();
586  };
587 
588  auto layerManagerCond =
589  [this] ( const SELECTION& )
590  {
591  return LayerManagerShown();
592  };
593 
594  auto highContrastCond =
595  [this] ( const SELECTION& )
596  {
597  return GetDisplayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
598  };
599 
600  auto globalRatsnestCond =
601  [this] (const SELECTION& )
602  {
603  return GetDisplayOptions().m_ShowGlobalRatsnest;
604  };
605 
606  auto curvedRatsnestCond =
607  [this] (const SELECTION& )
608  {
609  return GetDisplayOptions().m_DisplayRatsnestLinesCurved;
610  };
611 
612  auto netHighlightCond =
613  [this]( const SELECTION& )
614  {
615  KIGFX::RENDER_SETTINGS* settings = GetCanvas()->GetView()->GetPainter()->GetSettings();
616  return !settings->GetHighlightNetCodes().empty();
617  };
618 
619  auto enableNetHighlightCond =
620  [this]( const SELECTION& )
621  {
622  BOARD_INSPECTION_TOOL* tool = m_toolManager->GetTool<BOARD_INSPECTION_TOOL>();
623  return tool->IsNetHighlightSet();
624  };
625 
626  mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
627  mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
628  mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) );
629  mgr->SetConditions( PCB_ACTIONS::showRatsnest, CHECK( globalRatsnestCond ) );
630  mgr->SetConditions( PCB_ACTIONS::ratsnestLineMode, CHECK( curvedRatsnestCond ) );
632  CHECK( netHighlightCond ).Enable( enableNetHighlightCond ) );
633  mgr->SetConditions( PCB_ACTIONS::boardSetup , ENABLE( enableBoardSetupCondition ) );
634 
635 
636  auto isHighlightMode =
637  [this]( const SELECTION& )
638  {
639  ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
640  return tool->GetRouterMode() == PNS::RM_MarkObstacles;
641  };
642 
643  auto isShoveMode =
644  [this]( const SELECTION& )
645  {
646  ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
647  return tool->GetRouterMode() == PNS::RM_Shove;
648  };
649 
650  auto isWalkaroundMode =
651  [this]( const SELECTION& )
652  {
653  ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
654  return tool->GetRouterMode() == PNS::RM_Walkaround;
655  };
656 
657  mgr->SetConditions( PCB_ACTIONS::routerHighlightMode, CHECK( isHighlightMode ) );
658  mgr->SetConditions( PCB_ACTIONS::routerShoveMode, CHECK( isShoveMode ) );
659  mgr->SetConditions( PCB_ACTIONS::routerWalkaroundMode, CHECK( isWalkaroundMode ) );
660 
661  auto haveNetCond =
662  [] ( const SELECTION& aSel )
663  {
664  for( EDA_ITEM* item : aSel )
665  {
666  if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
667  {
668  if( bci->GetNetCode() > 0 )
669  return true;
670  }
671  }
672 
673  return false;
674  };
675 
676  mgr->SetConditions( PCB_ACTIONS::showNet, ENABLE( haveNetCond ) );
677  mgr->SetConditions( PCB_ACTIONS::hideNet, ENABLE( haveNetCond ) );
678  mgr->SetConditions( PCB_ACTIONS::highlightNet, ENABLE( haveNetCond ) );
679 
686 
687 
688  SELECTION_CONDITION singleZoneCond = SELECTION_CONDITIONS::Count( 1 ) &&
690 
694 
695  mgr->SetConditions( PCB_ACTIONS::zoneDuplicate, ENABLE( singleZoneCond ) );
696  mgr->SetConditions( PCB_ACTIONS::drawZoneCutout, ENABLE( singleZoneCond ) );
697  mgr->SetConditions( PCB_ACTIONS::drawSimilarZone, ENABLE( singleZoneCond ) );
698  mgr->SetConditions( PCB_ACTIONS::zoneMerge, ENABLE( zoneMergeCond ) );
701 
703 
704 #define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
705 
706  // These tools can be used at any time to inspect the board
711 
712 
713  auto isDrcRunning =
714  [this] ( const SELECTION& )
715  {
716  DRC_TOOL* tool = m_toolManager->GetTool<DRC_TOOL>();
717  return !tool->IsDRCRunning();
718  };
719 
720 #define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, ACTION_CONDITIONS().Check( cond.CurrentTool( action ) ).Enable( isDrcRunning ) )
721 
722  // These tools edit the board, so they must be disabled during some operations
746 
752 
753 #undef CURRENT_TOOL
754 #undef CURRENT_EDIT_TOOL
755 #undef ENABLE
756 #undef CHECK
757 }
758 
759 
760 void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event )
761 {
762  if( event.GetId() == wxID_EXIT )
763  Kiway().OnKiCadExit();
764 
765  if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
766  Close( false );
767 }
768 
769 
771 {
773  bds.m_DrcExclusions.clear();
774 
775  for( PCB_MARKER* marker : GetBoard()->Markers() )
776  {
777  if( marker->IsExcluded() )
778  bds.m_DrcExclusions.insert( marker->Serialize() );
779  }
780 }
781 
782 
784 {
785  BOARD_COMMIT commit( this );
786 
787  for( PCB_MARKER* marker : GetBoard()->ResolveDRCExclusions() )
788  commit.Add( marker );
789 
790  commit.Push( wxEmptyString, false, false );
791 
792  for( PCB_MARKER* marker : GetBoard()->Markers() )
793  {
794  if( marker->IsExcluded() )
795  {
796  GetCanvas()->GetView()->Remove( marker );
797  GetCanvas()->GetView()->Add( marker );
798  }
799  }
800 }
801 
802 
803 bool PCB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
804 {
805  // Shutdown blocks must be determined and vetoed as early as possible
806  if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
807  && IsContentModified() )
808  {
809  return false;
810  }
811 
812  if( IsContentModified() )
813  {
814  wxFileName fileName = GetBoard()->GetFileName();
815  wxString msg = _( "Save changes to '%s' before closing?" );
816 
817  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
818  [&]() -> bool
819  {
820  return Files_io_from_id( ID_SAVE_BOARD );
821  } ) )
822  {
823  return false;
824  }
825  }
826 
827  // Close modeless dialogs. They're trouble when they get destroyed after the frame and/or
828  // board.
829  wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
830 
831  if( open_dlg )
832  open_dlg->Close( true );
833 
834  return PCB_BASE_EDIT_FRAME::canCloseWindow( aEvent );
835 }
836 
837 
839 {
840  // On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes
841  // when closing this frame if a footprint was selected, and the footprint editor called
842  // to edit this footprint, and when closing pcbnew if this footprint is still selected
843  // See https://bugs.launchpad.net/kicad/+bug/1655858
844  // I think this is certainly a OpenGL event fired after frame deletion, so this workaround
845  // avoid the crash (JPC)
846  GetCanvas()->SetEvtHandlerEnabled( false );
847 
848  GetCanvas()->StopDrawing();
849 
850  // Delete the auto save file if it exists.
851  wxFileName fn = GetBoard()->GetFileName();
852 
853  // Auto save file name is the normal file name prefixed with 'GetAutoSaveFilePrefix()'.
854  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
855 
856  // When the auto save feature does not have write access to the board file path, it falls
857  // back to a platform specific user temporary file path.
858  if( !fn.IsOk() || !fn.IsDirWritable() )
859  fn.SetPath( wxFileName::GetTempDir() );
860 
861  wxLogTrace( traceAutoSave, "Deleting auto save file <" + fn.GetFullPath() + ">" );
862 
863  // Remove the auto save file on a normal close of Pcbnew.
864  if( fn.FileExists() && !wxRemoveFile( fn.GetFullPath() ) )
865  {
866  wxString msg = wxString::Format( _( "The auto save file '%s' could not be removed!" ),
867  fn.GetFullPath() );
868  wxMessageBox( msg, Pgm().App().GetAppName(), wxOK | wxICON_ERROR, this );
869  }
870 
871  // Make sure local settings are persisted
872  SaveProjectSettings();
873 
874  // Do not show the layer manager during closing to avoid flicker
875  // on some platforms (Windows) that generate useless redraw of items in
876  // the Layer Manager
877  if( m_show_layer_manager_tools )
878  m_auimgr.GetPane( "LayersManager" ).Show( false );
879 
880  // Unlink the old project if needed
881  GetBoard()->ClearProject();
882 
883  // Delete board structs and undo/redo lists, to avoid crash on exit
884  // when deleting some structs (mainly in undo/redo lists) too late
885  Clear_Pcb( false, true );
886 
887  // do not show the window because ScreenPcb will be deleted and we do not
888  // want any paint event
889  Show( false );
890 
892 }
893 
894 
896 {
898  GetCanvas()->UpdateColors();
899  GetCanvas()->Refresh();
900 }
901 
902 
903 void PCB_EDIT_FRAME::ShowBoardSetupDialog( const wxString& aInitialPage )
904 {
905  // Make sure everything's up-to-date
907 
908  DIALOG_BOARD_SETUP dlg( this );
909 
910  if( !aInitialPage.IsEmpty() )
911  dlg.SetInitialPage( aInitialPage, wxEmptyString );
912 
913  if( dlg.ShowQuasiModal() == wxID_OK )
914  {
916 
918  SaveProjectSettings();
919 
920  Kiway().CommonSettingsChanged( false, true );
921 
922  const PCB_DISPLAY_OPTIONS& opts = GetDisplayOptions();
923 
925  {
926  // Update clearance outlines
927  GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
928  [&]( KIGFX::VIEW_ITEM* aItem ) -> bool
929  {
930  PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( aItem );
931  PAD* pad = dynamic_cast<PAD*>( aItem );
932 
933  // PCB_TRACK is the base class of PCB_VIA and PCB_ARC so we don't need
934  // to check them independently
935 
936  return ( track && opts.m_ShowTrackClearanceMode )
937  || ( pad && opts.m_DisplayPadClearance );
938  } );
939  }
940 
941  GetCanvas()->Refresh();
942 
944  ReCreateAuxiliaryToolbar();
945  m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
946 
947  //this event causes the routing tool to reload its design rules information
949  toolEvent.SetHasPosition( false );
950  m_toolManager->ProcessEvent( toolEvent );
951  }
952 
953  GetCanvas()->SetFocus();
954 }
955 
956 
958 {
960 
961  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
962  wxASSERT( cfg );
963 
964  if( cfg )
965  {
966  m_rotationAngle = cfg->m_RotationAngle;
967  m_show_layer_manager_tools = cfg->m_AuiPanels.show_layer_manager;
968  m_showPageLimits = cfg->m_ShowPageLimits;
969  }
970 }
971 
972 
974 {
976 
977  auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
978  wxASSERT( cfg );
979 
980  if( cfg )
981  {
982  cfg->m_RotationAngle = m_rotationAngle;
983  cfg->m_AuiPanels.show_layer_manager = m_show_layer_manager_tools;
984  cfg->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
985  cfg->m_AuiPanels.appearance_panel_tab = m_appearancePanel->GetTabIndex();
986  cfg->m_ShowPageLimits = m_showPageLimits;
987  }
988 
989  GetSettingsManager()->SaveColorSettings( GetColorSettings(), "board" );
990 }
991 
992 
994 {
995  return GetColorSettings()->GetColor( LAYER_GRID );
996 }
997 
998 
1000 {
1001 
1002  GetColorSettings()->SetColor( LAYER_GRID, aColor );
1003  GetCanvas()->GetGAL()->SetGridColor( aColor );
1004 }
1005 
1006 
1008 {
1009  PCB_LAYER_ID oldLayer = GetActiveLayer();
1010 
1011  if( oldLayer == aLayer )
1012  return;
1013 
1015 
1016  m_appearancePanel->OnLayerChanged();
1017 
1018  m_toolManager->RunAction( PCB_ACTIONS::layerChanged ); // notify other tools
1019  GetCanvas()->SetFocus(); // allow capture of hotkeys
1020  GetCanvas()->SetHighContrastLayer( aLayer );
1021 
1022  GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
1023  [&]( KIGFX::VIEW_ITEM* aItem ) -> bool
1024  {
1025  if( PCB_VIA* via = dynamic_cast<PCB_VIA*>( aItem ) )
1026  {
1027  // Vias on a restricted layer set must be redrawn when the active layer
1028  // is changed
1029  return ( via->GetViaType() == VIATYPE::BLIND_BURIED ||
1030  via->GetViaType() == VIATYPE::MICROVIA );
1031  }
1032  else if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
1033  {
1034  // Clearances could be layer-dependent so redraw them when the active layer
1035  // is changed
1036  if( GetDisplayOptions().m_DisplayPadClearance )
1037  {
1038  // Round-corner rects are expensive to draw, but are mostly found on
1039  // SMD pads which only need redrawing on an active-to-not-active
1040  // switch.
1041  if( pad->GetAttribute() == PAD_ATTRIB::SMD )
1042  {
1043  if( ( oldLayer == F_Cu || aLayer == F_Cu ) && pad->IsOnLayer( F_Cu ) )
1044  return true;
1045 
1046  if( ( oldLayer == B_Cu || aLayer == B_Cu ) && pad->IsOnLayer( B_Cu ) )
1047  return true;
1048  }
1049 
1050  return true;
1051  }
1052  }
1053  else if( PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( aItem ) )
1054  {
1055  // Clearances could be layer-dependent so redraw them when the active layer
1056  // is changed
1057  if( GetDisplayOptions().m_ShowTrackClearanceMode )
1058  {
1059  // Tracks aren't particularly expensive to draw, but it's an easy check.
1060  return track->IsOnLayer( oldLayer ) || track->IsOnLayer( aLayer );
1061  }
1062  }
1063 
1064  return false;
1065  } );
1066 
1067  GetCanvas()->Refresh();
1068 }
1069 
1070 
1072 {
1073  DRC_TOOL* drcTool = m_toolManager->GetTool<DRC_TOOL>();
1074 
1075  try
1076  {
1077  drcTool->GetDRCEngine()->InitEngine( GetDesignRulesPath() );
1078  }
1079  catch( PARSE_ERROR& )
1080  {
1081  // Not sure this is the best place to tell the user their rules are buggy, so
1082  // we'll stay quiet for now. Feel free to revisit this decision....
1083  }
1084 
1085  UpdateTitle();
1086 
1087  wxFileName fn = GetBoard()->GetFileName();
1088 
1089  // Display a warning that the file is read only
1090  if( fn.FileExists() && !fn.IsFileWritable() )
1091  {
1092  m_infoBar->RemoveAllButtons();
1093  m_infoBar->AddCloseButton();
1094  m_infoBar->ShowMessage( _( "Board file is read only." ), wxICON_WARNING );
1095  }
1096 
1097  ReCreateLayerBox();
1098 
1099  // Sync layer and item visibility
1100  GetCanvas()->SyncLayersVisibility( m_pcb );
1101 
1102  SetElementVisibility( LAYER_RATSNEST, GetDisplayOptions().m_ShowGlobalRatsnest );
1103 
1104  m_appearancePanel->OnBoardChanged();
1105 
1106  // Apply saved display state to the appearance panel after it has been set up
1107  PROJECT_LOCAL_SETTINGS& localSettings = Prj().GetLocalSettings();
1108 
1109  m_appearancePanel->ApplyLayerPreset( localSettings.m_ActiveLayerPreset );
1110 
1111  if( GetBoard()->GetDesignSettings().IsLayerEnabled( localSettings.m_ActiveLayer ) )
1112  SetActiveLayer( localSettings.m_ActiveLayer );
1113 
1114  // Updates any auto dimensions and the auxiliary toolbar tracks/via sizes
1115  unitsChangeRefresh();
1116 
1117  // Display the loaded board:
1118  Zoom_Automatique( false );
1119 
1120  // Invalidate painting as loading the DRC engine will cause clearances to become valid
1121  GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
1122 
1123  Refresh();
1124 
1125  SetMsgPanel( GetBoard() );
1126  SetStatusText( wxEmptyString );
1127 
1128  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "PCB file changes are unsaved" ) );
1129 }
1130 
1131 
1133 {
1134  m_appearancePanel->UpdateDisplayOptions();
1135 }
1136 
1137 
1139 {
1140  return GetBoard()->IsElementVisible( aElement );
1141 }
1142 
1143 
1144 void PCB_EDIT_FRAME::SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState )
1145 {
1146  // Force the RATSNEST visible
1147  if( aElement == LAYER_RATSNEST )
1148  GetCanvas()->GetView()->SetLayerVisible( aElement, true );
1149  else
1150  GetCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
1151 
1152  GetBoard()->SetElementVisibility( aElement, aNewState );
1153 }
1154 
1155 
1157 {
1158  // call my base class
1160 
1161  wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_appearancePanel );
1162  pane_info.Caption( _( "Appearance" ) );
1163  m_auimgr.Update();
1164 
1165  m_appearancePanel->OnBoardChanged();
1166 }
1167 
1168 
1170 {
1172 
1173  if( project.m_PcbLastPath[ aType ].IsEmpty() )
1174  return wxEmptyString;
1175 
1176  wxFileName absoluteFileName = project.m_PcbLastPath[ aType ];
1177  wxFileName pcbFileName = GetBoard()->GetFileName();
1178 
1179  absoluteFileName.MakeAbsolute( pcbFileName.GetPath() );
1180  return absoluteFileName.GetFullPath();
1181 }
1182 
1183 
1184 void PCB_EDIT_FRAME::SetLastPath( LAST_PATH_TYPE aType, const wxString& aLastPath )
1185 {
1187 
1188  wxFileName relativeFileName = aLastPath;
1189  wxFileName pcbFileName = GetBoard()->GetFileName();
1190 
1191  relativeFileName.MakeRelativeTo( pcbFileName.GetPath() );
1192 
1193  if( relativeFileName.GetFullPath() != project.m_PcbLastPath[ aType ] )
1194  {
1195  project.m_PcbLastPath[ aType ] = relativeFileName.GetFullPath();
1196  SaveProjectSettings();
1197  }
1198 }
1199 
1200 
1202 {
1204 
1205  Update3DView( true, GetDisplayOptions().m_Live3DRefresh );
1206 
1207  if( !GetTitle().StartsWith( "*" ) )
1208  UpdateTitle();
1209 
1210  m_ZoneFillsDirty = true;
1211 }
1212 
1213 
1215 {
1216  Update3DView( true, true );
1217 }
1218 
1219 
1220 void PCB_EDIT_FRAME::ExportSVG( wxCommandEvent& event )
1221 {
1222  InvokeExportSVG( this, GetBoard() );
1223 }
1224 
1225 
1227 {
1228  wxFileName fn = GetBoard()->GetFileName();
1229  bool readOnly = false;
1230  bool unsaved = false;
1231 
1232  if( fn.IsOk() && fn.FileExists() )
1233  readOnly = !fn.IsFileWritable();
1234  else
1235  unsaved = true;
1236 
1237  wxString title;
1238 
1239  if( IsContentModified() )
1240  title = wxT( "*" );
1241 
1242  title += fn.GetName();
1243 
1244  if( readOnly )
1245  title += wxS( " " ) + _( "[Read Only]" );
1246 
1247  if( unsaved )
1248  title += wxS( " " ) + _( "[Unsaved]" );
1249 
1250  title += wxT( " \u2014 " ) + _( "PCB Editor" );
1251 
1252  SetTitle( title );
1253 }
1254 
1255 
1257 {
1258  // Update the layer manager and other widgets from the board setup
1259  // (layer and items visibility, colors ...)
1260 
1261  // Rebuild list of nets (full ratsnest rebuild)
1263  Compile_Ratsnest( true );
1264 
1265  // Update info shown by the horizontal toolbars
1266  ReCreateLayerBox();
1267 
1268  LSET activeLayers = GetBoard()->GetEnabledLayers();
1269 
1270  if( !activeLayers.test( GetActiveLayer() ) )
1271  SetActiveLayer( activeLayers.Seq().front() );
1272 
1273  m_SelLayerBox->SetLayerSelection( GetActiveLayer() );
1274 
1276 
1277  layerEnum.Choices().Clear();
1278  layerEnum.Undefined( UNDEFINED_LAYER );
1279 
1280  for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
1281  {
1282  // Canonical name
1283  layerEnum.Map( *seq, LSET::Name( *seq ) );
1284 
1285  // User name
1286  layerEnum.Map( *seq, GetBoard()->GetLayerName( *seq ) );
1287  }
1288 
1289  // Sync visibility with canvas
1290  KIGFX::VIEW* view = GetCanvas()->GetView();
1291  LSET visible = GetBoard()->GetVisibleLayers();
1292 
1293  for( PCB_LAYER_ID layer : LSET::AllLayersMask().Seq() )
1294  view->SetLayerVisible( layer, visible.Contains( layer ) );
1295 
1296  // Stackup and/or color theme may have changed
1297  m_appearancePanel->OnBoardChanged();
1298 }
1299 
1300 
1302 {
1303  // switches currently used canvas (Cairo / OpenGL).
1304  PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
1305 }
1306 
1307 
1309 {
1310  PCB_PLOT_PARAMS plotSettings = GetPlotSettings();
1311 
1312  switch( aID )
1313  {
1314  case ID_GEN_PLOT_GERBER:
1315  plotSettings.SetFormat( PLOT_FORMAT::GERBER );
1316  break;
1317  case ID_GEN_PLOT_DXF:
1318  plotSettings.SetFormat( PLOT_FORMAT::DXF );
1319  break;
1320  case ID_GEN_PLOT_HPGL:
1321  plotSettings.SetFormat( PLOT_FORMAT::HPGL );
1322  break;
1323  case ID_GEN_PLOT_PDF:
1324  plotSettings.SetFormat( PLOT_FORMAT::PDF );
1325  break;
1326  case ID_GEN_PLOT_PS:
1327  plotSettings.SetFormat( PLOT_FORMAT::POST );
1328  break;
1329  case ID_GEN_PLOT: /* keep the previous setup */ break;
1330  default:
1331  wxFAIL_MSG( "ToPlotter(): unexpected plot type" ); break;
1332  break;
1333  }
1334 
1335  SetPlotSettings( plotSettings );
1336 
1337  // Force rebuild the dialog if currently open because the old dialog can be not up to date
1338  // if the board (or units) has changed
1339  wxWindow* dlg = wxWindow::FindWindowByName( DLG_WINDOW_NAME );
1340 
1341  if( dlg )
1342  dlg->Destroy();
1343 
1344  dlg = new DIALOG_PLOT( this );
1345  dlg->Show( true );
1346 }
1347 
1348 
1350 {
1351  if( Kiface().IsSingle() )
1352  return false;
1353 
1354  // Update PCB requires a netlist. Therefore the schematic editor must be running
1355  // If this is not the case, open the schematic editor
1356  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
1357 
1358  if( !frame->IsShown() )
1359  {
1360  wxFileName fn( Prj().GetProjectPath(), Prj().GetProjectName(),
1362 
1363  // Maybe the file hasn't been converted to the new s-expression file format so
1364  // see if the legacy schematic file is still in play.
1365  if( !fn.FileExists() )
1366  {
1367  fn.SetExt( LegacySchematicFileExtension );
1368 
1369  if( !fn.FileExists() )
1370  {
1371  DisplayError( this, _( "The schematic for this board cannot be found." ) );
1372  return false;
1373  }
1374  }
1375 
1376  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1377 
1378  // we show the schematic editor frame, because do not show is seen as
1379  // a not yet opened schematic by Kicad manager, which is not the case
1380  frame->Show( true );
1381 
1382  // bring ourselves back to the front
1383  Raise();
1384  }
1385 
1386  return true; //Success!
1387 }
1388 
1389 
1391  const wxString& aAnnotateMessage )
1392 {
1393  if( !TestStandalone() )
1394  {
1395  DisplayErrorMessage( this, _( "Cannot update the PCB because PCB editor is opened in "
1396  "stand-alone mode. In order to create or update PCBs from "
1397  "schematics, you must launch the KiCad project manager and "
1398  "create a project." ) );
1399  return false; // Not in standalone mode
1400  }
1401 
1402  Raise(); // Show
1403 
1404  std::string payload( aAnnotateMessage );
1405 
1406  Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_GET_NETLIST, payload, this );
1407 
1408  if( payload == aAnnotateMessage )
1409  {
1410  Raise();
1411  DisplayErrorMessage( this, aAnnotateMessage );
1412  return false;
1413  }
1414 
1415  try
1416  {
1417  auto lineReader = new STRING_LINE_READER( payload, _( "Eeschema netlist" ) );
1418  KICAD_NETLIST_READER netlistReader( lineReader, &aNetlist );
1419  netlistReader.LoadNetlist();
1420  }
1421  catch( const IO_ERROR& )
1422  {
1423  Raise();
1424  assert( false ); // should never happen
1425  return false;
1426  }
1427 
1428  return true;
1429 }
1430 
1431 
1433 {
1434  wxString msg;
1435  wxFileName schematic( Prj().GetProjectPath(), Prj().GetProjectName(),
1437 
1438  if( !schematic.FileExists() )
1439  {
1440  wxFileName legacySchematic( Prj().GetProjectPath(), Prj().GetProjectName(),
1442 
1443  if( legacySchematic.FileExists() )
1444  {
1445  schematic = legacySchematic;
1446  }
1447  else
1448  {
1449  msg.Printf( _( "Schematic file '%s' not found." ), schematic.GetFullPath() );
1450  wxMessageBox( msg, _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
1451  return;
1452  }
1453  }
1454 
1455  if( Kiface().IsSingle() )
1456  {
1457  wxString filename = wxT( "\"" ) + schematic.GetFullPath( wxPATH_NATIVE ) + wxT( "\"" );
1458  ExecuteFile( this, EESCHEMA_EXE, filename );
1459  }
1460  else
1461  {
1462  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, false );
1463 
1464  // Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls
1465  // Kiway.Player( FRAME_SCH, true )
1466  // therefore, the schematic editor is sometimes running, but the schematic project
1467  // is not loaded, if the library editor was called, and the dialog field editor was used.
1468  // On Linux, it happens the first time the schematic editor is launched, if
1469  // library editor was running, and the dialog field editor was open
1470  // On Windows, it happens always after the library editor was called,
1471  // and the dialog field editor was used
1472  if( !frame )
1473  {
1474  try
1475  {
1476  frame = Kiway().Player( FRAME_SCH, true );
1477  }
1478  catch( const IO_ERROR& err )
1479  {
1480  wxMessageBox( _( "Eeschema failed to load." ) + wxS( "\n" ) + err.What(),
1481  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
1482  return;
1483  }
1484  }
1485 
1486  if( !frame->IsShown() ) // the frame exists, (created by the dialog field editor)
1487  // but no project loaded.
1488  {
1489  frame->OpenProjectFiles( std::vector<wxString>( 1, schematic.GetFullPath() ) );
1490  frame->Show( true );
1491  }
1492 
1493  // On Windows, Raise() does not bring the window on screen, when iconized or not shown
1494  // On Linux, Raise() brings the window on screen, but this code works fine
1495  if( frame->IsIconized() )
1496  {
1497  frame->Iconize( false );
1498  // If an iconized frame was created by Pcbnew, Iconize( false ) is not enough
1499  // to show the frame at its normal size: Maximize should be called.
1500  frame->Maximize( false );
1501  }
1502 
1503  frame->Raise();
1504  }
1505 }
1506 
1507 
1509 {
1510  const ENV_VAR_MAP& vars = Pgm().GetLocalEnvVariables();
1511 
1512  // Set the environment variables for python scripts
1513  // note: the string will be encoded UTF8 for python env
1514  for( auto& var : vars )
1515  UpdatePythonEnvVar( var.first, var.second.GetValue() );
1516 
1517  // Because the env vars can be modified by the python scripts (rewritten in UTF8),
1518  // regenerate them (in Unicode) for our normal environment
1519  for( auto& var : vars )
1520  wxSetEnv( var.first, var.second.GetValue() );
1521 }
1522 
1523 
1525 {
1526  wxString evValue;
1527  wxGetEnv( PROJECT_VAR_NAME, &evValue );
1528  UpdatePythonEnvVar( wxString( PROJECT_VAR_NAME ).ToStdString(), evValue );
1529 
1530  // Because PROJECT_VAR_NAME can be modified by the python scripts (rewritten in UTF8),
1531  // regenerate it (in Unicode) for our normal environment
1532  wxSetEnv( PROJECT_VAR_NAME, evValue );
1533 }
1534 
1535 
1537 {
1538  if( aFootprint == nullptr )
1539  return;
1540 
1541  DIALOG_FOOTPRINT_PROPERTIES dlg( this, aFootprint );
1542 
1543  // We use quasi modal to allow displaying help dialogs.
1544  dlg.ShowQuasiModal();
1546  /*
1547  * retvalue =
1548  * FP_PROPS_UPDATE_FP to show Update Footprints dialog
1549  * FP_PROPS_CHANGE_FP to show Change Footprints dialog
1550  * FP_PROPS_OK for normal edit
1551  * FP_PROPS_CANCEL if aborted
1552  * FP_PROPS_EDIT_BOARD_FP to load board footprint into Footprint Editor
1553  * FP_PROPS_EDIT_LIBRARY_FP to load library footprint into Footprint Editor
1554  */
1555 
1557  {
1558  // If something edited, push a refresh request
1559  GetCanvas()->Refresh();
1560  }
1562  {
1564 
1565  editor->LoadFootprintFromBoard( aFootprint );
1566 
1567  editor->Show( true );
1568  editor->Raise(); // Iconize( false );
1569  }
1570 
1572  {
1574 
1575  editor->LoadFootprintFromLibrary( aFootprint->GetFPID() );
1576 
1577  editor->Show( true );
1578  editor->Raise(); // Iconize( false );
1579  }
1580 
1582  {
1583  ShowExchangeFootprintsDialog( aFootprint, true, true );
1584  }
1585 
1587  {
1588  ShowExchangeFootprintsDialog( aFootprint, false, true );
1589  }
1590 }
1591 
1592 
1593 int PCB_EDIT_FRAME::ShowExchangeFootprintsDialog( FOOTPRINT* aFootprint, bool aUpdateMode,
1594  bool aSelectedMode )
1595 {
1596  DIALOG_EXCHANGE_FOOTPRINTS dialog( this, aFootprint, aUpdateMode, aSelectedMode );
1597 
1598  return dialog.ShowQuasiModal();
1599 }
1600 
1601 
1602 void PCB_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1603 {
1604  PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1605 
1606  GetAppearancePanel()->OnColorThemeChanged();
1607 
1608  // Netclass definitions could have changed, either by us or by Eeschema
1609  DRC_TOOL* drcTool = m_toolManager->GetTool<DRC_TOOL>();
1610  WX_INFOBAR* infobar = GetInfoBar();
1611 
1612  try
1613  {
1614  drcTool->GetDRCEngine()->InitEngine( GetDesignRulesPath() );
1615  infobar->Hide();
1616  }
1617  catch( PARSE_ERROR& )
1618  {
1619  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Edit design rules" ),
1620  wxEmptyString );
1621 
1622  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
1623  [&]( wxHyperlinkEvent& aEvent )
1624  {
1625  ShowBoardSetupDialog( _( "Custom Rules" ) );
1626  } ) );
1627 
1628  infobar->RemoveAllButtons();
1629  infobar->AddButton( button );
1630  infobar->AddCloseButton();
1631  infobar->ShowMessage( _( "Could not compile custom design rules." ), wxICON_ERROR );
1632  }
1633 
1634  // Update the environment variables in the Python interpreter
1635  if( aEnvVarsChanged )
1636  PythonSyncEnvironmentVariables();
1637 
1638  Layout();
1639  SendSizeEvent();
1640 }
1641 
1642 
1644 {
1646 }
1647 
1648 
1650 {
1651  PythonSyncProjectName();
1652 }
1653 
1654 
1655 bool ExportBoardToHyperlynx( BOARD* aBoard, const wxFileName& aPath );
1656 
1657 
1658 void PCB_EDIT_FRAME::OnExportHyperlynx( wxCommandEvent& event )
1659 {
1660  wxString wildcard = wxT( "*.hyp" );
1661  wxFileName fn = GetBoard()->GetFileName();
1662 
1663  fn.SetExt( wxT("hyp") );
1664 
1665  wxFileDialog dlg( this, _( "Export Hyperlynx Layout" ), fn.GetPath(), fn.GetFullName(),
1666  wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1667 
1668  if( dlg.ShowModal() != wxID_OK )
1669  return;
1670 
1671  fn = dlg.GetPath();
1672 
1673  // always enforce filename extension, user may not have entered it.
1674  fn.SetExt( wxT( "hyp" ) );
1675 
1677 }
1678 
1679 
1681 {
1682  return GetBoard()->GetFileName();
1683 }
1684 
1685 
1687 {
1688  return m_auimgr.GetPane( "LayersManager" ).IsShown();
1689 }
1690 
1691 
1692 void PCB_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
1693 {
1694  if( IsShown() )
1695  {
1696  // We only need this until the frame is done resizing and the final client size is
1697  // established.
1698  Unbind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this );
1699  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
1700  }
1701 
1702  // Skip() is called in the base class.
1703  EDA_DRAW_FRAME::OnSize( aEvent );
1704 }
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:247
void UpdateTitle()
Set the main window title bar text.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
The interactive edit tool.
static TOOL_ACTION drawLine
Definition: pcb_actions.h:142
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Open a project or set of files given by aFileList.
Definition: kiway_player.h:118
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:149
void BuildListOfNets()
Definition: board.h:663
void OnModify() override
Must be called after a board change to set the modified flag.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:207
#define CURRENT_EDIT_TOOL(action)
void SetPageSettings(const PAGE_INFO &aPageSettings) override
void RecreateCmpFileFromBoard(wxCommandEvent &aEvent)
Recreates a .cmp file from the current loaded board.
KiCad executable names.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:64
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
const PAGE_INFO & GetPageSettings() const
Definition: board.h:535
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Change the visibility of an element category.
void OnExportIDF3(wxCommandEvent &event)
Export the current BOARD to a IDFv3 board and lib files.
void OnKiCadExit()
Definition: kiway.cpp:625
static TOOL_ACTION unlock
Definition: pcb_actions.h:425
PNS::PNS_MODE GetRouterMode()
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:537
static const KICAD_T Tracks[]
A scan list for only TRACKs.
Definition: collectors.h:298
void ActivateGalCanvas() override
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
void OnExportHyperlynx(wxCommandEvent &event)
Export the current BOARD to a Hyperlynx HYP file.
Read the new s-expression based KiCad netlist format.
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
bool IsContentModified() const override
Get if the current board has been modified but not saved.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:260
This file is part of the common library TODO brief description.
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Model changes (required full reload)
Definition: tool_base.h:80
static TOOL_ACTION drawSimilarZone
Definition: pcb_actions.h:156
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:438
SELECTION_CONDITION HasItems()
Create a functor that tests if there are items in the board.
static TOOL_ACTION lock
Definition: pcb_actions.h:424
This file is part of the common library.
static TOOL_ACTION doDelete
Definition: actions.h:72
void HardRedraw() override
Rebuild the GAL and redraws the screen.
static TOOL_ACTION drawArc
Definition: pcb_actions.h:146
SELECTION_CONDITION TrackFillDisplay()
Create a functor that tests if the frame fills tracks.
void ToPlotter(int aID)
Open a dialog frame to create plot and drill files relative to the current board.
static TOOL_ACTION hideNet
Definition: pcb_actions.h:456
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
Definition: id.h:87
static SELECTION_CONDITION MoreThan(int aNumber)
Create a functor that tests if the number of selected items is greater than the value given as parame...
static TOOL_ACTION microwaveCreateStubArc
Definition: pcb_actions.h:416
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
Definition: commit.h:78
void SetInitialPage(const wxString &aPage, const wxString &aParentPage=wxEmptyString)
void doCloseWindow() override
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:242
static TOOL_ACTION zoomTool
Definition: actions.h:99
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)
Test if there no items selected or being edited.
ENUM_MAP & Undefined(T aValue)
Definition: property.h:523
PROJECT & Prj()
Definition: kicad.cpp:403
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Create 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.
Control for copper zone opacity/visibility (color ignored)
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:145
void ActivateGalCanvas() override
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
Tool responsible for adding microwave features to PCBs.
void OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
void OnExportSTEP(wxCommandEvent &event)
Export the current BOARD to a STEP assembly.
void ResolveDRCExclusions()
Update markers to match recorded exclusions.
static TOOL_ACTION toggleLine45degMode
Toggle 45 degree line drawing mode.
Definition: pcb_actions.h:167
static TOOL_ACTION selectNet
Select all connections belonging to a single net.
Definition: pcb_actions.h:77
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
void SetFileName(const std::string &aFileName)
Set the file name displayed in the title block.
Smd pad, appears on the solder paste layer (default)
static TOOL_ACTION routerTuneDiffPair
Activation of the Push and Shove router (diff pair tuning mode)
Definition: pcb_actions.h:190
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:148
static constexpr GAL_TYPE GAL_FALLBACK
Tool relating to pads and pad settings.
Definition: pad_tool.h:35
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:150
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
static TOOL_ACTION millimetersUnits
Definition: actions.h:146
static ENUM_MAP< T > & Instance()
Definition: property.h:510
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:72
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:479
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:143
#define ENABLE(x)
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
Definition: pcb_actions.h:203
static TOOL_ACTION microwaveCreateLine
Definition: pcb_actions.h:420
BOARD_NETLIST_UPDATER class definition.
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
NET_SETTINGS & NetSettings()
Definition: project_file.h:94
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:350
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:382
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:476
void ExportToGenCAD(wxCommandEvent &event)
Create a file in GenCAD 1.4 format from the current board.
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:349
static TOOL_ACTION group
Definition: pcb_actions.h:428
void SetSheetCount(int aSheetCount)
Changes the sheet-count number displayed in the title block.
SELECTION_CONDITION RedoAvailable()
Create 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.
Definition: board.cpp:465
bool FetchNetlistFromSchematic(NETLIST &aNetlist, const wxString &aAnnotateMessage)
PCB_LAYER_ID m_ActiveLayer
The current (active) board layer for editing.
SELECTION_CONDITION Line45degMode()
Create a functor that tests whether only 45 degree graphic lines should be drawn.
Manage TOOL_ACTION objects.
static TOOL_ACTION ungroup
Definition: pcb_actions.h:429
wxPGChoices & Choices()
Definition: property.h:559
static TOOL_ACTION localRatsnestTool
Definition: pcb_actions.h:460
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:81
static SELECTION_CONDITION Count(int aNumber)
Create 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.
All except INITIAL_ADD.
Definition: view_item.h:58
static TOOL_ACTION zoneDisplayFilled
Definition: pcb_actions.h:246
int ShowExchangeFootprintsDialog(FOOTPRINT *aFootprint, bool aUpdateMode, bool aSelectedMode)
Tool relating to pads and pad settings.
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:106
const wxString & GetFileName() const
Definition: board.h:228
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
void SetSheetName(const std::string &aSheetName)
Set the sheet name displayed in the title block.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:588
static SELECTION_CONDITION SameLayer()
Creates a functor that tests if selection contains items that belong exclusively to the same layer.
static TOOL_ACTION placeText
Definition: pcb_actions.h:147
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:64
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:306
SELECTION_CONDITION PadFillDisplay()
Create 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.
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition: project.h:151
static TOOL_ACTION routerTuneDiffPairSkew
Activation of the Push and Shove router (skew tuning mode)
Definition: pcb_actions.h:193
static TOOL_ACTION toggleNetHighlight
Definition: pcb_actions.h:453
const wxString & GetPageNumber() const
Definition: base_screen.cpp:71
void ShowFootprintPropertiesDialog(FOOTPRINT *aFootprint)
bool isAutoSaveRequired() const override
Return 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:83
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
void SetGridColor(const COLOR4D &aColor) override
Master controller class:
Definition: tool_manager.h:54
void SynchronizeNetsAndNetClasses()
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1409
void OnClearFileHistory(wxCommandEvent &aEvent)
static TOOL_ACTION measureTool
Definition: actions.h:154
static TOOL_ACTION copy
Definition: actions.h:67
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
Load the contents of the netlist file into aNetlist.
static TOOL_ACTION zoneDisplayFractured
Definition: pcb_actions.h:248
Container for display options like enable/disable some optional drawings.
PCB_LAYER_ID
A quick note on layer IDs:
void Tracks_and_Vias_Size_Event(wxCommandEvent &event)
Handle actions specific to filling copper zones.
bool ExportBoardToHyperlynx(BOARD *aBoard, const wxFileName &aPath)
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:101
Item needs to be redrawn.
Definition: view_item.h:57
const wxString EESCHEMA_EXE
LSET is a set of PCB_LAYER_IDs.
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString)
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
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition: pcb_netlist.h:206
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
bool IsSingle() const
Is this KIFACE_I running under single_top?
Definition: kiface_i.h:104
BOARD_ITEM_CONTAINER * GetModel() const override
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
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)
Create a functor that tests if the frame has the specified units.
void RemoveListener(BOARD_LISTENER *aListener)
Remove the specified listener.
Definition: board.cpp:1996
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
Tool responsible for drawing graphical elements like lines, arcs, circles, etc.
Definition: drawing_tool.h:50
static TOOL_ACTION toggleGrid
Definition: actions.h:140
Handle actions that are shared between different frames in PcbNew.
Definition: pcb_control.h:46
void onBoardLoaded()
Update the state of the GUI after a new board is loaded or created.
GAL_SET GetVisibleElements() const
Return a set of all the element categories that are visible.
Definition: board.cpp:525
virtual void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
int ShowQuasiModal()
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
static TOOL_ACTION inchesUnits
Definition: actions.h:144
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:40
void ResolveNetClassAssignments(bool aRebuildFromScratch=false)
Explode the list of netclass assignments to include atomic members of composite labels (buses).
static TOOL_ACTION save
Definition: actions.h:51
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Generic, UI-independent tool event.
Definition: tool_event.h:152
Inactive layers are shown normally (no high-contrast mode)
void ExportSVG(wxCommandEvent &event)
Show the Export to SVG file dialog.
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:310
SELECTION_CONDITION ScriptingConsoleVisible()
Create a functor testing if the python scripting console window is visible.
static TOOL_ACTION togglePolarCoords
Definition: actions.h:149
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:344
virtual ~PCB_EDIT_FRAME()
void OnSockRequest(wxSocketEvent &evt)
Definition: eda_dde.cpp:63
static TOOL_ACTION cut
Definition: actions.h:66
Handle actions specific to the board editor in PcbNew.
Definition of file extensions used in Kicad.
static const KICAD_T Zones[]
A scan list for zones outlines only.
Definition: collectors.h:272
void OnUpdateSelectAutoWidth(wxUpdateUIEvent &aEvent)
#define DIALOG_DRC_WINDOW_NAME
Definition: dialog_drc.h:41
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:241
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
COLOR4D GetGridColor() override
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:144
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
#define _(s)
static TOOL_ACTION microwaveCreateGap
Definition: pcb_actions.h:412
wxLogTrace helper definitions.
static LSET AllLayersMask()
Definition: lset.cpp:787
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:387
static TOOL_ACTION drawVia
Definition: pcb_actions.h:153
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:72
const LIB_ID & GetFPID() const
Definition: footprint.h:185
#define KICAD_DEFAULT_DRAWFRAME_STYLE
std::function< bool(const SELECTION &)> SELECTION_CONDITION
< Functor type that checks a specific condition for selected items.
void BuildConnectivity()
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition: board.cpp:136
void OnQuit(wxCommandEvent &event)
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
void PythonSyncEnvironmentVariables()
Synchronize the environment variables from KiCad's environment into the Python interpreter.
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
static TOOL_ACTION zoneDisplayTriangulated
Definition: pcb_actions.h:249
void SetFormat(PLOT_FORMAT aFormat)
std::shared_ptr< DRC_ENGINE > GetDRCEngine()
Definition: drc_tool.h:89
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
Parameters and options when plotting/printing a board.
static TOOL_ACTION drawZoneCutout
Definition: pcb_actions.h:155
Handle actions that are shared between different applications.
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:205
LAST_PATH_TYPE
For storing PcbNew MRU paths of various types.
Definition: project_file.h:46
The interactive edit tool.
Definition: edit_tool.h:64
static TOOL_ACTION placeTarget
Definition: pcb_actions.h:158
SELECTION_CONDITION ZoneDisplayMode(ZONE_DISPLAY_MODE aMode)
Create 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()
Create 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:145
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:320
Handles action that are shared between different applications.
Definition: common_tools.h:37
void ClearProject()
Definition: board.cpp:172
bool IsDRCRunning() const
Check to see if the DRC engine is running the tests.
Definition: drc_tool.h:82
Generic tool for picking an item.
A dialog to set the plot options and create plot files in various formats.
Definition: dialog_plot.h:39
void OnSockRequestServer(wxSocketEvent &evt)
Definition: eda_dde.cpp:93
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
static TOOL_ACTION zoneDisplayOutline
Definition: pcb_actions.h:247
SELECTION_CONDITION NoActiveTool()
Create a functor testing if there are no tools active in the frame.
static TOOL_ACTION microwaveCreateStub
Definition: pcb_actions.h:414
static TOOL_ACTION zoneUnfill
Definition: pcb_actions.h:308
BOARD * GetBoard()
static TOOL_ACTION pasteSpecial
Definition: actions.h:69
#define CHECK(x)
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:244
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:531
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:102
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:145
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:245
void SetProject(PROJECT *aProject)
Link a board to a given project.
Definition: board.cpp:142
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:313
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:73
static TOOL_ACTION redo
Definition: actions.h:65
virtual void OnModify()
Must be called after a change in order to set the "modify" flag of the current screen and update the ...
static TOOL_ACTION microwaveCreateFunctionShape
Definition: pcb_actions.h:418
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:293
virtual void ThemeChanged()
Process light/dark theme change.
Gather all the actions that are shared by tools.
Definition: pcb_actions.h:48
void OnFileHistory(wxCommandEvent &event)
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:160
static TOOL_ACTION showNet
Definition: pcb_actions.h:457
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:151
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:118
Class PCBNEW_ACTION_PLUGINS.
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:154
Ignore collisions, mark obstacles.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
see class PGM_BASE
Tool that displays edit points allowing to modify items by dragging the points.
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
void SetBoard(BOARD *aBoard) override
Declaration of the eda_3d_viewer class.
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
void PythonSyncProjectName()
Synchronize the project name from KiCad's environment into the Python interpreter.
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:451
#define CURRENT_TOOL(action)
Common, abstract interface for edit frames.
void Process_Special_Functions(wxCommandEvent &event)
Definition: edit.cpp:46
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
Global action (toolbar/main menu event, global shortcut)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set 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)
Call Files_io_from_id with the wxCommandEvent id.
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:181
SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
virtual void SetBoard(BOARD *aBoard) override
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
void OnExportVRML(wxCommandEvent &event)
Export the current BOARD to a VRML file.
void OnUpdateSelectViaSize(wxUpdateUIEvent &aEvent)
Represent a single user action.
Definition: tool_action.h:67
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Create a functor that tests if the selected items are only of given type.
const std::string KiCadSchematicFileExtension
The main frame for Pcbnew.
AUI_PANELS m_AuiPanels
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely saves a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
The selection tool: currently supports:
#define IU_PER_MILS
Definition: plotter.cpp:137
SELECTION_CONDITION ViaFillDisplay()
Create a functor that tests if the frame fills vias.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
Only walk around.
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Revert the commit by restoring the modified items state.
Tool useful for viewing footprints.
static TOOL_ACTION deselectNet
Remove all connections belonging to a single net from the active selection.
Definition: pcb_actions.h:80
bool InvokeExportSVG(PCB_EDIT_FRAME *aCaller, BOARD *aBoard)
Function InvokeExportSVG shows the Export SVG dialog.
virtual void SetPageSettings(const PAGE_INFO &aPageSettings) override
virtual void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
Definition: kiway.cpp:553
Definition: id.h:96
static TOOL_ACTION deleteTool
Definition: actions.h:73
void SetPageNumber(const std::string &aPageNumber)
Changes the page number displayed in the title block.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void onSize(wxSizeEvent &aEvent)
Definition: id.h:86
static SELECTION_CONDITION SameNet(bool aAllowUnconnected=false)
Create a functor that tests if selection contains items belonging to the same net or are unconnected ...
void OnUpdateSelectTrackWidth(wxUpdateUIEvent &aEvent)
static TOOL_ACTION undo
Definition: actions.h:64
#define PCB_EDIT_FRAME_NAME
void OnGridSettings(wxCommandEvent &event)
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:102
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:295
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.
static TOOL_ACTION gridSetOrigin
Definition: actions.h:137
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
bool IsElementVisible(GAL_LAYER_ID aElement) const
Test whether a given element category is visible.
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:516
enum FP_PROPS_RETVALUE GetReturnValue()
Definition: pad.h:57
void ThemeChanged() override
Called when light/dark theme is changed.
std::set< wxString > m_DrcExclusions
void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
Switch currently used canvas (Cairo / OpenGL).
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:240
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)
Call the executable file ExecFile with the command line parameters param.
Definition: gestfich.cpp:165
Group generic conditions for PCB editor states.
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:204
static TOOL_ACTION highContrastMode
Definition: actions.h:103
void OnDisplayOptionsChanged() override
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
static TOOL_ACTION selectAll
Definition: actions.h:70
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Change the currently active layer to aLayer and also update the APPEARANCE_CONTROLS.
static TOOL_ACTION paste
Definition: actions.h:68
static TOOL_ACTION drawZone
Definition: pcb_actions.h:152
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
#define DLG_WINDOW_NAME
static TOOL_ACTION duplicate
Definition: actions.h:71
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:243
static TOOL_ACTION selectionTool
Definition: actions.h:153
void SetHasPosition(bool aHasPosition)
Returns if the action associated with this event should be treated as immediate regardless of the cur...
Definition: tool_event.h:241
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
void SetLastPath(LAST_PATH_TYPE aType, const wxString &aLastPath)
Set the path of the last file successfully read.
Tool responsible for automagic placement of components.
static TOOL_ACTION selectSameSheet
Select all components on the same sheet as the selected footprint.
Definition: pcb_actions.h:86
Container for design settings for a BOARD object.
KIWAY Kiway
Tool for pcb inspection.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
static TOOL_ACTION routerTuneSingleTrace
Activation of the Push and Shove router (tune single line mode)
Definition: pcb_actions.h:187
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:184
bool Contains(GAL_LAYER_ID aPos)