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/pcb_control.h>
56 #include <tools/pcb_picker_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 = _( "KiCad 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( icon_footprint_browser_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 PCB_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  setupUnits( config() );
270 
271  if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
272  {
274  Raise(); // On some window managers, this is needed
275  Show( true );
276  }
277 }
278 
279 
281 {
282  // Shutdown all running tools
283  if( m_toolManager )
285 
286  GetCanvas()->StopDrawing();
287  GetCanvas()->GetView()->Clear();
288  // Be sure any event cannot be fired after frame deletion:
289  GetCanvas()->SetEvtHandlerEnabled( false );
290 }
291 
292 
294 {
295  return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
296 }
297 
298 
300 {
302 
304  PCB_EDITOR_CONDITIONS cond( this );
305 
306  wxASSERT( mgr );
307 
308 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
309 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
310 
316 
317 
321 
326 
327  auto autoZoomCond =
328  [this] ( const SELECTION& )
329  {
330  return GetAutoZoom();
331  };
332 
334 
335 #undef ENABLE
336 #undef CHECK
337 }
338 
339 
341 {
342  // A workaround to avoid flicker, in modal mode when modview frame is destroyed,
343  // when the aui toolbar is not docked (i.e. shown in a miniframe)
344  // (useful on windows only)
345  m_mainToolBar->SetFocus();
346 
347  GetCanvas()->StopDrawing();
348 
349  if( IsModal() )
350  {
351  // Only dismiss a modal frame once, so that the return values set by
352  // the prior DismissModal() are not bashed for ShowModal().
353  if( !IsDismissed() )
354  DismissModal( false );
355 
356  // window to be destroyed by the caller of KIWAY_PLAYER::ShowModal()
357  }
358  else
359  Destroy();
360 }
361 
362 
363 void FOOTPRINT_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv )
364 {
365  if( m_auimgr.GetManagedWindow() )
366  m_auimgr.Update();
367 
368  SizeEv.Skip();
369 }
370 
371 
373 {
374  m_libList->Clear();
375 
376  std::vector<wxString> nicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
377  std::set<wxString> excludes;
378 
379  if( !m_libFilter->GetValue().IsEmpty() )
380  {
381  wxStringTokenizer tokenizer( m_libFilter->GetValue() );
382 
383  while( tokenizer.HasMoreTokens() )
384  {
385  const wxString term = tokenizer.GetNextToken().Lower();
386  EDA_COMBINED_MATCHER matcher( term );
387  int matches, position;
388 
389  for( const wxString& nickname : nicknames )
390  {
391  if( !matcher.Find( nickname.Lower(), matches, position ) )
392  excludes.insert( nickname );
393  }
394  }
395  }
396 
397  for( const wxString& nickname : nicknames )
398  {
399  if( !excludes.count( nickname ) )
400  m_libList->Append( nickname );
401  }
402 
403  // Search for a previous selection:
404  int index = m_libList->FindString( getCurNickname(), true );
405 
406  if( index == wxNOT_FOUND )
407  {
408  if( m_libList->GetCount() > 0 )
409  {
410  m_libList->SetSelection( 0 );
411  wxCommandEvent dummy;
413  }
414  else
415  {
416  setCurNickname( wxEmptyString );
417  setCurFootprintName( wxEmptyString );
418  }
419  }
420  else
421  {
422  m_libList->SetSelection( index, true );
423  wxCommandEvent dummy;
425  }
426 
427  GetCanvas()->Refresh();
428 }
429 
430 
432 {
433  m_fpList->Clear();
434 
435  if( !getCurNickname() )
436  setCurFootprintName( wxEmptyString );
437 
438  auto fp_info_list = FOOTPRINT_LIST::GetInstance( Kiway() );
439 
440  wxString nickname = getCurNickname();
441 
442  fp_info_list->ReadFootprintFiles( Prj().PcbFootprintLibs(), !nickname ? NULL : &nickname );
443 
444  if( fp_info_list->GetErrorCount() )
445  {
446  fp_info_list->DisplayErrors( this );
447 
448  // For footprint libraries that support one footprint per file, there may have been
449  // valid footprints read so show the footprints that loaded properly.
450  if( fp_info_list->GetList().empty() )
451  return;
452  }
453 
454  std::set<wxString> excludes;
455 
456  if( !m_fpFilter->GetValue().IsEmpty() )
457  {
458  wxStringTokenizer tokenizer( m_fpFilter->GetValue() );
459 
460  while( tokenizer.HasMoreTokens() )
461  {
462  const wxString term = tokenizer.GetNextToken().Lower();
463  EDA_COMBINED_MATCHER matcher( term );
464  int matches, position;
465 
466  for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
467  {
468  wxString search = footprint->GetFootprintName() + " " + footprint->GetSearchText();
469  bool matched = matcher.Find( search.Lower(), matches, position );
470 
471  if( !matched && term.IsNumber() )
472  matched = ( wxAtoi( term ) == (int)footprint->GetPadCount() );
473 
474  if( !matched )
475  excludes.insert( footprint->GetFootprintName() );
476  }
477  }
478  }
479 
480  for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
481  {
482  if( !excludes.count( footprint->GetFootprintName() ) )
483  m_fpList->Append( footprint->GetFootprintName() );
484  }
485 
486  int index = m_fpList->FindString( getCurFootprintName(), true );
487 
488  if( index == wxNOT_FOUND )
489  {
490  if( m_fpList->GetCount() > 0 )
491  {
492  m_fpList->SetSelection( 0 );
493  m_fpList->EnsureVisible( 0 );
494 
495  wxCommandEvent dummy;
497  }
498  else
499  setCurFootprintName( wxEmptyString );
500  }
501  else
502  {
503  m_fpList->SetSelection( index, true );
504  m_fpList->EnsureVisible( index );
505  }
506 }
507 
508 
509 void FOOTPRINT_VIEWER_FRAME::OnLibFilter( wxCommandEvent& aEvent )
510 {
512 
513  // Required to avoid interaction with SetHint()
514  // See documentation for wxTextEntry::SetHint
515  aEvent.Skip();
516 }
517 
518 
519 void FOOTPRINT_VIEWER_FRAME::OnFPFilter( wxCommandEvent& aEvent )
520 {
522 
523  // Required to avoid interaction with SetHint()
524  // See documentation for wxTextEntry::SetHint
525  aEvent.Skip();
526 }
527 
528 
529 void FOOTPRINT_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent )
530 {
531  if( aEvent.GetKeyCode() == WXK_UP )
532  {
533  wxWindow* focused = FindFocus();
534 
535  if( m_libFilter->HasFocus() || m_libList->HasFocus() )
537  else
538  selectPrev( m_fpList );
539 
540  // Need to reset the focus after selection due to GTK mouse-refresh
541  // that captures the mouse into the canvas to update scrollbars
542  if( focused )
543  focused->SetFocus();
544  }
545  else if( aEvent.GetKeyCode() == WXK_DOWN )
546  {
547  wxWindow* focused = FindFocus();
548 
549  if( m_libFilter->HasFocus() || m_libList->HasFocus() )
551  else
552  selectNext( m_fpList );
553 
554  // Need to reset the focus after selection due to GTK mouse-refresh
555  // that captures the mouse into the canvas to update scrollbars
556  if( focused )
557  focused->SetFocus();
558  }
559  else if( aEvent.GetKeyCode() == WXK_TAB && m_libFilter->HasFocus() )
560  {
561  if( !aEvent.ShiftDown() )
562  m_fpFilter->SetFocus();
563  else
564  aEvent.Skip();
565  }
566  else if( aEvent.GetKeyCode() == WXK_TAB && m_fpFilter->HasFocus() )
567  {
568  if( aEvent.ShiftDown() )
569  m_libFilter->SetFocus();
570  else
571  aEvent.Skip();
572  }
573  else if( aEvent.GetKeyCode() == WXK_RETURN && m_fpList->GetSelection() >= 0 )
574  {
575  wxCommandEvent dummy;
577  }
578  else
579  aEvent.Skip();
580 }
581 
582 
583 void FOOTPRINT_VIEWER_FRAME::selectPrev( wxListBox* aListBox )
584 {
585  int prev = aListBox->GetSelection() - 1;
586 
587  if( prev >= 0 )
588  {
589  aListBox->SetSelection( prev );
590  aListBox->EnsureVisible( prev );
591 
592  wxCommandEvent dummy;
593 
594  if( aListBox == m_libList )
596  else
598  }
599 }
600 
601 
602 void FOOTPRINT_VIEWER_FRAME::selectNext( wxListBox* aListBox )
603 {
604  int next = aListBox->GetSelection() + 1;
605 
606  if( next < (int)aListBox->GetCount() )
607  {
608  aListBox->SetSelection( next );
609  aListBox->EnsureVisible( next );
610 
611  wxCommandEvent dummy;
612 
613  if( aListBox == m_libList )
615  else
617  }
618 }
619 
620 
621 void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& aEvent )
622 {
623  int ii = m_libList->GetSelection();
624 
625  if( ii < 0 )
626  return;
627 
628  wxString name = m_libList->GetString( ii );
629 
630  if( getCurNickname() == name )
631  return;
632 
633  setCurNickname( name );
634 
636  UpdateTitle();
637 
638  // The m_libList has now the focus, in order to be able to use arrow keys
639  // to navigate inside the list.
640  // the gal canvas must not steal the focus to allow navigation
641  GetCanvas()->SetStealsFocus( false );
642  m_libList->SetFocus();
643 }
644 
645 
646 void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& aEvent )
647 {
648  if( m_fpList->GetCount() == 0 )
649  return;
650 
651  int ii = m_fpList->GetSelection();
652 
653  if( ii < 0 )
654  return;
655 
656  wxString name = m_fpList->GetString( ii );
657 
658  if( getCurFootprintName().CmpNoCase( name ) != 0 )
659  {
661 
662  // Delete the current footprint (MUST reset tools first)
664 
666 
667  LIB_ID id;
669  id.SetLibItemName( getCurFootprintName() );
670 
671  try
672  {
673  GetBoard()->Add( loadFootprint( id ) );
674  }
675  catch( const IO_ERROR& ioe )
676  {
677  wxString msg = wxString::Format( _( "Could not load footprint '%s' from library '%s'."
678  "\n\n%s" ),
680  getCurNickname(),
681  ioe.Problem() );
682  DisplayError( this, msg );
683  }
684 
685  UpdateTitle();
686 
687  updateView();
688 
689  GetCanvas()->Refresh();
690  Update3DView( true );
691  }
692 
693  // The m_fpList has now the focus, in order to be able to use arrow keys
694  // to navigate inside the list.
695  // the gal canvas must not steal the focus to allow navigation
696  GetCanvas()->SetStealsFocus( false );
697  m_fpList->SetFocus();
698 }
699 
700 
701 void FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList( wxCommandEvent& aEvent )
702 {
703  AddFootprintToPCB( aEvent );
704 }
705 
706 
707 void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
708 {
709  if( IsModal() )
710  {
711  if( m_fpList->GetSelection() >= 0 )
712  {
713  LIB_ID fpid( getCurNickname(), m_fpList->GetStringSelection() );
714  DismissModal( true, fpid.Format() );
715  }
716  else
717  {
718  DismissModal( false );
719  }
720  }
721  else if( GetBoard()->GetFirstFootprint() )
722  {
723  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
724 
725  if( pcbframe == NULL ) // happens when the board editor is not active (or closed)
726  {
727  DisplayErrorMessage( this, _( "No board currently open." ) );
728  return;
729  }
730 
732  BOARD_COMMIT commit( pcbframe );
733 
734  // Create the "new" footprint
735  FOOTPRINT* newFootprint = (FOOTPRINT*) GetBoard()->GetFirstFootprint()->Duplicate();
736  newFootprint->SetParent( pcbframe->GetBoard() );
737  newFootprint->SetLink( niluuid );
738  newFootprint->SetFlags(IS_NEW ); // whatever
739 
740  for( PAD* pad : newFootprint->Pads() )
741  {
742  // Set the pads ratsnest settings to the global settings
743  pad->SetLocalRatsnestVisible( pcbframe->GetDisplayOptions().m_ShowGlobalRatsnest );
744  pad->SetLocked( !pcbframe->Settings().m_AddUnlockedPads );
745 
746  // Pads in the library all have orphaned nets. Replace with Default.
747  pad->SetNetCode( 0 );
748  }
749 
750  // Put it on FRONT layer,
751  // (Can be stored flipped if the lib is an archive built from a board)
752  if( newFootprint->IsFlipped() )
753  newFootprint->Flip( newFootprint->GetPosition(),
754  pcbframe->Settings().m_FlipLeftRight );
755 
756  KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetCanvas()->GetViewControls();
757  VECTOR2D cursorPos = viewControls->GetCursorPosition();
758 
759  commit.Add( newFootprint );
760  viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
761  pcbframe->PlaceFootprint( newFootprint );
762 
763  newFootprint->SetPosition( wxPoint( 0, 0 ) );
764  viewControls->SetCrossHairCursorPosition( cursorPos, false );
765  commit.Push( wxT( "Insert footprint" ) );
766 
767  pcbframe->Raise();
768  pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeFootprint, true, newFootprint );
769 
770  newFootprint->ClearFlags();
771  }
772 }
773 
774 
776 {
777  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
778  wxCHECK( cfg, /*void*/ );
779 
780  // We don't allow people to change this right now, so make sure it's on
782 
784 
785  // Fetch display and grid settings from Footprint Editor
786  auto fpedit = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
787  m_displayOptions = fpedit->m_Display;
788  GetGalDisplayOptions().ReadWindowSettings( fpedit->m_Window );
789 }
790 
791 
793 {
794  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
795  wxCHECK( cfg, /*void*/ );
796 
798 
799  // We don't want to store anything other than the window settings
801 
803 }
804 
805 
807 {
808  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
809  wxCHECK_MSG( cfg, nullptr, "config not existing" );
810 
811  return &cfg->m_FootprintViewer;
812 }
813 
814 
816 {
817  auto* settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
818 
819  if( settings )
820  return Pgm().GetSettingsManager().GetColorSettings( settings->m_ColorTheme );
821  else
822  return Pgm().GetSettingsManager().GetColorSettings();
823 }
824 
825 
827 {
828  // It is stored in pcbnew's settings
830  wxCHECK( cfg, false );
831  return cfg->m_FootprintViewerAutoZoom;
832 }
833 
834 
836 {
837  // It is stored in pcbnew's settings
839  wxASSERT( cfg );
840  cfg->m_FootprintViewerAutoZoom = aAutoZoom;
841 }
842 
843 
844 void FOOTPRINT_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
845 {
846  PCB_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
847 
848  if( aEnvVarsChanged )
850 }
851 
852 
854 {
856 }
857 
858 
859 void FOOTPRINT_VIEWER_FRAME::setCurNickname( const wxString& aNickname )
860 {
862 }
863 
864 
866 {
868 }
869 
870 
871 void FOOTPRINT_VIEWER_FRAME::setCurFootprintName( const wxString& aName )
872 {
874 }
875 
876 
877 void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
878 {
879  if( event.GetActive() )
880  {
881  // Ensure we have the right library list:
882  std::vector< wxString > libNicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
883  bool stale = false;
884 
885  if( libNicknames.size() != m_libList->GetCount() )
886  stale = true;
887  else
888  {
889  for( unsigned ii = 0; ii < libNicknames.size(); ii++ )
890  {
891  if( libNicknames[ii] != m_libList->GetString( ii ) )
892  {
893  stale = true;
894  break;
895  }
896  }
897  }
898 
899  if( stale )
900  {
902  UpdateTitle();
903  }
904  }
905 
906  event.Skip(); // required under wxMAC
907 }
908 
909 
910 void FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton( wxUpdateUIEvent& aEvent )
911 {
912  aEvent.Enable( GetBoard()->GetFirstFootprint() != nullptr );
913 }
914 
915 
916 bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
917 {
918  if( aFootprint && !aFootprint->IsEmpty() )
919  {
920  wxString msg;
921  LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
922  LIB_ID fpid;
923 
924  fpid.Parse( *aFootprint, true );
925 
926  if( fpid.IsValid() )
927  {
928  wxString libraryName = fpid.GetLibNickname();
929 
930  if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) )
931  {
932  msg.sprintf( _( "The current configuration does not include library '%s'. Use "
933  "Manage Footprint Libraries to edit the configuration." ),
934  libraryName );
935  DisplayErrorMessage( aParent, _( "Footprint library not found." ), msg );
936  }
937  else if ( !fpTable->HasLibrary( fpid.GetLibNickname(), true ) )
938  {
939  msg.sprintf( _( "Library '%s' is not enabled in the current configuration. Use "
940  "Manage Footprint Libraries to edit the configuration." ),
941  libraryName );
942  DisplayErrorMessage( aParent, _( "Footprint library not enabled." ), msg );
943  }
944  else
945  {
946  // Update last selection:
947  setCurNickname( libraryName );
949  m_libList->SetStringSelection( libraryName );
950  }
951  }
952  }
953 
954  // Rebuild the fp list from the last selected library,
955  // and show the last selected footprint
958 
959  bool retval = KIWAY_PLAYER::ShowModal( aFootprint, aParent );
960 
961  m_libFilter->SetFocus();
962  return retval;
963 }
964 
965 
966 void FOOTPRINT_VIEWER_FRAME::Update3DView( bool aForceReload, const wxString* aTitle )
967 {
968  wxString title = wxString::Format( _( "3D Viewer" ) + wxT( " \u2014 %s" ),
970  PCB_BASE_FRAME::Update3DView( aForceReload, &title );
971 }
972 
973 
975 {
976  return GetColorSettings()->GetColor( LAYER_GRID );
977 }
978 
979 
981 {
982  switch( event.GetId() )
983  {
984  case ID_MODVIEW_NEXT:
986  break;
987 
988  case ID_MODVIEW_PREVIOUS:
990  break;
991 
992  default:
993  wxString id = wxString::Format( "%i", event.GetId() );
994  wxFAIL_MSG( "FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList error: id = " + id );
995  }
996 }
997 
998 
1000 {
1001  wxString title;
1002  wxString path;
1003 
1004  title.Printf( getCurNickname().IsEmpty() ? _( "no library selected" ) : getCurNickname() );
1005 
1006  // Now, add the full path, for info
1007  if( !getCurNickname().IsEmpty() )
1008  {
1009  FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
1010  const LIB_TABLE_ROW* row = libtable->FindRow( getCurNickname() );
1011 
1012  if( row )
1013  title << L" \u2014 " << row->GetFullURI( true );
1014  }
1015 
1016  title += wxT( " \u2014 " ) + _( "Footprint Library Browser" );
1017 
1018  SetTitle( title );
1019 }
1020 
1021 
1023 {
1024  if( !getCurNickname() )
1025  return;
1026 
1027  int selection = m_fpList->FindString( getCurFootprintName(), true );
1028 
1029  if( aMode == NEXT_PART )
1030  {
1031  if( selection != wxNOT_FOUND && selection < (int)m_fpList->GetCount() - 1 )
1032  selection++;
1033  }
1034 
1035  if( aMode == PREVIOUS_PART )
1036  {
1037  if( selection != wxNOT_FOUND && selection > 0 )
1038  selection--;
1039  }
1040 
1041  if( selection != wxNOT_FOUND )
1042  {
1043  m_fpList->SetSelection( selection );
1044  m_fpList->EnsureVisible( selection );
1045 
1046  setCurFootprintName( m_fpList->GetString((unsigned) selection ) );
1047 
1048  // Delete the current footprint
1050 
1052  getCurFootprintName() );
1053 
1054  if( footprint )
1055  GetBoard()->Add( footprint, ADD_MODE::APPEND );
1056 
1057  Update3DView( true );
1058 
1059  updateView();
1060  }
1061 
1062  UpdateTitle();
1063 
1064  GetCanvas()->Refresh();
1065 }
1066 
1067 
1069 {
1070  GetCanvas()->UpdateColors();
1072 
1074 
1075  if( GetAutoZoom() )
1077  else
1079 
1080  UpdateMsgPanel();
1081 }
1082 
1083 
1084 void FOOTPRINT_VIEWER_FRAME::OnExitKiCad( wxCommandEvent& event )
1085 {
1086  Kiway().OnKiCadExit();
1087 }
1088 
1089 
1091 {
1092  Close( false );
1093 }
1094 
1095 
1097 {
1098  return GetBoard()->GetFirstFootprint();
1099 }
1100 
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:63
virtual bool ShowModal(wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until t...
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:253
CITER next(CITER it)
Definition: ptree.cpp:126
const BITMAP_OPAQUE icon_footprint_browser_xpm[1]
virtual void SetBoard(BOARD *aBoard)
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
void DClickOnFootprintList(wxCommandEvent &aEvent)
const UTF8 & GetLibItemName() const
Definition: lib_id.h:106
FOOTPRINT * FootprintLoad(const wxString &aNickname, const wxString &aFootprintName)
Load a footprint having aFootprintName from the library given by aNickname.
void OnKiCadExit()
Definition: kiway.cpp:587
#define PREVIOUS_PART
void OnExitKiCad(wxCommandEvent &event)
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:56
bool ShowModal(wxString *aFootprint, wxWindow *aParent) override
Run the footprint viewer as a modal dialog.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
KIID niluuid(0)
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
void UpdateTitle()
Update the window title with current library information.
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
#define FOOTPRINT_VIEWER_FRAME_NAME_MODAL
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:266
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:81
This file is part of the common library.
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Return a pointer to the window settings for this frame.
bool IsDismissed()
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
ACTION_TOOLBAR * m_optionsToolBar
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
Definition: commit.h:78
virtual void SetScreen(BASE_SCREEN *aScreen)
static TOOL_ACTION zoomTool
Definition: actions.h:102
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:32
EVT_UPDATE_UI(ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void setCurFootprintName(const wxString &aName)
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()
Create a functor that tests if the frame fills text items.
Component library viewer main window.
bool GetAutoZoom() override
Always returns false.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
FOOTPRINT_VIEWER_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType)
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
static TOOL_ACTION zoomFitScreen
Definition: actions.h: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)
Run the specified action.
Definition: tool_manager.h:141
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:591
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:345
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:490
wxAuiManager m_auimgr
void SetAutoZoom(bool aAutoZoom) override
Does nothing.
#define PARENT_STYLE
ACTION_TOOLBAR * m_mainToolBar
Manage TOOL_ACTION objects.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
double m_FootprintViewerZoom
The last zoom level in the footprint viewer.
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
The base class for create windows for drawing purpose.
void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:168
static TOOL_ACTION zoomFootprintAutomatically
Definition: pcb_actions.h:252
void setCurNickname(const wxString &aNickname)
void OnUpdateFootprintButton(wxUpdateUIEvent &aEvent)
Update the ID_ADD_FOOTPRINT_TO_BOARD tool state in main toolbar.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
virtual const wxString Problem() const
what was the problem?
Definition: exceptions.cpp:45
bool always_show_cursor
Definition: app_settings.h:42
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
SELECTION_CONDITION PadFillDisplay()
Create a functor that tests if the frame fills the pads.
#define NEW_PART
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:165
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void PlaceFootprint(FOOTPRINT *aFootprint, bool aRecreateRatsnest=true)
Places aFootprint at the current cursor position and updates footprint coordinates with the new posit...
PADS & Pads()
Definition: footprint.h:164
Abstract pattern-matching tool and implementations.
bool m_axesEnabled
Fullscreen crosshair or small cross.
void ClickOnLibList(wxCommandEvent &aEvent)
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
PCB_DISPLAY_OPTIONS m_displayOptions
Master controller class:
Definition: tool_manager.h:52
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:563
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)
Select and load the next or the previous footprint.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
FOOTPRINT * loadFootprint(const LIB_ID &aFootprintId)
Attempts to load aFootprintId from the footprint library table.
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:202
FOOTPRINT * GetFirstFootprint() const
Gets the first footprint on the board or nullptr.
Definition: board.h:380
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
CURSOR_SETTINGS cursor
Definition: app_settings.h:88
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
virtual void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
#define NULL
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
void DisplayBoard(BOARD *aBoard)
Add all items from the current board to the VIEW, so they can be displayed by GAL.
void Clear()
Remove all items from the view.
Definition: view.cpp:1083
void SetClearance(int aClearance)
Definition: netclass.h:125
static TOOL_ACTION toggleGrid
Definition: actions.h:143
bool m_Center
Center on screen.
Definition: base_screen.h:100
Handle actions that are shared between different frames in PcbNew.
Definition: pcb_control.h:45
static TOOL_ACTION showPadNumbers
Definition: pcb_actions.h:251
#define NEXT_PART
EDA_MSG_PANEL * m_messagePanel
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
static TOOL_ACTION inchesUnits
Definition: actions.h:147
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1366
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:158
bool Find(const wxString &aTerm, int &aMatchersTriggered, int &aPosition)
Definition of file extensions used in Kicad.
Helper dialog and control classes.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
An interface for classes handling user events controlling the view behavior such as zooming,...
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:92
BOARD_ITEM * Duplicate() const override
Create a copy of a of this BOARD_ITEM.
Definition: footprint.cpp:1587
void OnActivate(wxActivateEvent &event)
Called when the frame frame is activate to reload the libraries and component lists that can be chang...
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
#define MODAL_STYLE
WINDOW_SETTINGS m_FootprintViewer
#define FOOTPRINT_VIEWER_FRAME_NAME
void OnFPFilter(wxCommandEvent &aEvent)
Handle actions that are shared between different applications.
void selectPrev(wxListBox *aListBox)
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Specialization of the wxAuiPaneInfo class for KiCad panels.
bool IsModal() const override
Return true if the frame is shown in our modal mode and false if the frame is shown as an usual frame...
Definition: kiway_player.h:170
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
COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
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:159
Handles action that are shared between different applications.
Definition: common_tools.h:37
void UpdateColors()
Update the color settings in the painter and GAL.
Generic tool for picking an item.
void SetModal(bool aIsModal)
Definition: kiway_player.h:171
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
virtual void SetRString(RSTRING_T aStringId, const wxString &aString)
Store a "retained string", which is any session and project specific string identified in enum RSTRIN...
SELECTION_CONDITION PadNumbersDisplay()
Create a functor that tests if the pad numbers are displayed.
#define NONMODAL_STYLE
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:245
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 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:553
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:390
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
bool IsFlipped() const
Definition: footprint.h:263
void SetLink(const KIID &aLink)
Definition: footprint.h:529
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
COLOR4D GetColor(int aLayer) const
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:122
Gather all the actions that are shared by tools.
Definition: pcb_actions.h:52
#define CHECK(x)
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:162
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
see class PGM_BASE
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
Declaration of the eda_3d_viewer class.
const char * name
Definition: DXF_plotter.cpp:59
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
void CloseFootprintViewer(wxCommandEvent &event)
SELECTION_CONDITION GraphicsFillDisplay()
Create a functor that tests if the frame fills graphics items.
void AddFootprintToPCB(wxCommandEvent &aEvent)
Export the current footprint name and close the library browser.
void ReCreateMenuBar() override
Recreates the menu bar.
void ClickOnFootprintList(wxCommandEvent &aEvent)
void DismissModal(bool aRetVal, const wxString &aResult=wxEmptyString)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:197
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
#define _(s)
Definition: 3d_actions.cpp:33
void setupUnits(APP_SETTINGS_BASE *aCfg)
void ReCreateLibraryList()
Create or recreate the list of current loaded libraries.
NETCLASS * GetDefault() const
MAGNETIC_OPTIONS pads
The main frame for Pcbnew.
PCBNEW_SETTINGS & Settings()
PCBNEW_SETTINGS * GetPcbNewSettings() const
The selection tool: currently supports:
void OnLibFilter(wxCommandEvent &aEvent)
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Revert the commit by restoring the modified items state.
wxPoint GetPosition() const override
Definition: footprint.h:182
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Tool useful for viewing footprints.
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:203
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:388
BOARD_ITEM_CONTAINER * GetModel() const override
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
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()
Initializes all registered tools.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
BOARD * GetBoard() const
Definition: pad.h:60
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1437
double GetScale() const
Definition: view.h:263
Message panel definition file.
bool m_FootprintViewerAutoZoom
Should the footprint viewer auto zoom on select.
virtual COLOR4D GetGridColor() override
void Update3DView(bool aForceReload, const wxString *aTitle=nullptr) override
Updates the 3D view and 3D frame title.
Group generic conditions for PCB editor states.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
#define IS_NEW
New item, just created.
Definition: eda_item.h:106
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:262
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
Return the current cursor position in world coordinates.
wxString m_configName
MAGNETIC_OPTIONS tracks
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
virtual void UpdateMsgPanel()
Redraw the message panel.
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:393
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.