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_base.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_editorSettings = 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_editorSettings->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_editorSettings->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  // Ensure item UUIDs are valide
465  // ("old" footprints can have null uuids that create issues in fp editor)
466  aFootprint->FixUuids();
467 
468  if( IsCurrentFPFromBoard() )
469  {
470  wxString msg;
471  msg.Printf( _( "Editing %s from board. Saving will update the board only." ),
472  aFootprint->GetReference() );
473 
476  GetInfoBar()->ShowMessage( msg, wxICON_INFORMATION );
477  }
478 
479  UpdateMsgPanel();
480 }
481 
482 
484 {
486 }
487 
488 
490 {
491  return GetBoard()->GetDesignSettings();
492 }
493 
494 
496 {
497  wxFAIL_MSG( "Plotting not supported in Footprint Editor" );
498 
500 }
501 
502 
504 {
505  wxFAIL_MSG( "Plotting not supported in Footprint Editor" );
506 }
507 
508 
510 {
511  if( !m_editorSettings )
512  m_editorSettings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
513 
514  return m_editorSettings;
515 }
516 
517 
519 {
521  : Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
522 }
523 
524 
526 {
527  // aCfg will be the PCBNEW_SETTINGS
529 
531 
533 
535 
538 }
539 
540 
542 {
544 
545  // aCfg will be the PCBNEW_SETTINGS
547 
549 
552  cfg->m_LibWidth = m_treePane->GetSize().x;
556 
558 }
559 
560 
562 {
563  wxString currentTheme = GetFootprintEditorSettings()->m_ColorTheme;
564  return Pgm().GetSettingsManager().GetColorSettings( currentTheme );
565 }
566 
567 
569 {
570  // Get the actual frame settings for magnetic items
572  wxCHECK( cfg, nullptr );
573  return &cfg->m_MagneticItems;
574 }
575 
576 
577 const BOX2I FOOTPRINT_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
578 {
579  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
580 
581  if( footprint )
582  {
583  bool hasGraphicalItem = footprint->Pads().size() || footprint->Zones().size();
584 
585  if( !hasGraphicalItem )
586  {
587  for( const BOARD_ITEM* item : footprint->GraphicalItems() )
588  {
589  if( item->Type() == PCB_FP_TEXT_T )
590  continue;
591 
592  hasGraphicalItem = true;
593  break;
594  }
595  }
596 
597  if( hasGraphicalItem )
598  {
599  return footprint->GetBoundingBox( false, false );
600  }
601  else
602  {
603  BOX2I newFootprintBB( { 0, 0 }, { 0, 0 } );
604  newFootprintBB.Inflate( Millimeter2iu( 12 ) );
605  return newFootprintBB;
606  }
607  }
608 
609  return GetBoardBoundingBox( false );
610 }
611 
612 
613 bool FOOTPRINT_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
614 {
615  if( IsContentModified() )
616  {
617  // Shutdown blocks must be determined and vetoed as early as possible
619  aEvent.GetId() == wxEVT_QUERY_END_SESSION )
620  {
621  aEvent.Veto();
622  return false;
623  }
624 
625  wxString footprintName = GetBoard()->GetFirstFootprint()->GetFPID().GetLibItemName();
626  wxString msg = _( "Save changes to '%s' before closing?" );
627 
628  if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
629  [&]() -> bool
630  {
631  return SaveFootprint( GetBoard()->GetFirstFootprint() );
632  } ) )
633  {
634  aEvent.Veto();
635  return false;
636  }
637  }
638 
639  return PCB_BASE_EDIT_FRAME::canCloseWindow( aEvent );
640 }
641 
642 
644 {
645  // No more vetos
646  GetCanvas()->SetEventDispatcher( nullptr );
647  GetCanvas()->StopDrawing();
648 
649  // Do not show the layer manager during closing to avoid flicker
650  // on some platforms (Windows) that generate useless redraw of items in
651  // the Layer Manager
652  m_auimgr.GetPane( "LayersManager" ).Show( false );
653  m_auimgr.GetPane( "SelectionFilter" ).Show( false );
654 
655  Clear_Pcb( false );
656 
658 
659  if( mgr->IsProjectOpen() && wxFileName::IsDirWritable( Prj().GetProjectPath() ) )
660  {
661  GFootprintList.WriteCacheToFile( Prj().GetProjectPath() + "fp-info-cache" );
662  }
663 
664  mgr->FlushAndRelease( GetSettings() );
665 }
666 
667 
668 void FOOTPRINT_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
669 {
670  Kiway().OnKiCadExit();
671 }
672 
673 
674 void FOOTPRINT_EDIT_FRAME::CloseFootprintEditor( wxCommandEvent& Event )
675 {
676  Close();
677 }
678 
679 
681 {
683 
684  aEvent.Enable( frame && frame->GetBoard()->GetFirstFootprint() != nullptr );
685 }
686 
687 
689 {
691 
692  FOOTPRINT* editorFootprint = GetBoard()->GetFirstFootprint();
693  bool canInsert = frame && editorFootprint && editorFootprint->GetLink() == niluuid;
694 
695  // If the source was deleted, the footprint can inserted but not updated in the board.
696  if( frame && editorFootprint && editorFootprint->GetLink() != niluuid )
697  {
698  BOARD* mainpcb = frame->GetBoard();
699  canInsert = true;
700 
701  // search if the source footprint was not deleted:
702  for( FOOTPRINT* candidate : mainpcb->Footprints() )
703  {
704  if( editorFootprint->GetLink() == candidate->m_Uuid )
705  {
706  canInsert = false;
707  break;
708  }
709  }
710  }
711 
712  aEvent.Enable( canInsert );
713 }
714 
715 
717 {
718  // call my base class
720 
721  // We have 2 panes to update.
722  // For some obscure reason, the AUI manager hides the first modified pane.
723  // So force show panes
724  wxAuiPaneInfo& tree_pane_info = m_auimgr.GetPane( m_treePane );
725  bool tree_shown = tree_pane_info.IsShown();
726  tree_pane_info.Caption( _( "Libraries" ) );
727 
728  wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_appearancePanel );
729  bool lm_shown = lm_pane_info.IsShown();
730  lm_pane_info.Caption( _( "Appearance" ) );
731 
732  // update the layer manager
735 
736  // Now restore the visibility:
737  lm_pane_info.Show( lm_shown );
738  tree_pane_info.Show( tree_shown );
739  m_auimgr.Update();
740 }
741 
742 
744 {
746  Update3DView( true, true );
748 
749  if( !GetTitle().StartsWith( "*" ) )
750  UpdateTitle();
751 }
752 
753 
755 {
756  wxString title;
757  LIB_ID fpid = GetLoadedFPID();
758  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
759  bool writable = true;
760 
761  if( IsCurrentFPFromBoard() )
762  {
763  if( IsContentModified() )
764  title = wxT( "*" );
765 
766  title += footprint->GetReference();
767  title += wxS( " " ) + wxString::Format( _( "[from %s]" ),
768  Prj().GetProjectName() + "." + PcbFileExtension );
769  }
770  else if( fpid.IsValid() )
771  {
772  try
773  {
774  writable = Prj().PcbFootprintLibs()->IsFootprintLibWritable( fpid.GetLibNickname() );
775  }
776  catch( const IO_ERROR& )
777  {
778  // best efforts...
779  }
780 
781  // Note: don't used GetLoadedFPID(); footprint name may have been edited
782  if( IsContentModified() )
783  title = wxT( "*" );
784 
785  title += FROM_UTF8( footprint->GetFPID().Format().c_str() );
786 
787  if( !writable )
788  title += wxS( " " ) + _( "[Read Only]" );
789  }
790  else if( !fpid.GetLibItemName().empty() )
791  {
792  // Note: don't used GetLoadedFPID(); footprint name may have been edited
793  if( IsContentModified() )
794  title = wxT( "*" );
795 
796  title += FROM_UTF8( footprint->GetFPID().GetLibItemName().c_str() );
797  title += wxS( " " ) + _( "[Unsaved]" );
798  }
799  else
800  {
801  title = _( "[no footprint loaded]" );
802  }
803 
804  title += wxT( " \u2014 " ) + _( "Footprint Editor" );
805 
806  SetTitle( title );
807 }
808 
809 
811 {
813 }
814 
815 
817 {
818  GetCanvas()->UpdateColors();
821  UpdateTitle();
822 }
823 
824 
826 {
827  FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
828 
829  WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
830 
831  if( GFootprintList.GetCount() == 0 )
832  GFootprintList.ReadCacheFromFile( Prj().GetProjectPath() + "fp-info-cache" );
833 
834  GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
835  progressReporter.Show( false );
836 
839 
841  auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
842 
843  adapter->AddLibraries();
844 }
845 
846 
848 {
849  FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
850  auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
851  LIB_ID target = GetTargetFPID();
852  bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() );
853 
854  // Sync FOOTPRINT_INFO list to the libraries on disk
855  if( aProgress )
856  {
857  WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 2 );
858  GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
859  progressReporter.Show( false );
860  }
861  else
862  {
863  GFootprintList.ReadFootprintFiles( fpTable, nullptr, nullptr );
864  }
865 
866  // Sync the LIB_TREE to the FOOTPRINT_INFO list
867  adapter->Sync();
868 
870  m_treePane->GetLibTree()->Regenerate( true );
871 
872  if( target.IsValid() )
873  {
874  if( adapter->FindItem( target ) )
875  {
876  if( targetSelected )
877  m_treePane->GetLibTree()->SelectLibId( target );
878  else
879  m_treePane->GetLibTree()->CenterLibId( target );
880  }
881  else
882  {
883  // Try to focus on parent
884  target.SetLibItemName( wxEmptyString );
885  m_treePane->GetLibTree()->CenterLibId( target );
886  }
887  }
888 }
889 
890 
892 {
893  LIB_ID target = GetTargetFPID();
894 
895  m_treePane->GetLibTree()->Regenerate( true );
896 
897  if( target.IsValid() )
898  m_treePane->GetLibTree()->CenterLibId( target );
899 }
900 
901 
903 {
905 }
906 
907 
909 {
910  m_treePane->GetLibTree()->SelectLibId( aLibID );
911 }
912 
913 
915 {
917 }
918 
919 
921  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
922 {
923  wxTreebook* book = aParent->GetTreebook();
924 
925  book->AddPage( new wxPanel( book ), _( "Footprint Editor" ) );
926  book->AddSubPage( new PANEL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
927  book->AddSubPage( new PANEL_EDIT_OPTIONS( this, aParent ), _( "Editing Options" ) );
928  book->AddSubPage( new PANEL_FP_EDITOR_COLOR_SETTINGS( this, book ), _( "Colors" ) );
929  book->AddSubPage( new PANEL_FP_EDITOR_DEFAULTS( this, aParent ), _( "Default Values" ) );
930 
931  aHotkeysPanel->AddHotKeys( GetToolManager() );
932 }
933 
934 
936 {
937  // Create the manager and dispatcher & route draw panel events to the dispatcher
940  GetCanvas()->GetViewControls(), config(), this );
941  m_actions = new PCB_ACTIONS();
943 
945 
954  m_toolManager->RegisterTool( new PCB_CONTROL ); // copy/paste
963 
964  m_toolManager->GetTool<PCB_SELECTION_TOOL>()->SetIsFootprintEditor( true );
965  m_toolManager->GetTool<EDIT_TOOL>()->SetIsFootprintEditor( true );
966  m_toolManager->GetTool<PAD_TOOL>()->SetIsFootprintEditor( true );
967  m_toolManager->GetTool<DRAWING_TOOL>()->SetIsFootprintEditor( true );
968  m_toolManager->GetTool<PCB_POINT_EDITOR>()->SetIsFootprintEditor( true );
969  m_toolManager->GetTool<PCB_CONTROL>()->SetIsFootprintEditor( true );
970  m_toolManager->GetTool<PCB_PICKER_TOOL>()->SetIsFootprintEditor( true );
971  m_toolManager->GetTool<POSITION_RELATIVE_TOOL>()->SetIsFootprintEditor( true );
972  m_toolManager->GetTool<GROUP_TOOL>()->SetIsFootprintEditor( true );
973  m_toolManager->GetTool<SCRIPTING_TOOL>()->SetIsFootprintEditor( true );
974 
975  m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
977 
978  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
979 }
980 
981 
983 {
985 
987  PCB_EDITOR_CONDITIONS cond( this );
988 
989  wxASSERT( mgr );
990 
991 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
992 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
993 
994  auto haveFootprintCond =
995  [this]( const SELECTION& )
996  {
997  return GetBoard()->GetFirstFootprint() != nullptr;
998  };
999 
1000  auto footprintTargettedCond =
1001  [this] ( const SELECTION& )
1002  {
1003  return !GetTargetFPID().GetLibItemName().empty();
1004  };
1005 
1006  mgr->SetConditions( ACTIONS::saveAs, ENABLE( footprintTargettedCond ) );
1009 
1010  mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
1011  mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
1012 
1018 
1019  mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
1020  mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );
1023  mgr->SetConditions( ACTIONS::doDelete, ENABLE( cond.HasItems() ) );
1024  mgr->SetConditions( ACTIONS::duplicate, ENABLE( cond.HasItems() ) );
1025  mgr->SetConditions( ACTIONS::selectAll, ENABLE( cond.HasItems() ) );
1026 
1027  auto haveAtLeastOneGroupCond =
1028  []( const SELECTION& aSel )
1029  {
1030  for( EDA_ITEM* item : aSel )
1031  {
1032  if( item->Type() == PCB_GROUP_T )
1033  return true;
1034  }
1035 
1036  return false;
1037  };
1038 
1041  mgr->SetConditions( PCB_ACTIONS::mirror, ENABLE( cond.HasItems() ) );
1043  mgr->SetConditions( PCB_ACTIONS::ungroup, ENABLE( haveAtLeastOneGroupCond ) );
1044 
1048 
1051 
1054 
1055 
1056  auto highContrastCond =
1057  [this] ( const SELECTION& )
1058  {
1060  };
1061 
1062  auto boardFlippedCond =
1063  [this]( const SELECTION& )
1064  {
1065  return GetCanvas()->GetView()->IsMirroredX();
1066  };
1067 
1068  auto footprintTreeCond =
1069  [this] (const SELECTION& )
1070  {
1071  return IsSearchTreeShown();
1072  };
1073 
1074  mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
1075  mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
1076  mgr->SetConditions( PCB_ACTIONS::showFootprintTree, CHECK( footprintTreeCond ) );
1077 
1078  mgr->SetConditions( ACTIONS::print, ENABLE( haveFootprintCond ) );
1079  mgr->SetConditions( PCB_ACTIONS::exportFootprint, ENABLE( haveFootprintCond ) );
1080  mgr->SetConditions( PCB_ACTIONS::footprintProperties, ENABLE( haveFootprintCond ) );
1081  mgr->SetConditions( PCB_ACTIONS::cleanupGraphics, ENABLE( haveFootprintCond ) );
1082  mgr->SetConditions( PCB_ACTIONS::placeImportedGraphics, ENABLE( haveFootprintCond ) );
1083 
1084 
1085 // Only enable a tool if the part is edtable
1086 #define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, \
1087  ACTION_CONDITIONS().Enable( haveFootprintCond ).Check( cond.CurrentTool( action ) ) )
1088 
1101 
1102 #undef CURRENT_EDIT_TOOL
1103 #undef ENABLE
1104 #undef CHECK
1105 }
1106 
1107 
1109 {
1111 
1112  // Be sure the axis are enabled
1113  GetCanvas()->GetGAL()->SetAxesEnabled( true );
1114 
1115  UpdateView();
1116 
1117  // Ensure the m_Layers settings are using the canvas type:
1119 }
1120 
1121 
1122 void FOOTPRINT_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1123 {
1124  PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1125 
1127  GetCanvas()->ForceRefresh();
1128 
1130 
1131  if( aEnvVarsChanged )
1132  SyncLibraryTree( true );
1133 
1134  Layout();
1135  SendSizeEvent();
1136 }
1137 
1138 
1139 void FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng( wxCommandEvent& event )
1140 {
1141  wxString fullFileName;
1142 
1143  LIB_ID id = GetLoadedFPID();
1144 
1145  if( id.empty() )
1146  {
1147  wxMessageBox( _( "No footprint selected." ) );
1148  return;
1149  }
1150 
1151  wxFileName fn( id.GetLibItemName() );
1152  fn.SetExt( "png" );
1153 
1154  wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );
1155 
1156  wxFileDialog dlg( this, _( "Footprint Image File Name" ), projectPath,
1157  fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1158 
1159  if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
1160  return;
1161 
1162  // calling wxYield is mandatory under Linux, after closing the file selector dialog
1163  // to refresh the screen before creating the PNG or JPEG image from screen
1164  wxYield();
1165  SaveCanvasImageToFile( this, dlg.GetPath() );
1166 }
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:142
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:239
#define CHECK(x)
bool IsFootprintLibWritable(const wxString &aNickname)
Return true if the library given by aNickname is writable.
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:375
void OnKiCadExit()
Definition: kiway.cpp:626
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:445
bool IsContentModified() const
Definition: base_screen.h:60
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
bool FixUuids()
Old footprints do not alway have a valid UUID (some can be set to null uuid) However null UUIDs,...
Definition: footprint.cpp:227
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:539
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:49
APPEARANCE_CONTROLS * m_appearancePanel
static TOOL_ACTION checkFootprint
Definition: pcb_actions.h:378
static TOOL_ACTION drawArc
Definition: pcb_actions.h:146
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
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:323
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:461
void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:143
FOOTPRINT_EDITOR_SETTINGS * m_editorSettings
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:381
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:383
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:516
void SaveFootprintToBoard(wxCommandEvent &event)
static TOOL_ACTION group
Definition: pcb_actions.h:428
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:429
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:590
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:168
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:174
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:179
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:207
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:373
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:499
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:165
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
Definition: board.cpp:378
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:213
Definition of file extensions used in Kicad.
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:202
#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:463
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:171
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:194
#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:231
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:286
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:575
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:238
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
show a marker on pads with no nets
Definition: layer_ids.h:203
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:243
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:393
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.
static TOOL_ACTION showFootprintTree
Definition: pcb_actions.h:352
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:718
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
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
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:293
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:766
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1274
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:487
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:196
void OnSaveFootprintAsPng(wxCommandEvent &event)
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition: lib_tree.cpp:190
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:276
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:396
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:184