KiCad PCB EDA Suite
footprint_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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2015-2016 Wayne Stambaugh <stambaughw@gmail.com>
7  * Copyright (C) 1992-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 "tools/convert_tool.h"
24 #include "tools/drawing_tool.h"
25 #include "tools/edit_tool.h"
27 #include "tools/pad_tool.h"
28 #include "tools/pcb_actions.h"
29 #include "tools/pcb_control.h"
30 #include "tools/pcb_picker_tool.h"
31 #include "tools/placement_tool.h"
32 #include "tools/pcb_point_editor.h"
36 #include <bitmaps.h>
37 #include <board.h>
38 #include <footprint.h>
39 #include <confirm.h>
44 #include <footprint_edit_frame.h>
46 #include <footprint_info_impl.h>
47 #include <footprint_tree_pane.h>
48 #include <fp_lib_table.h>
50 #include <kiface_i.h>
51 #include <kiplatform/app.h>
52 #include <kiway.h>
53 #include <macros.h>
54 #include <panel_hotkeys_editor.h>
55 #include <pcb_draw_panel_gal.h>
56 #include <pcb_edit_frame.h>
57 #include <pcbnew.h>
58 #include <pcbnew_id.h>
59 #include <pgm_base.h>
60 #include <project.h>
62 #include <tool/action_toolbar.h>
63 #include <tool/common_control.h>
64 #include <tool/common_tools.h>
65 #include <tool/selection.h>
66 #include <tool/tool_dispatcher.h>
67 #include <tool/tool_manager.h>
68 #include <tool/zoom_tool.h>
70 #include <tools/pcb_viewer_tools.h>
71 #include <tools/group_tool.h>
74 #include <widgets/infobar.h>
75 #include <widgets/lib_tree.h>
76 #include <widgets/paged_dialog.h>
80 #include <wx/filedlg.h>
81 #include <wx/treebook.h>
82 
83 
84 BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
85  EVT_MENU( wxID_CLOSE, FOOTPRINT_EDIT_FRAME::CloseFootprintEditor )
86  EVT_MENU( wxID_EXIT, FOOTPRINT_EDIT_FRAME::OnExitKiCad )
87 
89 
92 
94 
97 
98  // Horizontal toolbar
101 
102  // UI update events.
108 END_EVENT_TABLE()
109 
110 
111 FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
112  EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend ) :
113  PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_FOOTPRINT_EDITOR, wxEmptyString,
114  wxDefaultPosition, wxDefaultSize,
115  KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() )
116 {
117  m_showBorderAndTitleBlock = false; // true to show the frame references
118  m_canvasType = aBackend;
119  m_aboutTitle = _( "KiCad Footprint Editor" );
120  m_selLayerBox = nullptr;
121  m_settings = nullptr;
122 
123  // Give an icon
124  wxIcon icon;
125  wxIconBundle icon_bundle;
126 
127  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit ) );
128  icon_bundle.AddIcon( icon );
129  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit_32 ) );
130  icon_bundle.AddIcon( icon );
131  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit_16 ) );
132  icon_bundle.AddIcon( icon );
133 
134  SetIcons( icon_bundle );
135 
136  // Create GAL canvas
137  if( aBackend == EDA_DRAW_PANEL_GAL::GAL_TYPE_UNKNOWN )
138  m_canvasType = loadCanvasTypeSetting();
139  else
140  m_canvasType = aBackend;
141 
142  PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
143  GetGalDisplayOptions(), m_canvasType );
144  SetCanvas( drawPanel );
145  SetBoard( new BOARD() );
146 
147 
148  // This board will only be used to hold a footprint for editing
150 
151  // In Footprint Editor, the default net clearance is not known (it depends on the actual
152  // board). So we do not show the default clearance, by setting it to 0. The footprint or
153  // pad specific clearance will be shown.
155 
156  // Don't show the default board solder mask clearance in the footprint editor. Only the
157  // footprint or pad clearance setting should be shown if it is not 0.
159 
160  // restore the last footprint from the project, if any
161  restoreLastFootprint();
162 
163  // Ensure all layers and items are visible:
164  // In footprint editor, some layers have no meaning or cannot be used, but we show all of
165  // them, at least to be able to edit a bad layer
167 
168  // However the "no net" mark on pads is useless, because there are no nets in footprint
169  // editor: make it non visible.
171 
172  GetGalDisplayOptions().m_axesEnabled = true;
173 
174  // In Footprint Editor, set the default paper size to A4 for plot/print
175  SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) );
176  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
177 
178  // Create the manager and dispatcher & route draw panel events to the dispatcher
179  setupTools();
180  setupUIConditions();
181 
182  initLibraryTree();
183  m_treePane = new FOOTPRINT_TREE_PANE( this );
184 
185  ReCreateMenuBar();
186  ReCreateHToolbar();
187  ReCreateVToolbar();
188  ReCreateOptToolbar();
189 
190  m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
191  m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas(), true );
192 
193  // LoadSettings() *after* creating m_LayersManager, because LoadSettings() initialize
194  // parameters in m_LayersManager
195  // NOTE: KifaceSettings() will return PCBNEW_SETTINGS if we started from pcbnew
196  LoadSettings( GetSettings() );
197 
198  // Must be set after calling LoadSettings() to be sure these parameters are not dependent
199  // on what is read in stored settings. Enable one internal layer, because footprints
200  // support keepout areas that can be on internal layers only (therefore on the first internal
201  // layer). This is needed to handle these keepout in internal layers only.
203  GetBoard()->SetEnabledLayers( GetBoard()->GetEnabledLayers().set( In1_Cu ) );
204  GetBoard()->SetVisibleLayers( GetBoard()->GetEnabledLayers() );
205  GetBoard()->SetLayerName( In1_Cu, _( "Inner layers" ) );
206 
207  SetActiveLayer( F_SilkS );
208 
209  m_auimgr.SetManagedWindow( this );
210 
211  CreateInfoBar();
212 
213  unsigned int auiFlags = wxAUI_MGR_DEFAULT;
214 #if !defined( _WIN32 )
215  // Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds
216  // of graphical glitches
217  auiFlags |= wxAUI_MGR_LIVE_RESIZE;
218 #endif
219  m_auimgr.SetFlags( auiFlags );
220 
221  // Rows; layers 4 - 6
222  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
223  .Top().Layer( 6 ) );
224  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
225  .Bottom().Layer( 6 ) );
226 
227  // Columns; layers 1 - 3
228  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
229  .Left().Layer( 3 ) );
230  m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "Footprints" )
231  .Left().Layer(2)
232  .Caption( _( "Libraries" ) )
233  .MinSize( 250, 400 ).Resizable() );
234 
235  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
236  .Right().Layer(2) );
237 
238  m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( "LayersManager" )
239  .Right().Layer( 3 )
240  .Caption( _( "Appearance" ) ).PaneBorder( false )
241  .MinSize( 180, -1 ).BestSize( 180, -1 ) );
242  m_auimgr.AddPane( m_selectionFilterPanel, EDA_PANE().Palette().Name( "SelectionFilter" )
243  .Right().Layer( 3 ).Position( 2 )
244  .Caption( _( "Selection Filter" ) ).PaneBorder( false )
245  .MinSize( 160, -1 ).BestSize( m_selectionFilterPanel->GetBestSize() ) );
246 
247  // Center
248  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
249  .Center() );
250 
251  // The selection filter doesn't need to grow in the vertical direction when docked
252  m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
253 
254  ActivateGalCanvas();
255 
256  FinishAUIInitialization();
257 
258  if( m_settings->m_LibWidth > 0 )
259  {
260  wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" );
261 
262  // wxAUI hack: force width by setting MinSize() and then Fixed()
263  // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
264  treePane.MinSize( m_settings->m_LibWidth, -1 );
265  treePane.Fixed();
266  m_auimgr.Update();
267 
268  // now make it resizable again
269  treePane.Resizable();
270  m_auimgr.Update();
271 
272  // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
273  // back to minimum.
274  treePane.MinSize( 250, -1 );
275  }
276 
277  // Apply saved visibility stuff at the end
278  FOOTPRINT_EDITOR_SETTINGS* cfg = GetSettings();
279  m_appearancePanel->SetUserLayerPresets( cfg->m_LayerPresets );
280  m_appearancePanel->ApplyLayerPreset( cfg->m_ActiveLayerPreset );
281 
282  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
283  UpdateTitle();
284  setupUnits( GetSettings() );
285 
286  // Default shutdown reason until a file is loaded
287  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Footprint changes are unsaved" ) );
288 
289  // Catch unhandled accelerator command characters that were no handled by the library tree
290  // panel.
291  Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
292  Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
293 
294  // Ensure the window is on top
295  Raise();
296  Show( true );
297 
298  // Register a call to update the toolbar sizes. It can't be done immediately because
299  // it seems to require some sizes calculated that aren't yet (at least on GTK).
300  CallAfter( [&]()
301  {
302  // Ensure the controls on the toolbars all are correctly sized
303  UpdateToolbarControlSizes();
304  } );
305 }
306 
307 
309 {
310  // Shutdown all running tools
311  if( m_toolManager )
313 
314  // save the footprint in the PROJECT
316 
317  delete m_selectionFilterPanel;
318  delete m_appearancePanel;
319 }
320 
321 
323 {
325 }
326 
327 
329 {
330  return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
331 }
332 
333 
335 {
336  // switches currently used canvas (Cairo / OpenGL).
337  PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
338 
339  GetCanvas()->GetGAL()->SetAxesEnabled( true );
340 
341  // The base class method *does not reinit* the layers manager. We must update the layer
342  // widget to match board visibility states, both layers and render columns, and and some
343  // settings dependent on the canvas.
345 }
346 
347 
349 {
350  SyncLibraryTree( true );
351  GetCanvas()->ForceRefresh();
352 }
353 
354 
356 {
357  wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
358  treePane.Show( !IsSearchTreeShown() );
359  m_auimgr.Update();
360 }
361 
362 
364 {
365  return m_auimgr.GetPane( m_treePane ).IsShown();
366 }
367 
368 
370 {
371  return GetBoard()->GetFirstFootprint();
372 }
373 
374 
376 {
378 }
379 
380 
382 {
384 }
385 
386 
388 {
389  LIB_ID id = GetTreeFPID();
390 
391  if( id.GetLibNickname().empty() )
392  return GetLoadedFPID();
393 
394  return id;
395 }
396 
397 
399 {
400  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
401 
402  if( footprint )
403  return LIB_ID( footprint->GetFPID().GetLibNickname(), m_footprintNameWhenLoaded );
404  else
405  return LIB_ID();
406 }
407 
408 
410 {
411  if( GetBoard()->GetFirstFootprint() )
413 
414  GetScreen()->SetContentModified( false );
415 }
416 
417 
419 {
420  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
421 
422  return ( footprint && footprint->GetLink() != niluuid );
423 }
424 
425 
427 {
428  LIB_ID id = GetLoadedFPID();
429 
430  if( id.IsValid() )
431  {
433  Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME, id.GetLibItemName() );
434  }
435 }
436 
437 
439 {
440  const wxString& footprintName = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME );
441  const wxString& libNickname = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_LIB_NICKNAME );
442 
443  if( libNickname.Length() && footprintName.Length() )
444  {
445  LIB_ID id;
446  id.SetLibNickname( libNickname );
447  id.SetLibItemName( footprintName );
448 
449  FOOTPRINT* footprint = loadFootprint( id );
450 
451  if( footprint )
452  AddFootprintToBoard( footprint );
453  }
454 }
455 
456 
458 {
459  m_revertModule.reset( (FOOTPRINT*) aFootprint->Clone() );
460 
462 
464 
465  if( IsCurrentFPFromBoard() )
466  {
467  wxString msg;
468  msg.Printf( _( "Editing %s from board. Saving will update the board only." ),
469  aFootprint->GetReference() );
470 
473  GetInfoBar()->ShowMessage( msg, wxICON_INFORMATION );
474  }
475 
476  UpdateMsgPanel();
477 }
478 
479 
481 {
483 }
484 
485 
487 {
488  return GetBoard()->GetDesignSettings();
489 }
490 
491 
493 {
494  wxFAIL_MSG( "Plotting not supported in Footprint Editor" );
495 
497 }
498 
499 
501 {
502  wxFAIL_MSG( "Plotting not supported in Footprint Editor" );
503 }
504 
505 
507 {
508  if( !m_settings )
509  m_settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
510 
511  return m_settings;
512 }
513 
514 
516 {
517  return m_settings ? m_settings
518  : Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
519 }
520 
521 
523 {
524  // aCfg will be the PCBNEW_SETTINGS
526 
528 
530 
532 
535 }
536 
537 
539 {
541 
542  // aCfg will be the PCBNEW_SETTINGS
544 
546 
549  cfg->m_LibWidth = m_treePane->GetSize().x;
553 
555 }
556 
557 
559 {
560  wxString currentTheme = GetFootprintEditorSettings()->m_ColorTheme;
561  return Pgm().GetSettingsManager().GetColorSettings( currentTheme );
562 }
563 
564 
566 {
567  // Get the actual frame settings for magnetic items
569  wxCHECK( cfg, nullptr );
570  return &cfg->m_MagneticItems;
571 }
572 
573 
574 const BOX2I FOOTPRINT_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
575 {
576  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
577 
578  if( footprint )
579  {
580  bool hasGraphicalItem = footprint->Pads().size() || footprint->Zones().size();
581 
582  if( !hasGraphicalItem )
583  {
584  for( const BOARD_ITEM* item : footprint->GraphicalItems() )
585  {
586  if( item->Type() == PCB_FP_TEXT_T )
587  continue;
588 
589  hasGraphicalItem = true;
590  break;
591  }
592  }
593 
594  if( hasGraphicalItem )
595  {
596  return footprint->GetBoundingBox( false, false );
597  }
598  else
599  {
600  BOX2I newFootprintBB( { 0, 0 }, { 0, 0 } );
601  newFootprintBB.Inflate( Millimeter2iu( 12 ) );
602  return newFootprintBB;
603  }
604  }
605 
606  return GetBoardBoundingBox( false );
607 }
608 
609 
610 bool FOOTPRINT_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
611 {
612  if( IsContentModified() )
613  {
614  // Shutdown blocks must be determined and vetoed as early as possible
616  aEvent.GetId() == wxEVT_QUERY_END_SESSION )
617  {
618  aEvent.Veto();
619  return false;
620  }
621 
622  wxString footprintName = GetBoard()->GetFirstFootprint()->GetFPID().GetLibItemName();
623  wxString msg = _( "Save changes to '%s' before closing?" );
624 
625  if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
626  [&]() -> bool
627  {
628  return SaveFootprint( GetBoard()->GetFirstFootprint() );
629  } ) )
630  {
631  aEvent.Veto();
632  return false;
633  }
634  }
635 
636  return PCB_BASE_EDIT_FRAME::canCloseWindow( aEvent );
637 }
638 
639 
641 {
642  // No more vetos
643  GetCanvas()->SetEventDispatcher( nullptr );
644  GetCanvas()->StopDrawing();
645 
646  // Do not show the layer manager during closing to avoid flicker
647  // on some platforms (Windows) that generate useless redraw of items in
648  // the Layer Manager
649  m_auimgr.GetPane( "LayersManager" ).Show( false );
650  m_auimgr.GetPane( "SelectionFilter" ).Show( false );
651 
652  Clear_Pcb( false );
653 
655 
656  if( mgr->IsProjectOpen() && wxFileName::IsDirWritable( Prj().GetProjectPath() ) )
657  {
658  GFootprintList.WriteCacheToFile( Prj().GetProjectPath() + "fp-info-cache" );
659  }
660 
661  mgr->FlushAndRelease( GetSettings() );
662 }
663 
664 
665 void FOOTPRINT_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
666 {
667  Kiway().OnKiCadExit();
668 }
669 
670 
671 void FOOTPRINT_EDIT_FRAME::CloseFootprintEditor( wxCommandEvent& Event )
672 {
673  Close();
674 }
675 
676 
678 {
680 
681  aEvent.Enable( frame && frame->GetBoard()->GetFirstFootprint() != nullptr );
682 }
683 
684 
686 {
688 
689  FOOTPRINT* editorFootprint = GetBoard()->GetFirstFootprint();
690  bool canInsert = frame && editorFootprint && editorFootprint->GetLink() == niluuid;
691 
692  // If the source was deleted, the footprint can inserted but not updated in the board.
693  if( frame && editorFootprint && editorFootprint->GetLink() != niluuid )
694  {
695  BOARD* mainpcb = frame->GetBoard();
696  canInsert = true;
697 
698  // search if the source footprint was not deleted:
699  for( FOOTPRINT* candidate : mainpcb->Footprints() )
700  {
701  if( editorFootprint->GetLink() == candidate->m_Uuid )
702  {
703  canInsert = false;
704  break;
705  }
706  }
707  }
708 
709  aEvent.Enable( canInsert );
710 }
711 
712 
714 {
715  // call my base class
717 
718  // We have 2 panes to update.
719  // For some obscure reason, the AUI manager hides the first modified pane.
720  // So force show panes
721  wxAuiPaneInfo& tree_pane_info = m_auimgr.GetPane( m_treePane );
722  bool tree_shown = tree_pane_info.IsShown();
723  tree_pane_info.Caption( _( "Libraries" ) );
724 
725  wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_appearancePanel );
726  bool lm_shown = lm_pane_info.IsShown();
727  lm_pane_info.Caption( _( "Appearance" ) );
728 
729  // update the layer manager
732 
733  // Now restore the visibility:
734  lm_pane_info.Show( lm_shown );
735  tree_pane_info.Show( tree_shown );
736  m_auimgr.Update();
737 }
738 
739 
741 {
743  Update3DView( true, true );
745 
746  if( !GetTitle().StartsWith( "*" ) )
747  UpdateTitle();
748 }
749 
750 
752 {
753  wxString title;
754  LIB_ID fpid = GetLoadedFPID();
755  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
756  bool writable = true;
757 
758  if( IsCurrentFPFromBoard() )
759  {
760  if( IsContentModified() )
761  title = wxT( "*" );
762 
763  title += footprint->GetReference();
764  title += wxS( " " ) + wxString::Format( _( "[from %s]" ),
765  Prj().GetProjectName() + "." + PcbFileExtension );
766  }
767  else if( fpid.IsValid() )
768  {
769  try
770  {
771  writable = Prj().PcbFootprintLibs()->IsFootprintLibWritable( fpid.GetLibNickname() );
772  }
773  catch( const IO_ERROR& )
774  {
775  // best efforts...
776  }
777 
778  // Note: don't used GetLoadedFPID(); footprint name may have been edited
779  if( IsContentModified() )
780  title = wxT( "*" );
781 
782  title += FROM_UTF8( footprint->GetFPID().Format().c_str() );
783 
784  if( !writable )
785  title += wxS( " " ) + _( "[Read Only]" );
786  }
787  else if( !fpid.GetLibItemName().empty() )
788  {
789  // Note: don't used GetLoadedFPID(); footprint name may have been edited
790  if( IsContentModified() )
791  title = wxT( "*" );
792 
793  title += FROM_UTF8( footprint->GetFPID().GetLibItemName().c_str() );
794  title += wxS( " " ) + _( "[Unsaved]" );
795  }
796  else
797  {
798  title = _( "[no footprint loaded]" );
799  }
800 
801  title += wxT( " \u2014 " ) + _( "Footprint Editor" );
802 
803  SetTitle( title );
804 }
805 
806 
808 {
810 }
811 
812 
814 {
815  GetCanvas()->UpdateColors();
818  UpdateTitle();
819 }
820 
821 
823 {
824  FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
825 
826  WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
827 
828  if( GFootprintList.GetCount() == 0 )
829  GFootprintList.ReadCacheFromFile( Prj().GetProjectPath() + "fp-info-cache" );
830 
831  GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
832  progressReporter.Show( false );
833 
836 
838  auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
839 
840  adapter->AddLibraries();
841 }
842 
843 
845 {
846  FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
847  auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
848  LIB_ID target = GetTargetFPID();
849  bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() );
850 
851  // Sync FOOTPRINT_INFO list to the libraries on disk
852  if( aProgress )
853  {
854  WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 2 );
855  GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
856  progressReporter.Show( false );
857  }
858  else
859  {
860  GFootprintList.ReadFootprintFiles( fpTable, nullptr, nullptr );
861  }
862 
863  // Sync the LIB_TREE to the FOOTPRINT_INFO list
864  adapter->Sync();
865 
867  m_treePane->GetLibTree()->Regenerate( true );
868 
869  if( target.IsValid() )
870  {
871  if( adapter->FindItem( target ) )
872  {
873  if( targetSelected )
874  m_treePane->GetLibTree()->SelectLibId( target );
875  else
876  m_treePane->GetLibTree()->CenterLibId( target );
877  }
878  else
879  {
880  // Try to focus on parent
881  target.SetLibItemName( wxEmptyString );
882  m_treePane->GetLibTree()->CenterLibId( target );
883  }
884  }
885 }
886 
887 
889 {
890  LIB_ID target = GetTargetFPID();
891 
892  m_treePane->GetLibTree()->Regenerate( true );
893 
894  if( target.IsValid() )
895  m_treePane->GetLibTree()->CenterLibId( target );
896 }
897 
898 
900 {
902 }
903 
904 
906 {
907  m_treePane->GetLibTree()->SelectLibId( aLibID );
908 }
909 
910 
912 {
914 }
915 
916 
918  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
919 {
920  wxTreebook* book = aParent->GetTreebook();
921 
922  book->AddPage( new wxPanel( book ), _( "Footprint Editor" ) );
923  book->AddSubPage( new PANEL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
924  book->AddSubPage( new PANEL_EDIT_OPTIONS( this, aParent ), _( "Editing Options" ) );
925  book->AddSubPage( new PANEL_FP_EDITOR_COLOR_SETTINGS( this, book ), _( "Colors" ) );
926  book->AddSubPage( new PANEL_FP_EDITOR_DEFAULTS( this, aParent ), _( "Default Values" ) );
927 
928  aHotkeysPanel->AddHotKeys( GetToolManager() );
929 }
930 
931 
933 {
934  // Create the manager and dispatcher & route draw panel events to the dispatcher
937  GetCanvas()->GetViewControls(), config(), this );
938  m_actions = new PCB_ACTIONS();
940 
942 
951  m_toolManager->RegisterTool( new PCB_CONTROL ); // copy/paste
960 
961  m_toolManager->GetTool<PCB_SELECTION_TOOL>()->SetIsFootprintEditor( true );
962  m_toolManager->GetTool<EDIT_TOOL>()->SetIsFootprintEditor( true );
963  m_toolManager->GetTool<PAD_TOOL>()->SetIsFootprintEditor( true );
964  m_toolManager->GetTool<DRAWING_TOOL>()->SetIsFootprintEditor( true );
965  m_toolManager->GetTool<PCB_POINT_EDITOR>()->SetIsFootprintEditor( true );
966  m_toolManager->GetTool<PCB_CONTROL>()->SetIsFootprintEditor( true );
967  m_toolManager->GetTool<PCB_PICKER_TOOL>()->SetIsFootprintEditor( true );
968  m_toolManager->GetTool<POSITION_RELATIVE_TOOL>()->SetIsFootprintEditor( true );
969  m_toolManager->GetTool<GROUP_TOOL>()->SetIsFootprintEditor( true );
970  m_toolManager->GetTool<SCRIPTING_TOOL>()->SetIsFootprintEditor( true );
971 
972  m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
974 
975  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
976 }
977 
978 
980 {
982 
984  PCB_EDITOR_CONDITIONS cond( this );
985 
986  wxASSERT( mgr );
987 
988 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
989 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
990 
991  auto haveFootprintCond =
992  [this]( const SELECTION& )
993  {
994  return GetBoard()->GetFirstFootprint() != nullptr;
995  };
996 
997  auto footprintTargettedCond =
998  [this] ( const SELECTION& )
999  {
1000  return !GetTargetFPID().GetLibItemName().empty();
1001  };
1002 
1003  mgr->SetConditions( ACTIONS::saveAs, ENABLE( footprintTargettedCond ) );
1006 
1007  mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
1008  mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
1009 
1015 
1016  mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
1017  mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );
1020  mgr->SetConditions( ACTIONS::doDelete, ENABLE( cond.HasItems() ) );
1021  mgr->SetConditions( ACTIONS::duplicate, ENABLE( cond.HasItems() ) );
1022  mgr->SetConditions( ACTIONS::selectAll, ENABLE( cond.HasItems() ) );
1023 
1026  mgr->SetConditions( PCB_ACTIONS::mirror, ENABLE( cond.HasItems() ) );
1029 
1033 
1036 
1039 
1040 
1041  auto highContrastCond =
1042  [this] ( const SELECTION& )
1043  {
1045  };
1046 
1047  auto boardFlippedCond =
1048  [this]( const SELECTION& )
1049  {
1050  return GetCanvas()->GetView()->IsMirroredX();
1051  };
1052 
1053  auto footprintTreeCond =
1054  [this] (const SELECTION& )
1055  {
1056  return IsSearchTreeShown();
1057  };
1058 
1059  mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
1060  mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
1061  mgr->SetConditions( PCB_ACTIONS::showFootprintTree, CHECK( footprintTreeCond ) );
1062 
1063  mgr->SetConditions( ACTIONS::print, ENABLE( haveFootprintCond ) );
1064  mgr->SetConditions( PCB_ACTIONS::exportFootprint, ENABLE( haveFootprintCond ) );
1065  mgr->SetConditions( PCB_ACTIONS::footprintProperties, ENABLE( haveFootprintCond ) );
1066  mgr->SetConditions( PCB_ACTIONS::cleanupGraphics, ENABLE( haveFootprintCond ) );
1067  mgr->SetConditions( PCB_ACTIONS::placeImportedGraphics, ENABLE( haveFootprintCond ) );
1068 
1069 
1070 // Only enable a tool if the part is edtable
1071 #define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, \
1072  ACTION_CONDITIONS().Enable( haveFootprintCond ).Check( cond.CurrentTool( action ) ) )
1073 
1086 
1087 #undef CURRENT_EDIT_TOOL
1088 #undef ENABLE
1089 #undef CHECK
1090 }
1091 
1092 
1094 {
1096 
1097  // Be sure the axis are enabled
1098  GetCanvas()->GetGAL()->SetAxesEnabled( true );
1099 
1100  UpdateView();
1101 
1102  // Ensure the m_Layers settings are using the canvas type:
1104 }
1105 
1106 
1107 void FOOTPRINT_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1108 {
1109  PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1110 
1112  GetCanvas()->ForceRefresh();
1113 
1115 
1116  if( aEnvVarsChanged )
1117  SyncLibraryTree( true );
1118 
1119  Layout();
1120  SendSizeEvent();
1121 }
1122 
1123 
1124 void FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng( wxCommandEvent& event )
1125 {
1126  wxString fullFileName;
1127 
1128  LIB_ID id = GetLoadedFPID();
1129 
1130  if( id.empty() )
1131  {
1132  wxMessageBox( _( "No footprint selected." ) );
1133  return;
1134  }
1135 
1136  wxFileName fn( id.GetLibItemName() );
1137  fn.SetExt( "png" );
1138 
1139  wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );
1140 
1141  wxFileDialog dlg( this, _( "Footprint Image File Name" ), projectPath,
1142  fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1143 
1144  if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
1145  return;
1146 
1147  // calling wxYield is mandatory under Linux, after closing the file selector dialog
1148  // to refresh the screen before creating the PNG or JPEG image from screen
1149  wxYield();
1150  SaveCanvasImageToFile( this, dlg.GetPath() );
1151 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
The interactive edit tool.
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Definition: infobar.cpp:134
static TOOL_ACTION drawLine
Definition: pcb_actions.h:142
Module editor specific tools.
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 CHECK(x)
bool IsFootprintLibWritable(const wxString &aNickname)
Return true if the library given by aNickname is writable.
show a marker on pads with no nets
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
static TOOL_ACTION placeImportedGraphics
Definition: pcb_actions.h:161
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:376
void OnKiCadExit()
Definition: kiway.cpp:625
void SelectLayer(wxCommandEvent &event)
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
void ForceRefresh()
Force a redraw.
void OnExitKiCad(wxCommandEvent &aEvent)
KIID niluuid(0)
static TOOL_ACTION repairFootprint
Definition: pcb_actions.h:444
bool IsContentModified() const
Definition: base_screen.h:60
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:537
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
void ActivateGalCanvas() override
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const override
Returns the BOARD_DESIGN_SETTINGS for the open project.
SETTINGS_MANAGER * GetSettingsManager() const
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
#define CURRENT_EDIT_TOOL(action)
Model changes (required full reload)
Definition: tool_base.h:80
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
SELECTION_CONDITION HasItems()
Create a functor that tests if there are items in the board.
This file is part of the common library.
static TOOL_ACTION doDelete
Definition: actions.h:72
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
APPEARANCE_CONTROLS * m_appearancePanel
static TOOL_ACTION checkFootprint
Definition: pcb_actions.h:379
static TOOL_ACTION drawArc
Definition: pcb_actions.h:146
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
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...
FOOTPRINT_EDITOR_SETTINGS * GetFootprintEditorSettings() const
static TOOL_ACTION cleanupGraphics
Definition: pcb_actions.h:324
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.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void initLibraryTree()
Make sure the footprint info list is loaded (with a progress dialog) and then initialize the footprin...
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
SELECTION_CONDITION TextFillDisplay()
Create a functor that tests if the frame fills text items.
#define ENABLE(x)
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(FOOTPRINT_EDIT_FRAME *aFrame, FP_LIB_TABLE *aLibs)
FOOTPRINT_LIST_IMPL GFootprintList
The global footprint info table.
Definition: cvpcb.cpp:140
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
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 zoomFitScreen
Definition: actions.h:96
static TOOL_ACTION millimetersUnits
Definition: actions.h:146
void SetCopperLayerCount(int aCount)
Definition: board.cpp:459
void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:143
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:382
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
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
static TOOL_ACTION mirror
Mirroring of selected items.
Definition: pcb_actions.h:108
void AddHotKeys(TOOL_MANAGER *aToolMgr)
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:514
void SaveFootprintToBoard(wxCommandEvent &event)
static TOOL_ACTION group
Definition: pcb_actions.h:427
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
wxAuiManager m_auimgr
Manage TOOL_ACTION objects.
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION ungroup
Definition: pcb_actions.h:428
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:159
Tool relating to pads and pad settings.
virtual const PCB_PLOT_PARAMS & GetPlotSettings() const
Return the PCB_PLOT_PARAMS for the BOARD owned by this frame.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
static TOOL_ACTION setAnchor
Definition: pcb_actions.h:162
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:588
static TOOL_ACTION placeText
Definition: pcb_actions.h:147
not specified: a GAL engine must be set by the client
SELECTION_CONDITION PadFillDisplay()
Create a functor that tests if the frame fills the pads.
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
PADS & Pads()
Definition: footprint.h:159
This file contains miscellaneous commonly used macros and functions.
const char * c_str() const
Definition: utf8.h:102
void OnDisplayOptionsChanged() override
bool m_axesEnabled
Fullscreen crosshair or small cross.
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
wxTreebook * GetTreebook()
Definition: paged_dialog.h:37
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:83
PCB_DISPLAY_OPTIONS m_displayOptions
Master controller class:
Definition: tool_manager.h:54
static TOOL_ACTION measureTool
Definition: actions.h:154
FP_ZONES & Zones()
Definition: footprint.h:165
void SyncLibraryTree(bool aProgress)
Synchronize the footprint library tree to the current state of the footprint library table.
void RegenerateLibraryTree()
Filter, sort, and redisplay the library tree.
static TOOL_ACTION copy
Definition: actions.h:67
unsigned GetCount() const
void UpdateDisplayOptions()
Return a list of the layer presets created by the user.
bool Clear_Pcb(bool aQuery)
Delete all and reinitialize the current board.
Definition: initpcb.cpp:97
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:101
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
void SetCheckboxesFromFilter(SELECTION_FILTER_OPTIONS &aOptions)
bool IsProjectOpen() const
Helper for checking if we have a project open TODO: This should be deprecated along with Prj() once w...
FOOTPRINT * loadFootprint(const LIB_ID &aFootprintId)
Attempts to load aFootprintId from the footprint library table.
void HardRedraw() override
Refresh the library tree and redraw the window.
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:317
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
LIB_TREE_NODE * GetCurrentTreeNode() const
Definition: lib_tree.cpp:188
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
bool SaveCanvasImageToFile(EDA_DRAW_FRAME *aFrame, const wxString &aFileName, BITMAP_TYPE aBitmapType)
Save the current view as an image file.
Definition: bitmap.cpp:204
void OnModify() override
Must be called after a footprint change in order to set the "modify" flag of the current screen and p...
void OnUpdateSaveFootprintToBoard(wxUpdateUIEvent &aEvent)
Install the corresponding dialog editor for the given item.
void DisplayBoard(BOARD *aBoard)
Add all items from the current board to the VIEW, so they can be displayed by GAL.
Tool responsible for drawing graphical elements like lines, arcs, circles, etc.
Definition: drawing_tool.h:50
void SetClearance(int aClearance)
Definition: netclass.h:125
static TOOL_ACTION toggleGrid
Definition: actions.h:140
Handle actions that are shared between different frames in PcbNew.
Definition: pcb_control.h:46
static TOOL_ACTION exportFootprint
Definition: pcb_actions.h:374
void FocusOnLibID(const LIB_ID &aLibID)
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:497
virtual void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
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
static TOOL_ACTION save
Definition: actions.h:51
LIB_ID GetTargetFPID() const
Return the LIB_ID of the part selected in the footprint tree, or the loaded part if there is no selec...
virtual void DispatchWxEvent(wxEvent &aEvent)
Process wxEvents (mostly UI events), translate them to TOOL_EVENTs, and make tools handle those.
FOOTPRINTS & Footprints()
Definition: board.h:233
Inactive layers are shown normally (no high-contrast mode)
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit symbols, if the user selects the symbol itself rather than picking an individual unit,...
Definition: lib_tree.cpp:170
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
Definition: board.cpp:376
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > m_adapter
ACTIONS * m_actions
Definition: tools_holder.h:159
static TOOL_ACTION cut
Definition: actions.h:66
void Regenerate(bool aKeepState)
Regenerate the tree.
Definition: lib_tree.cpp:222
Definition of file extensions used in Kicad.
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:211
FOOTPRINT_EDITOR_SETTINGS * m_settings
#define FOOTPRINT_EDIT_FRAME_NAME
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
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
SELECTION_FILTER_OPTIONS m_SelectionFilter
const wxString & GetReference() const
Definition: footprint.h:421
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
#define _(s)
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:90
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
EDA_RECT GetBoardBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
DRAWINGS & GraphicalItems()
Definition: footprint.h:162
static const wxChar A4[]
Definition: page_info.h:63
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
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
#define PcbFileExtension
Footprint Editor pane with footprint library tree.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
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.
Handle actions that are shared between different applications.
void RefreshLibTree()
Refreshes the tree (mainly to update highlighting and asterisking)
Definition: lib_tree.cpp:240
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
void DisplayErrors(wxTopLevelWindow *aCaller=nullptr)
std::unique_ptr< FOOTPRINT > m_revertModule
LIB_TREE * GetLibTree() const
The interactive edit tool.
Definition: edit_tool.h:64
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Specialization of the wxAuiPaneInfo class for KiCad panels.
std::vector< LAYER_PRESET > GetUserLayerPresets() const
Update the current layer presets from those saved in the project file.
COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
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...
LIB_TREE_NODE * GetCurrentTreeNode() const
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:287
static TOOL_ACTION milsUnits
Definition: actions.h:145
const PCB_PLOT_PARAMS & GetPlotSettings() const override
Return the PCB_PLOT_PARAMS for the BOARD owned by this frame.
UTF8 Format() const
Definition: lib_id.cpp:116
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:160
Handles action that are shared between different applications.
Definition: common_tools.h:37
void UpdateColors()
Update the color settings in the painter and GAL.
void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
Switch the currently used canvas (Cairo / OpenGL).
wxString PngFileWildcard()
Generic tool for picking an item.
KIID GetLink() const
Definition: footprint.h:526
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
SELECTION_CONDITION ContentModified()
Create a functor that tests if the content of the frame is modified.
virtual void SetRString(RSTRING_T aStringId, const wxString &aString)
Store a "retained string", which is any session and project specific string identified in enum RSTRIN...
Definition: project.cpp:212
bool IsMirroredX() const
Return true if view is flipped across the X axis.
Definition: view.h:237
SELECTION_CONDITION NoActiveTool()
Create a functor testing if there are no tools active in the frame.
BOARD * GetBoard()
static TOOL_ACTION pasteSpecial
Definition: actions.h:69
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:283
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:244
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:97
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
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:394
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Allow footprint editor to install its preferences panel into the preferences dialog.
void LoadFootprintFromBoard(wxCommandEvent &event)
Called from the main toolbar to load a footprint from board mainly to edit it.
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 ...
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:281
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
Definition: project.cpp:227
Gather all the actions that are shared by tools.
Definition: pcb_actions.h:48
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:154
see class PGM_BASE
void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings) override
Tool that displays edit points allowing to modify items by dragging the points.
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
Declaration of the eda_3d_viewer class.
static TOOL_ACTION showFootprintTree
Definition: pcb_actions.h:353
Common, abstract interface for edit frames.
void CloseFootprintEditor(wxCommandEvent &Event)
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
SELECTION_CONDITION GraphicsFillDisplay()
Create a functor that tests if the frame fills graphics items.
static TOOL_ACTION saveAs
Definition: actions.h:52
LIB_ID GetLoadedFPID() const
Return the LIB_ID of the part being edited.
PANEL_SELECTION_FILTER * m_selectionFilterPanel
bool canCloseWindow(wxCloseEvent &Event) override
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 SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:635
std::vector< LAYER_PRESET > m_LayerPresets
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
BOARD_ITEM_CONTAINER * GetModel() const override
NETCLASS * GetDefault() const
The main frame for Pcbnew.
FOOTPRINT_TREE_PANE * m_treePane
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:
static bool empty(const wxTextEntryBase *aCtrl)
unsigned GetErrorCount() const
virtual void AddFootprintToBoard(FOOTPRINT *aFootprint)
Add the given footprint to the board.
wxString GetActiveLayerPreset() const
MAGNETIC_SETTINGS * GetMagneticItemsSettings() override
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Tool useful for viewing footprints.
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:199
bool ReadFootprintFiles(FP_LIB_TABLE *aTable, const wxString *aNickname=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
Read all the footprints provided by the combination of aTable and aNickname.
void ShowChangedLanguage() override
Update visible items after a language change.
Color settings are a bit different than most of the settings objects in that there can be more than o...
void OnUpdateLoadFootprintFromBoard(wxUpdateUIEvent &aEvent)
WX_INFOBAR * GetInfoBar()
static TOOL_ACTION deleteTool
Definition: actions.h:73
void ReadCacheFromFile(const wxString &aFilePath) override
FOOTPRINT_EDITOR_SETTINGS * GetSettings()
static TOOL_ACTION undo
Definition: actions.h:64
void WriteCacheToFile(const wxString &aFilePath) override
APP_SETTINGS_BASE * config() const override
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void AddFootprintToBoard(FOOTPRINT *aFootprint) override
Override from PCB_BASE_EDIT_FRAME which adds a footprint to the editor's dummy board,...
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
void OnGridSettings(wxCommandEvent &event)
void RefreshLibraryTree()
Redisplay the library tree.
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:102
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:294
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
void InitTools()
Initializes all registered tools.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
BOARD * GetBoard() const
static TOOL_ACTION gridSetOrigin
Definition: actions.h:137
BOARD_DESIGN_SETTINGS m_DesignSettings
Only some of these settings are actually used for footprint editing.
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:773
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1183
bool IsContentModified() const override
Get if any footprints or libraries have been modified but not saved.
Group generic conditions for PCB editor states.
static constexpr int Millimeter2iu(double mm)
bool SaveFootprint(FOOTPRINT *aFootprint)
Save in an existing library a given footprint.
static TOOL_ACTION highContrastMode
Definition: actions.h:103
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 OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:485
static TOOL_ACTION paste
Definition: actions.h:68
void FlushAndRelease(JSON_SETTINGS *aSettings, bool aSave=true)
If the given settings object is registered, save it to disk and unregister it.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
static TOOL_ACTION duplicate
Definition: actions.h:71
LIB_ID GetTreeFPID() const
Return the LIB_ID of the part or library selected in the footprint tree.
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:203
static TOOL_ACTION revert
Definition: actions.h:55
static const wxChar * GetFootprintEditorFrameName()
static TOOL_ACTION selectionTool
Definition: actions.h:153
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
void CenterLibId(const LIB_ID &aLibId)
Ensure that an item is visible (preferably centered).
Definition: lib_tree.cpp:205
void OnSaveFootprintAsPng(wxCommandEvent &event)
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition: lib_tree.cpp:199
bool empty() const
Definition: utf8.h:103
virtual void UpdateMsgPanel()
Redraw the message panel.
Container for design settings for a BOARD object.
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: infobar.cpp:277
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:397
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:184