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 <dialog_helpers.h>
33 #include <eda_pattern_match.h>
34 #include <footprint_info.h>
35 #include <footprint_viewer_frame.h>
36 #include <fp_lib_table.h>
37 #include <kiway.h>
38 #include <widgets/msgpanel.h>
39 #include <pcb_draw_panel_gal.h>
40 #include <pcb_painter.h>
41 #include <pcbnew_id.h>
43 #include <pgm_base.h>
45 #include <tool/action_toolbar.h>
46 #include <tool/common_control.h>
47 #include <tool/common_tools.h>
48 #include <tool/selection.h>
49 #include <tool/tool_dispatcher.h>
50 #include <tool/tool_manager.h>
51 #include <tool/zoom_tool.h>
52 #include <tools/pcb_viewer_tools.h>
53 #include <tools/pcb_actions.h>
55 #include <tools/pcb_control.h>
56 #include <tools/pcb_picker_tool.h>
59 #include <wx/listbox.h>
60 #include <wx/srchctrl.h>
61 #include <wx/tokenzr.h>
62 
63 using namespace std::placeholders;
64 
65 
66 #define NEXT_PART 1
67 #define NEW_PART 0
68 #define PREVIOUS_PART -1
69 
70 
71 BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME )
72  // Window events
75 
76  EVT_MENU( wxID_EXIT, FOOTPRINT_VIEWER_FRAME::OnExitKiCad )
77  EVT_MENU( wxID_CLOSE, FOOTPRINT_VIEWER_FRAME::CloseFootprintViewer )
78 
79  // Toolbar events
85 
87 
90 
91  // listbox events
95 
96 END_EVENT_TABLE()
97 
98 
99 /*
100  * Note: FOOTPRINT_VIEWER_FRAME can be created in "modal mode", or as a usual frame.
101  */
102 #define PARENT_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT )
103 #define MODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP )
104 #define NONMODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE )
105 
106 
108  FRAME_T aFrameType ) :
109  PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Library Browser" ),
110  wxDefaultPosition, wxDefaultSize,
111  aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL ? ( aParent ? PARENT_STYLE : MODAL_STYLE )
112  : NONMODAL_STYLE,
115 {
116  wxASSERT( aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL || aFrameType == FRAME_FOOTPRINT_VIEWER );
117 
118  if( aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL )
119  SetModal( true );
120 
121  m_aboutTitle = _( "KiCad Footprint Library Viewer" );
122 
123  // Force the items to always snap
126  m_magneticItems.graphics = true;
127 
128  // Force the frame name used in config. the footprint viewer frame has a name
129  // depending on aFrameType (needed to identify the frame by wxWidgets),
130  // but only one configuration is preferable.
132 
133  // Give an icon
134  wxIcon icon;
135  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_footprint_browser ) );
136  SetIcon( icon );
137 
138  wxPanel* libPanel = new wxPanel( this );
139  wxSizer* libSizer = new wxBoxSizer( wxVERTICAL );
140 
141  m_libFilter = new wxSearchCtrl( libPanel, ID_MODVIEW_LIB_FILTER, wxEmptyString,
142  wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
143  m_libFilter->SetDescriptiveText( _( "Filter" ) );
144  libSizer->Add( m_libFilter, 0, wxEXPAND, 5 );
145 
146  m_libList = new wxListBox( libPanel, ID_MODVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
147  0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
148  libSizer->Add( m_libList, 1, wxEXPAND, 5 );
149 
150  libPanel->SetSizer( libSizer );
151  libPanel->Fit();
152 
153  wxPanel* fpPanel = new wxPanel( this );
154  wxSizer* fpSizer = new wxBoxSizer( wxVERTICAL );
155 
156  m_fpFilter = new wxSearchCtrl( fpPanel, ID_MODVIEW_FOOTPRINT_FILTER, wxEmptyString,
157  wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
158  m_fpFilter->SetDescriptiveText( _( "Filter" ) );
159  m_fpFilter->SetToolTip(
160  _( "Filter on footprint name, keywords, description and pad count.\n"
161  "Search terms are separated by spaces. All search terms must match.\n"
162  "A term which is a number will also match against the pad count." ) );
163  fpSizer->Add( m_fpFilter, 0, wxEXPAND, 5 );
164 
165  m_fpList = new wxListBox( fpPanel, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize,
166  0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
167  fpSizer->Add( m_fpList, 1, wxEXPAND, 5 );
168 
169  fpPanel->SetSizer( fpSizer );
170  fpPanel->Fit();
171 
172  // Create GAL canvas
174  PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
176  SetCanvas( drawPanel );
177 
178  SetBoard( new BOARD() );
179 
180  // This board will only be used to hold a footprint for viewing
182 
183  // In viewer, the default net clearance is not known (it depends on the actual board).
184  // So we do not show the default clearance, by setting it to 0
185  // The footprint or pad specific clearance will be shown
187 
188  // Don't show the default board solder mask clearance in the footprint viewer. Only the
189  // footprint or pad clearance setting should be shown if it is not 0.
191 
192  // Ensure all layers and items are visible:
194  SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
195 
196  GetScreen()->m_Center = true; // Center coordinate origins on screen.
197  LoadSettings( config() );
199 
200  // Create the manager and dispatcher & route draw panel events to the dispatcher
202  m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(),
203  drawPanel->GetViewControls(), config(), this );
204  m_actions = new PCB_ACTIONS();
206  drawPanel->SetEventDispatcher( m_toolDispatcher );
207 
210  m_toolManager->RegisterTool( new COMMON_TOOLS ); // for std context menus (zoom & grid)
212  m_toolManager->RegisterTool( new PCB_PICKER_TOOL ); // for setting grid origin
215 
216  m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
217 
219  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
220 
222  ReCreateMenuBar();
226 
228  UpdateTitle();
229 
230  // If a footprint was previously loaded, reload it
231  if( getCurNickname().size() && getCurFootprintName().size() )
232  {
233  LIB_ID id;
234 
236  id.SetLibItemName( getCurFootprintName() );
237  GetBoard()->Add( loadFootprint( id ) );
238  }
239 
240  drawPanel->DisplayBoard( m_pcb );
241 
242  m_auimgr.SetManagedWindow( this );
243 
244  // Horizontal items; layers 4 - 6
245  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().VToolbar().Name( "MainToolbar" ).Top().Layer(6) );
246  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
247  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
248 
249  // Vertical items; layers 1 - 3
250  m_auimgr.AddPane( libPanel, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(2)
251  .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
252  m_auimgr.AddPane( fpPanel, EDA_PANE().Palette().Name( "Footprints" ).Left().Layer( 1)
253  .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
254 
255  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
256 
257  // after changing something to the aui manager call Update() to reflect the changes
258  m_auimgr.Update();
259 
260  // The canvas should not steal the focus from the list boxes
261  GetCanvas()->SetCanFocus( false );
262  GetCanvas()->GetGAL()->SetAxesEnabled( true );
264 
265  // Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.)
267  wxASSERT( cfg );
269 
270  updateView();
271  setupUnits( config() );
272 
273  if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
274  {
276  Raise(); // On some window managers, this is needed
277  Show( true );
278  }
279 }
280 
281 
283 {
284  // Shutdown all running tools
285  if( m_toolManager )
287 
288  GetCanvas()->StopDrawing();
289  GetCanvas()->GetView()->Clear();
290  // Be sure any event cannot be fired after frame deletion:
291  GetCanvas()->SetEvtHandlerEnabled( false );
292 }
293 
294 
296 {
297  return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
298 }
299 
300 
302 {
304 
306  PCB_EDITOR_CONDITIONS cond( this );
307 
308  wxASSERT( mgr );
309 
310 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
311 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
312 
316  CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
319 
320 
322  CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
327 
332 
333  auto autoZoomCond =
334  [this] ( const SELECTION& )
335  {
336  return GetAutoZoom();
337  };
338 
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 
717  BOARD_COMMIT commit( pcbframe );
718 
719  // Create the "new" footprint
720  FOOTPRINT* newFootprint = (FOOTPRINT*) GetBoard()->GetFirstFootprint()->Duplicate();
721  newFootprint->SetParent( pcbframe->GetBoard() );
722  newFootprint->SetLink( niluuid );
723  newFootprint->SetFlags(IS_NEW ); // whatever
724 
725  for( PAD* pad : newFootprint->Pads() )
726  {
727  // Set the pads ratsnest settings to the global settings
728  pad->SetLocalRatsnestVisible( pcbframe->GetDisplayOptions().m_ShowGlobalRatsnest );
729 
730  // Pads in the library all have orphaned nets. Replace with Default.
731  pad->SetNetCode( 0 );
732  }
733 
734  // Put it on FRONT layer,
735  // (Can be stored flipped if the lib is an archive built from a board)
736  if( newFootprint->IsFlipped() )
737  newFootprint->Flip( newFootprint->GetPosition(),
738  pcbframe->Settings().m_FlipLeftRight );
739 
740  KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetCanvas()->GetViewControls();
741  VECTOR2D cursorPos = viewControls->GetCursorPosition();
742 
743  commit.Add( newFootprint );
744  viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
745  pcbframe->PlaceFootprint( newFootprint );
746 
747  newFootprint->SetPosition( wxPoint( 0, 0 ) );
748  viewControls->SetCrossHairCursorPosition( cursorPos, false );
749  commit.Push( wxT( "Insert footprint" ) );
750 
751  pcbframe->Raise();
752  pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeFootprint, true, newFootprint );
753 
754  newFootprint->ClearFlags();
755  }
756 }
757 
758 
760 {
761  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
762  wxCHECK( cfg, /*void*/ );
763 
764  // We don't allow people to change this right now, so make sure it's on
766 
768 
769  // Fetch display and grid settings from Footprint Editor
770  auto fpedit = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
771  m_displayOptions = fpedit->m_Display;
772  GetGalDisplayOptions().ReadWindowSettings( fpedit->m_Window );
773 }
774 
775 
777 {
778  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
779  wxCHECK( cfg, /*void*/ );
780 
782 
783  // We don't want to store anything other than the window settings
785 
787 }
788 
789 
791 {
792  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
793  wxCHECK_MSG( cfg, nullptr, "config not existing" );
794 
795  return &cfg->m_FootprintViewer;
796 }
797 
798 
800 {
801  auto* settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
802 
803  if( settings )
804  return Pgm().GetSettingsManager().GetColorSettings( settings->m_ColorTheme );
805  else
806  return Pgm().GetSettingsManager().GetColorSettings();
807 }
808 
809 
811 {
812  // It is stored in pcbnew's settings
814  wxCHECK( cfg, false );
815  return cfg->m_FootprintViewerAutoZoom;
816 }
817 
818 
820 {
821  // It is stored in pcbnew's settings
823  wxASSERT( cfg );
824  cfg->m_FootprintViewerAutoZoom = aAutoZoom;
825 }
826 
827 
828 void FOOTPRINT_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
829 {
830  PCB_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
831 
832  if( aEnvVarsChanged )
834 }
835 
836 
838 {
840 }
841 
842 
843 void FOOTPRINT_VIEWER_FRAME::setCurNickname( const wxString& aNickname )
844 {
846 }
847 
848 
850 {
852 }
853 
854 
855 void FOOTPRINT_VIEWER_FRAME::setCurFootprintName( const wxString& aName )
856 {
858 }
859 
860 
861 void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
862 {
863  if( event.GetActive() )
864  {
865  // Ensure we have the right library list:
866  std::vector< wxString > libNicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
867  bool stale = false;
868 
869  if( libNicknames.size() != m_libList->GetCount() )
870  stale = true;
871  else
872  {
873  for( unsigned ii = 0; ii < libNicknames.size(); ii++ )
874  {
875  if( libNicknames[ii] != m_libList->GetString( ii ) )
876  {
877  stale = true;
878  break;
879  }
880  }
881  }
882 
883  if( stale )
884  {
886  UpdateTitle();
887  }
888  }
889 
890  event.Skip(); // required under wxMAC
891 }
892 
893 
894 void FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton( wxUpdateUIEvent& aEvent )
895 {
896  aEvent.Enable( GetBoard()->GetFirstFootprint() != nullptr );
897 }
898 
899 
900 bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
901 {
902  if( aFootprint && !aFootprint->IsEmpty() )
903  {
904  wxString msg;
905  LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
906  LIB_ID fpid;
907 
908  fpid.Parse( *aFootprint, true );
909 
910  if( fpid.IsValid() )
911  {
912  wxString libraryName = fpid.GetLibNickname();
913 
914  if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) )
915  {
916  msg.sprintf( _( "The current configuration does not include library '%s'. Use "
917  "Manage Footprint Libraries to edit the configuration." ),
918  libraryName );
919  DisplayErrorMessage( aParent, _( "Footprint library not found." ), msg );
920  }
921  else if ( !fpTable->HasLibrary( fpid.GetLibNickname(), true ) )
922  {
923  msg.sprintf( _( "Library '%s' is not enabled in the current configuration. Use "
924  "Manage Footprint Libraries to edit the configuration." ),
925  libraryName );
926  DisplayErrorMessage( aParent, _( "Footprint library not enabled." ), msg );
927  }
928  else
929  {
930  // Update last selection:
931  setCurNickname( libraryName );
933  m_libList->SetStringSelection( libraryName );
934  }
935  }
936  }
937 
938  // Rebuild the fp list from the last selected library,
939  // and show the last selected footprint
942 
943  bool retval = KIWAY_PLAYER::ShowModal( aFootprint, aParent );
944 
945  m_libFilter->SetFocus();
946  return retval;
947 }
948 
949 
950 void FOOTPRINT_VIEWER_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
951 {
952  wxString title = _( "3D Viewer" ) + wxT( " \u2014 " ) + getCurFootprintName();
953  PCB_BASE_FRAME::Update3DView( aMarkDirty, aRefresh, &title );
954 }
955 
956 
958 {
959  return GetColorSettings()->GetColor( LAYER_GRID );
960 }
961 
962 
964 {
965  switch( event.GetId() )
966  {
967  case ID_MODVIEW_NEXT:
969  break;
970 
971  case ID_MODVIEW_PREVIOUS:
973  break;
974 
975  default:
976  wxString id = wxString::Format( "%i", event.GetId() );
977  wxFAIL_MSG( "FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList error: id = " + id );
978  }
979 }
980 
981 
983 {
984  wxString title;
985  wxString path;
986 
987  if( !getCurNickname().IsEmpty() )
988  {
989  title = getCurNickname();
990 
991  FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
992  const LIB_TABLE_ROW* row = libtable->FindRow( getCurNickname() );
993 
994  if( row )
995  title += wxT( " \u2014 " ) + row->GetFullURI( true );
996  }
997  else
998  {
999  title = _( "[no library selected]" );
1000  }
1001 
1002  title += wxT( " \u2014 " ) + _( "Footprint Library Browser" );
1003 
1004  SetTitle( title );
1005 }
1006 
1007 
1009 {
1010  if( !getCurNickname() )
1011  return;
1012 
1013  int selection = m_fpList->FindString( getCurFootprintName(), true );
1014 
1015  if( aMode == NEXT_PART )
1016  {
1017  if( selection != wxNOT_FOUND && selection < (int)m_fpList->GetCount() - 1 )
1018  selection++;
1019  }
1020 
1021  if( aMode == PREVIOUS_PART )
1022  {
1023  if( selection != wxNOT_FOUND && selection > 0 )
1024  selection--;
1025  }
1026 
1027  if( selection != wxNOT_FOUND )
1028  {
1029  m_fpList->SetSelection( selection );
1030  m_fpList->EnsureVisible( selection );
1031 
1032  setCurFootprintName( m_fpList->GetString((unsigned) selection ) );
1033 
1034  // Delete the current footprint
1036 
1038  getCurFootprintName() );
1039 
1040  if( footprint )
1041  GetBoard()->Add( footprint, ADD_MODE::APPEND );
1042 
1043  Update3DView( true, true );
1044 
1045  updateView();
1046  }
1047 
1048  UpdateTitle();
1049 
1050  GetCanvas()->Refresh();
1051 }
1052 
1053 
1055 {
1056  GetCanvas()->UpdateColors();
1058 
1060 
1061  if( GetAutoZoom() )
1063  else
1065 
1066  UpdateMsgPanel();
1067 }
1068 
1069 
1070 void FOOTPRINT_VIEWER_FRAME::OnExitKiCad( wxCommandEvent& event )
1071 {
1072  Kiway().OnKiCadExit();
1073 }
1074 
1075 
1077 {
1078  Close( false );
1079 }
1080 
1081 
1083 {
1084  return GetBoard()->GetFirstFootprint();
1085 }
1086 
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:247
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:625
#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:260
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.
bool GetAutoZoom() override
Always returns false.
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:382
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:514
wxAuiManager m_auimgr
void SetAutoZoom(bool aAutoZoom) override
Does nothing.
#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 in the footprint viewer.
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
static TOOL_ACTION zoomFootprintAutomatically
Definition: pcb_actions.h:252
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:588
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:159
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:71
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:606
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:1091
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:251
#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
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1381
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)
Definition of file extensions used in Kicad.
Helper dialog and control classes.
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:1615
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:244
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:553
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:395
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
bool IsFlipped() const
Definition: footprint.h:261
void SetLink(const KIID &aLink)
Definition: footprint.h:527
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.
Declaration of the eda_3d_viewer class.
const char * name
Definition: DXF_plotter.cpp:59
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.
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:177
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:858
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:1452
double GetScale() const
Definition: view.h:263
Message panel definition file.
bool m_FootprintViewerAutoZoom
Should the footprint viewer auto zoom on select.
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:398
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.