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 <class_board.h>
30 #include <class_module.h>
31 #include <confirm.h>
32 #include <dialog_helpers.h>
33 #include <eda_pattern_match.h>
34 #include <fctsys.h>
35 #include <footprint_info.h>
36 #include <footprint_viewer_frame.h>
37 #include <fp_lib_table.h>
38 #include <kiway.h>
39 #include <msgpanel.h>
40 #include <pcb_draw_panel_gal.h>
41 #include <pcb_painter.h>
42 #include <pcbnew_id.h>
44 #include <pgm_base.h>
46 #include <tool/action_toolbar.h>
47 #include <tool/common_control.h>
48 #include <tool/common_tools.h>
49 #include <tool/selection.h>
50 #include <tool/tool_dispatcher.h>
51 #include <tool/tool_manager.h>
52 #include <tool/zoom_tool.h>
53 #include <tools/pcb_viewer_tools.h>
54 #include <tools/pcb_actions.h>
56 #include <tools/pcbnew_control.h>
58 #include <tools/selection_tool.h>
60 #include <wx/tokenzr.h>
61 
62 using namespace std::placeholders;
63 
64 
65 #define NEXT_PART 1
66 #define NEW_PART 0
67 #define PREVIOUS_PART -1
68 
69 
70 BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME )
71  // Window events
74 
75  EVT_MENU( wxID_EXIT, FOOTPRINT_VIEWER_FRAME::OnExitKiCad )
76  EVT_MENU( wxID_CLOSE, FOOTPRINT_VIEWER_FRAME::CloseFootprintViewer )
77 
78  // Toolbar events
84 
86 
89 
90  // listbox events
94 
95 END_EVENT_TABLE()
96 
97 
98 /*
99  * Note: FOOTPRINT_VIEWER_FRAME can be created in "modal mode", or as a usual frame.
100  */
101 #define PARENT_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT )
102 #define MODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP )
103 #define NONMODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE )
104 
105 
107  FRAME_T aFrameType ) :
108  PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Library Browser" ),
109  wxDefaultPosition, wxDefaultSize,
110  aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL ? ( aParent ? PARENT_STYLE : MODAL_STYLE )
111  : NONMODAL_STYLE,
114 {
115  wxASSERT( aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL || aFrameType == FRAME_FOOTPRINT_VIEWER );
116 
117  if( aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL )
118  SetModal( true );
119 
120  m_AboutTitle = "Footprint Library Viewer";
121 
122  // Force the items to always snap
125  m_magneticItems.graphics = true;
126 
127  // Force the frame name used in config. the footprint viewer frame has a name
128  // depending on aFrameType (needed to identify the frame by wxWidgets),
129  // but only one configuration is preferable.
131 
132  // Give an icon
133  wxIcon icon;
134  icon.CopyFromBitmap( KiBitmap( modview_icon_xpm ) );
135  SetIcon( icon );
136 
137  wxPanel* libPanel = new wxPanel( this );
138  wxSizer* libSizer = new wxBoxSizer( wxVERTICAL );
139 
140  m_libFilter = new wxTextCtrl( libPanel, ID_MODVIEW_LIB_FILTER, wxEmptyString,
141  wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
142  m_libFilter->SetHint( _( "Filter" ) );
143  libSizer->Add( m_libFilter, 0, wxEXPAND, 5 );
144 
145  m_libList = new wxListBox( libPanel, ID_MODVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
146  0, NULL, wxLB_HSCROLL | wxNO_BORDER );
147  libSizer->Add( m_libList, 1, wxEXPAND, 5 );
148 
149  libPanel->SetSizer( libSizer );
150  libPanel->Fit();
151 
152  wxPanel* fpPanel = new wxPanel( this );
153  wxSizer* fpSizer = new wxBoxSizer( wxVERTICAL );
154 
155  m_fpFilter = new wxTextCtrl( fpPanel, ID_MODVIEW_FOOTPRINT_FILTER, wxEmptyString,
156  wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
157  m_fpFilter->SetHint( _( "Filter" ) );
158  m_fpFilter->SetToolTip(
159  _( "Filter on footprint name, keywords, description and pad count.\n"
160  "Search terms are separated by spaces. All search terms must match.\n"
161  "A term which is a number will also match against the pad count." ) );
162  fpSizer->Add( m_fpFilter, 0, wxEXPAND, 5 );
163 
164  m_fpList = new wxListBox( fpPanel, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize,
165  0, NULL, wxLB_HSCROLL | wxNO_BORDER );
166  fpSizer->Add( m_fpList, 1, wxEXPAND, 5 );
167 
168  fpPanel->SetSizer( fpSizer );
169  fpPanel->Fit();
170 
171  // Create GAL canvas
173  auto drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
175  SetCanvas( drawPanel );
176 
177  SetBoard( new BOARD() );
178  // In viewer, the default net clearance is not known (it depends on the actual board).
179  // So we do not show the default clearance, by setting it to 0
180  // The footprint or pad specific clearance will be shown
182 
183  // Don't show the default board solder mask clearance in the footprint viewer. Only the
184  // footprint or pad clearance setting should be shown if it is not 0.
186 
187  // Ensure all layers and items are visible:
189  SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
190 
191  GetScreen()->m_Center = true; // Center coordinate origins on screen.
192  LoadSettings( config() );
194 
195  // Create the manager and dispatcher & route draw panel events to the dispatcher
197  m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(),
198  drawPanel->GetViewControls(), config(), this );
199  m_actions = new PCB_ACTIONS();
201  drawPanel->SetEventDispatcher( m_toolDispatcher );
202 
205  m_toolManager->RegisterTool( new COMMON_TOOLS ); // for std context menus (zoom & grid)
207  m_toolManager->RegisterTool( new PCBNEW_PICKER_TOOL ); // for setting grid origin
210 
211  m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
212 
214  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
215 
217  ReCreateMenuBar();
221 
223  UpdateTitle();
224 
225  // If a footprint was previously loaded, reload it
226  if( getCurNickname().size() && getCurFootprintName().size() )
227  {
228  LIB_ID id;
229 
231  id.SetLibItemName( getCurFootprintName() );
232  GetBoard()->Add( loadFootprint( id ) );
233  }
234 
235  drawPanel->DisplayBoard( m_Pcb );
236 
237  m_auimgr.SetManagedWindow( this );
238 
239  // Horizontal items; layers 4 - 6
240  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().VToolbar().Name( "MainToolbar" ).Top().Layer(6) );
241  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
242  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
243 
244  // Vertical items; layers 1 - 3
245  m_auimgr.AddPane( libPanel, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(2)
246  .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
247  m_auimgr.AddPane( fpPanel, EDA_PANE().Palette().Name( "Footprints" ).Left().Layer( 1)
248  .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
249 
250  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
251 
252  // after changing something to the aui manager call Update() to reflect the changes
253  m_auimgr.Update();
254 
255  // The canvas should not steal the focus from the list boxes
256  GetCanvas()->SetCanFocus( false );
257  GetCanvas()->GetGAL()->SetAxesEnabled( true );
259 
260  // Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.)
262  wxASSERT( cfg );
264 
265  updateView();
266  InitExitKey();
267 
268  if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
269  {
271  Raise(); // On some window managers, this is needed
272  Show( true );
273  }
274 }
275 
276 
278 {
279  // Shutdown all running tools
280  if( m_toolManager )
282 
283  GetCanvas()->StopDrawing();
284  GetCanvas()->GetView()->Clear();
285  // Be sure any event cannot be fired after frame deletion:
286  GetCanvas()->SetEvtHandlerEnabled( false );
287 }
288 
289 
291 {
292  return m_toolManager->GetTool<SELECTION_TOOL>()->GetSelection();
293 }
294 
295 
297 {
299 
301  PCB_EDITOR_CONDITIONS cond( this );
302 
303  wxASSERT( mgr );
304 
305 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
306 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
307 
312 
313 
317 
322 
323  auto autoZoomCond =
324  [this] ( const SELECTION& )
325  {
326  return GetAutoZoom();
327  };
328 
330 
331 #undef ENABLE
332 #undef CHECK
333 }
334 
335 
337 {
338  // A workaround to avoid flicker, in modal mode when modview frame is destroyed,
339  // when the aui toolbar is not docked (i.e. shown in a miniframe)
340  // (useful on windows only)
341  m_mainToolBar->SetFocus();
342 
343  GetCanvas()->StopDrawing();
344 
345  if( IsModal() )
346  {
347  // Only dismiss a modal frame once, so that the return values set by
348  // the prior DismissModal() are not bashed for ShowModal().
349  if( !IsDismissed() )
350  DismissModal( false );
351 
352  // window to be destroyed by the caller of KIWAY_PLAYER::ShowModal()
353  }
354  else
355  Destroy();
356 }
357 
358 
359 void FOOTPRINT_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv )
360 {
361  if( m_auimgr.GetManagedWindow() )
362  m_auimgr.Update();
363 
364  SizeEv.Skip();
365 }
366 
367 
369 {
370  m_libList->Clear();
371 
372  std::vector<wxString> nicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
373  std::set<wxString> excludes;
374 
375  if( !m_libFilter->GetValue().IsEmpty() )
376  {
377  wxStringTokenizer tokenizer( m_libFilter->GetValue() );
378 
379  while( tokenizer.HasMoreTokens() )
380  {
381  const wxString term = tokenizer.GetNextToken().Lower();
382  EDA_COMBINED_MATCHER matcher( term );
383  int matches, position;
384 
385  for( const wxString& nickname : nicknames )
386  {
387  if( !matcher.Find( nickname.Lower(), matches, position ) )
388  excludes.insert( nickname );
389  }
390  }
391  }
392 
393  for( const wxString& nickname : nicknames )
394  {
395  if( !excludes.count( nickname ) )
396  m_libList->Append( nickname );
397  }
398 
399  // Search for a previous selection:
400  int index = m_libList->FindString( getCurNickname(), true );
401 
402  if( index == wxNOT_FOUND )
403  {
404  if( m_libList->GetCount() > 0 )
405  {
406  m_libList->SetSelection( 0 );
407  wxCommandEvent dummy;
409  }
410  else
411  {
412  setCurNickname( wxEmptyString );
413  setCurFootprintName( wxEmptyString );
414  }
415  }
416  else
417  {
418  m_libList->SetSelection( index, true );
419  wxCommandEvent dummy;
421  }
422 
423  GetCanvas()->Refresh();
424 }
425 
426 
428 {
429  m_fpList->Clear();
430 
431  if( !getCurNickname() )
432  setCurFootprintName( wxEmptyString );
433 
434  auto fp_info_list = FOOTPRINT_LIST::GetInstance( Kiway() );
435 
436  wxString nickname = getCurNickname();
437 
438  fp_info_list->ReadFootprintFiles( Prj().PcbFootprintLibs(), !nickname ? NULL : &nickname );
439 
440  if( fp_info_list->GetErrorCount() )
441  {
442  fp_info_list->DisplayErrors( this );
443 
444  // For footprint libraries that support one footprint per file, there may have been
445  // valid footprints read so show the footprints that loaded properly.
446  if( fp_info_list->GetList().empty() )
447  return;
448  }
449 
450  std::set<wxString> excludes;
451 
452  if( !m_fpFilter->GetValue().IsEmpty() )
453  {
454  wxStringTokenizer tokenizer( m_fpFilter->GetValue() );
455 
456  while( tokenizer.HasMoreTokens() )
457  {
458  const wxString term = tokenizer.GetNextToken().Lower();
459  EDA_COMBINED_MATCHER matcher( term );
460  int matches, position;
461 
462  for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
463  {
464  wxString search = footprint->GetFootprintName() + " " + footprint->GetSearchText();
465  bool matched = matcher.Find( search.Lower(), matches, position );
466 
467  if( !matched && term.IsNumber() )
468  matched = ( wxAtoi( term ) == (int)footprint->GetPadCount() );
469 
470  if( !matched )
471  excludes.insert( footprint->GetFootprintName() );
472  }
473  }
474  }
475 
476  for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
477  {
478  if( !excludes.count( footprint->GetFootprintName() ) )
479  m_fpList->Append( footprint->GetFootprintName() );
480  }
481 
482  int index = m_fpList->FindString( getCurFootprintName(), true );
483 
484  if( index == wxNOT_FOUND )
485  {
486  if( m_fpList->GetCount() > 0 )
487  {
488  m_fpList->SetSelection( 0 );
489  m_fpList->EnsureVisible( 0 );
490 
491  wxCommandEvent dummy;
493  }
494  else
495  setCurFootprintName( wxEmptyString );
496  }
497  else
498  {
499  m_fpList->SetSelection( index, true );
500  m_fpList->EnsureVisible( index );
501  }
502 }
503 
504 
505 void FOOTPRINT_VIEWER_FRAME::OnLibFilter( wxCommandEvent& aEvent )
506 {
508 
509  // Required to avoid interaction with SetHint()
510  // See documentation for wxTextEntry::SetHint
511  aEvent.Skip();
512 }
513 
514 
515 void FOOTPRINT_VIEWER_FRAME::OnFPFilter( wxCommandEvent& aEvent )
516 {
518 
519  // Required to avoid interaction with SetHint()
520  // See documentation for wxTextEntry::SetHint
521  aEvent.Skip();
522 }
523 
524 
525 void FOOTPRINT_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent )
526 {
527  if( aEvent.GetKeyCode() == WXK_UP )
528  {
529  wxWindow* focused = FindFocus();
530 
531  if( m_libFilter->HasFocus() || m_libList->HasFocus() )
533  else
534  selectPrev( m_fpList );
535 
536  // Need to reset the focus after selection due to GTK mouse-refresh
537  // that captures the mouse into the canvas to update scrollbars
538  if( focused )
539  focused->SetFocus();
540  }
541  else if( aEvent.GetKeyCode() == WXK_DOWN )
542  {
543  wxWindow* focused = FindFocus();
544 
545  if( m_libFilter->HasFocus() || m_libList->HasFocus() )
547  else
548  selectNext( m_fpList );
549 
550  // Need to reset the focus after selection due to GTK mouse-refresh
551  // that captures the mouse into the canvas to update scrollbars
552  if( focused )
553  focused->SetFocus();
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  aEvent.Skip();
576 }
577 
578 
579 void FOOTPRINT_VIEWER_FRAME::selectPrev( wxListBox* aListBox )
580 {
581  int prev = aListBox->GetSelection() - 1;
582 
583  if( prev >= 0 )
584  {
585  aListBox->SetSelection( prev );
586  aListBox->EnsureVisible( prev );
587 
588  wxCommandEvent dummy;
589 
590  if( aListBox == m_libList )
592  else
594  }
595 }
596 
597 
598 void FOOTPRINT_VIEWER_FRAME::selectNext( wxListBox* aListBox )
599 {
600  int next = aListBox->GetSelection() + 1;
601 
602  if( next < (int)aListBox->GetCount() )
603  {
604  aListBox->SetSelection( next );
605  aListBox->EnsureVisible( next );
606 
607  wxCommandEvent dummy;
608 
609  if( aListBox == m_libList )
611  else
613  }
614 }
615 
616 
617 void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& aEvent )
618 {
619  int ii = m_libList->GetSelection();
620 
621  if( ii < 0 )
622  return;
623 
624  wxString name = m_libList->GetString( ii );
625 
626  if( getCurNickname() == name )
627  return;
628 
629  setCurNickname( name );
630 
632  UpdateTitle();
633 
634  // The m_libList has now the focus, in order to be able to use arrow keys
635  // to navigate inside the list.
636  // the gal canvas must not steal the focus to allow navigation
637  GetCanvas()->SetStealsFocus( false );
638  m_libList->SetFocus();
639 }
640 
641 
642 void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& aEvent )
643 {
644  if( m_fpList->GetCount() == 0 )
645  return;
646 
647  int ii = m_fpList->GetSelection();
648 
649  if( ii < 0 )
650  return;
651 
652  wxString name = m_fpList->GetString( ii );
653 
654  if( getCurFootprintName().CmpNoCase( name ) != 0 )
655  {
657 
658  // Delete the current footprint (MUST reset tools first)
660 
662 
663  LIB_ID id;
665  id.SetLibItemName( getCurFootprintName() );
666 
667  try
668  {
669  GetBoard()->Add( loadFootprint( id ) );
670  }
671  catch( const IO_ERROR& ioe )
672  {
673  wxString msg = wxString::Format( _( "Could not load footprint '%s' from library '%s'."
674  "\n\n%s" ),
676  getCurNickname(),
677  ioe.Problem() );
678  DisplayError( this, msg );
679  }
680 
681  UpdateTitle();
682 
683  updateView();
684 
685  GetCanvas()->Refresh();
686  Update3DView( true );
687  }
688 
689  // The m_fpList has now the focus, in order to be able to use arrow keys
690  // to navigate inside the list.
691  // the gal canvas must not steal the focus to allow navigation
692  GetCanvas()->SetStealsFocus( false );
693  m_fpList->SetFocus();
694 }
695 
696 
697 void FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList( wxCommandEvent& aEvent )
698 {
699  AddFootprintToPCB( aEvent );
700 }
701 
702 
703 void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
704 {
705  if( IsModal() )
706  {
707  if( m_fpList->GetSelection() >= 0 )
708  {
709  LIB_ID fpid( getCurNickname(), m_fpList->GetStringSelection() );
710  DismissModal( true, fpid.Format() );
711  }
712  else
713  {
714  DismissModal( false );
715  }
716  }
717  else if( GetBoard()->GetFirstModule() )
718  {
719  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
720 
721  if( pcbframe == NULL ) // happens when the board editor is not active (or closed)
722  {
723  DisplayErrorMessage( this, _( "No board currently open." ) );
724  return;
725  }
726 
728  BOARD_COMMIT commit( pcbframe );
729 
730  // Create the "new" module
731  MODULE* newmodule = (MODULE*) GetBoard()->GetFirstModule()->Duplicate();
732  newmodule->SetParent( pcbframe->GetBoard() );
733  newmodule->SetLink( 0 );
734 
735  KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetCanvas()->GetViewControls();
736  VECTOR2D cursorPos = viewControls->GetCursorPosition();
737 
738  commit.Add( newmodule );
739  viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
740  pcbframe->PlaceModule( newmodule );
741  newmodule->SetPosition( wxPoint( 0, 0 ) );
742  viewControls->SetCrossHairCursorPosition( cursorPos, false );
743  commit.Push( wxT( "Insert module" ) );
744 
745  pcbframe->Raise();
746  pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeModule, true, newmodule );
747 
748  newmodule->ClearFlags();
749  }
750 }
751 
752 
754 {
755  auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
756  wxCHECK( cfg, /*void*/ );
757 
758  // We don't allow people to change this right now, so make sure it's on
760 
762 
763  // Fetch display and grid settings from Footprint Editor
764  auto fpedit = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
765  m_DisplayOptions = fpedit->m_Display;
766  GetGalDisplayOptions().ReadWindowSettings( fpedit->m_Window );
767 }
768 
769 
771 {
772  auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
773  wxCHECK( cfg, /*void*/ );
774 
775  // We don't want to store anything other than the window settings
777 
778  cfg->m_FootprintViewerZoom = GetCanvas()->GetView()->GetScale();
779 }
780 
781 
783 {
784  auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
785  wxCHECK_MSG( cfg, nullptr, "config not existing" );
786 
787  return &cfg->m_FootprintViewer;
788 }
789 
790 
792 {
793  auto* settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
794 
795  if( settings )
796  return Pgm().GetSettingsManager().GetColorSettings( settings->m_ColorTheme );
797  else
798  return Pgm().GetSettingsManager().GetColorSettings();
799 }
800 
801 
803 {
804  // It is stored in pcbnew's settings
806  wxCHECK( cfg, false );
807  return cfg->m_FootprintViewerAutoZoom;
808 }
809 
810 
812 {
813  // It is stored in pcbnew's settings
815  wxASSERT( cfg );
816  cfg->m_FootprintViewerAutoZoom = aAutoZoom;
817 }
818 
819 
820 void FOOTPRINT_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
821 {
822  PCB_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
823 
824  if( aEnvVarsChanged )
826 }
827 
828 
830 {
832 }
833 
834 
835 void FOOTPRINT_VIEWER_FRAME::setCurNickname( const wxString& aNickname )
836 {
838 }
839 
840 
842 {
844 }
845 
846 
847 void FOOTPRINT_VIEWER_FRAME::setCurFootprintName( const wxString& aName )
848 {
850 }
851 
852 
853 void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
854 {
855  if( event.GetActive() )
856  {
857  // Ensure we have the right library list:
858  std::vector< wxString > libNicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
859  bool stale = false;
860 
861  if( libNicknames.size() != m_libList->GetCount() )
862  stale = true;
863  else
864  {
865  for( unsigned ii = 0; ii < libNicknames.size(); ii++ )
866  {
867  if( libNicknames[ii] != m_libList->GetString( ii ) )
868  {
869  stale = true;
870  break;
871  }
872  }
873  }
874 
875  if( stale )
876  {
878  UpdateTitle();
879  }
880  }
881 
882  event.Skip(); // required under wxMAC
883 }
884 
885 
886 void FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton( wxUpdateUIEvent& aEvent )
887 {
888  aEvent.Enable( GetBoard()->GetFirstModule() != nullptr );
889 }
890 
891 
892 bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
893 {
894  if( aFootprint && !aFootprint->IsEmpty() )
895  {
896  wxString msg;
897  LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
898  LIB_ID fpid;
899 
900  fpid.Parse( *aFootprint, LIB_ID::ID_PCB, true );
901 
902  if( fpid.IsValid() )
903  {
904  wxString nickname = fpid.GetLibNickname();
905 
906  if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) )
907  {
908  msg.sprintf( _( "The current configuration does not include a library with the\n"
909  "nickname \"%s\". Use Manage Footprint Libraries\n"
910  "to edit the configuration." ), nickname );
911  DisplayErrorMessage( aParent, _( "Footprint library not found." ), msg );
912  }
913  else if ( !fpTable->HasLibrary( fpid.GetLibNickname(), true ) )
914  {
915  msg.sprintf( _( "The library with the nickname \"%s\" is not enabled\n"
916  "in the current configuration. Use Manage Footprint Libraries to\n"
917  "edit the configuration." ), nickname );
918  DisplayErrorMessage( aParent, _( "Footprint library not enabled." ), msg );
919  }
920  else
921  {
922  // Update last selection:
923  setCurNickname( nickname );
925  m_libList->SetStringSelection( nickname );
926  }
927  }
928  }
929 
930  // Rebuild the fp list from the last selected library,
931  // and show the last selected footprint
934 
935  bool retval = KIWAY_PLAYER::ShowModal( aFootprint, aParent );
936 
937  m_libFilter->SetFocus();
938  return retval;
939 }
940 
941 
942 void FOOTPRINT_VIEWER_FRAME::Update3DView( bool aForceReload, const wxString* aTitle )
943 {
944  wxString title = wxString::Format( _( "3D Viewer" ) + wxT( " \u2014 %s" ),
946  PCB_BASE_FRAME::Update3DView( aForceReload, &title );
947 }
948 
949 
951 {
952  return GetColorSettings()->GetColor( LAYER_GRID );
953 }
954 
955 
957 {
958  switch( event.GetId() )
959  {
960  case ID_MODVIEW_NEXT:
962  break;
963 
964  case ID_MODVIEW_PREVIOUS:
966  break;
967 
968  default:
969  wxString id = wxString::Format( "%i", event.GetId() );
970  wxFAIL_MSG( "FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList error: id = " + id );
971  }
972 }
973 
974 
976 {
977  wxString title;
978  wxString path;
979 
980  title.Printf( getCurNickname().IsEmpty() ? _( "no library selected" ) : getCurNickname() );
981 
982  // Now, add the full path, for info
983  if( !getCurNickname().IsEmpty() )
984  {
985  FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
986  const LIB_TABLE_ROW* row = libtable->FindRow( getCurNickname() );
987 
988  if( row )
989  title << L" \u2014 " << row->GetFullURI( true );
990  }
991 
992  title += wxT( " \u2014 " ) + _( "Footprint Library Browser" );
993 
994  SetTitle( title );
995 }
996 
997 
999 {
1000  if( !getCurNickname() )
1001  return;
1002 
1003  int selection = m_fpList->FindString( getCurFootprintName(), true );
1004 
1005  if( aMode == NEXT_PART )
1006  {
1007  if( selection != wxNOT_FOUND && selection < (int)m_fpList->GetCount() - 1 )
1008  selection++;
1009  }
1010 
1011  if( aMode == PREVIOUS_PART )
1012  {
1013  if( selection != wxNOT_FOUND && selection > 0 )
1014  selection--;
1015  }
1016 
1017  if( selection != wxNOT_FOUND )
1018  {
1019  m_fpList->SetSelection( selection );
1020  m_fpList->EnsureVisible( selection );
1021 
1022  setCurFootprintName( m_fpList->GetString((unsigned) selection ) );
1023 
1024  // Delete the current footprint
1026 
1028  getCurFootprintName() );
1029 
1030  if( footprint )
1031  GetBoard()->Add( footprint, ADD_MODE::APPEND );
1032 
1033  Update3DView( true );
1034 
1035  updateView();
1036  }
1037 
1038  UpdateTitle();
1039 
1040  GetCanvas()->Refresh();
1041 }
1042 
1043 
1045 {
1046  GetCanvas()->UpdateColors();
1048 
1050 
1051  if( GetAutoZoom() )
1053  else
1055 
1056  UpdateMsgPanel();
1057 }
1058 
1059 
1060 void FOOTPRINT_VIEWER_FRAME::OnExitKiCad( wxCommandEvent& event )
1061 {
1062  Kiway().OnKiCadExit();
1063 }
1064 
1065 
1067 {
1068  Close( false );
1069 }
1070 
1071 
1073 {
1074  return GetBoard()->GetFirstModule();
1075 }
1076 
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
static TOOL_ACTION selectionClear
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:239
CITER next(CITER it)
Definition: ptree.cpp:126
void SetLink(const KIID &aLink)
Definition: class_module.h:568
static TOOL_ACTION placeModule
Definition: pcb_actions.h:155
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
const BITMAP_OPAQUE modview_icon_xpm[1]
void OnKiCadExit()
Definition: kiway.cpp:585
#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.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
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:252
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.
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:97
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
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.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
MODULE * FootprintLoad(const wxString &aNickname, const wxString &aFootprintName)
Function FootprintLoad.
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:94
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:140
wxString m_AboutTitle
EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: class_board.h:514
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
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:242
void setCurNickname(const wxString &aNickname)
void OnUpdateFootprintButton(wxUpdateUIEvent &aEvent)
Update the ID_ADD_FOOTPRINT_TO_BOARD tool state in main toolbar.
virtual const wxString Problem() const
what was the problem?
Definition: exceptions.cpp:45
bool always_show_cursor
Definition: app_settings.h:42
static TOOL_ACTION imperialUnits
Definition: actions.h:142
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: base_struct.h:196
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
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...
TOOL_MANAGER.
Definition: tool_manager.h:51
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
static TOOL_ACTION measureTool
Definition: actions.h:150
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
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:98
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.
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:343
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:1107
void SetClearance(int aClearance)
Definition: netclass.h:166
static TOOL_ACTION toggleGrid
Definition: actions.h:138
bool m_Center
Center on screen.
Definition: base_screen.h:69
static TOOL_ACTION showPadNumbers
Definition: pcb_actions.h:241
#define NEXT_PART
EDA_MSG_PANEL * m_messagePanel
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
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:51
bool Find(const wxString &aTerm, int &aMatchersTriggered, int &aPosition)
MODULE * GetFirstModule() const
Gets the first module in the list (used in footprint viewer/editor) or NULL if none.
Definition: class_board.h:308
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
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
void SetPosition(const wxPoint &aPos) override
#define FOOTPRINT_VIEWER_FRAME_NAME
void InitExitKey()
Sets the common key-pair for exiting the application (Ctrl-Q) and ties it to the wxID_EXIT event id.
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:176
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...
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:52
COMMON_TOOLS.
Definition: common_tools.h:38
void UpdateColors()
Updates the color settings in the painter and GAL.
PCB_DISPLAY_OPTIONS m_DisplayOptions
void SetModal(bool aIsModal)
Definition: kiway_player.h:177
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:214
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:286
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:235
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:193
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Function SetScale() Sets the scaling factor, zooming around a given anchor point.
Definition: view.cpp:577
static TOOL_ACTION graphicsOutlines
Display module edges as outlines.
Definition: pcb_actions.h:379
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName)
Function FindRow.
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
static TOOL_ACTION metricUnits
Definition: actions.h:143
COLOR4D GetColor(int aLayer) const
BOARD_ITEM * Duplicate() const override
Function Duplicate creates a copy of a BOARD_ITEM.
VTBL_ENTRY const wxString & GetRString(RSTRING_T aStringId)
Function GetRString returns a "retained string", which is any session and project specific string ide...
Definition: project.cpp:229
PCB_ACTIONS.
Definition: pcb_actions.h:51
#define CHECK(x)
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:50
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:60
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
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: class_board.h:176
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:199
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Sets the work environment (model, view, view controls and the parent window).
#define _(s)
Definition: 3d_actions.cpp:33
void ReCreateLibraryList()
Function ReCreateLibraryList.
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnToggleShowLayerManager GERBVIEW_FRAME::OnSelectHighlightChoice EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, GERBVIEW_FRAME::OnUpdateLayerSelectBox) EVT_UPDATE_UI_RANGE(ID_TB_OPTIONS_SHOW_GBR_MODE_0
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: base_struct.h:233
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 DeleteAllModules()
Removes all modules from the deque and frees the memory associated with them.
Definition: class_board.h:316
BOARD_ITEM_CONTAINER * GetModel() const override
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:78
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:100
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 PlaceModule(MODULE *aModule, bool aRecreateRatsnest=true)
Function PlaceModule places aModule at the current cursor position and updates module coordinates wit...
virtual void Update3DView(bool aForceReload, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
double GetScale() const
Function GetScale()
Definition: view.h:257
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
MODULE * loadFootprint(const LIB_ID &aFootprintId)
Function loadFootprint attempts to load aFootprintId from the footprint library table.
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...
static TOOL_ACTION selectionTool
Definition: actions.h:149
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
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:382
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99
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.