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/drawing_tool.h"
24 #include "tools/edit_tool.h"
26 #include "tools/pad_tool.h"
27 #include "tools/pcb_actions.h"
28 #include "tools/pcbnew_control.h"
30 #include "tools/placement_tool.h"
31 #include "tools/point_editor.h"
32 #include "tools/selection_tool.h"
34 #include <bitmaps.h>
35 #include <class_board.h>
36 #include <class_module.h>
37 #include <confirm.h>
42 #include <fctsys.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>
49 #include <kicad_plugin.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 <pcb_layer_widget.h>
57 #include <pcbnew.h>
58 #include <pcbnew_id.h>
59 #include <pgm_base.h>
60 #include <project.h>
62 #include <tool/action_toolbar.h>
63 #include <tool/common_control.h>
64 #include <tool/common_tools.h>
65 #include <tool/selection.h>
66 #include <tool/tool_dispatcher.h>
67 #include <tool/tool_manager.h>
68 #include <tool/zoom_tool.h>
70 #include <tools/pcb_viewer_tools.h>
72 #include <widgets/infobar.h>
73 #include <widgets/lib_tree.h>
74 #include <widgets/paged_dialog.h>
78 
79 
80 BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
81  EVT_MENU( wxID_CLOSE, FOOTPRINT_EDIT_FRAME::CloseModuleEditor )
82  EVT_MENU( wxID_EXIT, FOOTPRINT_EDIT_FRAME::OnExitKiCad )
83 
85 
88 
90 
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 = "ModEdit";
119  m_selLayerBox = nullptr;
120  m_settings = nullptr;
121 
122  // Give an icon
123  wxIcon icon;
124  icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
125  SetIcon( icon );
126 
127  // Create GAL canvas
128  if( aBackend == EDA_DRAW_PANEL_GAL::GAL_TYPE_UNKNOWN )
129  m_canvasType = LoadCanvasTypeSetting();
130  else
131  m_canvasType = aBackend;
132 
133  PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
134  GetGalDisplayOptions(), m_canvasType );
135  SetCanvas( drawPanel );
136  SetBoard( new BOARD() );
137 
138  m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), true );
139 
140  // In modedit, the default net clearance is not known (it depends on the actual board).
141  // So we do not show the default clearance, by setting it to 0.
142  // The footprint or pad specific clearance will be shown.
144 
145  // Don't show the default board solder mask clearance in the footprint editor. Only the
146  // footprint or pad clearance setting should be shown if it is not 0.
148 
149  // restore the last footprint from the project, if any
150  restoreLastFootprint();
151 
152  // Ensure all layers and items are visible:
153  // In footprint editor, some layers have no meaning or cannot be used, but we show all of
154  // them, at least to be able to edit a bad layer
156 
157  // However the "no net" mark on pads is useless, because there are no nets in footprint
158  // editor: make it non visible.
160 
161  GetGalDisplayOptions().m_axesEnabled = true;
162 
163  // In modedit, set the default paper size to A4 for plot/print
164  SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) );
165  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
166 
167  // Create the manager and dispatcher & route draw panel events to the dispatcher
168  setupTools();
169  setupUIConditions();
170 
171  initLibraryTree();
172  m_treePane = new FOOTPRINT_TREE_PANE( this );
173 
174  ReCreateMenuBar();
175  ReCreateHToolbar();
176  ReCreateVToolbar();
177  ReCreateOptToolbar();
178 
179  m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
180 
181  // LoadSettings() *after* creating m_LayersManager, because LoadSettings() initialize
182  // parameters in m_LayersManager
183  // NOTE: KifaceSettings() will return PCBNEW_SETTINGS if we started from pcbnew
184  LoadSettings( GetSettings() );
185 
186  // Must be set after calling LoadSettings() to be sure these parameters are not dependent
187  // on what is read in stored settings. Enable one internal layer, because footprints
188  // support keepout areas that can be on internal layers only (therefore on the first internal
189  // layer). This is needed to handle these keepout in internal layers only.
191  GetBoard()->SetEnabledLayers( GetBoard()->GetEnabledLayers().set( In1_Cu ) );
192  GetBoard()->SetVisibleLayers( GetBoard()->GetEnabledLayers() );
193  GetBoard()->SetLayerName( In1_Cu, _( "Inner layers" ) );
194 
195  m_Layers->ReFill();
196  m_Layers->ReFillRender();
197 
198  GetScreen()->m_Active_Layer = F_SilkS;
199  m_Layers->SelectLayer( F_SilkS );
200  m_Layers->OnLayerSelected();
201 
202  // Create the infobar
203  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
204 
205  m_auimgr.SetManagedWindow( this );
206  m_auimgr.SetFlags( wxAUI_MGR_DEFAULT | wxAUI_MGR_LIVE_RESIZE );
207 
208  // Horizontal items; layers 4 - 6
209  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
210  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
211  m_auimgr.AddPane( m_infoBar,
212  EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
213 
214  // Vertical items; layers 1 - 3
215  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
216  m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "Footprints" ).Left().Layer(2)
217  .Caption( _( "Libraries" ) ).MinSize( 250, 400 )
218  .BestSize( m_defaultLibWidth, -1 ) );
219 
220  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(2) );
221  m_auimgr.AddPane( m_Layers, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(3)
222  .Caption( _( "Layers Manager" ) ).PaneBorder( false )
223  .MinSize( 80, -1 ).BestSize( m_Layers->GetBestSize() ) );
224 
225  m_auimgr.AddPane( m_selectionFilterPanel,
226  EDA_PANE().Palette().Name( "SelectionFilter" ).Right().Layer( 3 )
227  .Caption( _( "Selection Filter" ) ).PaneBorder( false ).Position( 2 )
228  .MinSize( 160, -1 ).BestSize( m_selectionFilterPanel->GetBestSize() ) );
229 
230  // The selection filter doesn't need to grow in the vertical direction when docked
231  m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
232 
233  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
234 
235  ActivateGalCanvas();
236 
237  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
238  // hidding it.
239  m_auimgr.Update();
240 
241  // We don't want the infobar displayed right away
242  m_auimgr.GetPane( "InfoBar" ).Hide();
243  m_auimgr.Update();
244 
245  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
246  updateTitle();
247  InitExitKey();
248 
249  // Default shutdown reason until a file is loaded
250  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Footprint changes are unsaved" ) );
251 
252  // Ensure the window is on top
253  Raise();
254  Show( true );
255 }
256 
257 
259 {
260  // Shutdown all running tools
261  if( m_toolManager )
263 
264  // save the footprint in the PROJECT
266 
267  delete m_selectionFilterPanel;
268  delete m_Layers;
269 }
270 
271 
273 {
274  return GetScreen() && GetScreen()->IsModify() && GetBoard() && GetBoard()->GetFirstModule();
275 }
276 
277 
279 {
280  return m_toolManager->GetTool<SELECTION_TOOL>()->GetSelection();
281 }
282 
283 
285 {
286  // switches currently used canvas (Cairo / OpenGL).
287  PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
288 
289  GetCanvas()->GetGAL()->SetAxesEnabled( true );
290 
291  // The base class method *does not reinit* the layers manager. We must upate the layer
292  // widget to match board visibility states, both layers and render columns, and and some
293  // settings dependent on the canvas.
295 }
296 
297 
299 {
300  SyncLibraryTree( true );
301  GetCanvas()->ForceRefresh();
302 }
303 
304 
306 {
307  wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
308  treePane.Show( !IsSearchTreeShown() );
309  m_auimgr.Update();
310 }
311 
312 
314 {
315  return m_auimgr.GetPane( m_treePane ).IsShown();
316 }
317 
318 
320 {
321  return GetBoard()->GetFirstModule();
322 }
323 
324 
326 {
328 }
329 
330 
332 {
334 }
335 
336 
338 {
339  LIB_ID id = GetTreeFPID();
340 
341  if( id.GetLibNickname().empty() )
342  return GetLoadedFPID();
343 
344  return id;
345 }
346 
347 
349 {
350  MODULE* module = GetBoard()->GetFirstModule();
351 
352  if( module )
354  else
355  return LIB_ID();
356 }
357 
358 
360 {
361  MODULE* module = GetBoard()->GetFirstModule();
362 
363  return ( module && module->GetLink() != niluuid );
364 }
365 
366 
368 {
369  LIB_ID id = GetLoadedFPID();
370 
371  if( id.IsValid() )
372  {
374  Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME, id.GetLibItemName() );
375  }
376 }
377 
378 
380 {
381  const wxString& footprintName = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME );
382  const wxString& libNickname = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_LIB_NICKNAME );
383 
384  if( libNickname.Length() && footprintName.Length() )
385  {
386  LIB_ID id;
387  id.SetLibNickname( libNickname );
388  id.SetLibItemName( footprintName );
389 
390  MODULE* module = loadFootprint( id );
391 
392  if( module )
393  AddModuleToBoard( module );
394  }
395 }
396 
397 
399 {
400  m_revertModule.reset( (MODULE*) aFootprint->Clone() );
401 
403 
404  // Pads are always editable in Footprint Editor
405  aFootprint->SetPadsLocked( false );
406 
408 
409  if( IsCurrentFPFromBoard() )
410  {
411  wxString msg;
412  msg.Printf( _( "Editing %s from board. Saving will update the board only." ),
413  aFootprint->GetReference() );
414 
416  GetInfoBar()->ShowMessage( msg, wxICON_INFORMATION );
417  }
418 
419  UpdateMsgPanel();
420 }
421 
422 
424 {
426 }
427 
428 
430 {
431  return GetBoard()->GetDesignSettings();
432 }
433 
434 
436 {
437  wxFAIL_MSG( "Plotting not supported in Footprint Editor" );
438 
440 }
441 
442 
444 {
445  wxFAIL_MSG( "Plotting not supported in Footprint Editor" );
446 }
447 
448 
450 {
451  if( !m_settings )
452  m_settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
453 
454  return m_settings;
455 }
456 
457 
459 {
460  // aCfg will be the PCBNEW_SETTINGS
462 
464 
466 
470 }
471 
472 
474 {
475  // aCfg will be the PCBNEW_SETTINGS
477 
479 
482  cfg->m_LibWidth = m_treePane->GetSize().x;
483  cfg->m_SelectionFilter = GetToolManager()->GetTool<SELECTION_TOOL>()->GetFilter();
484 
486 }
487 
488 
490 {
491  return Pgm().GetSettingsManager().GetColorSettings(
492  GetFootprintEditorSettings()->m_ColorTheme );
493 }
494 
495 
497 {
498  // Get the actual frame settings for magnetic items
500  wxCHECK( cfg, nullptr );
501  return &cfg->m_MagneticItems;
502 }
503 
504 
506 {
507  MODULE* module = GetBoard()->GetFirstModule();
508 
509  if( module )
510  {
511  bool hasGraphicalItem = module->Pads().size() || module->Zones().size();
512 
513  if( !hasGraphicalItem )
514  {
515  for( const BOARD_ITEM* item : module->GraphicalItems() )
516  {
517  if( item->Type() == PCB_MODULE_TEXT_T )
518  continue;
519 
520  hasGraphicalItem = true;
521  break;
522  }
523  }
524 
525  if( hasGraphicalItem )
526  {
527  return module->GetFootprintRect();
528  }
529  else
530  {
531  BOX2I newModuleBB( { 0, 0 }, { 0, 0 } );
532  newModuleBB.Inflate( Millimeter2iu( 12 ) );
533  return newModuleBB;
534  }
535  }
536 
537  return GetBoardBoundingBox( false );
538 }
539 
540 
541 bool FOOTPRINT_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
542 {
543  if( IsContentModified() )
544  {
545  // Shutdown blocks must be determined and vetoed as early as possible
546  if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION )
547  {
548  aEvent.Veto();
549  return false;
550  }
551 
552  wxString footprintName = GetBoard()->GetFirstModule()->GetFPID().GetLibItemName();
553  wxString msg = _( "Save changes to \"%s\" before closing?" );
554 
555  if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
556  [&]() -> bool
557  {
558  return SaveFootprint( GetBoard()->GetFirstModule() );
559  } ) )
560  {
561  aEvent.Veto();
562  return false;
563  }
564  }
565 
566  return true;
567 }
568 
569 
571 {
572  // No more vetos
574  GetCanvas()->StopDrawing();
575 
576  // Do not show the layer manager during closing to avoid flicker
577  // on some platforms (Windows) that generate useless redraw of items in
578  // the Layer Manger
579  m_auimgr.GetPane( "LayersManager" ).Show( false );
580  m_auimgr.GetPane( "SelectionFilter" ).Show( false );
581 
582  Pgm().GetSettingsManager().FlushAndRelease( GetSettings() );
583 
584  Clear_Pcb( false );
585 }
586 
587 
588 void FOOTPRINT_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
589 {
590  Kiway().OnKiCadExit();
591 }
592 
593 
594 void FOOTPRINT_EDIT_FRAME::CloseModuleEditor( wxCommandEvent& Event )
595 {
596  Close();
597 }
598 
599 
600 void FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected( wxUpdateUIEvent& aEvent )
601 {
602  aEvent.Enable( GetBoard()->GetFirstModule() != NULL );
603 }
604 
605 
607 {
609 
610  aEvent.Enable( frame && frame->GetBoard()->GetFirstModule() != NULL );
611 }
612 
613 
615 {
617 
618  MODULE* module_in_edit = GetBoard()->GetFirstModule();
619  bool canInsert = frame && module_in_edit && module_in_edit->GetLink() == niluuid;
620 
621  // If the source was deleted, the module can inserted but not updated in the board.
622  if( frame && module_in_edit && module_in_edit->GetLink() != niluuid ) // this is not a new module
623  {
624  BOARD* mainpcb = frame->GetBoard();
625  canInsert = true;
626 
627  // search if the source module was not deleted:
628  for( auto source_module : mainpcb->Modules() )
629  {
630  if( module_in_edit->GetLink() == source_module->m_Uuid )
631  {
632  canInsert = false;
633  break;
634  }
635  }
636  }
637 
638  aEvent.Enable( canInsert );
639 }
640 
641 
643 {
644 
645  m_Layers->Freeze();
646  m_Layers->ReFill();
647  m_Layers->Thaw();
648 
649  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_Layers );
650 
651  wxSize bestz = m_Layers->GetBestSize();
652 
653  lyrs.MinSize( bestz );
654  lyrs.BestSize( bestz );
655  lyrs.FloatingSize( bestz );
656 
657  if( lyrs.IsDocked() )
658  m_auimgr.Update();
659  else
660  m_Layers->SetSize( bestz );
661 }
662 
663 
665 {
666  // call my base class
668 
669  // We have 2 panes to update.
670  // For some obscure reason, the AUI manager hides the first modified pane.
671  // So force show panes
672  wxAuiPaneInfo& tree_pane_info = m_auimgr.GetPane( m_treePane );
673  bool tree_shown = tree_pane_info.IsShown();
674  tree_pane_info.Caption( _( "Libraries" ) );
675 
676  wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_Layers );
677  bool lm_shown = lm_pane_info.IsShown();
678  lm_pane_info.Caption( _( "Layers Manager" ) );
679 
680  // update the layer manager
683 
684  // Now restore the visibility:
685  lm_pane_info.Show( lm_shown );
686  tree_pane_info.Show( tree_shown );
687  m_auimgr.Update();
688 }
689 
690 
692 {
694  Update3DView( false );
696 }
697 
698 
700 {
701  wxString title;
702  LIB_ID fpid = GetLoadedFPID();
703  bool writable = true;
704 
705  if( IsCurrentFPFromBoard() )
706  {
707  title += wxString::Format( _( "%s [from %s.%s]" ) + wxT( " \u2014 " ),
708  GetBoard()->GetFirstModule()->GetReference(), Prj().GetProjectName(),
710  }
711  else if( fpid.IsValid() )
712  {
713  try
714  {
715  writable = Prj().PcbFootprintLibs()->IsFootprintLibWritable( fpid.GetLibNickname() );
716  }
717  catch( const IO_ERROR& )
718  {
719  // best efforts...
720  }
721 
722  // Note: don't used GetLoadedFPID(); footprint name may have been edited
723  title += wxString::Format( wxT( "%s %s\u2014 " ),
724  FROM_UTF8( GetBoard()->GetFirstModule()->GetFPID().Format().c_str() ),
725  writable ? wxString( wxEmptyString ) : _( "[Read Only] " ) );
726  }
727  else if( !fpid.GetLibItemName().empty() )
728  {
729  // Note: don't used GetLoadedFPID(); footprint name may have been edited
730  title += wxString::Format( wxT( "%s %s \u2014 " ),
731  FROM_UTF8( GetBoard()->GetFirstModule()->GetFPID().GetLibItemName().c_str() ),
732  _( "[Unsaved]" ) );
733  }
734 
735  title += _( "Footprint Editor" );
736 
737  SetTitle( title );
738 }
739 
740 
742 {
743  // Update the layer manager and other widgets from the board setup
744  // (layer and items visibility, colors ...)
745 
746  // Update the layer manager
747  m_Layers->Freeze();
750 
751  // update the layer widget to match board visibility states.
756 
757  m_Layers->Thaw();
758 }
759 
760 
762 {
763  GetCanvas()->UpdateColors();
767  updateTitle();
768 }
769 
770 
772 {
773  FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
774 
775  WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
776  GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter );
777  progressReporter.Show( false );
778 
781 
783  auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
784 
785  adapter->AddLibraries();
786 }
787 
788 
790 {
791  FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
792  auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
793  LIB_ID target = GetTargetFPID();
794  bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() );
795 
796  // Sync FOOTPRINT_INFO list to the libraries on disk
797  if( aProgress )
798  {
799  WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 2 );
800  GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter );
801  progressReporter.Show( false );
802  }
803  else
804  {
806  }
807 
808  // Sync the LIB_TREE to the FOOTPRINT_INFO list
809  adapter->Sync();
810 
812  m_treePane->GetLibTree()->Regenerate( true );
813 
814  if( target.IsValid() )
815  {
816  if( adapter->FindItem( target ) )
817  {
818  if( targetSelected )
819  m_treePane->GetLibTree()->SelectLibId( target );
820  else
821  m_treePane->GetLibTree()->CenterLibId( target );
822  }
823  else
824  {
825  // Try to focus on parent
826  target.SetLibItemName( wxEmptyString );
827  m_treePane->GetLibTree()->CenterLibId( target );
828  }
829  }
830 }
831 
832 
834 {
835  LIB_ID target = GetTargetFPID();
836 
837  m_treePane->GetLibTree()->Regenerate( true );
838 
839  if( target.IsValid() )
840  m_treePane->GetLibTree()->CenterLibId( target );
841 }
842 
843 
845 {
846  m_treePane->GetLibTree()->SelectLibId( aLibID );
847 }
848 
849 
851 {
852  return GetBoard()->IsElementVisible( aElement );
853 }
854 
855 
857 {
858  GetCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
859  GetBoard()->SetElementVisibility( aElement, aNewState );
860  m_Layers->SetRenderState( aElement, aNewState );
861 }
862 
863 
865 {
867 }
868 
869 
871  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
872 {
873  wxTreebook* book = aParent->GetTreebook();
874 
875  book->AddPage( new wxPanel( book ), _( "Footprint Editor" ) );
876  book->AddSubPage( new PANEL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
877  book->AddSubPage( new PANEL_MODEDIT_COLOR_SETTINGS( this, book ), _( "Colors" ) );
878  book->AddSubPage( new PANEL_EDIT_OPTIONS( this, aParent ), _( "Editing Options" ) );
879  book->AddSubPage( new PANEL_MODEDIT_DEFAULTS( this, aParent ), _( "Default Values" ) );
880 
881  aHotkeysPanel->AddHotKeys( GetToolManager() );
882 }
883 
884 
886 {
887  // Create the manager and dispatcher & route draw panel events to the dispatcher
890  GetCanvas()->GetViewControls(), config(), this );
891  m_actions = new PCB_ACTIONS();
893 
895 
904  m_toolManager->RegisterTool( new PCBNEW_CONTROL ); // copy/paste
910 
911  m_toolManager->GetTool<SELECTION_TOOL>()->SetEditModules( true );
912  m_toolManager->GetTool<EDIT_TOOL>()->SetEditModules( true );
913  m_toolManager->GetTool<PAD_TOOL>()->SetEditModules( true );
914  m_toolManager->GetTool<DRAWING_TOOL>()->SetEditModules( true );
915  m_toolManager->GetTool<POINT_EDITOR>()->SetEditModules( true );
916  m_toolManager->GetTool<PCBNEW_CONTROL>()->SetEditModules( true );
917  m_toolManager->GetTool<PCBNEW_PICKER_TOOL>()->SetEditModules( true );
918  m_toolManager->GetTool<POSITION_RELATIVE_TOOL>()->SetEditModules( true );
919 
920  m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
922 
923  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
924 }
925 
926 
928 {
930 
932  PCB_EDITOR_CONDITIONS cond( this );
933 
934  wxASSERT( mgr );
935 
936 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
937 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
938 
939  auto haveFootprintCond =
940  [this]( const SELECTION& )
941  {
942  return GetBoard()->GetFirstModule() != nullptr;
943  };
944 
945  auto footprintTargettedCond =
946  [this] ( const SELECTION& )
947  {
948  return !GetTargetFPID().GetLibItemName().empty();
949  };
950 
951  mgr->SetConditions( ACTIONS::saveAs, ENABLE( footprintTargettedCond ) );
955 
956  mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
957  mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
958 
965 
972  mgr->SetConditions( ACTIONS::selectAll, ENABLE( cond.HasItems() ) );
973 
977 
980 
981 
982  auto highContrastCond =
983  [this] ( const SELECTION& )
984  {
986  };
987 
988  auto footprintTreeCond =
989  [this] (const SELECTION& )
990  {
991  return IsSearchTreeShown();
992  };
993 
994  mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
995  mgr->SetConditions( PCB_ACTIONS::toggleFootprintTree, CHECK( footprintTreeCond ) );
996 
997  mgr->SetConditions( ACTIONS::print, ENABLE( haveFootprintCond ) );
998  mgr->SetConditions( PCB_ACTIONS::exportFootprint, ENABLE( haveFootprintCond ) );
999  mgr->SetConditions( PCB_ACTIONS::footprintProperties, ENABLE( haveFootprintCond ) );
1000  mgr->SetConditions( PCB_ACTIONS::cleanupGraphics, ENABLE( haveFootprintCond ) );
1001 
1002 
1003 // Only enable a tool if the part is edtable
1004 #define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, \
1005  ACTION_CONDITIONS().Enable( haveFootprintCond ).Check( cond.CurrentTool( action ) ) )
1006 
1019 
1020 #undef CURRENT_EDIT_TOOL
1021 #undef ENABLE
1022 #undef CHECK
1023 }
1024 
1025 
1027 {
1029 
1030  // Be sure the axis are enabled
1031  GetCanvas()->GetGAL()->SetAxesEnabled( true );
1032 
1033  updateView();
1034 
1035  // Ensure the m_Layers settings are using the canvas type:
1037 }
1038 
1039 
1040 void FOOTPRINT_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1041 {
1042  PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1043 
1045  GetCanvas()->ForceRefresh();
1046 
1048 
1049  if( aEnvVarsChanged )
1050  SyncLibraryTree( true );
1051 
1052  Layout();
1053  SendSizeEvent();
1054 }
1055 
1056 
1057 void FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng( wxCommandEvent& event )
1058 {
1059  wxString fullFileName;
1060 
1061  LIB_ID id = GetLoadedFPID();
1062 
1063  if( id.empty() )
1064  {
1065  wxMessageBox( _( "No footprint selected." ) );
1066  return;
1067  }
1068 
1069  wxFileName fn( id.GetLibItemName() );
1070  fn.SetExt( "png" );
1071 
1072  wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );
1073 
1074  wxFileDialog dlg( this, _( "Footprint Image File Name" ), projectPath,
1075  fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1076 
1077  if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
1078  return;
1079 
1080  // calling wxYield is mandatory under Linux, after closing the file selector dialog
1081  // to refresh the screen before creating the PNG or JPEG image from screen
1082  wxYield();
1083  SaveCanvasImageToFile( this, dlg.GetPath() );
1084 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
POSITION_RELATIVE_TOOL.
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Definition: infobar.cpp:119
static TOOL_ACTION drawLine
Definition: pcb_actions.h:139
static TOOL_ACTION saveToBoard
Definition: pcb_actions.h:352
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:201
wxSize GetBestSize() const
Function GetBestSize returns the preferred minimum size, taking into consideration the dynamic conten...
#define CHECK(x)
bool IsFootprintLibWritable(const wxString &aNickname)
Function IsFootprintLibWritable.
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:114
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:363
void OnKiCadExit()
Definition: kiway.cpp:585
EVT_UPDATE_UI(ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
void ForceRefresh()
Function ForceRefresh() Forces a redraw.
void OnExitKiCad(wxCommandEvent &aEvent)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:114
void ActivateGalCanvas() override
FOOTPRINT_EDITOR_TOOLS.
void OnUpdateLayerAlpha(wxUpdateUIEvent &aEvent) override
BOARD_DESIGN_SETTINGS & GetDesignSettings() const override
Returns the BOARD_DESIGN_SETTINGS for the open project Overloaded in FOOTPRINT_EDIT_FRAME.
SETTINGS_MANAGER * GetSettingsManager() const
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
const BOX2I GetDocumentExtents() const override
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
#define CURRENT_EDIT_TOOL(action)
virtual void AddModuleToBoard(MODULE *module)
Adds the given module to the board.
bool SaveCanvasImageToFile(EDA_DRAW_FRAME *aFrame, const wxString &aFileName, wxBitmapType aBitmapType)
Save the current view as an image file.
Definition: bitmap.cpp:177
Model changes (required full reload)
Definition: tool_base.h:82
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
SELECTION_CONDITION HasItems()
Creates 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
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
static TOOL_ACTION drawArc
Definition: pcb_actions.h:143
SELECTION_CONDITION FullscreenCursor()
Creates a functor testing if the cursor is full screen in a frame.
PCB_LAYER_WIDGET is here to implement the abstract functions of LAYER_WIDGET so they may be tied into...
static TOOL_ACTION cleanupGraphics
Definition: pcb_actions.h:311
static TOOL_ACTION zoomTool
Definition: actions.h:97
FOOTPRINT_EDITOR_SETTINGS * GetFootprintEditorSettings()
static bool Idle(const SELECTION &aSelection)
Tests 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.
SELECTION_TOOL.
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()
Creates a functor that tests if the frame fills text items.
#define ENABLE(x)
void DisplayErrors(wxTopLevelWindow *aCaller=NULL)
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Creates a functor testing if the specified tool is the current active tool in the frame.
PADS & Pads()
Definition: class_module.h:181
PAD_TOOL.
Definition: pad_tool.h:37
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
void SetCopperLayerCount(int aCount)
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:140
static TOOL_ACTION standardGraphics
Definition: actions.h:162
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: class_board.h:514
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:367
EDA_RECT GetFootprintRect() const
Function GetFootprintRect() Build and returns the boundary box of the module footprint excluding any ...
SELECTION_CONDITION CanvasType(EDA_DRAW_PANEL_GAL::GAL_TYPE aType)
Creates a functor testing if the specified canvas is active in the frame.
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
void AddHotKeys(TOOL_MANAGER *aToolMgr)
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
bool OnLayerSelected()
Function OnLayerSelected ensure the active layer is visible, and other layers not visible when m_alwa...
const LIB_ID & GetFPID() const
Definition: class_module.h:228
SELECTION_CONDITION RedoAvailable()
Creates a functor that tests if there are any items in the redo queue.
wxAuiManager m_auimgr
ACTION_MANAGER.
static TOOL_ACTION print
Definition: actions.h:60
DRAWINGS & GraphicalItems()
Definition: class_module.h:191
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.
void OnUpdateLoadModuleFromBoard(wxUpdateUIEvent &aEvent)
bool IsValid() const
Definition: lib_id.h:171
virtual const PCB_PLOT_PARAMS & GetPlotSettings() const
Function GetPlotSettings returns the PCB_PLOT_PARAMS for the BOARD owned by this frame.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions Display options control the way tracks, vias, outlines and other things ar...
static TOOL_ACTION setAnchor
Definition: pcb_actions.h:157
static TOOL_ACTION imperialUnits
Definition: actions.h:142
static bool NotEmpty(const SELECTION &aSelection)
Tests if there are any items selected.
static TOOL_ACTION placeText
Definition: pcb_actions.h:144
not specified: a GAL engine must be set by the client
SELECTION_CONDITION PadFillDisplay()
Creates a functor that tests if the frame fills the pads.
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.
void SetLayersManagerTabsText()
Function SetLayersManagerTabsText Update the layer manager tabs labels Useful when changing Language ...
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
PCBNEW_CONTROL.
const wxString GetReference() const
Function GetReference.
Definition: class_module.h:451
bool IsContentModified() override
Get if any footprints or libraries have been modified but not saved.
wxTreebook * GetTreebook()
Definition: paged_dialog.h:50
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:51
virtual PCB_LAYER_ID GetActiveLayer() const
FOOTPRINT_LIST_IMPL GFootprintList
The global footprint info table.
TOOL_MANAGER.
Definition: tool_manager.h:51
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
static TOOL_ACTION measureTool
Definition: actions.h:150
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
std::unique_ptr< MODULE > m_revertModule
bool Clear_Pcb(bool aQuery)
Delete all and reinitialize the current board.
Definition: initpcb.cpp:95
static TOOL_ACTION toggleFootprintTree
Definition: pcb_actions.h:341
Generic tool for picking a point.
Multi-thread safe progress reporter dialog, intended for use of tasks that paralleize reporting back ...
void SetCheckboxesFromFilter(SELECTION_FILTER_OPTIONS &aOptions)
void HardRedraw() override
Refresh the library tree and redraw the window.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
SELECTION_CONDITION GridVisible()
Creates a functor testing if the grid is visible in a frame.
#define NULL
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:343
LIB_TREE_NODE * GetCurrentTreeNode() const
Definition: lib_tree.cpp:168
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Creates a functor that tests if the frame has the specified units.
MODULES & Modules()
Definition: class_board.h:247
void OnModify() override
Must be called after a footprint change in order to set the "modify" flag of the current screen and p...
void DisplayBoard(BOARD *aBoard)
Function DisplayBoard adds all items from the current board to the VIEW, so they can be displayed by ...
DRAWING_TOOL.
Definition: drawing_tool.h:50
void SetClearance(int aClearance)
Definition: netclass.h:166
static TOOL_ACTION toggleGrid
Definition: actions.h:138
static TOOL_ACTION exportFootprint
Definition: pcb_actions.h:361
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...
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
PAGE_INFO describes the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.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...
KIID niluuid(0)
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
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.
void ReFillRender()
Function ReFillRender rebuilds Render for instance after the config is read.
PCB_LAYER_WIDGET * m_Layers
Layer manager. It is the responsibility of the child frames to instantiate this.
ACTIONS * m_actions
Definition: tools_holder.h:51
static TOOL_ACTION cut
Definition: actions.h:69
MODULE * GetFirstModule() const
Gets the first module in the list (used in footprint viewer/editor) or NULL if none.
Definition: class_board.h:308
void Regenerate(bool aKeepState)
Regenerates 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)
Function ResetTools() Resets all tools (i.e.
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:141
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
SELECTION_FILTER_OPTIONS m_SelectionFilter
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns 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:97
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
EDA_RECT GetBoardBoundingBox(bool aBoardEdgesOnly=false) const
Function GetBoardBoundingBox calculates the bounding box containing all board items (or board edge se...
static const wxChar A4[]
Definition: page_info.h:65
virtual void OnSize(wxSizeEvent &event)
Recalculate the size of toolbars and display panel when the frame size changes.
void SetLayerVisible(int aLayer, bool aVisible=true)
Function SetLayerVisible() Controls the visibility of a particular layer.
Definition: view.h:388
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves 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
#define KICAD_DEFAULT_DRAWFRAME_STYLE
void SetPadsLocked(bool aPadsLocked)
Definition: class_module.h:349
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
bool IsModify() const
Definition: base_screen.h:104
#define PcbFileExtension
Footprint Editor pane with footprint library tree.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
void SyncLayersVisibility(const BOARD *aBoard)
Function SyncLayersVisibility Updates "visibility" property of each layer of a given BOARD.
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.
COMMON_CONTROL.
void RefreshLibTree()
Refreshes the tree (mainly to update highlighting and asterisking)
Definition: lib_tree.cpp:220
void SetAxesEnabled(bool aAxesEnabled)
Enables drawing the axes.
LIB_TREE * GetLibTree() const
EDIT_TOOL.
Definition: edit_tool.h:74
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
Specialization of the wxAuiPaneInfo class for KiCad panels.
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:212
const PCB_PLOT_PARAMS & GetPlotSettings() const override
Function GetPlotSettings returns the PCB_PLOT_PARAMS for the BOARD owned by this frame.
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:52
void SyncLayerAlphaIndicators()
Function SyncLayerAlphaIndicators updates each "Layer"s alpha indicator to show if the board is curre...
COMMON_TOOLS.
Definition: common_tools.h:38
void UpdateColors()
Updates the color settings in the painter and GAL.
void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
switches currently used canvas (Cairo / OpenGL).
wxString PngFileWildcard()
PCB_DISPLAY_OPTIONS m_DisplayOptions
const BITMAP_OPAQUE icon_modedit_xpm[1]
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
SELECTION_CONDITION ContentModified()
Creates a functor that tests if the content of the frame is modified.
VTBL_ENTRY void SetRString(RSTRING_T aStringId, const wxString &aString)
Function SetRString stores a "retained string", which is any session and project specific string iden...
Definition: project.cpp:214
SELECTION_CONDITION NoActiveTool()
Creates a functor testing if there are no tools active in the frame.
BOARD * GetBoard()
static TOOL_ACTION pasteSpecial
Definition: actions.h:72
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:286
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:235
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:193
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:142
static TOOL_ACTION graphicsOutlines
Display module edges as outlines.
Definition: pcb_actions.h:379
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Allows Modedit to install its preferences panel into the preferences dialog.
void Process_Special_Functions(wxCommandEvent &event)
static TOOL_ACTION saveToLibrary
Definition: pcb_actions.h:353
void updateTitle()
Updates window title according to getLibNickName().
static TOOL_ACTION metricUnits
Definition: actions.h:143
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:68
static TOOL_ACTION redo
Definition: actions.h:68
virtual void OnModify()
Function OnModify Must be called after a change in order to set the "modify" flag of the current scre...
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
VTBL_ENTRY const wxString & GetRString(RSTRING_T aStringId)
Function GetRString returns a "retained string", which is any session and project specific string ide...
Definition: project.cpp:229
LIB_TREE_MODEL_ADAPTER::PTR m_adapter
PCB_ACTIONS.
Definition: pcb_actions.h:51
void SyncLayerVisibilities()
Function SyncLayerVisibilities updates each "Layer" checkbox in this layer widget according to each l...
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:50
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:151
see class PGM_BASE
void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings) override
void LoadModuleFromBoard(wxCommandEvent &event)
Called from the main toolbar to load a footprint from board mainly to edit it.
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 Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
SELECTION_CONDITION GraphicsFillDisplay()
Creates 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: class_board.h:176
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:199
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Sets the work environment (model, view, view controls and the parent window).
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools.
#define _(s)
Definition: 3d_actions.cpp:33
COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
SELECTION_CONDITION UndoAvailable()
Creates a functor that tests if there are any items in the undo queue.
void OnUpdateInsertModuleInBoard(wxUpdateUIEvent &aEvent)
BOARD_ITEM_CONTAINER * GetModel() const override
static TOOL_ACTION acceleratedGraphics
Definition: actions.h:161
void updateView()
Reloads displayed items and sets view.
bool SaveFootprint(MODULE *aModule)
Save in an existing library a given footprint.
NETCLASS * GetDefault() const
Function GetDefault.
PCB_EDIT_FRAME is the main frame for Pcbnew.
FOOTPRINT_TREE_PANE * m_treePane
POINT_EDITOR.
Definition: point_editor.h:43
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely saves a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
static bool empty(const wxTextEntryBase *aCtrl)
unsigned GetErrorCount() const
MAGNETIC_SETTINGS * GetMagneticItemsSettings() override
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
KIID GetLink() const
Definition: class_module.h:567
PCB_VIEWER_TOOLS.
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...
WX_INFOBAR * GetInfoBar()
MODULE_ZONE_CONTAINERS & Zones()
Definition: class_module.h:201
static TOOL_ACTION deleteTool
Definition: actions.h:76
FOOTPRINT_EDITOR_SETTINGS * GetSettings()
static PTR Create(FOOTPRINT_EDIT_FRAME *aFrame, FP_LIB_TABLE *aLibs)
static TOOL_ACTION undo
Definition: actions.h:67
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:78
void OnGridSettings(wxCommandEvent &event)
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:100
void AddModuleToBoard(MODULE *module) override
Override from PCB_BASE_EDIT_FRAME which adds a module to the editor's dummy board,...
void CloseModuleEditor(wxCommandEvent &Event)
void InitTools()
Function 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:135
void OnUpdateModuleSelected(wxUpdateUIEvent &aEvent)
BOARD_DESIGN_SETTINGS m_DesignSettings
Only some of these settings are actually used for footprint editing.
void UpdateAllLayersColor()
Function UpdateAllLayersColor() Applies the new coloring scheme to all layers.
Definition: view.cpp:794
virtual void Update3DView(bool aForceReload, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
void SetRenderState(int aId, bool isSet)
Function SetRenderState sets the state of the checkbox associated with aId within the Render tab grou...
Class that groups generic conditions for PCB editor states.
static constexpr int Millimeter2iu(double mm)
static TOOL_ACTION highContrastMode
Definition: actions.h:101
void SelectLayer(LAYER_NUM aLayer)
Function SelectLayer changes the row selection in the layer list to aLayer provided.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
static TOOL_ACTION selectAll
Definition: actions.h:73
void OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
MODULE * loadFootprint(const LIB_ID &aFootprintId)
Function loadFootprint attempts to load aFootprintId from the footprint library table.
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings Changes the bit-mask of ena...
static TOOL_ACTION paste
Definition: actions.h:71
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
void StopDrawing()
Function StopDrawing() Prevents the GAL canvas from further drawing till it is recreated or StartDraw...
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.
static TOOL_ACTION revert
Definition: actions.h:58
static const wxChar * GetFootprintEditorFrameName()
Function GetFootprintEditorFrameName (static)
static TOOL_ACTION selectionTool
Definition: actions.h:149
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)
Function RegisterTool() Adds a tool to the manager set and sets it up.
void CenterLibId(const LIB_ID &aLibId)
Ensure that an item is visible (preferrably 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:108
virtual void UpdateMsgPanel()
Redraw the message panel.
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:382
bool IsElementVisible(GAL_LAYER_ID aElement) const
Test whether a given element category is visible.