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 <fp_lib_table.h>
49 #include <kiface_i.h>
50 #include <kiplatform/app.h>
51 #include <kiway.h>
52 #include <macros.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.
105 END_EVENT_TABLE()
106 
107 
108 FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
109  EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend ) :
110  PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_FOOTPRINT_EDITOR, wxEmptyString,
111  wxDefaultPosition, wxDefaultSize,
112  KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() )
113 {
114  m_showBorderAndTitleBlock = false; // true to show the frame references
115  m_canvasType = aBackend;
116  m_aboutTitle = _( "KiCad Footprint Editor" );
117  m_selLayerBox = nullptr;
118  m_settings = nullptr;
119 
120  // Give an icon
121  wxIcon icon;
122  wxIconBundle icon_bundle;
123 
124  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit ) );
125  icon_bundle.AddIcon( icon );
126  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit_32 ) );
127  icon_bundle.AddIcon( icon );
128  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit_16 ) );
129  icon_bundle.AddIcon( icon );
130 
131  SetIcons( icon_bundle );
132 
133  // Create GAL canvas
134  if( aBackend == EDA_DRAW_PANEL_GAL::GAL_TYPE_UNKNOWN )
135  m_canvasType = loadCanvasTypeSetting();
136  else
137  m_canvasType = aBackend;
138 
139  PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
140  GetGalDisplayOptions(), m_canvasType );
141  SetCanvas( drawPanel );
142  SetBoard( new BOARD() );
143 
144 
145  // This board will only be used to hold a footprint for editing
147 
148  // In Footprint Editor, the default net clearance is not known (it depends on the actual
149  // board). So we do not show the default clearance, by setting it to 0. The footprint or
150  // pad specific clearance will be shown.
152 
153  // Don't show the default board solder mask clearance in the footprint editor. Only the
154  // footprint or pad clearance setting should be shown if it is not 0.
156 
157  // restore the last footprint from the project, if any
158  restoreLastFootprint();
159 
160  // Ensure all layers and items are visible:
161  // In footprint editor, some layers have no meaning or cannot be used, but we show all of
162  // them, at least to be able to edit a bad layer
164 
165  // However the "no net" mark on pads is useless, because there are no nets in footprint
166  // editor: make it non visible.
168 
169  GetGalDisplayOptions().m_axesEnabled = true;
170 
171  // In Footprint Editor, set the default paper size to A4 for plot/print
172  SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) );
173  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
174 
175  // Create the manager and dispatcher & route draw panel events to the dispatcher
176  setupTools();
177  setupUIConditions();
178 
179  initLibraryTree();
180  m_treePane = new FOOTPRINT_TREE_PANE( this );
181 
182  ReCreateMenuBar();
183  ReCreateHToolbar();
184  ReCreateVToolbar();
185  ReCreateOptToolbar();
186 
187  m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
188  m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas(), true );
189 
190  // LoadSettings() *after* creating m_LayersManager, because LoadSettings() initialize
191  // parameters in m_LayersManager
192  // NOTE: KifaceSettings() will return PCBNEW_SETTINGS if we started from pcbnew
193  LoadSettings( GetSettings() );
194 
195  // Must be set after calling LoadSettings() to be sure these parameters are not dependent
196  // on what is read in stored settings. Enable one internal layer, because footprints
197  // support keepout areas that can be on internal layers only (therefore on the first internal
198  // layer). This is needed to handle these keepout in internal layers only.
200  GetBoard()->SetEnabledLayers( GetBoard()->GetEnabledLayers().set( In1_Cu ) );
201  GetBoard()->SetVisibleLayers( GetBoard()->GetEnabledLayers() );
202  GetBoard()->SetLayerName( In1_Cu, _( "Inner layers" ) );
203 
204  SetActiveLayer( F_SilkS );
205 
206  m_auimgr.SetManagedWindow( this );
207 
208  CreateInfoBar();
209 
210  unsigned int auiFlags = wxAUI_MGR_DEFAULT;
211 #if !defined( _WIN32 )
212  // Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds
213  // of graphical glitches
214  auiFlags |= wxAUI_MGR_LIVE_RESIZE;
215 #endif
216  m_auimgr.SetFlags( auiFlags );
217 
218  // Rows; layers 4 - 6
219  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
220  .Top().Layer( 6 ) );
221  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
222  .Bottom().Layer( 6 ) );
223 
224  // Columns; layers 1 - 3
225  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
226  .Left().Layer( 3 ) );
227  m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "Footprints" )
228  .Left().Layer(2)
229  .Caption( _( "Libraries" ) )
230  .MinSize( 250, 400 ).Resizable() );
231 
232  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
233  .Right().Layer(2) );
234 
235  m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( "LayersManager" )
236  .Right().Layer( 3 )
237  .Caption( _( "Appearance" ) ).PaneBorder( false )
238  .MinSize( 180, -1 ).BestSize( 180, -1 ) );
239  m_auimgr.AddPane( m_selectionFilterPanel, EDA_PANE().Palette().Name( "SelectionFilter" )
240  .Right().Layer( 3 ).Position( 2 )
241  .Caption( _( "Selection Filter" ) ).PaneBorder( false )
242  .MinSize( 160, -1 ).BestSize( m_selectionFilterPanel->GetBestSize() ) );
243 
244  // Center
245  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
246  .Center() );
247 
248  // The selection filter doesn't need to grow in the vertical direction when docked
249  m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
250 
251  ActivateGalCanvas();
252 
253  FinishAUIInitialization();
254 
255  if( m_settings->m_LibWidth > 0 )
256  {
257  wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" );
258 
259  // wxAUI hack: force width by setting MinSize() and then Fixed()
260  // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
261  treePane.MinSize( m_settings->m_LibWidth, -1 );
262  treePane.Fixed();
263  m_auimgr.Update();
264 
265  // now make it resizable again
266  treePane.Resizable();
267  m_auimgr.Update();
268 
269  // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
270  // back to minimum.
271  treePane.MinSize( 250, -1 );
272  }
273 
274  // Apply saved visibility stuff at the end
275  FOOTPRINT_EDITOR_SETTINGS* cfg = GetSettings();
276  m_appearancePanel->SetUserLayerPresets( cfg->m_LayerPresets );
277  m_appearancePanel->ApplyLayerPreset( cfg->m_ActiveLayerPreset );
278 
279  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
280  UpdateTitle();
281  setupUnits( GetSettings() );
282 
283  // Default shutdown reason until a file is loaded
284  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Footprint changes are unsaved" ) );
285 
286  // Catch unhandled accelerator command characters that were no handled by the library tree
287  // panel.
288  Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
289  Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
290 
291  // Ensure the window is on top
292  Raise();
293  Show( true );
294 
295  // Register a call to update the toolbar sizes. It can't be done immediately because
296  // it seems to require some sizes calculated that aren't yet (at least on GTK).
297  CallAfter( [&]()
298  {
299  // Ensure the controls on the toolbars all are correctly sized
300  UpdateToolbarControlSizes();
301  } );
302 }
303 
304 
306 {
307  // Shutdown all running tools
308  if( m_toolManager )
310 
311  // save the footprint in the PROJECT
313 
314  delete m_selectionFilterPanel;
315  delete m_appearancePanel;
316 }
317 
318 
320 {
321  return GetScreen() && GetScreen()->IsModify() && GetBoard() && GetBoard()->GetFirstFootprint();
322 }
323 
324 
326 {
327  return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
328 }
329 
330 
332 {
333  // switches currently used canvas (Cairo / OpenGL).
334  PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
335 
336  GetCanvas()->GetGAL()->SetAxesEnabled( true );
337 
338  // The base class method *does not reinit* the layers manager. We must upate the layer
339  // widget to match board visibility states, both layers and render columns, and and some
340  // settings dependent on the canvas.
342 }
343 
344 
346 {
347  SyncLibraryTree( true );
348  GetCanvas()->ForceRefresh();
349 }
350 
351 
353 {
354  wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
355  treePane.Show( !IsSearchTreeShown() );
356  m_auimgr.Update();
357 }
358 
359 
361 {
362  return m_auimgr.GetPane( m_treePane ).IsShown();
363 }
364 
365 
367 {
368  return GetBoard()->GetFirstFootprint();
369 }
370 
371 
373 {
375 }
376 
377 
379 {
381 }
382 
383 
385 {
386  LIB_ID id = GetTreeFPID();
387 
388  if( id.GetLibNickname().empty() )
389  return GetLoadedFPID();
390 
391  return id;
392 }
393 
394 
396 {
397  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
398 
399  if( footprint )
400  return LIB_ID( footprint->GetFPID().GetLibNickname(), m_footprintNameWhenLoaded );
401  else
402  return LIB_ID();
403 }
404 
405 
407 {
408  if( GetBoard()->GetFirstFootprint() )
410 
411  GetScreen()->ClrModify();
412 }
413 
414 
416 {
417  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
418 
419  return ( footprint && footprint->GetLink() != niluuid );
420 }
421 
422 
424 {
425  LIB_ID id = GetLoadedFPID();
426 
427  if( id.IsValid() )
428  {
430  Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME, id.GetLibItemName() );
431  }
432 }
433 
434 
436 {
437  const wxString& footprintName = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME );
438  const wxString& libNickname = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_LIB_NICKNAME );
439 
440  if( libNickname.Length() && footprintName.Length() )
441  {
442  LIB_ID id;
443  id.SetLibNickname( libNickname );
444  id.SetLibItemName( footprintName );
445 
446  FOOTPRINT* footprint = loadFootprint( id );
447 
448  if( footprint )
449  AddFootprintToBoard( footprint );
450  }
451 }
452 
453 
455 {
456  m_revertModule.reset( (FOOTPRINT*) aFootprint->Clone() );
457 
459 
461 
462  if( IsCurrentFPFromBoard() )
463  {
464  wxString msg;
465  msg.Printf( _( "Editing %s from board. Saving will update the board only." ),
466  aFootprint->GetReference() );
467 
470  GetInfoBar()->ShowMessage( msg, wxICON_INFORMATION );
471  }
472 
473  UpdateMsgPanel();
474 }
475 
476 
478 {
480 }
481 
482 
484 {
485  return GetBoard()->GetDesignSettings();
486 }
487 
488 
490 {
491  wxFAIL_MSG( "Plotting not supported in Footprint Editor" );
492 
494 }
495 
496 
498 {
499  wxFAIL_MSG( "Plotting not supported in Footprint Editor" );
500 }
501 
502 
504 {
505  if( !m_settings )
506  m_settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
507 
508  return m_settings;
509 }
510 
511 
513 {
514  return m_settings ? m_settings
515  : Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
516 }
517 
518 
520 {
521  // aCfg will be the PCBNEW_SETTINGS
523 
525 
527 
529 
532 }
533 
534 
536 {
538 
539  // aCfg will be the PCBNEW_SETTINGS
541 
543 
546  cfg->m_LibWidth = m_treePane->GetSize().x;
550 
552 }
553 
554 
556 {
557  wxString currentTheme = GetFootprintEditorSettings()->m_ColorTheme;
558  return Pgm().GetSettingsManager().GetColorSettings( currentTheme );
559 }
560 
561 
563 {
564  // Get the actual frame settings for magnetic items
566  wxCHECK( cfg, nullptr );
567  return &cfg->m_MagneticItems;
568 }
569 
570 
571 const BOX2I FOOTPRINT_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
572 {
573  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
574 
575  if( footprint )
576  {
577  bool hasGraphicalItem = footprint->Pads().size() || footprint->Zones().size();
578 
579  if( !hasGraphicalItem )
580  {
581  for( const BOARD_ITEM* item : footprint->GraphicalItems() )
582  {
583  if( item->Type() == PCB_FP_TEXT_T )
584  continue;
585 
586  hasGraphicalItem = true;
587  break;
588  }
589  }
590 
591  if( hasGraphicalItem )
592  {
593  return footprint->GetBoundingBox( false, false );
594  }
595  else
596  {
597  BOX2I newFootprintBB( { 0, 0 }, { 0, 0 } );
598  newFootprintBB.Inflate( Millimeter2iu( 12 ) );
599  return newFootprintBB;
600  }
601  }
602 
603  return GetBoardBoundingBox( false );
604 }
605 
606 
607 bool FOOTPRINT_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
608 {
609  if( IsContentModified() )
610  {
611  // Shutdown blocks must be determined and vetoed as early as possible
612  if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION )
613  {
614  aEvent.Veto();
615  return false;
616  }
617 
618  wxString footprintName = GetBoard()->GetFirstFootprint()->GetFPID().GetLibItemName();
619  wxString msg = _( "Save changes to \"%s\" before closing?" );
620 
621  if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
622  [&]() -> bool
623  {
624  return SaveFootprint( GetBoard()->GetFirstFootprint() );
625  } ) )
626  {
627  aEvent.Veto();
628  return false;
629  }
630  }
631 
632  return true;
633 }
634 
635 
637 {
638  // No more vetos
640  GetCanvas()->StopDrawing();
641 
642  // Do not show the layer manager during closing to avoid flicker
643  // on some platforms (Windows) that generate useless redraw of items in
644  // the Layer Manger
645  m_auimgr.GetPane( "LayersManager" ).Show( false );
646  m_auimgr.GetPane( "SelectionFilter" ).Show( false );
647 
648  Clear_Pcb( false );
649 
651 
652  if( mgr->IsProjectOpen() && wxFileName::IsDirWritable( Prj().GetProjectPath() ) )
653  {
654  GFootprintList.WriteCacheToFile( Prj().GetProjectPath() + "fp-info-cache" );
655  }
656 
657  mgr->FlushAndRelease( GetSettings() );
658 }
659 
660 
661 void FOOTPRINT_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
662 {
663  Kiway().OnKiCadExit();
664 }
665 
666 
667 void FOOTPRINT_EDIT_FRAME::CloseFootprintEditor( wxCommandEvent& Event )
668 {
669  Close();
670 }
671 
672 
674 {
676 
677  aEvent.Enable( frame && frame->GetBoard()->GetFirstFootprint() != NULL );
678 }
679 
680 
682 {
684 
685  FOOTPRINT* editorFootprint = GetBoard()->GetFirstFootprint();
686  bool canInsert = frame && editorFootprint && editorFootprint->GetLink() == niluuid;
687 
688  // If the source was deleted, the footprint can inserted but not updated in the board.
689  if( frame && editorFootprint && editorFootprint->GetLink() != niluuid )
690  {
691  BOARD* mainpcb = frame->GetBoard();
692  canInsert = true;
693 
694  // search if the source footprint was not deleted:
695  for( FOOTPRINT* candidate : mainpcb->Footprints() )
696  {
697  if( editorFootprint->GetLink() == candidate->m_Uuid )
698  {
699  canInsert = false;
700  break;
701  }
702  }
703  }
704 
705  aEvent.Enable( canInsert );
706 }
707 
708 
710 {
711  // call my base class
713 
714  // We have 2 panes to update.
715  // For some obscure reason, the AUI manager hides the first modified pane.
716  // So force show panes
717  wxAuiPaneInfo& tree_pane_info = m_auimgr.GetPane( m_treePane );
718  bool tree_shown = tree_pane_info.IsShown();
719  tree_pane_info.Caption( _( "Libraries" ) );
720 
721  wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_appearancePanel );
722  bool lm_shown = lm_pane_info.IsShown();
723  lm_pane_info.Caption( _( "Appearance" ) );
724 
725  // update the layer manager
728 
729  // Now restore the visibility:
730  lm_pane_info.Show( lm_shown );
731  tree_pane_info.Show( tree_shown );
732  m_auimgr.Update();
733 }
734 
735 
737 {
739  Update3DView( true, true );
741 
742  if( !GetTitle().StartsWith( "*" ) )
743  UpdateTitle();
744 }
745 
746 
748 {
749  wxString title;
750  LIB_ID fpid = GetLoadedFPID();
751  FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
752  bool writable = true;
753 
754  if( IsCurrentFPFromBoard() )
755  {
756  title = wxString::Format( _( "%s%s [from %s.%s]" ) + wxT( " \u2014 " ),
757  IsContentModified() ? "*" : "",
758  footprint->GetReference(),
759  Prj().GetProjectName(),
761  }
762  else if( fpid.IsValid() )
763  {
764  try
765  {
766  writable = Prj().PcbFootprintLibs()->IsFootprintLibWritable( fpid.GetLibNickname() );
767  }
768  catch( const IO_ERROR& )
769  {
770  // best efforts...
771  }
772 
773  // Note: don't used GetLoadedFPID(); footprint name may have been edited
774  title += wxString::Format( wxT( "%s%s %s\u2014 " ),
775  IsContentModified() ? "*" : "",
776  FROM_UTF8( footprint->GetFPID().Format().c_str() ),
777  writable ? "" : _( "[Read Only]" ) + wxS( " " ) );
778  }
779  else if( !fpid.GetLibItemName().empty() )
780  {
781  // Note: don't used GetLoadedFPID(); footprint name may have been edited
782  title += wxString::Format( wxT( "%s%s %s \u2014 " ),
783  IsContentModified() ? "*" : "",
784  FROM_UTF8( footprint->GetFPID().GetLibItemName().c_str() ),
785  _( "[Unsaved]" ) );
786  }
787 
788  title += _( "Footprint Editor" );
789 
790  SetTitle( title );
791 }
792 
793 
795 {
797 }
798 
799 
801 {
802  GetCanvas()->UpdateColors();
805  UpdateTitle();
806 }
807 
808 
810 {
811  FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
812 
813  WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
814  if( GFootprintList.GetCount() == 0 )
815  {
816  GFootprintList.ReadCacheFromFile( Prj().GetProjectPath() + "fp-info-cache" );
817  }
818  GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter );
819  progressReporter.Show( false );
820 
823 
825  auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
826 
827  adapter->AddLibraries();
828 }
829 
830 
832 {
833  FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
834  auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
835  LIB_ID target = GetTargetFPID();
836  bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() );
837 
838  // Sync FOOTPRINT_INFO list to the libraries on disk
839  if( aProgress )
840  {
841  WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 2 );
842  GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter );
843  progressReporter.Show( false );
844  }
845  else
846  {
848  }
849 
850  // Sync the LIB_TREE to the FOOTPRINT_INFO list
851  adapter->Sync();
852 
854  m_treePane->GetLibTree()->Regenerate( true );
855 
856  if( target.IsValid() )
857  {
858  if( adapter->FindItem( target ) )
859  {
860  if( targetSelected )
861  m_treePane->GetLibTree()->SelectLibId( target );
862  else
863  m_treePane->GetLibTree()->CenterLibId( target );
864  }
865  else
866  {
867  // Try to focus on parent
868  target.SetLibItemName( wxEmptyString );
869  m_treePane->GetLibTree()->CenterLibId( target );
870  }
871  }
872 }
873 
874 
876 {
877  LIB_ID target = GetTargetFPID();
878 
879  m_treePane->GetLibTree()->Regenerate( true );
880 
881  if( target.IsValid() )
882  m_treePane->GetLibTree()->CenterLibId( target );
883 }
884 
885 
887 {
889 }
890 
891 
893 {
894  m_treePane->GetLibTree()->SelectLibId( aLibID );
895 }
896 
897 
899 {
901 }
902 
903 
905  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
906 {
907  wxTreebook* book = aParent->GetTreebook();
908 
909  book->AddPage( new wxPanel( book ), _( "Footprint Editor" ) );
910  book->AddSubPage( new PANEL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
911  book->AddSubPage( new PANEL_EDIT_OPTIONS( this, aParent ), _( "Editing Options" ) );
912  book->AddSubPage( new PANEL_FP_EDITOR_COLOR_SETTINGS( this, book ), _( "Colors" ) );
913  book->AddSubPage( new PANEL_FP_EDITOR_DEFAULTS( this, aParent ), _( "Default Values" ) );
914 
915  aHotkeysPanel->AddHotKeys( GetToolManager() );
916 }
917 
918 
920 {
921  // Create the manager and dispatcher & route draw panel events to the dispatcher
924  GetCanvas()->GetViewControls(), config(), this );
925  m_actions = new PCB_ACTIONS();
927 
929 
938  m_toolManager->RegisterTool( new PCB_CONTROL ); // copy/paste
946 
947  m_toolManager->GetTool<PCB_SELECTION_TOOL>()->SetIsFootprintEditor( true );
948  m_toolManager->GetTool<EDIT_TOOL>()->SetIsFootprintEditor( true );
949  m_toolManager->GetTool<PAD_TOOL>()->SetIsFootprintEditor( true );
950  m_toolManager->GetTool<DRAWING_TOOL>()->SetIsFootprintEditor( true );
951  m_toolManager->GetTool<PCB_POINT_EDITOR>()->SetIsFootprintEditor( true );
952  m_toolManager->GetTool<PCB_CONTROL>()->SetIsFootprintEditor( true );
953  m_toolManager->GetTool<PCB_PICKER_TOOL>()->SetIsFootprintEditor( true );
954  m_toolManager->GetTool<POSITION_RELATIVE_TOOL>()->SetIsFootprintEditor( true );
955  m_toolManager->GetTool<GROUP_TOOL>()->SetIsFootprintEditor( true );
956 
957  m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
959 
960  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
961 }
962 
963 
965 {
967 
969  PCB_EDITOR_CONDITIONS cond( this );
970 
971  wxASSERT( mgr );
972 
973 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
974 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
975 
976  auto haveFootprintCond =
977  [this]( const SELECTION& )
978  {
979  return GetBoard()->GetFirstFootprint() != nullptr;
980  };
981 
982  auto footprintTargettedCond =
983  [this] ( const SELECTION& )
984  {
985  return !GetTargetFPID().GetLibItemName().empty();
986  };
987 
988  mgr->SetConditions( ACTIONS::saveAs, ENABLE( footprintTargettedCond ) );
991 
992  mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
993  mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
994 
1000 
1001  mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
1002  mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );
1005  mgr->SetConditions( ACTIONS::doDelete, ENABLE( cond.HasItems() ) );
1006  mgr->SetConditions( ACTIONS::duplicate, ENABLE( cond.HasItems() ) );
1007  mgr->SetConditions( ACTIONS::selectAll, ENABLE( cond.HasItems() ) );
1008 
1011  mgr->SetConditions( PCB_ACTIONS::mirror, ENABLE( cond.HasItems() ) );
1014 
1018 
1021 
1022 
1023  auto highContrastCond =
1024  [this] ( const SELECTION& )
1025  {
1027  };
1028 
1029  auto boardFlippedCond =
1030  [this]( const SELECTION& )
1031  {
1032  return GetCanvas()->GetView()->IsMirroredX();
1033  };
1034 
1035  auto footprintTreeCond =
1036  [this] (const SELECTION& )
1037  {
1038  return IsSearchTreeShown();
1039  };
1040 
1041  mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
1042  mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
1043  mgr->SetConditions( PCB_ACTIONS::showFootprintTree, CHECK( footprintTreeCond ) );
1044 
1045  mgr->SetConditions( ACTIONS::print, ENABLE( haveFootprintCond ) );
1046  mgr->SetConditions( PCB_ACTIONS::exportFootprint, ENABLE( haveFootprintCond ) );
1047  mgr->SetConditions( PCB_ACTIONS::footprintProperties, ENABLE( haveFootprintCond ) );
1048  mgr->SetConditions( PCB_ACTIONS::cleanupGraphics, ENABLE( haveFootprintCond ) );
1049  mgr->SetConditions( PCB_ACTIONS::placeImportedGraphics, ENABLE( haveFootprintCond ) );
1050 
1051 
1052 // Only enable a tool if the part is edtable
1053 #define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, \
1054  ACTION_CONDITIONS().Enable( haveFootprintCond ).Check( cond.CurrentTool( action ) ) )
1055 
1068 
1069 #undef CURRENT_EDIT_TOOL
1070 #undef ENABLE
1071 #undef CHECK
1072 }
1073 
1074 
1076 {
1078 
1079  // Be sure the axis are enabled
1080  GetCanvas()->GetGAL()->SetAxesEnabled( true );
1081 
1082  UpdateView();
1083 
1084  // Ensure the m_Layers settings are using the canvas type:
1086 }
1087 
1088 
1089 void FOOTPRINT_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1090 {
1091  PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1092 
1094  GetCanvas()->ForceRefresh();
1095 
1097 
1098  if( aEnvVarsChanged )
1099  SyncLibraryTree( true );
1100 
1101  Layout();
1102  SendSizeEvent();
1103 }
1104 
1105 
1106 void FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng( wxCommandEvent& event )
1107 {
1108  wxString fullFileName;
1109 
1110  LIB_ID id = GetLoadedFPID();
1111 
1112  if( id.empty() )
1113  {
1114  wxMessageBox( _( "No footprint selected." ) );
1115  return;
1116  }
1117 
1118  wxFileName fn( id.GetLibItemName() );
1119  fn.SetExt( "png" );
1120 
1121  wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );
1122 
1123  wxFileDialog dlg( this, _( "Footprint Image File Name" ), projectPath,
1124  fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1125 
1126  if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
1127  return;
1128 
1129  // calling wxYield is mandatory under Linux, after closing the file selector dialog
1130  // to refresh the screen before creating the PNG or JPEG image from screen
1131  wxYield();
1132  SaveCanvasImageToFile( this, dlg.GetPath() );
1133 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
The interactive edit tool.
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Definition: infobar.cpp:134
static TOOL_ACTION drawLine
Definition: pcb_actions.h: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:207
#define CHECK(x)
bool IsFootprintLibWritable(const wxString &aNickname)
Return true if the library given by aNickname is writable.
show a marker on pads with no nets
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
const UTF8 & GetLibItemName() const
Definition: lib_id.h:106
static TOOL_ACTION placeImportedGraphics
Definition: pcb_actions.h:165
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:375
void OnKiCadExit()
Definition: kiway.cpp:610
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.
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:203
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
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:323
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.
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:593
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:368
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:426
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:427
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:166
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
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.
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:76
FOOTPRINT_LIST_IMPL GFootprintList
The global footprint info table.
Definition: pcbnew.cpp:339
PCB_DISPLAY_OPTIONS m_displayOptions
Master controller class:
Definition: tool_manager.h:52
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 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:382
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:168
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: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: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...
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:305
Inactive 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:150
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:202
Definition of file extensions used in Kicad.
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:191
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:426
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
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:65
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.
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:104
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:220
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:287
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:531
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:213
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.
Definition: project.cpp:285
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:247
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: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: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...
Definition: project.cpp:228
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.
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:55
LIB_ID GetLoadedFPID() const
Return the LIB_ID of the part being edited.
PANEL_SELECTION_FILTER * m_selectionFilterPanel
bool canCloseWindow(wxCloseEvent &Event) override
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
#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:631
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.
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.
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:197
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.
Definition: project.cpp:129
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()
Redisplay the library tree.
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:105
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:297
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
BOARD_DESIGN_SETTINGS m_DesignSettings
Only some of these settings are actually used for footprint editing.
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:773
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1169
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:185
void OnSaveFootprintAsPng(wxCommandEvent &event)
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition: lib_tree.cpp:179
bool empty() const
Definition: utf8.h:103
virtual void UpdateMsgPanel()
Redraw the message panel.
Container for design settings for a BOARD object.
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: infobar.cpp:277
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:396
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:184