KiCad PCB EDA Suite
footprint_viewer_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) 2012-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
27 #include <bitmaps.h>
28 #include <board_commit.h>
29 #include <board.h>
30 #include <footprint.h>
31 #include <confirm.h>
32 #include <eda_pattern_match.h>
33 #include <footprint_info.h>
34 #include <footprint_viewer_frame.h>
35 #include <fp_lib_table.h>
36 #include <kiway.h>
37 #include <widgets/msgpanel.h>
38 #include <pcb_draw_panel_gal.h>
39 #include <pcb_painter.h>
40 #include <pcbnew_id.h>
42 #include <pgm_base.h>
44 #include <tool/action_toolbar.h>
45 #include <tool/common_control.h>
46 #include <tool/common_tools.h>
47 #include <tool/selection.h>
48 #include <tool/tool_dispatcher.h>
49 #include <tool/tool_manager.h>
50 #include <tool/zoom_tool.h>
51 #include <tools/pcb_viewer_tools.h>
52 #include <tools/pcb_actions.h>
54 #include <tools/pcb_control.h>
55 #include <tools/pcb_picker_tool.h>
59 #include <wx/listbox.h>
60 #include <wx/srchctrl.h>
61 #include <wx/tokenzr.h>
62 #include <wx/choice.h>
63 
64 using namespace std::placeholders;
65 
66 
67 #define NEXT_PART 1
68 #define NEW_PART 0
69 #define PREVIOUS_PART -1
70 
71 
72 BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME )
73  // Window events
76 
77  EVT_MENU( wxID_EXIT, FOOTPRINT_VIEWER_FRAME::OnExitKiCad )
78  EVT_MENU( wxID_CLOSE, FOOTPRINT_VIEWER_FRAME::CloseFootprintViewer )
79 
80  // Toolbar events
86 
88 
91 
92  // listbox events
96 
97 END_EVENT_TABLE()
98 
99 
100 /*
101  * Note: FOOTPRINT_VIEWER_FRAME can be created in "modal mode", or as a usual frame.
102  */
103 #define PARENT_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT )
104 #define MODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP )
105 #define NONMODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE )
106 
107 
109  FRAME_T aFrameType ) :
110  PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Library Browser" ),
111  wxDefaultPosition, wxDefaultSize,
112  aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL ? ( aParent ? PARENT_STYLE : MODAL_STYLE )
113  : NONMODAL_STYLE,
116 {
117  wxASSERT( aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL || aFrameType == FRAME_FOOTPRINT_VIEWER );
118 
119  if( aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL )
120  SetModal( true );
121 
122  m_aboutTitle = _( "KiCad Footprint Library Viewer" );
123 
124  // Force the items to always snap
127  m_magneticItems.graphics = true;
128 
129  // Force the frame name used in config. the footprint viewer frame has a name
130  // depending on aFrameType (needed to identify the frame by wxWidgets),
131  // but only one configuration is preferable.
133 
134  // Give an icon
135  wxIcon icon;
136  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_footprint_browser ) );
137  SetIcon( icon );
138 
139  wxPanel* libPanel = new wxPanel( this );
140  wxSizer* libSizer = new wxBoxSizer( wxVERTICAL );
141 
142  m_libFilter = new wxSearchCtrl( libPanel, ID_MODVIEW_LIB_FILTER, wxEmptyString,
143  wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
144  m_libFilter->SetDescriptiveText( _( "Filter" ) );
145  libSizer->Add( m_libFilter, 0, wxEXPAND, 5 );
146 
147  m_libList = new wxListBox( libPanel, ID_MODVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
148  0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
149  libSizer->Add( m_libList, 1, wxEXPAND, 5 );
150 
151  libPanel->SetSizer( libSizer );
152  libPanel->Fit();
153 
154  wxPanel* fpPanel = new wxPanel( this );
155  wxSizer* fpSizer = new wxBoxSizer( wxVERTICAL );
156 
157  m_fpFilter = new wxSearchCtrl( fpPanel, ID_MODVIEW_FOOTPRINT_FILTER, wxEmptyString,
158  wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
159  m_fpFilter->SetDescriptiveText( _( "Filter" ) );
160  m_fpFilter->SetToolTip(
161  _( "Filter on footprint name, keywords, description and pad count.\n"
162  "Search terms are separated by spaces. All search terms must match.\n"
163  "A term which is a number will also match against the pad count." ) );
164  fpSizer->Add( m_fpFilter, 0, wxEXPAND, 5 );
165 
166 #ifdef __WXGTK__
167  // wxSearchCtrl vertical height is not calculated correctly on some GTK setups
168  // See https://gitlab.com/kicad/code/kicad/-/issues/9019
169  m_libFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT( "qb" ) ).y + 10 ) );
170  m_fpFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT( "qb" ) ).y + 10 ) );
171 #endif
172 
173  m_fpList = new wxListBox( fpPanel, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize,
174  0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
175  fpSizer->Add( m_fpList, 1, wxEXPAND, 5 );
176 
177  fpPanel->SetSizer( fpSizer );
178  fpPanel->Fit();
179 
180  // Create GAL canvas
182  PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
184  SetCanvas( drawPanel );
185 
186  SetBoard( new BOARD() );
187 
188  // This board will only be used to hold a footprint for viewing
190 
191  // In viewer, the default net clearance is not known (it depends on the actual board).
192  // So we do not show the default clearance, by setting it to 0
193  // The footprint or pad specific clearance will be shown
195 
196  // Don't show the default board solder mask clearance in the footprint viewer. Only the
197  // footprint or pad clearance setting should be shown if it is not 0.
199 
200  // Ensure all layers and items are visible:
202  SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
203 
204  GetScreen()->m_Center = true; // Center coordinate origins on screen.
205  LoadSettings( config() );
207 
208  // Create the manager and dispatcher & route draw panel events to the dispatcher
210  m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(),
211  drawPanel->GetViewControls(), config(), this );
212  m_actions = new PCB_ACTIONS();
214  drawPanel->SetEventDispatcher( m_toolDispatcher );
215 
218  m_toolManager->RegisterTool( new COMMON_TOOLS ); // for std context menus (zoom & grid)
220  m_toolManager->RegisterTool( new PCB_PICKER_TOOL ); // for setting grid origin
223 
224  m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
225 
227  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
228 
230  ReCreateMenuBar();
234 
236  UpdateTitle();
237 
238  // If a footprint was previously loaded, reload it
239  if( getCurNickname().size() && getCurFootprintName().size() )
240  {
241  LIB_ID id;
242 
244  id.SetLibItemName( getCurFootprintName() );
245  GetBoard()->Add( loadFootprint( id ) );
246  }
247 
248  drawPanel->DisplayBoard( m_pcb );
249 
250  m_auimgr.SetManagedWindow( this );
251 
252  // Horizontal items; layers 4 - 6
253  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().VToolbar().Name( "MainToolbar" ).Top().Layer(6) );
254  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
255  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
256 
257  // Vertical items; layers 1 - 3
258  m_auimgr.AddPane( libPanel, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(2)
259  .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
260  m_auimgr.AddPane( fpPanel, EDA_PANE().Palette().Name( "Footprints" ).Left().Layer( 1)
261  .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
262 
263  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
264 
265  // after changing something to the aui manager call Update() to reflect the changes
266  m_auimgr.Update();
267 
268  // The canvas should not steal the focus from the list boxes
269  GetCanvas()->SetCanFocus( false );
270  GetCanvas()->GetGAL()->SetAxesEnabled( true );
272 
273  // Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.)
275  wxASSERT( cfg );
277 
278  updateView();
279  setupUnits( config() );
280 
281  if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
282  {
284  Raise(); // On some window managers, this is needed
285  Show( true );
286  }
287 }
288 
289 
291 {
292  // Shutdown all running tools
293  if( m_toolManager )
295 
296  GetCanvas()->StopDrawing();
297  GetCanvas()->GetView()->Clear();
298  // Be sure any event cannot be fired after frame deletion:
299  GetCanvas()->SetEvtHandlerEnabled( false );
300 }
301 
302 
304 {
305  return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
306 }
307 
308 
310 {
312 
314  PCB_EDITOR_CONDITIONS cond( this );
315 
316  wxASSERT( mgr );
317 
318 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
319 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
320 
324  CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
327 
328 
330  CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
335 
340 
341 #undef ENABLE
342 #undef CHECK
343 }
344 
345 
347 {
348  // A workaround to avoid flicker, in modal mode when modview frame is destroyed,
349  // when the aui toolbar is not docked (i.e. shown in a miniframe)
350  // (useful on windows only)
351  m_mainToolBar->SetFocus();
352 
353  GetCanvas()->StopDrawing();
354 
355  if( IsModal() )
356  {
357  // Only dismiss a modal frame once, so that the return values set by
358  // the prior DismissModal() are not bashed for ShowModal().
359  if( !IsDismissed() )
360  DismissModal( false );
361 
362  // window to be destroyed by the caller of KIWAY_PLAYER::ShowModal()
363  }
364  else
365  {
366  Destroy();
367  }
368 }
369 
370 
371 void FOOTPRINT_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv )
372 {
373  if( m_auimgr.GetManagedWindow() )
374  m_auimgr.Update();
375 
376  SizeEv.Skip();
377 }
378 
379 
381 {
382  m_libList->Clear();
383 
384  std::vector<wxString> nicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
385  std::set<wxString> excludes;
386 
387  if( !m_libFilter->GetValue().IsEmpty() )
388  {
389  wxStringTokenizer tokenizer( m_libFilter->GetValue() );
390 
391  while( tokenizer.HasMoreTokens() )
392  {
393  const wxString term = tokenizer.GetNextToken().Lower();
394  EDA_COMBINED_MATCHER matcher( term );
395  int matches, position;
396 
397  for( const wxString& nickname : nicknames )
398  {
399  if( !matcher.Find( nickname.Lower(), matches, position ) )
400  excludes.insert( nickname );
401  }
402  }
403  }
404 
405  for( const wxString& nickname : nicknames )
406  {
407  if( !excludes.count( nickname ) )
408  m_libList->Append( nickname );
409  }
410 
411  // Search for a previous selection:
412  int index = m_libList->FindString( getCurNickname(), true );
413 
414  if( index == wxNOT_FOUND )
415  {
416  if( m_libList->GetCount() > 0 )
417  {
418  m_libList->SetSelection( 0 );
419  wxCommandEvent dummy;
421  }
422  else
423  {
424  setCurNickname( wxEmptyString );
425  setCurFootprintName( wxEmptyString );
426  }
427  }
428  else
429  {
430  m_libList->SetSelection( index, true );
431  wxCommandEvent dummy;
433  }
434 
435  GetCanvas()->Refresh();
436 }
437 
438 
440 {
441  m_fpList->Clear();
442 
443  if( !getCurNickname() )
444  setCurFootprintName( wxEmptyString );
445 
446  auto fp_info_list = FOOTPRINT_LIST::GetInstance( Kiway() );
447 
448  wxString nickname = getCurNickname();
449 
450  fp_info_list->ReadFootprintFiles( Prj().PcbFootprintLibs(), !nickname ? nullptr : &nickname );
451 
452  if( fp_info_list->GetErrorCount() )
453  {
454  fp_info_list->DisplayErrors( this );
455 
456  // For footprint libraries that support one footprint per file, there may have been
457  // valid footprints read so show the footprints that loaded properly.
458  if( fp_info_list->GetList().empty() )
459  return;
460  }
461 
462  std::set<wxString> excludes;
463 
464  if( !m_fpFilter->GetValue().IsEmpty() )
465  {
466  wxStringTokenizer tokenizer( m_fpFilter->GetValue() );
467 
468  while( tokenizer.HasMoreTokens() )
469  {
470  const wxString term = tokenizer.GetNextToken().Lower();
471  EDA_COMBINED_MATCHER matcher( term );
472  int matches, position;
473 
474  for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
475  {
476  wxString search = footprint->GetFootprintName() + " " + footprint->GetSearchText();
477  bool matched = matcher.Find( search.Lower(), matches, position );
478 
479  if( !matched && term.IsNumber() )
480  matched = ( wxAtoi( term ) == (int)footprint->GetPadCount() );
481 
482  if( !matched )
483  excludes.insert( footprint->GetFootprintName() );
484  }
485  }
486  }
487 
488  for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
489  {
490  if( !excludes.count( footprint->GetFootprintName() ) )
491  m_fpList->Append( footprint->GetFootprintName() );
492  }
493 
494  int index = m_fpList->FindString( getCurFootprintName(), true );
495 
496  if( index == wxNOT_FOUND )
497  {
498  if( m_fpList->GetCount() > 0 )
499  {
500  m_fpList->SetSelection( 0 );
501  m_fpList->EnsureVisible( 0 );
502 
503  wxCommandEvent dummy;
505  }
506  else
507  {
508  setCurFootprintName( wxEmptyString );
509  }
510  }
511  else
512  {
513  m_fpList->SetSelection( index, true );
514  m_fpList->EnsureVisible( index );
515  }
516 }
517 
518 
519 void FOOTPRINT_VIEWER_FRAME::OnLibFilter( wxCommandEvent& aEvent )
520 {
522 
523  // Required to avoid interaction with SetHint()
524  // See documentation for wxTextEntry::SetHint
525  aEvent.Skip();
526 }
527 
528 
529 void FOOTPRINT_VIEWER_FRAME::OnFPFilter( wxCommandEvent& aEvent )
530 {
532 
533  // Required to avoid interaction with SetHint()
534  // See documentation for wxTextEntry::SetHint
535  aEvent.Skip();
536 }
537 
538 
539 void FOOTPRINT_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent )
540 {
541  if( aEvent.GetKeyCode() == WXK_UP )
542  {
543  if( m_libFilter->HasFocus() || m_libList->HasFocus() )
545  else
546  selectPrev( m_fpList );
547  }
548  else if( aEvent.GetKeyCode() == WXK_DOWN )
549  {
550  if( m_libFilter->HasFocus() || m_libList->HasFocus() )
552  else
553  selectNext( m_fpList );
554  }
555  else if( aEvent.GetKeyCode() == WXK_TAB && m_libFilter->HasFocus() )
556  {
557  if( !aEvent.ShiftDown() )
558  m_fpFilter->SetFocus();
559  else
560  aEvent.Skip();
561  }
562  else if( aEvent.GetKeyCode() == WXK_TAB && m_fpFilter->HasFocus() )
563  {
564  if( aEvent.ShiftDown() )
565  m_libFilter->SetFocus();
566  else
567  aEvent.Skip();
568  }
569  else if( aEvent.GetKeyCode() == WXK_RETURN && m_fpList->GetSelection() >= 0 )
570  {
571  wxCommandEvent dummy;
573  }
574  else
575  {
576  aEvent.Skip();
577  }
578 }
579 
580 
581 void FOOTPRINT_VIEWER_FRAME::selectPrev( wxListBox* aListBox )
582 {
583  int prev = aListBox->GetSelection() - 1;
584 
585  if( prev >= 0 )
586  {
587  aListBox->SetSelection( prev );
588  aListBox->EnsureVisible( prev );
589 
590  wxCommandEvent dummy;
591 
592  if( aListBox == m_libList )
594  else
596  }
597 }
598 
599 
600 void FOOTPRINT_VIEWER_FRAME::selectNext( wxListBox* aListBox )
601 {
602  int next = aListBox->GetSelection() + 1;
603 
604  if( next < (int)aListBox->GetCount() )
605  {
606  aListBox->SetSelection( next );
607  aListBox->EnsureVisible( next );
608 
609  wxCommandEvent dummy;
610 
611  if( aListBox == m_libList )
613  else
615  }
616 }
617 
618 
619 void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& aEvent )
620 {
621  int ii = m_libList->GetSelection();
622 
623  if( ii < 0 )
624  return;
625 
626  wxString name = m_libList->GetString( ii );
627 
628  if( getCurNickname() == name )
629  return;
630 
631  setCurNickname( name );
632 
634  UpdateTitle();
635 }
636 
637 
638 void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& aEvent )
639 {
640  if( m_fpList->GetCount() == 0 )
641  return;
642 
643  int ii = m_fpList->GetSelection();
644 
645  if( ii < 0 )
646  return;
647 
648  wxString name = m_fpList->GetString( ii );
649 
650  if( getCurFootprintName().CmpNoCase( name ) != 0 )
651  {
653 
654  // Delete the current footprint (MUST reset tools first)
656 
658 
659  LIB_ID id;
661  id.SetLibItemName( getCurFootprintName() );
662 
663  try
664  {
665  GetBoard()->Add( loadFootprint( id ) );
666  }
667  catch( const IO_ERROR& ioe )
668  {
669  wxString msg =
670  wxString::Format( _( "Could not load footprint '%s' from library '%s'."
671  "\n\n%s" ),
673  DisplayError( this, msg );
674  }
675 
676  UpdateTitle();
677 
678  updateView();
679 
680  GetCanvas()->Refresh();
681  Update3DView( true, true );
682  }
683 }
684 
685 
686 void FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList( wxCommandEvent& aEvent )
687 {
688  AddFootprintToPCB( aEvent );
689 }
690 
691 
692 void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
693 {
694  if( IsModal() )
695  {
696  if( m_fpList->GetSelection() >= 0 )
697  {
698  LIB_ID fpid( getCurNickname(), m_fpList->GetStringSelection() );
699  DismissModal( true, fpid.Format() );
700  }
701  else
702  {
703  DismissModal( false );
704  }
705  }
706  else if( GetBoard()->GetFirstFootprint() )
707  {
708  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
709 
710  if( pcbframe == nullptr ) // happens when the board editor is not active (or closed)
711  {
712  DisplayErrorMessage( this, _( "No board currently open." ) );
713  return;
714  }
715 
716  TOOL_MANAGER* toolMgr = pcbframe->GetToolManager();
717 
718  if( toolMgr->GetTool<BOARD_EDITOR_CONTROL>()->PlacingFootprint() )
719  {
720  DisplayError( this, _( "Previous footprint placement still in progress." ) );
721  return;
722  }
723 
724  toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
725  BOARD_COMMIT commit( pcbframe );
726 
727  // Create the "new" footprint
728  FOOTPRINT* newFootprint = (FOOTPRINT*) GetBoard()->GetFirstFootprint()->Duplicate();
729  newFootprint->SetParent( pcbframe->GetBoard() );
730  newFootprint->SetLink( niluuid );
731  newFootprint->SetFlags(IS_NEW ); // whatever
732 
733  for( PAD* pad : newFootprint->Pads() )
734  {
735  // Set the pads ratsnest settings to the global settings
736  pad->SetLocalRatsnestVisible( pcbframe->GetDisplayOptions().m_ShowGlobalRatsnest );
737 
738  // Pads in the library all have orphaned nets. Replace with Default.
739  pad->SetNetCode( 0 );
740  }
741 
742  // Put it on FRONT layer,
743  // (Can be stored flipped if the lib is an archive built from a board)
744  if( newFootprint->IsFlipped() )
745  newFootprint->Flip( newFootprint->GetPosition(),
746  pcbframe->Settings().m_FlipLeftRight );
747 
748  KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetCanvas()->GetViewControls();
749  VECTOR2D cursorPos = viewControls->GetCursorPosition();
750 
751  commit.Add( newFootprint );
752  viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
753  pcbframe->PlaceFootprint( newFootprint );
754 
755  newFootprint->SetPosition( wxPoint( 0, 0 ) );
756  viewControls->SetCrossHairCursorPosition( cursorPos, false );
757  commit.Push( wxT( "Insert footprint" ) );
758 
759  pcbframe->Raise();
760  toolMgr->RunAction( PCB_ACTIONS::placeFootprint, true, newFootprint );
761 
762  newFootprint->ClearFlags();
763  }
764 }
765 
766 
768 {
769  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
770  wxCHECK( cfg, /*void*/ );
771 
772  // We don't allow people to change this right now, so make sure it's on
774 
776 
777  // Fetch display and grid settings from Footprint Editor
778  auto fpedit = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
779  m_displayOptions = fpedit->m_Display;
780  GetGalDisplayOptions().ReadWindowSettings( fpedit->m_Window );
781 }
782 
783 
785 {
786  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
787  wxCHECK( cfg, /*void*/ );
788 
790 
791  // We don't want to store anything other than the window settings
793 
795 }
796 
797 
799 {
800  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
801  wxCHECK_MSG( cfg, nullptr, "config not existing" );
802 
803  return &cfg->m_FootprintViewer;
804 }
805 
806 
808 {
809  auto* settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
810 
811  if( settings )
812  return Pgm().GetSettingsManager().GetColorSettings( settings->m_ColorTheme );
813  else
814  return Pgm().GetSettingsManager().GetColorSettings();
815 }
816 
817 
818 void FOOTPRINT_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
819 {
820  PCB_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
821 
822  if( aEnvVarsChanged )
824 }
825 
826 
828 {
830 }
831 
832 
833 void FOOTPRINT_VIEWER_FRAME::setCurNickname( const wxString& aNickname )
834 {
836 }
837 
838 
840 {
842 }
843 
844 
845 void FOOTPRINT_VIEWER_FRAME::setCurFootprintName( const wxString& aName )
846 {
848 }
849 
850 
851 void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
852 {
853  if( event.GetActive() )
854  {
855  // Ensure we have the right library list:
856  std::vector< wxString > libNicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
857  bool stale = false;
858 
859  if( libNicknames.size() != m_libList->GetCount() )
860  stale = true;
861  else
862  {
863  for( unsigned ii = 0; ii < libNicknames.size(); ii++ )
864  {
865  if( libNicknames[ii] != m_libList->GetString( ii ) )
866  {
867  stale = true;
868  break;
869  }
870  }
871  }
872 
873  if( stale )
874  {
876  UpdateTitle();
877  }
878  }
879 
880  event.Skip(); // required under wxMAC
881 }
882 
883 
884 void FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton( wxUpdateUIEvent& aEvent )
885 {
886  aEvent.Enable( GetBoard()->GetFirstFootprint() != nullptr );
887 }
888 
889 
890 bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
891 {
892  if( aFootprint && !aFootprint->IsEmpty() )
893  {
894  wxString msg;
895  LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
896  LIB_ID fpid;
897 
898  fpid.Parse( *aFootprint, true );
899 
900  if( fpid.IsValid() )
901  {
902  wxString libraryName = fpid.GetLibNickname();
903 
904  if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) )
905  {
906  msg.sprintf( _( "The current configuration does not include library '%s'. Use "
907  "Manage Footprint Libraries to edit the configuration." ),
908  libraryName );
909  DisplayErrorMessage( aParent, _( "Footprint library not found." ), msg );
910  }
911  else if ( !fpTable->HasLibrary( fpid.GetLibNickname(), true ) )
912  {
913  msg.sprintf( _( "Library '%s' is not enabled in the current configuration. Use "
914  "Manage Footprint Libraries to edit the configuration." ),
915  libraryName );
916  DisplayErrorMessage( aParent, _( "Footprint library not enabled." ), msg );
917  }
918  else
919  {
920  // Update last selection:
921  setCurNickname( libraryName );
923  m_libList->SetStringSelection( libraryName );
924  }
925  }
926  }
927 
928  // Rebuild the fp list from the last selected library,
929  // and show the last selected footprint
932 
933  bool retval = KIWAY_PLAYER::ShowModal( aFootprint, aParent );
934 
935  m_libFilter->SetFocus();
936  return retval;
937 }
938 
939 
940 void FOOTPRINT_VIEWER_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
941 {
942  wxString title = _( "3D Viewer" ) + wxT( " \u2014 " ) + getCurFootprintName();
943  PCB_BASE_FRAME::Update3DView( aMarkDirty, aRefresh, &title );
944 }
945 
946 
948 {
949  return GetColorSettings()->GetColor( LAYER_GRID );
950 }
951 
952 
954 {
955  switch( event.GetId() )
956  {
957  case ID_MODVIEW_NEXT:
959  break;
960 
961  case ID_MODVIEW_PREVIOUS:
963  break;
964 
965  default:
966  wxString id = wxString::Format( "%i", event.GetId() );
967  wxFAIL_MSG( "FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList error: id = " + id );
968  }
969 }
970 
971 
973 {
974  wxString title;
975  wxString path;
976 
977  if( !getCurNickname().IsEmpty() )
978  {
979  title = getCurNickname();
980 
981  FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
982  const LIB_TABLE_ROW* row = libtable->FindRow( getCurNickname() );
983 
984  if( row )
985  title += wxT( " \u2014 " ) + row->GetFullURI( true );
986  }
987  else
988  {
989  title = _( "[no library selected]" );
990  }
991 
992  title += wxT( " \u2014 " ) + _( "Footprint Library Browser" );
993 
994  SetTitle( title );
995 }
996 
997 
999 {
1000  if( !getCurNickname() )
1001  return;
1002 
1003  int selection = m_fpList->FindString( getCurFootprintName(), true );
1004 
1005  if( aMode == NEXT_PART )
1006  {
1007  if( selection != wxNOT_FOUND && selection < (int)m_fpList->GetCount() - 1 )
1008  selection++;
1009  }
1010 
1011  if( aMode == PREVIOUS_PART )
1012  {
1013  if( selection != wxNOT_FOUND && selection > 0 )
1014  selection--;
1015  }
1016 
1017  if( selection != wxNOT_FOUND )
1018  {
1019  m_fpList->SetSelection( selection );
1020  m_fpList->EnsureVisible( selection );
1021 
1022  setCurFootprintName( m_fpList->GetString((unsigned) selection ) );
1023 
1024  // Delete the current footprint
1026 
1028  getCurFootprintName() );
1029 
1030  if( footprint )
1031  GetBoard()->Add( footprint, ADD_MODE::APPEND );
1032 
1033  Update3DView( true, true );
1034 
1035  updateView();
1036  }
1037 
1038  UpdateTitle();
1039 
1040  GetCanvas()->Refresh();
1041 }
1042 
1043 
1045 {
1046  GetCanvas()->UpdateColors();
1048 
1050 
1051  if( m_zoomSelectBox->GetSelection() == 0 )
1053  else
1055 
1056  UpdateMsgPanel();
1057 }
1058 
1059 
1060 void FOOTPRINT_VIEWER_FRAME::OnExitKiCad( wxCommandEvent& event )
1061 {
1062  Kiway().OnKiCadExit();
1063 }
1064 
1065 
1067 {
1068  Close( false );
1069 }
1070 
1071 
1073 {
1074  return GetBoard()->GetFirstFootprint();
1075 }
1076 
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
virtual bool ShowModal(wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until t...
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
CITER next(CITER it)
Definition: ptree.cpp:126
virtual void SetBoard(BOARD *aBoard)
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
void DClickOnFootprintList(wxCommandEvent &aEvent)
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
void OnKiCadExit()
Definition: kiway.cpp:626
#define PREVIOUS_PART
void OnExitKiCad(wxCommandEvent &event)
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
bool ShowModal(wxString *aFootprint, wxWindow *aParent) override
Run the footprint viewer as a modal dialog.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
KIID niluuid(0)
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
void UpdateTitle()
Update the window title with current library information.
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
#define FOOTPRINT_VIEWER_FRAME_NAME_MODAL
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:292
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
Model changes (required full reload)
Definition: tool_base.h:80
#define IS_NEW
New item, just created.
This file is part of the common library.
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Return a pointer to the window settings for this frame.
bool IsDismissed()
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
ACTION_TOOLBAR * m_optionsToolBar
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
Definition: commit.h:78
virtual void SetScreen(BASE_SCREEN *aScreen)
static TOOL_ACTION zoomTool
Definition: actions.h:99
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:32
EVT_UPDATE_UI(ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void setCurFootprintName(const wxString &aName)
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.
Component library viewer main window.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
FOOTPRINT_VIEWER_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType)
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
static TOOL_ACTION millimetersUnits
Definition: actions.h:146
void selectNext(wxListBox *aListBox)
FOOTPRINT * FootprintLoad(const wxString &aNickname, const wxString &aFootprintName, bool aKeepUUID=false)
Load a footprint having aFootprintName from the library given by aNickname.
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:153
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:383
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:516
wxAuiManager m_auimgr
#define PARENT_STYLE
ACTION_TOOLBAR * m_mainToolBar
Manage TOOL_ACTION objects.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
double m_FootprintViewerZoom
The last zoom level used (0 for auto)
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.
The base class for create windows for drawing purpose.
void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:159
void setCurNickname(const wxString &aNickname)
void OnUpdateFootprintButton(wxUpdateUIEvent &aEvent)
Update the ID_ADD_FOOTPRINT_TO_BOARD tool state in main toolbar.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr) override
Update the 3D view, if the viewer is opened by this frame.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
virtual const wxString Problem() const
what was the problem?
Definition: exceptions.cpp:46
bool always_show_cursor
Definition: app_settings.h:42
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
SELECTION_CONDITION PadFillDisplay()
Create a functor that tests if the frame fills the pads.
#define NEW_PART
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:116
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void PlaceFootprint(FOOTPRINT *aFootprint, bool aRecreateRatsnest=true)
Places aFootprint at the current cursor position and updates footprint coordinates with the new posit...
PADS & Pads()
Definition: footprint.h:168
Abstract pattern-matching tool and implementations.
bool m_axesEnabled
Fullscreen crosshair or small cross.
void ClickOnLibList(wxCommandEvent &aEvent)
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
PCB_DISPLAY_OPTIONS m_displayOptions
Master controller class:
Definition: tool_manager.h:54
static TOOL_ACTION measureTool
Definition: actions.h:154
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:608
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:81
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
static FOOTPRINT_LIST * GetInstance(KIWAY &aKiway)
Factory function to return a FOOTPRINT_LIST via Kiway.
static TOOL_ACTION centerContents
Definition: actions.h:100
void SelectAndViewFootprint(int aMode)
Select and load the next or the previous footprint.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
FOOTPRINT * loadFootprint(const LIB_ID &aFootprintId)
Attempts to load aFootprintId from the footprint library table.
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:317
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
CURSOR_SETTINGS cursor
Definition: app_settings.h:88
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
virtual void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
void DisplayBoard(BOARD *aBoard)
Add all items from the current board to the VIEW, so they can be displayed by GAL.
void Clear()
Remove all items from the view.
Definition: view.cpp:1104
void SetClearance(int aClearance)
Definition: netclass.h:125
static TOOL_ACTION toggleGrid
Definition: actions.h:140
bool m_Center
Center on screen.
Definition: base_screen.h:96
Handle actions that are shared between different frames in PcbNew.
Definition: pcb_control.h:46
static TOOL_ACTION showPadNumbers
Definition: pcb_actions.h:250
#define NEXT_PART
EDA_MSG_PANEL * m_messagePanel
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
static TOOL_ACTION inchesUnits
Definition: actions.h:144
wxChoice * m_zoomSelectBox
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1472
void OnCharHook(wxKeyEvent &aEvent) override
Capture the key event before it is sent to the GUI.
ACTIONS * m_actions
Definition: tools_holder.h:159
bool Find(const wxString &aTerm, int &aMatchersTriggered, int &aPosition)
Handle actions specific to the board editor in PcbNew.
Definition of file extensions used in Kicad.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
An interface for classes handling user events controlling the view behavior such as zooming,...
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
#define _(s)
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:90
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:154
BOARD_ITEM * Duplicate() const override
Create a copy of this BOARD_ITEM.
Definition: footprint.cpp:1706
void OnActivate(wxActivateEvent &event)
Called when the frame frame is activate to reload the libraries and component lists that can be chang...
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
#define MODAL_STYLE
WINDOW_SETTINGS m_FootprintViewer
#define FOOTPRINT_VIEWER_FRAME_NAME
void OnFPFilter(wxCommandEvent &aEvent)
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
Handle actions that are shared between different applications.
void selectPrev(wxListBox *aListBox)
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
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.
bool IsModal() const override
Return true if the frame is shown in our modal mode and false if the frame is shown as an usual frame...
Definition: kiway_player.h:173
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...
static TOOL_ACTION milsUnits
Definition: actions.h:145
COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:160
Handles action that are shared between different applications.
Definition: common_tools.h:37
void UpdateColors()
Update the color settings in the painter and GAL.
Generic tool for picking an item.
void SetModal(bool aIsModal)
Definition: kiway_player.h:174
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
virtual void SetRString(RSTRING_T aStringId, const wxString &aString)
Store a "retained string", which is any session and project specific string identified in enum RSTRIN...
Definition: project.cpp:212
SELECTION_CONDITION PadNumbersDisplay()
Create a functor that tests if the pad numbers are displayed.
#define NONMODAL_STYLE
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:283
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:243
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:97
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:550
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 graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:393
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
bool IsFlipped() const
Definition: footprint.h:277
void SetLink(const KIID &aLink)
Definition: footprint.h:562
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
COLOR4D GetColor(int aLayer) const
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
Definition: project.cpp:227
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:49
Gather all the actions that are shared by tools.
Definition: pcb_actions.h:48
#define CHECK(x)
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:160
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
see class PGM_BASE
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
const char * name
Definition: DXF_plotter.cpp:56
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
void CloseFootprintViewer(wxCommandEvent &event)
SELECTION_CONDITION GraphicsFillDisplay()
Create a functor that tests if the frame fills graphics items.
void AddFootprintToPCB(wxCommandEvent &aEvent)
Export the current footprint name and close the library browser.
bool PlacingFootprint() const
Re-entrancy checker for above.
void ReCreateMenuBar() override
Recreates the menu bar.
void ClickOnFootprintList(wxCommandEvent &aEvent)
void DismissModal(bool aRetVal, const wxString &aResult=wxEmptyString)
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.
void setupUnits(APP_SETTINGS_BASE *aCfg)
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
void ReCreateLibraryList()
Create or recreate the list of current loaded libraries.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
NETCLASS * GetDefault() const
MAGNETIC_OPTIONS pads
The main frame for Pcbnew.
PCBNEW_SETTINGS & Settings()
PCBNEW_SETTINGS * GetPcbNewSettings() const
The selection tool: currently supports:
void OnLibFilter(wxCommandEvent &aEvent)
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Revert the commit by restoring the modified items state.
wxPoint GetPosition() const override
Definition: footprint.h:186
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Tool useful for viewing footprints.
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:199
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
MAGNETIC_SETTINGS m_magneticItems
Color settings are a bit different than most of the settings objects in that there can be more than o...
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
Definition: board.cpp:836
BOARD_ITEM_CONTAINER * GetModel() const override
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:102
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 OnIterateFootprintList(wxCommandEvent &event)
void InitTools()
Initializes all registered tools.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
BOARD * GetBoard() const
Definition: pad.h:57
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1543
double GetScale() const
Definition: view.h:264
Message panel definition file.
virtual COLOR4D GetGridColor() override
Group generic conditions for PCB editor states.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
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.
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:203
wxString m_aboutTitle
static TOOL_ACTION selectionTool
Definition: actions.h:153
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
wxString m_configName
MAGNETIC_OPTIONS tracks
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
virtual void UpdateMsgPanel()
Redraw the message panel.
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:396
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.