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-2019 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"
35 #include <bitmaps.h>
36 #include <board.h>
37 #include <footprint.h>
38 #include <confirm.h>
43 #include <footprint_edit_frame.h>
45 #include <footprint_info_impl.h>
46 #include <footprint_tree_pane.h>
47 #include <footprint_viewer_frame.h>
48 #include <fp_lib_table.h>
50 #include <kiface_i.h>
51 #include <kiplatform/app.h>
52 #include <kiway.h>
53 #include <panel_hotkeys_editor.h>
54 #include <pcb_draw_panel_gal.h>
55 #include <pcb_edit_frame.h>
56 #include <pcbnew.h>
57 #include <pcbnew_id.h>
58 #include <pgm_base.h>
59 #include <project.h>
61 #include <tool/action_toolbar.h>
62 #include <tool/common_control.h>
63 #include <tool/common_tools.h>
64 #include <tool/selection.h>
65 #include <tool/tool_dispatcher.h>
66 #include <tool/tool_manager.h>
67 #include <tool/zoom_tool.h>
69 #include <tools/pcb_viewer_tools.h>
70 #include <tools/group_tool.h>
73 #include <widgets/infobar.h>
74 #include <widgets/lib_tree.h>
75 #include <widgets/paged_dialog.h>
79 
80 
81 BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
82  EVT_MENU( wxID_CLOSE, FOOTPRINT_EDIT_FRAME::CloseFootprintEditor )
83  EVT_MENU( wxID_EXIT, FOOTPRINT_EDIT_FRAME::OnExitKiCad )
84 
86 
89 
91 
94 
95  // Horizontal toolbar
98 
99  // UI update events.
106 
107 END_EVENT_TABLE()
108 
109 
110 FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
111  EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend ) :
112  PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_FOOTPRINT_EDITOR, wxEmptyString,
113  wxDefaultPosition, wxDefaultSize,
114  KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() )
115 {
116  m_showBorderAndTitleBlock = false; // true to show the frame references
117  m_canvasType = aBackend;
118  m_aboutTitle = _( "KiCad Footprint Editor" );
119  m_selLayerBox = nullptr;
120  m_settings = nullptr;
121 
122  // Give an icon
123  wxIcon icon;
124  wxIconBundle icon_bundle;
125 
126  icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
127  icon_bundle.AddIcon( icon );
128  icon.CopyFromBitmap( KiBitmap( icon_modedit_32_xpm ) );
129  icon_bundle.AddIcon( icon );
130  icon.CopyFromBitmap( KiBitmap( icon_modedit_16_xpm ) );
131  icon_bundle.AddIcon( icon );
132 
133  SetIcons( icon_bundle );
134 
135  // Create GAL canvas
136  if( aBackend == EDA_DRAW_PANEL_GAL::GAL_TYPE_UNKNOWN )
137  m_canvasType = loadCanvasTypeSetting();
138  else
139  m_canvasType = aBackend;
140 
141  PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
142  GetGalDisplayOptions(), m_canvasType );
143  SetCanvas( drawPanel );
144  SetBoard( new BOARD() );
145 
146 
147  // This board will only be used to hold a footprint for editing
149 
150  // In Footprint Editor, the default net clearance is not known (it depends on the actual
151  // board). So we do not show the default clearance, by setting it to 0. The footprint or
152  // pad specific clearance will be shown.
154 
155  // Don't show the default board solder mask clearance in the footprint editor. Only the
156  // footprint or pad clearance setting should be shown if it is not 0.
158 
159  // restore the last footprint from the project, if any
160  restoreLastFootprint();
161 
162  // Ensure all layers and items are visible:
163  // In footprint editor, some layers have no meaning or cannot be used, but we show all of
164  // them, at least to be able to edit a bad layer
166 
167  // However the "no net" mark on pads is useless, because there are no nets in footprint
168  // editor: make it non visible.
170 
171  GetGalDisplayOptions().m_axesEnabled = true;
172 
173  // In Footprint Editor, set the default paper size to A4 for plot/print
174  SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) );
175  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
176 
177  // Create the manager and dispatcher & route draw panel events to the dispatcher
178  setupTools();
179  setupUIConditions();
180 
181  initLibraryTree();
182  m_treePane = new FOOTPRINT_TREE_PANE( this );
183 
184  ReCreateMenuBar();
185  ReCreateHToolbar();
186  ReCreateVToolbar();
187  ReCreateOptToolbar();
188 
189  m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
190  m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas(), true );
191 
192  // LoadSettings() *after* creating m_LayersManager, because LoadSettings() initialize
193  // parameters in m_LayersManager
194  // NOTE: KifaceSettings() will return PCBNEW_SETTINGS if we started from pcbnew
195  LoadSettings( GetSettings() );
196 
197  // Must be set after calling LoadSettings() to be sure these parameters are not dependent
198  // on what is read in stored settings. Enable one internal layer, because footprints
199  // support keepout areas that can be on internal layers only (therefore on the first internal
200  // layer). This is needed to handle these keepout in internal layers only.
202  GetBoard()->SetEnabledLayers( GetBoard()->GetEnabledLayers().set( In1_Cu ) );
203  GetBoard()->SetVisibleLayers( GetBoard()->GetEnabledLayers() );
204  GetBoard()->SetLayerName( In1_Cu, _( "Inner layers" ) );
205 
206  SetActiveLayer( F_SilkS );
207 
208  m_auimgr.SetManagedWindow( this );
209 
210  CreateInfoBar();
211 
212  unsigned int auiFlags = wxAUI_MGR_DEFAULT;
213 #if !defined( _WIN32 )
214  // Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds
215  // of graphical glitches
216  auiFlags |= wxAUI_MGR_LIVE_RESIZE;
217 #endif
218  m_auimgr.SetFlags( auiFlags );
219 
220  // Rows; layers 4 - 6
221  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
222  .Top().Layer( 6 ) );
223  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
224  .Bottom().Layer( 6 ) );
225 
226  // Columns; layers 1 - 3
227  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
228  .Left().Layer( 3 ) );
229  m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "Footprints" )
230  .Left().Layer(2)
231  .Caption( _( "Libraries" ) )
232  .MinSize( 250, 400 ).Resizable() );
233 
234  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
235  .Right().Layer(2) );
236 
237  m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( "LayersManager" )
238  .Right().Layer( 3 )
239  .Caption( _( "Appearance" ) ).PaneBorder( false )
240  .MinSize( 180, -1 ).BestSize( 180, -1 ) );
241  m_auimgr.AddPane( m_selectionFilterPanel, EDA_PANE().Palette().Name( "SelectionFilter" )
242  .Right().Layer( 3 ).Position( 2 )
243  .Caption( _( "Selection Filter" ) ).PaneBorder( false )
244  .MinSize( 160, -1 ).BestSize( m_selectionFilterPanel->GetBestSize() ) );
245 
246  // Center
247  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
248  .Center() );
249 
250  // The selection filter doesn't need to grow in the vertical direction when docked
251  m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
252 
253  ActivateGalCanvas();
254 
255  m_auimgr.GetArtProvider()->SetColour( wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR,
256  wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) );
257  m_auimgr.GetArtProvider()->SetColour( wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR,
258  wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) );
259 
260  FinishAUIInitialization();
261 
262  if( m_settings->m_LibWidth > 0 )
263  {
264  wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" );
265 
266  // wxAUI hack: force width by setting MinSize() and then Fixed()
267  // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
268  treePane.MinSize( m_settings->m_LibWidth, -1 );
269  treePane.Fixed();
270  m_auimgr.Update();
271 
272  // now make it resizable again
273  treePane.Resizable();
274  m_auimgr.Update();
275 
276  // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
277  // back to minimum.
278  treePane.MinSize( 250, -1 );
279  }
280 
281  // Apply saved visibility stuff at the end
282  FOOTPRINT_EDITOR_SETTINGS* cfg = GetSettings();
283  m_appearancePanel->SetUserLayerPresets( cfg->m_LayerPresets );
284  m_appearancePanel->ApplyLayerPreset( cfg->m_ActiveLayerPreset );
285 
286  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
287  UpdateTitle();
288  setupUnits( GetSettings() );
289 
290  // Default shutdown reason until a file is loaded
291  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Footprint changes are unsaved" ) );
292 
293  // Ensure the window is on top
294  Raise();
295  Show( true );
296 }
297 
298 
300 {
301  // Shutdown all running tools
302  if( m_toolManager )
304 
305  // save the footprint in the PROJECT
307 
308  delete m_selectionFilterPanel;
309  delete m_appearancePanel;
310 }
311 
312 
314 {
315  return GetScreen() && GetScreen()->IsModify() && GetBoard() && GetBoard()->GetFirstFootprint();
316 }
317 
318 
320 {
321  return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
322 }
323 
324 
326 {
327  // switches currently used canvas (Cairo / OpenGL).
328  PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
329 
330  GetCanvas()->GetGAL()->SetAxesEnabled( true );
331 
332  // The base class method *does not reinit* the layers manager. We must upate the layer
333  // widget to match board visibility states, both layers and render columns, and and some
334  // settings dependent on the canvas.
336 }
337 
338 
340 {
341  SyncLibraryTree( true );
342  GetCanvas()->ForceRefresh();
343 }
344 
345 
347 {
348  wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
349  treePane.Show( !IsSearchTreeShown() );
350  m_auimgr.Update();
351 }
352 
353 
355 {
356  return m_auimgr.GetPane( m_treePane ).IsShown();
357 }
358 
359 
361 {
362  return GetBoard()->GetFirstFootprint();
363 }
364 
365 
367 {
369 }
370 
371 
373 {
375 }
376 
377 
379 {
380  LIB_ID id = GetTreeFPID();
381 
382  if( id.GetLibNickname().empty() )
383  return GetLoadedFPID();
384 
385  return id;
386 }
387 
388 
390 {
391  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
392 
393  if( footprint )
394  return LIB_ID( footprint->GetFPID().GetLibNickname(), m_footprintNameWhenLoaded );
395  else
396  return LIB_ID();
397 }
398 
399 
401 {
402  if( GetBoard()->GetFirstFootprint() )
404 
405  GetScreen()->ClrModify();
406 }
407 
408 
410 {
411  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
412 
413  return ( footprint && footprint->GetLink() != niluuid );
414 }
415 
416 
418 {
419  LIB_ID id = GetLoadedFPID();
420 
421  if( id.IsValid() )
422  {
424  Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME, id.GetLibItemName() );
425  }
426 }
427 
428 
430 {
431  const wxString& footprintName = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME );
432  const wxString& libNickname = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_LIB_NICKNAME );
433 
434  if( libNickname.Length() && footprintName.Length() )
435  {
436  LIB_ID id;
437  id.SetLibNickname( libNickname );
438  id.SetLibItemName( footprintName );
439 
440  FOOTPRINT* footprint = loadFootprint( id );
441 
442  if( footprint )
443  AddFootprintToBoard( footprint );
444  }
445 }
446 
447 
449 {
450  m_revertModule.reset( (FOOTPRINT*) aFootprint->Clone() );
451 
453 
455 
456  if( IsCurrentFPFromBoard() )
457  {
458  wxString msg;
459  msg.Printf( _( "Editing %s from board. Saving will update the board only." ),
460  aFootprint->GetReference() );
461 
463  GetInfoBar()->ShowMessage( msg, wxICON_INFORMATION );
464  }
465 
466  UpdateMsgPanel();
467 }
468 
469 
471 {
473 }
474 
475 
477 {
478  return GetBoard()->GetDesignSettings();
479 }
480 
481 
483 {
484  wxFAIL_MSG( "Plotting not supported in Footprint Editor" );
485 
487 }
488 
489 
491 {
492  wxFAIL_MSG( "Plotting not supported in Footprint Editor" );
493 }
494 
495 
497 {
498  if( !m_settings )
499  m_settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
500 
501  return m_settings;
502 }
503 
504 
506 {
507  return m_settings ? m_settings
508  : Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
509 }
510 
511 
513 {
514  // aCfg will be the PCBNEW_SETTINGS
516 
518 
520 
522 
525 }
526 
527 
529 {
531 
532  // aCfg will be the PCBNEW_SETTINGS
534 
536 
539  cfg->m_LibWidth = m_treePane->GetSize().x;
543 
545 }
546 
547 
549 {
550  wxString currentTheme = GetFootprintEditorSettings()->m_ColorTheme;
551  return Pgm().GetSettingsManager().GetColorSettings( currentTheme );
552 }
553 
554 
556 {
557  // Get the actual frame settings for magnetic items
559  wxCHECK( cfg, nullptr );
560  return &cfg->m_MagneticItems;
561 }
562 
563 
564 const BOX2I FOOTPRINT_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
565 {
566  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
567 
568  if( footprint )
569  {
570  bool hasGraphicalItem = footprint->Pads().size() || footprint->Zones().size();
571 
572  if( !hasGraphicalItem )
573  {
574  for( const BOARD_ITEM* item : footprint->GraphicalItems() )
575  {
576  if( item->Type() == PCB_FP_TEXT_T )
577  continue;
578 
579  hasGraphicalItem = true;
580  break;
581  }
582  }
583 
584  if( hasGraphicalItem )
585  {
586  return footprint->GetBoundingBox( false, false );
587  }
588  else
589  {
590  BOX2I newFootprintBB( { 0, 0 }, { 0, 0 } );
591  newFootprintBB.Inflate( Millimeter2iu( 12 ) );
592  return newFootprintBB;
593  }
594  }
595 
596  return GetBoardBoundingBox( false );
597 }
598 
599 
600 bool FOOTPRINT_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
601 {
602  if( IsContentModified() )
603  {
604  // Shutdown blocks must be determined and vetoed as early as possible
605  if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION )
606  {
607  aEvent.Veto();
608  return false;
609  }
610 
611  wxString footprintName = GetBoard()->GetFirstFootprint()->GetFPID().GetLibItemName();
612  wxString msg = _( "Save changes to \"%s\" before closing?" );
613 
614  if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
615  [&]() -> bool
616  {
617  return SaveFootprint( GetBoard()->GetFirstFootprint() );
618  } ) )
619  {
620  aEvent.Veto();
621  return false;
622  }
623  }
624 
625  return true;
626 }
627 
628 
630 {
631  // No more vetos
633  GetCanvas()->StopDrawing();
634 
635  // Do not show the layer manager during closing to avoid flicker
636  // on some platforms (Windows) that generate useless redraw of items in
637  // the Layer Manger
638  m_auimgr.GetPane( "LayersManager" ).Show( false );
639  m_auimgr.GetPane( "SelectionFilter" ).Show( false );
640 
641  Clear_Pcb( false );
642 
644 
645  if( mgr->IsProjectOpen() && wxFileName::IsDirWritable( Prj().GetProjectPath() ) )
646  {
647  GFootprintList.WriteCacheToFile( Prj().GetProjectPath() + "fp-info-cache" );
648  }
649 
650  mgr->FlushAndRelease( GetSettings() );
651 }
652 
653 
654 void FOOTPRINT_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
655 {
656  Kiway().OnKiCadExit();
657 }
658 
659 
660 void FOOTPRINT_EDIT_FRAME::CloseFootprintEditor( wxCommandEvent& Event )
661 {
662  Close();
663 }
664 
665 
666 void FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected( wxUpdateUIEvent& aEvent )
667 {
668  aEvent.Enable( GetBoard()->GetFirstFootprint() != NULL );
669 }
670 
671 
673 {
675 
676  aEvent.Enable( frame && frame->GetBoard()->GetFirstFootprint() != NULL );
677 }
678 
679 
681 {
683 
684  FOOTPRINT* editorFootprint = GetBoard()->GetFirstFootprint();
685  bool canInsert = frame && editorFootprint && editorFootprint->GetLink() == niluuid;
686 
687  // If the source was deleted, the footprint can inserted but not updated in the board.
688  if( frame && editorFootprint && editorFootprint->GetLink() != niluuid )
689  {
690  BOARD* mainpcb = frame->GetBoard();
691  canInsert = true;
692 
693  // search if the source footprint was not deleted:
694  for( FOOTPRINT* candidate : mainpcb->Footprints() )
695  {
696  if( editorFootprint->GetLink() == candidate->m_Uuid )
697  {
698  canInsert = false;
699  break;
700  }
701  }
702  }
703 
704  aEvent.Enable( canInsert );
705 }
706 
707 
709 {
710  // call my base class
712 
713  // We have 2 panes to update.
714  // For some obscure reason, the AUI manager hides the first modified pane.
715  // So force show panes
716  wxAuiPaneInfo& tree_pane_info = m_auimgr.GetPane( m_treePane );
717  bool tree_shown = tree_pane_info.IsShown();
718  tree_pane_info.Caption( _( "Libraries" ) );
719 
720  wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_appearancePanel );
721  bool lm_shown = lm_pane_info.IsShown();
722  lm_pane_info.Caption( _( "Appearance" ) );
723 
724  // update the layer manager
727 
728  // Now restore the visibility:
729  lm_pane_info.Show( lm_shown );
730  tree_pane_info.Show( tree_shown );
731  m_auimgr.Update();
732 }
733 
734 
736 {
738  Update3DView( true );
740 
741  if( !GetTitle().StartsWith( "*" ) )
742  UpdateTitle();
743 }
744 
745 
747 {
748  wxString title;
749  LIB_ID fpid = GetLoadedFPID();
750  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
751  bool writable = true;
752 
753  if( IsCurrentFPFromBoard() )
754  {
755  title = wxString::Format( _( "%s%s [from %s.%s]" ) + wxT( " \u2014 " ),
756  IsContentModified() ? "*" : "",
757  footprint->GetReference(),
758  Prj().GetProjectName(),
760  }
761  else if( fpid.IsValid() )
762  {
763  try
764  {
765  writable = Prj().PcbFootprintLibs()->IsFootprintLibWritable( fpid.GetLibNickname() );
766  }
767  catch( const IO_ERROR& )
768  {
769  // best efforts...
770  }
771 
772  // Note: don't used GetLoadedFPID(); footprint name may have been edited
773  title += wxString::Format( wxT( "%s%s %s\u2014 " ),
774  IsContentModified() ? "*" : "",
775  FROM_UTF8( footprint->GetFPID().Format().c_str() ),
776  writable ? "" : _( "[Read Only]" ) + wxS( " " ) );
777  }
778  else if( !fpid.GetLibItemName().empty() )
779  {
780  // Note: don't used GetLoadedFPID(); footprint name may have been edited
781  title += wxString::Format( wxT( "%s%s %s \u2014 " ),
782  IsContentModified() ? "*" : "",
783  FROM_UTF8( footprint->GetFPID().GetLibItemName().c_str() ),
784  _( "[Unsaved]" ) );
785  }
786 
787  title += _( "Footprint Editor" );
788 
789  SetTitle( title );
790 }
791 
792 
794 {
796 }
797 
798 
800 {
801  GetCanvas()->UpdateColors();
804  UpdateTitle();
805 }
806 
807 
809 {
810  FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
811 
812  WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
813  if( GFootprintList.GetCount() == 0 )
814  {
815  GFootprintList.ReadCacheFromFile( Prj().GetProjectPath() + "fp-info-cache" );
816  }
817  GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter );
818  progressReporter.Show( false );
819 
822 
824  auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
825 
826  adapter->AddLibraries();
827 }
828 
829 
831 {
832  FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
833  auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
834  LIB_ID target = GetTargetFPID();
835  bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() );
836 
837  // Sync FOOTPRINT_INFO list to the libraries on disk
838  if( aProgress )
839  {
840  WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 2 );
841  GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter );
842  progressReporter.Show( false );
843  }
844  else
845  {
847  }
848 
849  // Sync the LIB_TREE to the FOOTPRINT_INFO list
850  adapter->Sync();
851 
853  m_treePane->GetLibTree()->Regenerate( true );
854 
855  if( target.IsValid() )
856  {
857  if( adapter->FindItem( target ) )
858  {
859  if( targetSelected )
860  m_treePane->GetLibTree()->SelectLibId( target );
861  else
862  m_treePane->GetLibTree()->CenterLibId( target );
863  }
864  else
865  {
866  // Try to focus on parent
867  target.SetLibItemName( wxEmptyString );
868  m_treePane->GetLibTree()->CenterLibId( target );
869  }
870  }
871 }
872 
873 
875 {
876  LIB_ID target = GetTargetFPID();
877 
878  m_treePane->GetLibTree()->Regenerate( true );
879 
880  if( target.IsValid() )
881  m_treePane->GetLibTree()->CenterLibId( target );
882 }
883 
884 
886 {
888 }
889 
890 
892 {
893  m_treePane->GetLibTree()->SelectLibId( aLibID );
894 }
895 
896 
898 {
900 }
901 
902 
904 {
906 }
907 
908 
910  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
911 {
912  wxTreebook* book = aParent->GetTreebook();
913 
914  book->AddPage( new wxPanel( book ), _( "Footprint Editor" ) );
915  book->AddSubPage( new PANEL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
916  book->AddSubPage( new PANEL_EDIT_OPTIONS( this, aParent ), _( "Editing Options" ) );
917  book->AddSubPage( new PANEL_FP_EDITOR_COLOR_SETTINGS( this, book ), _( "Colors" ) );
918  book->AddSubPage( new PANEL_FP_EDITOR_DEFAULTS( this, aParent ), _( "Default Values" ) );
919 
920  aHotkeysPanel->AddHotKeys( GetToolManager() );
921 }
922 
923 
925 {
926  // Create the manager and dispatcher & route draw panel events to the dispatcher
929  GetCanvas()->GetViewControls(), config(), this );
930  m_actions = new PCB_ACTIONS();
932 
934 
943  m_toolManager->RegisterTool( new PCB_CONTROL ); // copy/paste
951 
952  m_toolManager->GetTool<PCB_SELECTION_TOOL>()->SetIsFootprintEditor( true );
953  m_toolManager->GetTool<EDIT_TOOL>()->SetIsFootprintEditor( true );
954  m_toolManager->GetTool<PAD_TOOL>()->SetIsFootprintEditor( true );
955  m_toolManager->GetTool<DRAWING_TOOL>()->SetIsFootprintEditor( true );
956  m_toolManager->GetTool<PCB_POINT_EDITOR>()->SetIsFootprintEditor( true );
957  m_toolManager->GetTool<PCB_CONTROL>()->SetIsFootprintEditor( true );
958  m_toolManager->GetTool<PCB_PICKER_TOOL>()->SetIsFootprintEditor( true );
959  m_toolManager->GetTool<POSITION_RELATIVE_TOOL>()->SetIsFootprintEditor( true );
960  m_toolManager->GetTool<GROUP_TOOL>()->SetIsFootprintEditor( true );
961 
962  m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
964 
965  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
966 }
967 
968 
970 {
972 
974  PCB_EDITOR_CONDITIONS cond( this );
975 
976  wxASSERT( mgr );
977 
978 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
979 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
980 
981  auto haveFootprintCond =
982  [this]( const SELECTION& )
983  {
984  return GetBoard()->GetFirstFootprint() != nullptr;
985  };
986 
987  auto footprintTargettedCond =
988  [this] ( const SELECTION& )
989  {
990  return !GetTargetFPID().GetLibItemName().empty();
991  };
992 
993  mgr->SetConditions( ACTIONS::saveAs, ENABLE( footprintTargettedCond ) );
996 
997  mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
998  mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
999 
1005 
1006  mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
1007  mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );
1010  mgr->SetConditions( ACTIONS::doDelete, ENABLE( cond.HasItems() ) );
1011  mgr->SetConditions( ACTIONS::duplicate, ENABLE( cond.HasItems() ) );
1012  mgr->SetConditions( ACTIONS::selectAll, ENABLE( cond.HasItems() ) );
1013 
1016  mgr->SetConditions( PCB_ACTIONS::mirror, ENABLE( cond.HasItems() ) );
1019 
1023 
1026 
1027 
1028  auto highContrastCond =
1029  [this] ( const SELECTION& )
1030  {
1032  };
1033 
1034  auto boardFlippedCond =
1035  [this]( const SELECTION& )
1036  {
1037  return GetCanvas()->GetView()->IsMirroredX();
1038  };
1039 
1040  auto footprintTreeCond =
1041  [this] (const SELECTION& )
1042  {
1043  return IsSearchTreeShown();
1044  };
1045 
1046  mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
1047  mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
1048  mgr->SetConditions( PCB_ACTIONS::toggleFootprintTree, CHECK( footprintTreeCond ) );
1049 
1050  mgr->SetConditions( ACTIONS::print, ENABLE( haveFootprintCond ) );
1051  mgr->SetConditions( PCB_ACTIONS::exportFootprint, ENABLE( haveFootprintCond ) );
1052  mgr->SetConditions( PCB_ACTIONS::footprintProperties, ENABLE( haveFootprintCond ) );
1053  mgr->SetConditions( PCB_ACTIONS::cleanupGraphics, ENABLE( haveFootprintCond ) );
1054 
1055 
1056 // Only enable a tool if the part is edtable
1057 #define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, \
1058  ACTION_CONDITIONS().Enable( haveFootprintCond ).Check( cond.CurrentTool( action ) ) )
1059 
1072 
1073 #undef CURRENT_EDIT_TOOL
1074 #undef ENABLE
1075 #undef CHECK
1076 }
1077 
1078 
1080 {
1082 
1083  // Be sure the axis are enabled
1084  GetCanvas()->GetGAL()->SetAxesEnabled( true );
1085 
1086  UpdateView();
1087 
1088  // Ensure the m_Layers settings are using the canvas type:
1090 }
1091 
1092 
1093 void FOOTPRINT_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1094 {
1095  PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1096 
1098  GetCanvas()->ForceRefresh();
1099 
1101 
1102  if( aEnvVarsChanged )
1103  SyncLibraryTree( true );
1104 
1105  Layout();
1106  SendSizeEvent();
1107 }
1108 
1109 
1110 void FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng( wxCommandEvent& event )
1111 {
1112  wxString fullFileName;
1113 
1114  LIB_ID id = GetLoadedFPID();
1115 
1116  if( id.empty() )
1117  {
1118  wxMessageBox( _( "No footprint selected." ) );
1119  return;
1120  }
1121 
1122  wxFileName fn( id.GetLibItemName() );
1123  fn.SetExt( "png" );
1124 
1125  wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );
1126 
1127  wxFileDialog dlg( this, _( "Footprint Image File Name" ), projectPath,
1128  fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1129 
1130  if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
1131  return;
1132 
1133  // calling wxYield is mandatory under Linux, after closing the file selector dialog
1134  // to refresh the screen before creating the PNG or JPEG image from screen
1135  wxYield();
1136  SaveCanvasImageToFile( this, dlg.GetPath() );
1137 }
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:124
static TOOL_ACTION drawLine
Definition: pcb_actions.h:146
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:208
#define CHECK(x)
bool IsFootprintLibWritable(const wxString &aNickname)
Return true if the library given by aNickname is writable.
show a marker on pads with no nets
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
const UTF8 & GetLibItemName() const
Definition: lib_id.h:106
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:372
void OnKiCadExit()
Definition: kiway.cpp:587
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:56
void ForceRefresh()
Force a redraw.
void OnExitKiCad(wxCommandEvent &aEvent)
KIID niluuid(0)
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:513
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.
void OnUpdateLayerAlpha(wxUpdateUIEvent &aEvent) 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)
bool SaveCanvasImageToFile(EDA_DRAW_FRAME *aFrame, const wxString &aFileName, wxBitmapType aBitmapType)
Save the current view as an image file.
Definition: bitmap.cpp:179
Model changes (required full reload)
Definition: tool_base.h:81
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:75
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
APPEARANCE_CONTROLS * m_appearancePanel
AUI panel for controlling layer and object visibility and appearance.
static TOOL_ACTION drawArc
Definition: pcb_actions.h:150
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:102
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.
virtual void Update3DView(bool aReloadRequest, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
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)
void DisplayErrors(wxTopLevelWindow *aCaller=NULL)
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:99
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
void SetCopperLayerCount(int aCount)
Definition: board.cpp:441
void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:147
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:591
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:378
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:345
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:112
void AddHotKeys(TOOL_MANAGER *aToolMgr)
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:490
void SaveFootprintToBoard(wxCommandEvent &event)
static TOOL_ACTION group
Definition: pcb_actions.h:423
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:60
static TOOL_ACTION ungroup
Definition: pcb_actions.h:424
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:168
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:164
static TOOL_ACTION placeText
Definition: pcb_actions.h:151
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:164
const char * c_str() const
Definition: utf8.h:102
void OnDisplayOptionsChanged() override
bool m_axesEnabled
Fullscreen crosshair or small cross.
bool IsContentModified() override
Get if any footprints or libraries have been modified but not saved.
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:52
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:51
FOOTPRINT_LIST_IMPL GFootprintList
The global footprint info table.
Definition: pcbnew.cpp:332
PCB_DISPLAY_OPTIONS m_displayOptions
Master controller class:
Definition: tool_manager.h:52
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:82
static TOOL_ACTION measureTool
Definition: actions.h:157
FP_ZONES & Zones()
Definition: footprint.h:170
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:70
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:96
static TOOL_ACTION toggleFootprintTree
Definition: pcb_actions.h:350
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:105
Multi-thread safe progress reporter dialog, intended for use of tasks that paralleize reporting back ...
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
Gets the first footprint on the board or nullptr.
Definition: board.h:380
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.
#define NULL
LIB_TREE_NODE * GetCurrentTreeNode() const
Definition: lib_tree.cpp:166
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
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:143
Handle actions that are shared between different frames in PcbNew.
Definition: pcb_control.h:45
static TOOL_ACTION exportFootprint
Definition: pcb_actions.h:370
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:473
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:147
static TOOL_ACTION save
Definition: actions.h:54
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...
FOOTPRINTS & Footprints()
Definition: board.h:303
Non-active layers are shown normally (no high-contrast mode)
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit components, if the user selects the component itself rather than picking an individual...
Definition: lib_tree.cpp:148
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
Definition: board.cpp:358
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > m_adapter
ACTIONS * m_actions
Definition: tools_holder.h:158
static TOOL_ACTION cut
Definition: actions.h:69
void Regenerate(bool aKeepState)
Regenerate the tree.
Definition: lib_tree.cpp:200
Definition of file extensions used in Kicad.
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:189
FOOTPRINT_EDITOR_SETTINGS * m_settings
#define FOOTPRINT_EDIT_FRAME_NAME
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:148
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:423
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
const BITMAP_OPAQUE icon_modedit_32_xpm[1]
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:92
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:167
static const wxChar A4[]
Definition: page_info.h:63
virtual void OnSize(wxSizeEvent &event)
Recalculate the size of toolbars and display panel when the frame size changes.
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:40
const LIB_ID & GetFPID() const
Definition: footprint.h:190
#define KICAD_DEFAULT_DRAWFRAME_STYLE
bool IsModify() const
Definition: base_screen.h:63
#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.
PCB_PLOT_PARAMS handles plot 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:218
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
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:277
static TOOL_ACTION milsUnits
Definition: actions.h:148
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:233
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:159
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:528
const BITMAP_OPAQUE icon_modedit_xpm[1]
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...
bool IsMirroredX() const
Return true if view is flipped across the X axis.
Definition: view.h:237
SELECTION_CONDITION NoActiveTool()
Create a functor testing if there are no tools active in the frame.
BOARD * GetBoard()
static TOOL_ACTION pasteSpecial
Definition: actions.h:72
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:245
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:193
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:106
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:149
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:390
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:68
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)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:302
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
Gather all the actions that are shared by tools.
Definition: pcb_actions.h:52
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:158
see class PGM_BASE
void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings) override
Tool that displays edit points allowing to modify items by dragging the points.
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
Declaration of the eda_3d_viewer class.
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:55
LIB_ID GetLoadedFPID() const
Return the LIB_ID of the part being edited.
PANEL_SELECTION_FILTER * m_selectionFilterPanel
AUI panel for changing the selection tool filter controls.
bool canCloseWindow(wxCloseEvent &Event) override
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:197
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.
#define _(s)
Definition: 3d_actions.cpp:33
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:630
std::vector< LAYER_PRESET > m_LayerPresets
BOARD_ITEM_CONTAINER * GetModel() const override
NETCLASS * GetDefault() const
The main frame for Pcbnew.
void ClrModify()
Definition: base_screen.h:60
FOOTPRINT_TREE_PANE * m_treePane
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely saves a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
The selection tool: currently supports:
static bool empty(const wxTextEntryBase *aCtrl)
unsigned GetErrorCount() const
virtual void AddFootprintToBoard(FOOTPRINT *aFootprint)
Add the given footprint to the board.
wxString GetActiveLayerPreset() const
MAGNETIC_SETTINGS * GetMagneticItemsSettings() override
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Tool useful for viewing footprints.
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:76
void ReadCacheFromFile(const wxString &aFilePath) override
FOOTPRINT_EDITOR_SETTINGS * GetSettings()
virtual const wxString GetProjectName() const
Return the short name of the project.
static TOOL_ACTION undo
Definition: actions.h:67
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:55
void OnGridSettings(wxCommandEvent &event)
void RefreshLibraryTree()
Reload displayed items and sets view.
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:105
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:295
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnSelectDisplayMode EVT_CHOICE(ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice) EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER
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:140
void OnUpdateModuleSelected(wxUpdateUIEvent &aEvent)
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:770
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1168
const BITMAP_OPAQUE icon_modedit_16_xpm[1]
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:106
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:73
void OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings Changes the bit-mask of ena...
Definition: board.cpp:467
static TOOL_ACTION paste
Definition: actions.h:71
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:74
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:262
static TOOL_ACTION revert
Definition: actions.h:58
static const wxChar * GetFootprintEditorFrameName()
static TOOL_ACTION selectionTool
Definition: actions.h:156
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:183
void OnSaveFootprintAsPng(wxCommandEvent &event)
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition: lib_tree.cpp:177
bool empty() const
Definition: utf8.h:103
virtual void UpdateMsgPanel()
Redraw the message panel.
Container for design settings for a BOARD object.
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:393
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:184