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 <[email protected]>
6  * Copyright (C) 2015-2016 Wayne Stambaugh <[email protected]>
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 #include <widgets/wx_aui_utils.h>
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  PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_FOOTPRINT_EDITOR, wxEmptyString,
113  wxDefaultPosition, wxDefaultSize,
114  KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() ),
115  m_show_layer_manager_tools( true )
116 {
117  m_showBorderAndTitleBlock = false; // true to show the frame references
118  m_aboutTitle = _( "KiCad Footprint Editor" );
119  m_selLayerBox = nullptr;
120  m_editorSettings = nullptr;
121 
122  // Give an icon
123  wxIcon icon;
124  wxIconBundle icon_bundle;
125 
126  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit ) );
127  icon_bundle.AddIcon( icon );
128  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit_32 ) );
129  icon_bundle.AddIcon( icon );
130  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit_16 ) );
131  icon_bundle.AddIcon( icon );
132 
133  SetIcons( icon_bundle );
134 
135  // Create GAL canvas
136  m_canvasType = loadCanvasTypeSetting();
137 
138  PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
139  GetGalDisplayOptions(), m_canvasType );
140  SetCanvas( drawPanel );
141  SetBoard( new BOARD() );
142 
143  // This board will only be used to hold a footprint for editing
145 
146  // In Footprint Editor, the default net clearance is not known (it depends on the actual
147  // board). So we do not show the default clearance, by setting it to 0. The footprint or
148  // pad specific clearance will be shown.
150 
151  // Don't show the default board solder mask clearance in the footprint editor. Only the
152  // footprint or pad clearance setting should be shown if it is not 0.
154 
155  // restore the last footprint from the project, if any
156  restoreLastFootprint();
157 
158  // Ensure all layers and items are visible:
159  // In footprint editor, some layers have no meaning or cannot be used, but we show all of
160  // them, at least to be able to edit a bad layer
162 
163  // However the "no net" mark on pads is useless, because there are no nets in footprint
164  // editor: make it non visible.
166 
167  GetGalDisplayOptions().m_axesEnabled = true;
168 
169  // In Footprint Editor, set the default paper size to A4 for plot/print
170  SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) );
171  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
172 
173  // Create the manager and dispatcher & route draw panel events to the dispatcher
174  setupTools();
175  setupUIConditions();
176 
177  initLibraryTree();
178  m_treePane = new FOOTPRINT_TREE_PANE( this );
179 
180  ReCreateMenuBar();
181  ReCreateHToolbar();
182  ReCreateVToolbar();
183  ReCreateOptToolbar();
184 
185  m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
186  m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas(), true );
187 
188  // LoadSettings() *after* creating m_LayersManager, because LoadSettings() initialize
189  // parameters in m_LayersManager
190  // NOTE: KifaceSettings() will return PCBNEW_SETTINGS if we started from pcbnew
191  LoadSettings( GetSettings() );
192 
193  // Must be set after calling LoadSettings() to be sure these parameters are not dependent
194  // on what is read in stored settings. Enable one internal layer, because footprints
195  // support keepout areas that can be on internal layers only (therefore on the first internal
196  // layer). This is needed to handle these keepout in internal layers only.
198  GetBoard()->SetEnabledLayers( GetBoard()->GetEnabledLayers().set( In1_Cu ) );
199  GetBoard()->SetVisibleLayers( GetBoard()->GetEnabledLayers() );
200  GetBoard()->SetLayerName( In1_Cu, _( "Inner layers" ) );
201 
202  SetActiveLayer( F_SilkS );
203 
204  m_auimgr.SetManagedWindow( this );
205 
206  CreateInfoBar();
207 
208  unsigned int auiFlags = wxAUI_MGR_DEFAULT;
209 #if !defined( _WIN32 )
210  // Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds
211  // of graphical glitches
212  auiFlags |= wxAUI_MGR_LIVE_RESIZE;
213 #endif
214  m_auimgr.SetFlags( auiFlags );
215 
216  // Rows; layers 4 - 6
217  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
218  .Top().Layer( 6 ) );
219  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
220  .Bottom().Layer( 6 ) );
221 
222  // Columns; layers 1 - 3
223  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
224  .Left().Layer( 3 ) );
225  m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "Footprints" )
226  .Left().Layer(2)
227  .Caption( _( "Libraries" ) )
228  .MinSize( 250, 400 ).Resizable() );
229 
230  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
231  .Right().Layer(2) );
232 
233  m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( "LayersManager" )
234  .Right().Layer( 3 )
235  .Caption( _( "Appearance" ) ).PaneBorder( false )
236  .MinSize( 180, -1 ).BestSize( 180, -1 ) );
237  m_auimgr.AddPane( m_selectionFilterPanel, EDA_PANE().Palette().Name( "SelectionFilter" )
238  .Right().Layer( 3 ).Position( 2 )
239  .Caption( _( "Selection Filter" ) ).PaneBorder( false )
240  .MinSize( 160, -1 ).BestSize( m_selectionFilterPanel->GetBestSize() ) );
241 
242  // Center
243  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
244  .Center() );
245 
246  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
247  m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
248 
249  // The selection filter doesn't need to grow in the vertical direction when docked
250  m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
251 
252  ActivateGalCanvas();
253 
254  FinishAUIInitialization();
255 
256  if( m_editorSettings->m_LibWidth > 0 )
257  {
258  wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" );
259 
260  // wxAUI hack: force width by setting MinSize() and then Fixed()
261  // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
262  treePane.MinSize( m_editorSettings->m_LibWidth, -1 );
263  treePane.Fixed();
264  m_auimgr.Update();
265 
266  // now make it resizable again
267  treePane.Resizable();
268  m_auimgr.Update();
269 
270  // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
271  // back to minimum.
272  treePane.MinSize( 250, -1 );
273  }
274 
275  // Apply saved visibility stuff at the end
276  FOOTPRINT_EDITOR_SETTINGS* cfg = GetSettings();
277  m_appearancePanel->SetUserLayerPresets( cfg->m_LayerPresets );
278  m_appearancePanel->ApplyLayerPreset( cfg->m_ActiveLayerPreset );
279 
280  if( cfg->m_AuiPanels.right_panel_width > 0 )
281  {
282  wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
283  SetAuiPaneSize( m_auimgr, layersManager, cfg->m_AuiPanels.right_panel_width, -1 );
284  }
285 
286  m_appearancePanel->SetTabIndex( cfg->m_AuiPanels.appearance_panel_tab );
287 
288  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
289  UpdateTitle();
290  setupUnits( GetSettings() );
291 
292  resolveCanvasType();
293 
294  // Default shutdown reason until a file is loaded
295  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Footprint changes are unsaved" ) );
296 
297  // Catch unhandled accelerator command characters that were no handled by the library tree
298  // panel.
299  Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
300  Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
301 
302  // Ensure the window is on top
303  Raise();
304  Show( true );
305 
306  // Register a call to update the toolbar sizes. It can't be done immediately because
307  // it seems to require some sizes calculated that aren't yet (at least on GTK).
308  CallAfter( [&]()
309  {
310  // Ensure the controls on the toolbars all are correctly sized
311  UpdateToolbarControlSizes();
312  } );
313 }
314 
315 
317 {
318  // Shutdown all running tools
319  if( m_toolManager )
321 
322  // save the footprint in the PROJECT
324 
325  delete m_selectionFilterPanel;
326  delete m_appearancePanel;
327  delete m_treePane;
328 }
329 
330 
332 {
334 }
335 
336 
338 {
339  return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
340 }
341 
342 
344 {
345  // switches currently used canvas (Cairo / OpenGL).
346  PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
347 
348  GetCanvas()->GetGAL()->SetAxesEnabled( true );
349 
350  // The base class method *does not reinit* the layers manager. We must update the layer
351  // widget to match board visibility states, both layers and render columns, and and some
352  // settings dependent on the canvas.
354 }
355 
356 
358 {
359  SyncLibraryTree( true );
360  GetCanvas()->ForceRefresh();
361 }
362 
363 
365 {
366  wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
367  treePane.Show( !IsSearchTreeShown() );
368  m_auimgr.Update();
369 }
370 
371 
373 {
375  wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
376  wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
377 
378  // show auxiliary Vertical layers and visibility manager toolbar
380  layersManager.Show( m_show_layer_manager_tools );
381  selectionFilter.Show( m_show_layer_manager_tools );
382 
384  {
385  SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
386  }
387  else
388  {
389  settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
390  m_auimgr.Update();
391  }
392 }
393 
394 
396 {
397  return const_cast<wxAuiManager&>( m_auimgr ).GetPane( m_treePane ).IsShown();
398 }
399 
400 
402 {
403  return GetBoard()->GetFirstFootprint();
404 }
405 
406 
408 {
410 }
411 
412 
414 {
416 }
417 
418 
420 {
421  LIB_ID id;
422 
423  if( IsSearchTreeShown() )
424  id = GetTreeFPID();
425 
426  if( id.GetLibNickname().empty() )
427  id = GetLoadedFPID();
428 
429  return id;
430 }
431 
432 
434 {
435  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
436 
437  if( footprint )
438  return LIB_ID( footprint->GetFPID().GetLibNickname(), m_footprintNameWhenLoaded );
439  else
440  return LIB_ID();
441 }
442 
443 
445 {
446  if( GetBoard()->GetFirstFootprint() )
448 
449  GetScreen()->SetContentModified( false );
450 }
451 
452 
454 {
455  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
456 
457  return ( footprint && footprint->GetLink() != niluuid );
458 }
459 
460 
462 {
463  LIB_ID id = GetLoadedFPID();
464 
465  if( id.IsValid() )
466  {
468  Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME, id.GetLibItemName() );
469  }
470 }
471 
472 
474 {
475  const wxString& footprintName = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME );
476  const wxString& libNickname = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_LIB_NICKNAME );
477 
478  if( libNickname.Length() && footprintName.Length() )
479  {
480  LIB_ID id;
481  id.SetLibNickname( libNickname );
482  id.SetLibItemName( footprintName );
483 
484  FOOTPRINT* footprint = loadFootprint( id );
485 
486  if( footprint )
487  AddFootprintToBoard( footprint );
488  }
489 }
490 
491 
493 {
494  m_revertModule.reset( (FOOTPRINT*) aFootprint->Clone() );
495 
497 
499  // Ensure item UUIDs are valide
500  // ("old" footprints can have null uuids that create issues in fp editor)
501  aFootprint->FixUuids();
502 
503  if( IsCurrentFPFromBoard() )
504  {
505  wxString msg;
506  msg.Printf( _( "Editing %s from board. Saving will update the board only." ),
507  aFootprint->GetReference() );
508 
511  GetInfoBar()->ShowMessage( msg, wxICON_INFORMATION );
512  }
513 
514  UpdateMsgPanel();
515 }
516 
517 
519 {
521 }
522 
523 
525 {
526  return GetBoard()->GetDesignSettings();
527 }
528 
529 
531 {
532  wxFAIL_MSG( wxT( "Plotting not supported in Footprint Editor" ) );
533 
535 }
536 
537 
539 {
540  wxFAIL_MSG( wxT( "Plotting not supported in Footprint Editor" ) );
541 }
542 
543 
545 {
546  if( !m_editorSettings )
547  m_editorSettings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
548 
549  return m_editorSettings;
550 }
551 
552 
554 {
556  : Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
557 }
558 
559 
561 {
562  // aCfg will be the PCBNEW_SETTINGS
564 
566 
568 
571 
574 }
575 
576 
578 {
580 
581  // aCfg will be the PCBNEW_SETTINGS
583 
585 
588  cfg->m_LibWidth = m_treePane->GetSize().x;
592 
594  cfg->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
596 
598 }
599 
600 
602 {
603  wxString currentTheme = GetFootprintEditorSettings()->m_ColorTheme;
604  return Pgm().GetSettingsManager().GetColorSettings( currentTheme );
605 }
606 
607 
609 {
610  // Get the actual frame settings for magnetic items
612  wxCHECK( cfg, nullptr );
613  return &cfg->m_MagneticItems;
614 }
615 
616 
617 const BOX2I FOOTPRINT_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
618 {
619  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
620 
621  if( footprint )
622  {
623  bool hasGraphicalItem = footprint->Pads().size() || footprint->Zones().size();
624 
625  if( !hasGraphicalItem )
626  {
627  for( const BOARD_ITEM* item : footprint->GraphicalItems() )
628  {
629  if( item->Type() == PCB_FP_TEXT_T )
630  continue;
631 
632  hasGraphicalItem = true;
633  break;
634  }
635  }
636 
637  if( hasGraphicalItem )
638  {
639  return footprint->GetBoundingBox( false, false );
640  }
641  else
642  {
643  BOX2I newFootprintBB( { 0, 0 }, { 0, 0 } );
644  newFootprintBB.Inflate( Millimeter2iu( 12 ) );
645  return newFootprintBB;
646  }
647  }
648 
649  return GetBoardBoundingBox( false );
650 }
651 
652 
654 {
655  if( IsContentModified() )
656  {
657  wxString footprintName = GetBoard()->GetFirstFootprint()->GetReference();
658  wxString msg = _( "Save changes to '%s' before closing?" );
659 
660  if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
661  [&]() -> bool
662  {
663  return SaveFootprint( GetBoard()->GetFirstFootprint() );
664  } ) )
665  {
666  return false;
667  }
668  }
669 
670  if( doClose )
671  {
672  GetInfoBar()->ShowMessageFor( wxEmptyString, 1 );
673  Clear_Pcb( false );
674  UpdateTitle();
675  }
676 
677  return true;
678 }
679 
680 
681 bool FOOTPRINT_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
682 {
683  if( IsContentModified() )
684  {
685  // Shutdown blocks must be determined and vetoed as early as possible
687  aEvent.GetId() == wxEVT_QUERY_END_SESSION )
688  {
689  aEvent.Veto();
690  return false;
691  }
692 
693  wxString footprintName = GetBoard()->GetFirstFootprint()->GetFPID().GetLibItemName();
694 
695  if( IsCurrentFPFromBoard() )
696  footprintName = GetBoard()->GetFirstFootprint()->GetReference();
697 
698  wxString msg = _( "Save changes to '%s' before closing?" );
699 
700  if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
701  [&]() -> bool
702  {
703  return SaveFootprint( GetBoard()->GetFirstFootprint() );
704  } ) )
705  {
706  aEvent.Veto();
707  return false;
708  }
709  }
710 
711  return PCB_BASE_EDIT_FRAME::canCloseWindow( aEvent );
712 }
713 
714 
716 {
717  // No more vetos
718  GetCanvas()->SetEventDispatcher( nullptr );
719  GetCanvas()->StopDrawing();
720 
721  // Do not show the layer manager during closing to avoid flicker
722  // on some platforms (Windows) that generate useless redraw of items in
723  // the Layer Manager
724  m_auimgr.GetPane( wxT( "LayersManager" ) ).Show( false );
725  m_auimgr.GetPane( wxT( "SelectionFilter" ) ).Show( false );
726 
727  Clear_Pcb( false );
728 
730 
731  if( mgr->IsProjectOpen() && wxFileName::IsDirWritable( Prj().GetProjectPath() ) )
732  {
733  GFootprintList.WriteCacheToFile( Prj().GetProjectPath() + wxT( "fp-info-cache" ) );
734  }
735 
736  mgr->FlushAndRelease( GetSettings() );
737 }
738 
739 
740 void FOOTPRINT_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
741 {
742  Kiway().OnKiCadExit();
743 }
744 
745 
746 void FOOTPRINT_EDIT_FRAME::CloseFootprintEditor( wxCommandEvent& Event )
747 {
748  Close();
749 }
750 
751 
753 {
755 
756  aEvent.Enable( frame && frame->GetBoard()->GetFirstFootprint() != nullptr );
757 }
758 
759 
761 {
763 
764  FOOTPRINT* editorFootprint = GetBoard()->GetFirstFootprint();
765  bool canInsert = frame && editorFootprint && editorFootprint->GetLink() == niluuid;
766 
767  // If the source was deleted, the footprint can inserted but not updated in the board.
768  if( frame && editorFootprint && editorFootprint->GetLink() != niluuid )
769  {
770  BOARD* mainpcb = frame->GetBoard();
771  canInsert = true;
772 
773  // search if the source footprint was not deleted:
774  for( FOOTPRINT* candidate : mainpcb->Footprints() )
775  {
776  if( editorFootprint->GetLink() == candidate->m_Uuid )
777  {
778  canInsert = false;
779  break;
780  }
781  }
782  }
783 
784  aEvent.Enable( canInsert );
785 }
786 
787 
789 {
790  // call my base class
792 
793  // We have 2 panes to update.
794  // For some obscure reason, the AUI manager hides the first modified pane.
795  // So force show panes
796  wxAuiPaneInfo& tree_pane_info = m_auimgr.GetPane( m_treePane );
797  bool tree_shown = tree_pane_info.IsShown();
798  tree_pane_info.Caption( _( "Libraries" ) );
799 
800  wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_appearancePanel );
801  bool lm_shown = lm_pane_info.IsShown();
802  lm_pane_info.Caption( _( "Appearance" ) );
803  wxAuiPaneInfo& sf_pane_info = m_auimgr.GetPane( m_selectionFilterPanel );
804  sf_pane_info.Caption( _( "Selection Filter" ) );
805 
806  // update the layer manager
810 
811  // Now restore the visibility:
812  lm_pane_info.Show( lm_shown );
813  tree_pane_info.Show( tree_shown );
814  m_auimgr.Update();
815 
816  UpdateTitle();
817 }
818 
819 
821 {
823  Update3DView( true, true );
825 
826  if( !GetTitle().StartsWith( wxT( "*" ) ) )
827  UpdateTitle();
828 }
829 
830 
832 {
833  wxString title;
834  LIB_ID fpid = GetLoadedFPID();
835  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
836  bool writable = true;
837 
838  if( IsCurrentFPFromBoard() )
839  {
840  if( IsContentModified() )
841  title = wxT( "*" );
842 
843  title += footprint->GetReference();
844  title += wxS( " " ) + wxString::Format( _( "[from %s]" ), Prj().GetProjectName()
845  + wxT( "." )
846  + PcbFileExtension );
847  }
848  else if( fpid.IsValid() )
849  {
850  try
851  {
852  writable = Prj().PcbFootprintLibs()->IsFootprintLibWritable( fpid.GetLibNickname() );
853  }
854  catch( const IO_ERROR& )
855  {
856  // best efforts...
857  }
858 
859  // Note: don't used GetLoadedFPID(); footprint name may have been edited
860  if( IsContentModified() )
861  title = wxT( "*" );
862 
863  title += FROM_UTF8( footprint->GetFPID().Format().c_str() );
864 
865  if( !writable )
866  title += wxS( " " ) + _( "[Read Only]" );
867  }
868  else if( !fpid.GetLibItemName().empty() )
869  {
870  // Note: don't used GetLoadedFPID(); footprint name may have been edited
871  if( IsContentModified() )
872  title = wxT( "*" );
873 
874  title += FROM_UTF8( footprint->GetFPID().GetLibItemName().c_str() );
875  title += wxS( " " ) + _( "[Unsaved]" );
876  }
877  else
878  {
879  title = _( "[no footprint loaded]" );
880  }
881 
882  title += wxT( " \u2014 " ) + _( "Footprint Editor" );
883 
884  SetTitle( title );
885 }
886 
887 
889 {
891 }
892 
893 
895 {
896  GetCanvas()->UpdateColors();
899  UpdateTitle();
900 }
901 
902 
904 {
905  FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
906 
907  WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
908 
909  if( GFootprintList.GetCount() == 0 )
910  GFootprintList.ReadCacheFromFile( Prj().GetProjectPath() + wxT( "fp-info-cache" ) );
911 
912  GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
913  progressReporter.Show( false );
914 
917 
919  auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
920 
921  adapter->AddLibraries();
922 }
923 
924 
926 {
927  FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
928  auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
929  LIB_ID target = GetTargetFPID();
930  bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() );
931 
932  // Sync FOOTPRINT_INFO list to the libraries on disk
933  if( aProgress )
934  {
935  WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 2 );
936  GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
937  progressReporter.Show( false );
938  }
939  else
940  {
941  GFootprintList.ReadFootprintFiles( fpTable, nullptr, nullptr );
942  }
943 
944  // Sync the LIB_TREE to the FOOTPRINT_INFO list
945  adapter->Sync();
946 
948  m_treePane->GetLibTree()->Regenerate( true );
949 
950  if( target.IsValid() )
951  {
952  if( adapter->FindItem( target ) )
953  {
954  if( targetSelected )
955  m_treePane->GetLibTree()->SelectLibId( target );
956  else
957  m_treePane->GetLibTree()->CenterLibId( target );
958  }
959  else
960  {
961  // Try to focus on parent
962  target.SetLibItemName( wxEmptyString );
963  m_treePane->GetLibTree()->CenterLibId( target );
964  }
965  }
966 }
967 
968 
970 {
971  LIB_ID target = GetTargetFPID();
972 
973  m_treePane->GetLibTree()->Regenerate( true );
974 
975  if( target.IsValid() )
976  m_treePane->GetLibTree()->CenterLibId( target );
977 }
978 
979 
981 {
983 }
984 
985 
987 {
988  m_treePane->GetLibTree()->SelectLibId( aLibID );
989 }
990 
991 
993 {
995 }
996 
997 
999  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
1000 {
1001  wxTreebook* book = aParent->GetTreebook();
1002 
1003  book->AddPage( new wxPanel( book ), _( "Footprint Editor" ) );
1004  book->AddSubPage( new PANEL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
1005  book->AddSubPage( new PANEL_EDIT_OPTIONS( this, aParent ), _( "Editing Options" ) );
1006  book->AddSubPage( new PANEL_FP_EDITOR_COLOR_SETTINGS( this, book ), _( "Colors" ) );
1007  book->AddSubPage( new PANEL_FP_EDITOR_DEFAULTS( this, aParent ), _( "Default Values" ) );
1008 
1009  aHotkeysPanel->AddHotKeys( GetToolManager() );
1010 }
1011 
1012 
1014 {
1015  // Create the manager and dispatcher & route draw panel events to the dispatcher
1017  m_toolManager->SetEnvironment( GetBoard(), GetCanvas()->GetView(),
1018  GetCanvas()->GetViewControls(), config(), this );
1019  m_actions = new PCB_ACTIONS();
1021 
1023 
1032  m_toolManager->RegisterTool( new PCB_CONTROL ); // copy/paste
1041 
1042  m_toolManager->GetTool<PCB_SELECTION_TOOL>()->SetIsFootprintEditor( true );
1043  m_toolManager->GetTool<EDIT_TOOL>()->SetIsFootprintEditor( true );
1044  m_toolManager->GetTool<PAD_TOOL>()->SetIsFootprintEditor( true );
1045  m_toolManager->GetTool<DRAWING_TOOL>()->SetIsFootprintEditor( true );
1046  m_toolManager->GetTool<PCB_POINT_EDITOR>()->SetIsFootprintEditor( true );
1047  m_toolManager->GetTool<PCB_CONTROL>()->SetIsFootprintEditor( true );
1048  m_toolManager->GetTool<PCB_PICKER_TOOL>()->SetIsFootprintEditor( true );
1049  m_toolManager->GetTool<POSITION_RELATIVE_TOOL>()->SetIsFootprintEditor( true );
1050  m_toolManager->GetTool<GROUP_TOOL>()->SetIsFootprintEditor( true );
1051  m_toolManager->GetTool<SCRIPTING_TOOL>()->SetIsFootprintEditor( true );
1052 
1053  m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
1055 
1056  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
1057 }
1058 
1059 
1061 {
1063 
1065  PCB_EDITOR_CONDITIONS cond( this );
1066 
1067  wxASSERT( mgr );
1068 
1069 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
1070 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
1071 
1072  auto haveFootprintCond =
1073  [this]( const SELECTION& )
1074  {
1075  return GetBoard()->GetFirstFootprint() != nullptr;
1076  };
1077 
1078  auto footprintTargettedCond =
1079  [this]( const SELECTION& )
1080  {
1081  return !GetTargetFPID().GetLibItemName().empty();
1082  };
1083 
1084  mgr->SetConditions( ACTIONS::saveAs, ENABLE( footprintTargettedCond ) );
1087 
1088  mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
1089  mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
1090 
1096 
1097  mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
1098  mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );
1101  mgr->SetConditions( ACTIONS::doDelete, ENABLE( cond.HasItems() ) );
1102  mgr->SetConditions( ACTIONS::duplicate, ENABLE( cond.HasItems() ) );
1103  mgr->SetConditions( ACTIONS::selectAll, ENABLE( cond.HasItems() ) );
1104 
1105  auto haveAtLeastOneGroupCond =
1106  []( const SELECTION& aSel )
1107  {
1108  for( EDA_ITEM* item : aSel )
1109  {
1110  if( item->Type() == PCB_GROUP_T )
1111  return true;
1112  }
1113 
1114  return false;
1115  };
1116 
1119  mgr->SetConditions( PCB_ACTIONS::mirror, ENABLE( cond.HasItems() ) );
1121  mgr->SetConditions( PCB_ACTIONS::ungroup, ENABLE( haveAtLeastOneGroupCond ) );
1122 
1126 
1129 
1132 
1133 
1134  auto highContrastCond =
1135  [this]( const SELECTION& )
1136  {
1138  };
1139 
1140  auto boardFlippedCond =
1141  [this]( const SELECTION& )
1142  {
1143  return GetCanvas()->GetView()->IsMirroredX();
1144  };
1145 
1146  auto footprintTreeCond =
1147  [this](const SELECTION& )
1148  {
1149  return IsSearchTreeShown();
1150  };
1151 
1152  auto layerManagerCond =
1153  [this]( const SELECTION& )
1154  {
1155  return m_auimgr.GetPane( "LayersManager" ).IsShown();
1156  };
1157 
1158  mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
1159  mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
1160  mgr->SetConditions( PCB_ACTIONS::showFootprintTree, CHECK( footprintTreeCond ) );
1161  mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) );
1162 
1163  mgr->SetConditions( ACTIONS::print, ENABLE( haveFootprintCond ) );
1164  mgr->SetConditions( PCB_ACTIONS::exportFootprint, ENABLE( haveFootprintCond ) );
1165  mgr->SetConditions( PCB_ACTIONS::footprintProperties, ENABLE( haveFootprintCond ) );
1166  mgr->SetConditions( PCB_ACTIONS::cleanupGraphics, ENABLE( haveFootprintCond ) );
1167  mgr->SetConditions( PCB_ACTIONS::placeImportedGraphics, ENABLE( haveFootprintCond ) );
1168 
1169 
1170 // Only enable a tool if the part is edtable
1171 #define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, \
1172  ACTION_CONDITIONS().Enable( haveFootprintCond ).Check( cond.CurrentTool( action ) ) )
1173 
1186 
1187 #undef CURRENT_EDIT_TOOL
1188 #undef ENABLE
1189 #undef CHECK
1190 }
1191 
1192 
1194 {
1196 
1197  // Be sure the axis are enabled
1198  GetCanvas()->GetGAL()->SetAxesEnabled( true );
1199 
1200  UpdateView();
1201 
1202  // Ensure the m_Layers settings are using the canvas type:
1204 }
1205 
1206 
1207 void FOOTPRINT_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1208 {
1209  PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1210 
1212  GetCanvas()->ForceRefresh();
1213 
1215 
1216  if( aEnvVarsChanged )
1217  SyncLibraryTree( true );
1218 
1219  Layout();
1220  SendSizeEvent();
1221 }
1222 
1223 
1224 void FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng( wxCommandEvent& event )
1225 {
1226  wxString fullFileName;
1227 
1228  LIB_ID id = GetLoadedFPID();
1229 
1230  if( id.empty() )
1231  {
1232  wxMessageBox( _( "No footprint selected." ) );
1233  return;
1234  }
1235 
1236  wxFileName fn( id.GetLibItemName() );
1237  fn.SetExt( wxT( "png" ) );
1238 
1239  wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );
1240 
1241  wxFileDialog dlg( this, _( "Footprint Image File Name" ), projectPath,
1242  fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1243 
1244  if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
1245  return;
1246 
1247  // calling wxYield is mandatory under Linux, after closing the file selector dialog
1248  // to refresh the screen before creating the PNG or JPEG image from screen
1249  wxYield();
1250  SaveCanvasImageToFile( this, dlg.GetPath() );
1251 }
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:139
void DisplayBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr)
Add all items from the current board to the VIEW, so they can be displayed by GAL.
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.
bool CanCloseFPFromBoard(bool doClose)
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:158
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:375
void OnKiCadExit()
Definition: kiway.cpp:636
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)
void SetAuiPaneSize(wxAuiManager &aManager, wxAuiPaneInfo &aPane, int aWidth, int aHeight)
Sets the size of an AUI pane, working around http://trac.wxwidgets.org/ticket/13180.
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:143
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:321
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 OnLanguageChanged()
Update the panel contents from the application and board models.
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:140
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:393
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
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:347
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
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
Definition: infobar.cpp:128
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:159
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
static TOOL_ACTION placeText
Definition: pcb_actions.h:144
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:169
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:175
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:318
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.
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:234
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:141
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:172
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:195
#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
int GetTabIndex() const
Set the current notebook tab.
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:214
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:241
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:142
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:151
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:191
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:736
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:99
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:291
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnSelectDisplayMode EVT_CHOICE(ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice) EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER
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:762
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1293
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:204
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