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@verizon.net>
6  * Copyright (C) 2004-2019 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/pcbnew_control.h>
57 #include <tools/selection_tool.h>
59 #include <wx/tokenzr.h>
60 
61 using namespace std::placeholders;
62 
63 
64 #define NEXT_PART 1
65 #define NEW_PART 0
66 #define PREVIOUS_PART -1
67 
68 
69 BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME )
70  // Window events
73 
74  EVT_MENU( wxID_EXIT, FOOTPRINT_VIEWER_FRAME::OnExitKiCad )
75  EVT_MENU( wxID_CLOSE, FOOTPRINT_VIEWER_FRAME::CloseFootprintViewer )
76 
77  // Toolbar events
83 
85 
88 
89  // listbox events
93 
94 END_EVENT_TABLE()
95 
96 
97 /*
98  * Note: FOOTPRINT_VIEWER_FRAME can be created in "modal mode", or as a usual frame.
99  */
100 #define PARENT_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT )
101 #define MODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP )
102 #define NONMODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE )
103 
104 
106  FRAME_T aFrameType ) :
107  PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Library Browser" ),
108  wxDefaultPosition, wxDefaultSize,
109  aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL ? ( aParent ? PARENT_STYLE : MODAL_STYLE )
110  : NONMODAL_STYLE,
113 {
114  wxASSERT( aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL || aFrameType == FRAME_FOOTPRINT_VIEWER );
115 
116  if( aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL )
117  SetModal( true );
118 
119  m_aboutTitle = "Footprint Library Viewer";
120 
121  // Force the items to always snap
124  m_magneticItems.graphics = true;
125 
126  // Force the frame name used in config. the footprint viewer frame has a name
127  // depending on aFrameType (needed to identify the frame by wxWidgets),
128  // but only one configuration is preferable.
130 
131  // Give an icon
132  wxIcon icon;
133  icon.CopyFromBitmap( KiBitmap( modview_icon_xpm ) );
134  SetIcon( icon );
135 
136  wxPanel* libPanel = new wxPanel( this );
137  wxSizer* libSizer = new wxBoxSizer( wxVERTICAL );
138 
139  m_libFilter = new wxTextCtrl( libPanel, ID_MODVIEW_LIB_FILTER, wxEmptyString,
140  wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
141  m_libFilter->SetHint( _( "Filter" ) );
142  libSizer->Add( m_libFilter, 0, wxEXPAND, 5 );
143 
144  m_libList = new wxListBox( libPanel, ID_MODVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
145  0, NULL, wxLB_HSCROLL | wxNO_BORDER );
146  libSizer->Add( m_libList, 1, wxEXPAND, 5 );
147 
148  libPanel->SetSizer( libSizer );
149  libPanel->Fit();
150 
151  wxPanel* fpPanel = new wxPanel( this );
152  wxSizer* fpSizer = new wxBoxSizer( wxVERTICAL );
153 
154  m_fpFilter = new wxTextCtrl( fpPanel, ID_MODVIEW_FOOTPRINT_FILTER, wxEmptyString,
155  wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
156  m_fpFilter->SetHint( _( "Filter" ) );
157  m_fpFilter->SetToolTip(
158  _( "Filter on footprint name, keywords, description and pad count.\n"
159  "Search terms are separated by spaces. All search terms must match.\n"
160  "A term which is a number will also match against the pad count." ) );
161  fpSizer->Add( m_fpFilter, 0, wxEXPAND, 5 );
162 
163  m_fpList = new wxListBox( fpPanel, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize,
164  0, NULL, wxLB_HSCROLL | wxNO_BORDER );
165  fpSizer->Add( m_fpList, 1, wxEXPAND, 5 );
166 
167  fpPanel->SetSizer( fpSizer );
168  fpPanel->Fit();
169 
170  // Create GAL canvas
172  PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
174  SetCanvas( drawPanel );
175 
176  SetBoard( new BOARD() );
177 
178  // This board will only be used to hold a footprint for viewing
180 
181  // In viewer, the default net clearance is not known (it depends on the actual board).
182  // So we do not show the default clearance, by setting it to 0
183  // The footprint or pad specific clearance will be shown
185 
186  // Don't show the default board solder mask clearance in the footprint viewer. Only the
187  // footprint or pad clearance setting should be shown if it is not 0.
189 
190  // Ensure all layers and items are visible:
192  SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
193 
194  GetScreen()->m_Center = true; // Center coordinate origins on screen.
195  LoadSettings( config() );
197 
198  // Create the manager and dispatcher & route draw panel events to the dispatcher
200  m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(),
201  drawPanel->GetViewControls(), config(), this );
202  m_actions = new PCB_ACTIONS();
204  drawPanel->SetEventDispatcher( m_toolDispatcher );
205 
208  m_toolManager->RegisterTool( new COMMON_TOOLS ); // for std context menus (zoom & grid)
210  m_toolManager->RegisterTool( new PCBNEW_PICKER_TOOL ); // for setting grid origin
213 
214  m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
215 
217  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
218 
220  ReCreateMenuBar();
224 
226  UpdateTitle();
227 
228  // If a footprint was previously loaded, reload it
229  if( getCurNickname().size() && getCurFootprintName().size() )
230  {
231  LIB_ID id;
232 
234  id.SetLibItemName( getCurFootprintName() );
235  GetBoard()->Add( loadFootprint( id ) );
236  }
237 
238  drawPanel->DisplayBoard( m_pcb );
239 
240  m_auimgr.SetManagedWindow( this );
241 
242  // Horizontal items; layers 4 - 6
243  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().VToolbar().Name( "MainToolbar" ).Top().Layer(6) );
244  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
245  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
246 
247  // Vertical items; layers 1 - 3
248  m_auimgr.AddPane( libPanel, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(2)
249  .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
250  m_auimgr.AddPane( fpPanel, EDA_PANE().Palette().Name( "Footprints" ).Left().Layer( 1)
251  .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
252 
253  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
254 
255  // after changing something to the aui manager call Update() to reflect the changes
256  m_auimgr.Update();
257 
258  // The canvas should not steal the focus from the list boxes
259  GetCanvas()->SetCanFocus( false );
260  GetCanvas()->GetGAL()->SetAxesEnabled( true );
262 
263  // Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.)
265  wxASSERT( cfg );
267 
268  updateView();
269  initExitKey();
270  setupUnits( config() );
271 
272  if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
273  {
275  Raise(); // On some window managers, this is needed
276  Show( true );
277  }
278 }
279 
280 
282 {
283  // Shutdown all running tools
284  if( m_toolManager )
286 
287  GetCanvas()->StopDrawing();
288  GetCanvas()->GetView()->Clear();
289  // Be sure any event cannot be fired after frame deletion:
290  GetCanvas()->SetEvtHandlerEnabled( false );
291 }
292 
293 
295 {
296  return m_toolManager->GetTool<SELECTION_TOOL>()->GetSelection();
297 }
298 
299 
301 {
303 
305  PCB_EDITOR_CONDITIONS cond( this );
306 
307  wxASSERT( mgr );
308 
309 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
310 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
311 
317 
318 
322 
327 
328  auto autoZoomCond =
329  [this] ( const SELECTION& )
330  {
331  return GetAutoZoom();
332  };
333 
335 
336 #undef ENABLE
337 #undef CHECK
338 }
339 
340 
342 {
343  // A workaround to avoid flicker, in modal mode when modview frame is destroyed,
344  // when the aui toolbar is not docked (i.e. shown in a miniframe)
345  // (useful on windows only)
346  m_mainToolBar->SetFocus();
347 
348  GetCanvas()->StopDrawing();
349 
350  if( IsModal() )
351  {
352  // Only dismiss a modal frame once, so that the return values set by
353  // the prior DismissModal() are not bashed for ShowModal().
354  if( !IsDismissed() )
355  DismissModal( false );
356 
357  // window to be destroyed by the caller of KIWAY_PLAYER::ShowModal()
358  }
359  else
360  Destroy();
361 }
362 
363 
364 void FOOTPRINT_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv )
365 {
366  if( m_auimgr.GetManagedWindow() )
367  m_auimgr.Update();
368 
369  SizeEv.Skip();
370 }
371 
372 
374 {
375  m_libList->Clear();
376 
377  std::vector<wxString> nicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
378  std::set<wxString> excludes;
379 
380  if( !m_libFilter->GetValue().IsEmpty() )
381  {
382  wxStringTokenizer tokenizer( m_libFilter->GetValue() );
383 
384  while( tokenizer.HasMoreTokens() )
385  {
386  const wxString term = tokenizer.GetNextToken().Lower();
387  EDA_COMBINED_MATCHER matcher( term );
388  int matches, position;
389 
390  for( const wxString& nickname : nicknames )
391  {
392  if( !matcher.Find( nickname.Lower(), matches, position ) )
393  excludes.insert( nickname );
394  }
395  }
396  }
397 
398  for( const wxString& nickname : nicknames )
399  {
400  if( !excludes.count( nickname ) )
401  m_libList->Append( nickname );
402  }
403 
404  // Search for a previous selection:
405  int index = m_libList->FindString( getCurNickname(), true );
406 
407  if( index == wxNOT_FOUND )
408  {
409  if( m_libList->GetCount() > 0 )
410  {
411  m_libList->SetSelection( 0 );
412  wxCommandEvent dummy;
414  }
415  else
416  {
417  setCurNickname( wxEmptyString );
418  setCurFootprintName( wxEmptyString );
419  }
420  }
421  else
422  {
423  m_libList->SetSelection( index, true );
424  wxCommandEvent dummy;
426  }
427 
428  GetCanvas()->Refresh();
429 }
430 
431 
433 {
434  m_fpList->Clear();
435 
436  if( !getCurNickname() )
437  setCurFootprintName( wxEmptyString );
438 
439  auto fp_info_list = FOOTPRINT_LIST::GetInstance( Kiway() );
440 
441  wxString nickname = getCurNickname();
442 
443  fp_info_list->ReadFootprintFiles( Prj().PcbFootprintLibs(), !nickname ? NULL : &nickname );
444 
445  if( fp_info_list->GetErrorCount() )
446  {
447  fp_info_list->DisplayErrors( this );
448 
449  // For footprint libraries that support one footprint per file, there may have been
450  // valid footprints read so show the footprints that loaded properly.
451  if( fp_info_list->GetList().empty() )
452  return;
453  }
454 
455  std::set<wxString> excludes;
456 
457  if( !m_fpFilter->GetValue().IsEmpty() )
458  {
459  wxStringTokenizer tokenizer( m_fpFilter->GetValue() );
460 
461  while( tokenizer.HasMoreTokens() )
462  {
463  const wxString term = tokenizer.GetNextToken().Lower();
464  EDA_COMBINED_MATCHER matcher( term );
465  int matches, position;
466 
467  for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
468  {
469  wxString search = footprint->GetFootprintName() + " " + footprint->GetSearchText();
470  bool matched = matcher.Find( search.Lower(), matches, position );
471 
472  if( !matched && term.IsNumber() )
473  matched = ( wxAtoi( term ) == (int)footprint->GetPadCount() );
474 
475  if( !matched )
476  excludes.insert( footprint->GetFootprintName() );
477  }
478  }
479  }
480 
481  for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
482  {
483  if( !excludes.count( footprint->GetFootprintName() ) )
484  m_fpList->Append( footprint->GetFootprintName() );
485  }
486 
487  int index = m_fpList->FindString( getCurFootprintName(), true );
488 
489  if( index == wxNOT_FOUND )
490  {
491  if( m_fpList->GetCount() > 0 )
492  {
493  m_fpList->SetSelection( 0 );
494  m_fpList->EnsureVisible( 0 );
495 
496  wxCommandEvent dummy;
498  }
499  else
500  setCurFootprintName( wxEmptyString );
501  }
502  else
503  {
504  m_fpList->SetSelection( index, true );
505  m_fpList->EnsureVisible( index );
506  }
507 }
508 
509 
510 void FOOTPRINT_VIEWER_FRAME::OnLibFilter( wxCommandEvent& aEvent )
511 {
513 
514  // Required to avoid interaction with SetHint()
515  // See documentation for wxTextEntry::SetHint
516  aEvent.Skip();
517 }
518 
519 
520 void FOOTPRINT_VIEWER_FRAME::OnFPFilter( wxCommandEvent& aEvent )
521 {
523 
524  // Required to avoid interaction with SetHint()
525  // See documentation for wxTextEntry::SetHint
526  aEvent.Skip();
527 }
528 
529 
530 void FOOTPRINT_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent )
531 {
532  if( aEvent.GetKeyCode() == WXK_UP )
533  {
534  wxWindow* focused = FindFocus();
535 
536  if( m_libFilter->HasFocus() || m_libList->HasFocus() )
538  else
539  selectPrev( m_fpList );
540 
541  // Need to reset the focus after selection due to GTK mouse-refresh
542  // that captures the mouse into the canvas to update scrollbars
543  if( focused )
544  focused->SetFocus();
545  }
546  else if( aEvent.GetKeyCode() == WXK_DOWN )
547  {
548  wxWindow* focused = FindFocus();
549 
550  if( m_libFilter->HasFocus() || m_libList->HasFocus() )
552  else
553  selectNext( m_fpList );
554 
555  // Need to reset the focus after selection due to GTK mouse-refresh
556  // that captures the mouse into the canvas to update scrollbars
557  if( focused )
558  focused->SetFocus();
559  }
560  else if( aEvent.GetKeyCode() == WXK_TAB && m_libFilter->HasFocus() )
561  {
562  if( !aEvent.ShiftDown() )
563  m_fpFilter->SetFocus();
564  else
565  aEvent.Skip();
566  }
567  else if( aEvent.GetKeyCode() == WXK_TAB && m_fpFilter->HasFocus() )
568  {
569  if( aEvent.ShiftDown() )
570  m_libFilter->SetFocus();
571  else
572  aEvent.Skip();
573  }
574  else if( aEvent.GetKeyCode() == WXK_RETURN && m_fpList->GetSelection() >= 0 )
575  {
576  wxCommandEvent dummy;
578  }
579  else
580  aEvent.Skip();
581 }
582 
583 
584 void FOOTPRINT_VIEWER_FRAME::selectPrev( wxListBox* aListBox )
585 {
586  int prev = aListBox->GetSelection() - 1;
587 
588  if( prev >= 0 )
589  {
590  aListBox->SetSelection( prev );
591  aListBox->EnsureVisible( prev );
592 
593  wxCommandEvent dummy;
594 
595  if( aListBox == m_libList )
597  else
599  }
600 }
601 
602 
603 void FOOTPRINT_VIEWER_FRAME::selectNext( wxListBox* aListBox )
604 {
605  int next = aListBox->GetSelection() + 1;
606 
607  if( next < (int)aListBox->GetCount() )
608  {
609  aListBox->SetSelection( next );
610  aListBox->EnsureVisible( next );
611 
612  wxCommandEvent dummy;
613 
614  if( aListBox == m_libList )
616  else
618  }
619 }
620 
621 
622 void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& aEvent )
623 {
624  int ii = m_libList->GetSelection();
625 
626  if( ii < 0 )
627  return;
628 
629  wxString name = m_libList->GetString( ii );
630 
631  if( getCurNickname() == name )
632  return;
633 
634  setCurNickname( name );
635 
637  UpdateTitle();
638 
639  // The m_libList has now the focus, in order to be able to use arrow keys
640  // to navigate inside the list.
641  // the gal canvas must not steal the focus to allow navigation
642  GetCanvas()->SetStealsFocus( false );
643  m_libList->SetFocus();
644 }
645 
646 
647 void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& aEvent )
648 {
649  if( m_fpList->GetCount() == 0 )
650  return;
651 
652  int ii = m_fpList->GetSelection();
653 
654  if( ii < 0 )
655  return;
656 
657  wxString name = m_fpList->GetString( ii );
658 
659  if( getCurFootprintName().CmpNoCase( name ) != 0 )
660  {
662 
663  // Delete the current footprint (MUST reset tools first)
665 
667 
668  LIB_ID id;
670  id.SetLibItemName( getCurFootprintName() );
671 
672  try
673  {
674  GetBoard()->Add( loadFootprint( id ) );
675  }
676  catch( const IO_ERROR& ioe )
677  {
678  wxString msg = wxString::Format( _( "Could not load footprint '%s' from library '%s'."
679  "\n\n%s" ),
681  getCurNickname(),
682  ioe.Problem() );
683  DisplayError( this, msg );
684  }
685 
686  UpdateTitle();
687 
688  updateView();
689 
690  GetCanvas()->Refresh();
691  Update3DView( true );
692  }
693 
694  // The m_fpList has now the focus, in order to be able to use arrow keys
695  // to navigate inside the list.
696  // the gal canvas must not steal the focus to allow navigation
697  GetCanvas()->SetStealsFocus( false );
698  m_fpList->SetFocus();
699 }
700 
701 
702 void FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList( wxCommandEvent& aEvent )
703 {
704  AddFootprintToPCB( aEvent );
705 }
706 
707 
708 void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
709 {
710  if( IsModal() )
711  {
712  if( m_fpList->GetSelection() >= 0 )
713  {
714  LIB_ID fpid( getCurNickname(), m_fpList->GetStringSelection() );
715  DismissModal( true, fpid.Format() );
716  }
717  else
718  {
719  DismissModal( false );
720  }
721  }
722  else if( GetBoard()->GetFirstFootprint() )
723  {
724  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
725 
726  if( pcbframe == NULL ) // happens when the board editor is not active (or closed)
727  {
728  DisplayErrorMessage( this, _( "No board currently open." ) );
729  return;
730  }
731 
733  BOARD_COMMIT commit( pcbframe );
734 
735  // Create the "new" footprint
736  FOOTPRINT* newFootprint = (FOOTPRINT*) GetBoard()->GetFirstFootprint()->Duplicate();
737  newFootprint->SetParent( pcbframe->GetBoard() );
738  newFootprint->SetLink( 0 );
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  newFootprint->SetPosition( wxPoint( 0, 0 ) );
747  viewControls->SetCrossHairCursorPosition( cursorPos, false );
748  commit.Push( wxT( "Insert footprint" ) );
749 
750  pcbframe->Raise();
751  pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeModule, true, newFootprint );
752 
753  newFootprint->ClearFlags();
754  }
755 }
756 
757 
759 {
760  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
761  wxCHECK( cfg, /*void*/ );
762 
763  // We don't allow people to change this right now, so make sure it's on
765 
767 
768  // Fetch display and grid settings from Footprint Editor
769  auto fpedit = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
770  m_displayOptions = fpedit->m_Display;
771  GetGalDisplayOptions().ReadWindowSettings( fpedit->m_Window );
772 }
773 
774 
776 {
777  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
778  wxCHECK( cfg, /*void*/ );
779 
780  // We don't want to store anything other than the window settings
782 
784 }
785 
786 
788 {
789  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
790  wxCHECK_MSG( cfg, nullptr, "config not existing" );
791 
792  return &cfg->m_FootprintViewer;
793 }
794 
795 
797 {
798  auto* settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
799 
800  if( settings )
801  return Pgm().GetSettingsManager().GetColorSettings( settings->m_ColorTheme );
802  else
803  return Pgm().GetSettingsManager().GetColorSettings();
804 }
805 
806 
808 {
809  // It is stored in pcbnew's settings
811  wxCHECK( cfg, false );
812  return cfg->m_FootprintViewerAutoZoom;
813 }
814 
815 
817 {
818  // It is stored in pcbnew's settings
820  wxASSERT( cfg );
821  cfg->m_FootprintViewerAutoZoom = aAutoZoom;
822 }
823 
824 
825 void FOOTPRINT_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
826 {
827  PCB_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
828 
829  if( aEnvVarsChanged )
831 }
832 
833 
835 {
837 }
838 
839 
840 void FOOTPRINT_VIEWER_FRAME::setCurNickname( const wxString& aNickname )
841 {
843 }
844 
845 
847 {
849 }
850 
851 
852 void FOOTPRINT_VIEWER_FRAME::setCurFootprintName( const wxString& aName )
853 {
855 }
856 
857 
858 void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
859 {
860  if( event.GetActive() )
861  {
862  // Ensure we have the right library list:
863  std::vector< wxString > libNicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
864  bool stale = false;
865 
866  if( libNicknames.size() != m_libList->GetCount() )
867  stale = true;
868  else
869  {
870  for( unsigned ii = 0; ii < libNicknames.size(); ii++ )
871  {
872  if( libNicknames[ii] != m_libList->GetString( ii ) )
873  {
874  stale = true;
875  break;
876  }
877  }
878  }
879 
880  if( stale )
881  {
883  UpdateTitle();
884  }
885  }
886 
887  event.Skip(); // required under wxMAC
888 }
889 
890 
891 void FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton( wxUpdateUIEvent& aEvent )
892 {
893  aEvent.Enable( GetBoard()->GetFirstFootprint() != nullptr );
894 }
895 
896 
897 bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
898 {
899  if( aFootprint && !aFootprint->IsEmpty() )
900  {
901  wxString msg;
902  LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
903  LIB_ID fpid;
904 
905  fpid.Parse( *aFootprint, LIB_ID::ID_PCB, true );
906 
907  if( fpid.IsValid() )
908  {
909  wxString nickname = fpid.GetLibNickname();
910 
911  if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) )
912  {
913  msg.sprintf( _( "The current configuration does not include a library with the\n"
914  "nickname \"%s\". Use Manage Footprint Libraries\n"
915  "to edit the configuration." ), nickname );
916  DisplayErrorMessage( aParent, _( "Footprint library not found." ), msg );
917  }
918  else if ( !fpTable->HasLibrary( fpid.GetLibNickname(), true ) )
919  {
920  msg.sprintf( _( "The library with the nickname \"%s\" is not enabled\n"
921  "in the current configuration. Use Manage Footprint Libraries to\n"
922  "edit the configuration." ), nickname );
923  DisplayErrorMessage( aParent, _( "Footprint library not enabled." ), msg );
924  }
925  else
926  {
927  // Update last selection:
928  setCurNickname( nickname );
930  m_libList->SetStringSelection( nickname );
931  }
932  }
933  }
934 
935  // Rebuild the fp list from the last selected library,
936  // and show the last selected footprint
939 
940  bool retval = KIWAY_PLAYER::ShowModal( aFootprint, aParent );
941 
942  m_libFilter->SetFocus();
943  return retval;
944 }
945 
946 
947 void FOOTPRINT_VIEWER_FRAME::Update3DView( bool aForceReload, const wxString* aTitle )
948 {
949  wxString title = wxString::Format( _( "3D Viewer" ) + wxT( " \u2014 %s" ),
951  PCB_BASE_FRAME::Update3DView( aForceReload, &title );
952 }
953 
954 
956 {
957  return GetColorSettings()->GetColor( LAYER_GRID );
958 }
959 
960 
962 {
963  switch( event.GetId() )
964  {
965  case ID_MODVIEW_NEXT:
967  break;
968 
969  case ID_MODVIEW_PREVIOUS:
971  break;
972 
973  default:
974  wxString id = wxString::Format( "%i", event.GetId() );
975  wxFAIL_MSG( "FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList error: id = " + id );
976  }
977 }
978 
979 
981 {
982  wxString title;
983  wxString path;
984 
985  title.Printf( getCurNickname().IsEmpty() ? _( "no library selected" ) : getCurNickname() );
986 
987  // Now, add the full path, for info
988  if( !getCurNickname().IsEmpty() )
989  {
990  FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
991  const LIB_TABLE_ROW* row = libtable->FindRow( getCurNickname() );
992 
993  if( row )
994  title << L" \u2014 " << row->GetFullURI( true );
995  }
996 
997  title += wxT( " \u2014 " ) + _( "Footprint Library Browser" );
998 
999  SetTitle( title );
1000 }
1001 
1002 
1004 {
1005  if( !getCurNickname() )
1006  return;
1007 
1008  int selection = m_fpList->FindString( getCurFootprintName(), true );
1009 
1010  if( aMode == NEXT_PART )
1011  {
1012  if( selection != wxNOT_FOUND && selection < (int)m_fpList->GetCount() - 1 )
1013  selection++;
1014  }
1015 
1016  if( aMode == PREVIOUS_PART )
1017  {
1018  if( selection != wxNOT_FOUND && selection > 0 )
1019  selection--;
1020  }
1021 
1022  if( selection != wxNOT_FOUND )
1023  {
1024  m_fpList->SetSelection( selection );
1025  m_fpList->EnsureVisible( selection );
1026 
1027  setCurFootprintName( m_fpList->GetString((unsigned) selection ) );
1028 
1029  // Delete the current footprint
1031 
1033  getCurFootprintName() );
1034 
1035  if( footprint )
1036  GetBoard()->Add( footprint, ADD_MODE::APPEND );
1037 
1038  Update3DView( true );
1039 
1040  updateView();
1041  }
1042 
1043  UpdateTitle();
1044 
1045  GetCanvas()->Refresh();
1046 }
1047 
1048 
1050 {
1051  GetCanvas()->UpdateColors();
1053 
1055 
1056  if( GetAutoZoom() )
1058  else
1060 
1061  UpdateMsgPanel();
1062 }
1063 
1064 
1065 void FOOTPRINT_VIEWER_FRAME::OnExitKiCad( wxCommandEvent& event )
1066 {
1067  Kiway().OnKiCadExit();
1068 }
1069 
1070 
1072 {
1073  Close( false );
1074 }
1075 
1076 
1078 {
1079  return GetBoard()->GetFirstFootprint();
1080 }
1081 
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:240
CITER next(CITER it)
Definition: ptree.cpp:126
static TOOL_ACTION placeModule
Definition: pcb_actions.h:161
virtual void SetBoard(BOARD *aBoard)
Function SetBoard sets 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:114
FOOTPRINT * FootprintLoad(const wxString &aNickname, const wxString &aFootprintName)
Function FootprintLoad.
const BITMAP_OPAQUE modview_icon_xpm[1]
void OnKiCadExit()
Definition: kiway.cpp:587
#define PREVIOUS_PART
void OnExitKiCad(wxCommandEvent &event)
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
bool ShowModal(wxString *aFootprint, wxWindow *aParent) override
Function ShowModal.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel.
void UpdateTitle()
Function UpdateTitle updates 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:253
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:82
This file is part of the common library.
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Returns a pointer to the window settings for this frame.
void initExitKey()
Sets the common key-pair for exiting the application (Ctrl-Q) and ties it to the wxID_EXIT event id.
bool IsDismissed()
Function IsDismissed returns false only if both the frame is acting in modal mode and it has not been...
SELECTION_CONDITION FullscreenCursor()
Creates a functor testing if the cursor is full screen in a frame.
ACTION_TOOLBAR * m_optionsToolBar
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
virtual void SetScreen(BASE_SCREEN *aScreen)
static TOOL_ACTION zoomTool
Definition: actions.h:102
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
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
The current canvas type.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void setCurFootprintName(const wxString &aName)
SELECTION_TOOL.
virtual void Update3DView(bool aReloadRequest, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
SELECTION_CONDITION TextFillDisplay()
Creates a functor that tests if the frame fills text items.
Component library viewer main window.
bool GetAutoZoom() override
Always returns false.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Creates 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:99
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
void selectNext(wxListBox *aListBox)
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:559
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:480
wxAuiManager m_auimgr
void SetAutoZoom(bool aAutoZoom) override
Does nothing.
#define PARENT_STYLE
ACTION_TOOLBAR * m_mainToolBar
ACTION_MANAGER.
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.
PCBNEW_SETTINGS * GetPcbNewSettings()
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
Definition: lib_id.h:171
static TOOL_ACTION zoomFootprintAutomatically
Definition: pcb_actions.h:248
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:102
virtual const wxString Problem() const
what was the problem?
Definition: exceptions.cpp:45
bool always_show_cursor
Definition: app_settings.h:42
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
SELECTION_CONDITION PadFillDisplay()
Creates a functor that tests if the frame fills the pads.
#define NEW_PART
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:184
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
void PlaceFootprint(FOOTPRINT *aFootprint, bool aRecreateRatsnest=true)
Function PlaceFootprint places aFootprint at the current cursor position and updates footprint coordi...
PCBNEW_CONTROL.
Abstract pattern-matching tool and implementations.
COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
bool m_axesEnabled
Whether or not to draw the coordinate system axes
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...
PCB_DISPLAY_OPTIONS m_displayOptions
TOOL_MANAGER.
Definition: tool_manager.h:51
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:82
static TOOL_ACTION measureTool
Definition: actions.h:157
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:553
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:103
void SelectAndViewFootprint(int aMode)
Function SelectAndViewFootprint Select and load the next or the previous footprint if no current foot...
Generic tool for picking a point.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
FOOTPRINT * loadFootprint(const LIB_ID &aFootprintId)
Function loadFootprint attempts to load aFootprintId from the footprint library table.
FOOTPRINT * GetFirstFootprint() const
Gets the first footprint on the board or nullptr.
Definition: board.h:348
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()
Creates a functor testing if the grid is visible in a frame.
virtual void ActivateGalCanvas() override
#define NULL
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:345
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Creates a functor that tests if the frame has the specified units.
void DisplayBoard(BOARD *aBoard)
Function DisplayBoard adds all items from the current board to the VIEW, so they can be displayed by ...
void Clear()
Function Clear() Removes all items from the view.
Definition: view.cpp:1089
void SetClearance(int aClearance)
Definition: netclass.h:160
static TOOL_ACTION toggleGrid
Definition: actions.h:143
bool m_Center
Center on screen.
Definition: base_screen.h:95
static TOOL_ACTION showPadNumbers
Definition: pcb_actions.h:247
#define NEXT_PART
EDA_MSG_PANEL * m_messagePanel
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
static TOOL_ACTION inchesUnits
Definition: actions.h:147
void SetStealsFocus(bool aStealsFocus)
Set whether focus is taken on certain events (mouseover, keys, etc).
void OnCharHook(wxKeyEvent &aEvent) override
Capture the key event before it is sent to the GUI.
ACTIONS * m_actions
Definition: tools_holder.h:49
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)
Function ResetTools() Resets all tools (i.e.
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
BOARD_ITEM * Duplicate() const override
Function Duplicate creates a copy of a BOARD_ITEM.
Definition: footprint.cpp:1482
void OnActivate(wxActivateEvent &event)
Function OnActivate is called when the frame frame is activate to reload the libraries and component ...
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Moves 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)
COMMON_CONTROL.
void selectPrev(wxListBox *aListBox)
void SetAxesEnabled(bool aAxesEnabled)
Enables drawing the axes.
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
Specialization of the wxAuiPaneInfo class for KiCad panels.
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:178
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:148
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:50
COMMON_TOOLS.
Definition: common_tools.h:38
void UpdateColors()
Updates the color settings in the painter and GAL.
void SetModal(bool aIsModal)
Definition: kiway_player.h:179
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
VTBL_ENTRY void SetRString(RSTRING_T aStringId, const wxString &aString)
Function SetRString stores a "retained string", which is any session and project specific string iden...
Definition: project.cpp:212
SELECTION_CONDITION PadNumbersDisplay()
Creates a functor that tests if the pad numbers are displayed.
#define NONMODAL_STYLE
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:284
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:241
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:193
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Function SetScale() Sets the scaling factor, zooming around a given anchor point.
Definition: view.cpp:559
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs 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:386
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName)
Function FindRow.
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
void SetLink(const KIID &aLink)
Definition: footprint.h:557
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
COLOR4D GetColor(int aLayer) const
VTBL_ENTRY const wxString & GetRString(RSTRING_T aStringId)
Function GetRString returns a "retained string", which is any session and project specific string ide...
Definition: project.cpp:227
PCB_ACTIONS.
Definition: pcb_actions.h:51
#define CHECK(x)
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:48
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
void CloseFootprintViewer(wxCommandEvent &event)
SELECTION_CONDITION GraphicsFillDisplay()
Creates a functor that tests if the frame fills graphics items.
void AddFootprintToPCB(wxCommandEvent &aEvent)
Function AddFootprintToPCB exports the current footprint name and close the library browser.
void ReCreateMenuBar() override
Recreates the menu bar.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
void ClickOnFootprintList(wxCommandEvent &aEvent)
void DismissModal(bool aRetVal, const wxString &aResult=wxEmptyString)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:186
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:200
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Sets the work environment (model, view, view controls and the parent window).
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools.
#define _(s)
Definition: 3d_actions.cpp:33
void setupUnits(APP_SETTINGS_BASE *aCfg)
void ReCreateLibraryList()
Function ReCreateLibraryList.
NETCLASS * GetDefault() const
Function GetDefault.
MAGNETIC_OPTIONS pads
PCB_EDIT_FRAME is the main frame for Pcbnew.
void OnLibFilter(wxCommandEvent &aEvent)
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
PCB_VIEWER_TOOLS.
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.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:221
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()
Removes all footprints from the deque and frees the memory associated with them.
Definition: board.h:356
BOARD_ITEM_CONTAINER * GetModel() const override
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:76
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:105
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()
Function InitTools() Initializes all registered tools.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
BOARD * GetBoard() const
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1344
double GetScale() const
Function GetScale()
Definition: view.h:259
int Parse(const UTF8 &aId, LIB_ID_TYPE aType, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:122
Message panel definition file.
bool m_FootprintViewerAutoZoom
Should the footprint viewer auto zoom on select.
virtual COLOR4D GetGridColor() override
void Update3DView(bool aForceReload, const wxString *aTitle=nullptr) override
Function Update3DView must be called after a footprint selection Updates the 3D view and 3D frame tit...
Class that groups generic conditions for PCB editor states.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
virtual bool ShowModal(wxString *aResult=NULL, wxWindow *aResultantFocusWindow=NULL)
Function ShowModal puts up this wxFrame as if it were a modal dialog, with all other instantiated wxF...
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
void StopDrawing()
Function StopDrawing() Prevents the GAL canvas from further drawing till it is recreated or StartDraw...
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:257
wxString m_aboutTitle
static TOOL_ACTION selectionTool
Definition: actions.h:156
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
wxString m_configName
MAGNETIC_OPTIONS tracks
void RegisterTool(TOOL_BASE *aTool)
Function RegisterTool() Adds 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:389
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from applicaton-level config.
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.