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( BITMAPS::icon_footprint_browser ) );
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  bool filterFocus = m_libFilter->HasFocus();
634 
635  setCurNickname( name );
636 
638  UpdateTitle();
639 
640  // The m_libList has now the focus, in order to be able to use arrow keys
641  // to navigate inside the list.
642  // the gal canvas must not steal the focus to allow navigation
643  GetCanvas()->SetStealsFocus( false );
644 
645  if( filterFocus )
646  m_libFilter->SetFocus();
647  else
648  m_libList->SetFocus();
649 }
650 
651 
652 void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& aEvent )
653 {
654  if( m_fpList->GetCount() == 0 )
655  return;
656 
657  int ii = m_fpList->GetSelection();
658 
659  if( ii < 0 )
660  return;
661 
662  bool filterFocus = m_fpFilter->HasFocus();
663 
664  wxString name = m_fpList->GetString( ii );
665 
666  if( getCurFootprintName().CmpNoCase( name ) != 0 )
667  {
669 
670  // Delete the current footprint (MUST reset tools first)
672 
674 
675  LIB_ID id;
677  id.SetLibItemName( getCurFootprintName() );
678 
679  try
680  {
681  GetBoard()->Add( loadFootprint( id ) );
682  }
683  catch( const IO_ERROR& ioe )
684  {
685  wxString msg = wxString::Format( _( "Could not load footprint '%s' from library '%s'."
686  "\n\n%s" ),
688  getCurNickname(),
689  ioe.Problem() );
690  DisplayError( this, msg );
691  }
692 
693  UpdateTitle();
694 
695  updateView();
696 
697  GetCanvas()->Refresh();
698  Update3DView( true, true );
699  }
700 
701  // The m_fpList has now the focus, in order to be able to use arrow keys
702  // to navigate inside the list.
703  // the gal canvas must not steal the focus to allow navigation
704  GetCanvas()->SetStealsFocus( false );
705 
706  if( filterFocus )
707  m_fpFilter->SetFocus();
708  else
709  m_fpList->SetFocus();
710 }
711 
712 
713 void FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList( wxCommandEvent& aEvent )
714 {
715  AddFootprintToPCB( aEvent );
716 }
717 
718 
719 void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
720 {
721  if( IsModal() )
722  {
723  if( m_fpList->GetSelection() >= 0 )
724  {
725  LIB_ID fpid( getCurNickname(), m_fpList->GetStringSelection() );
726  DismissModal( true, fpid.Format() );
727  }
728  else
729  {
730  DismissModal( false );
731  }
732  }
733  else if( GetBoard()->GetFirstFootprint() )
734  {
735  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
736 
737  if( pcbframe == NULL ) // happens when the board editor is not active (or closed)
738  {
739  DisplayErrorMessage( this, _( "No board currently open." ) );
740  return;
741  }
742 
744  BOARD_COMMIT commit( pcbframe );
745 
746  // Create the "new" footprint
747  FOOTPRINT* newFootprint = (FOOTPRINT*) GetBoard()->GetFirstFootprint()->Duplicate();
748  newFootprint->SetParent( pcbframe->GetBoard() );
749  newFootprint->SetLink( niluuid );
750  newFootprint->SetFlags(IS_NEW ); // whatever
751 
752  for( PAD* pad : newFootprint->Pads() )
753  {
754  // Set the pads ratsnest settings to the global settings
755  pad->SetLocalRatsnestVisible( pcbframe->GetDisplayOptions().m_ShowGlobalRatsnest );
756 
757  // Pads in the library all have orphaned nets. Replace with Default.
758  pad->SetNetCode( 0 );
759  }
760 
761  // Put it on FRONT layer,
762  // (Can be stored flipped if the lib is an archive built from a board)
763  if( newFootprint->IsFlipped() )
764  newFootprint->Flip( newFootprint->GetPosition(),
765  pcbframe->Settings().m_FlipLeftRight );
766 
767  KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetCanvas()->GetViewControls();
768  VECTOR2D cursorPos = viewControls->GetCursorPosition();
769 
770  commit.Add( newFootprint );
771  viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
772  pcbframe->PlaceFootprint( newFootprint );
773 
774  newFootprint->SetPosition( wxPoint( 0, 0 ) );
775  viewControls->SetCrossHairCursorPosition( cursorPos, false );
776  commit.Push( wxT( "Insert footprint" ) );
777 
778  pcbframe->Raise();
779  pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeFootprint, true, newFootprint );
780 
781  newFootprint->ClearFlags();
782  }
783 }
784 
785 
787 {
788  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
789  wxCHECK( cfg, /*void*/ );
790 
791  // We don't allow people to change this right now, so make sure it's on
793 
795 
796  // Fetch display and grid settings from Footprint Editor
797  auto fpedit = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
798  m_displayOptions = fpedit->m_Display;
799  GetGalDisplayOptions().ReadWindowSettings( fpedit->m_Window );
800 }
801 
802 
804 {
805  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
806  wxCHECK( cfg, /*void*/ );
807 
809 
810  // We don't want to store anything other than the window settings
812 
814 }
815 
816 
818 {
819  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
820  wxCHECK_MSG( cfg, nullptr, "config not existing" );
821 
822  return &cfg->m_FootprintViewer;
823 }
824 
825 
827 {
828  auto* settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
829 
830  if( settings )
831  return Pgm().GetSettingsManager().GetColorSettings( settings->m_ColorTheme );
832  else
833  return Pgm().GetSettingsManager().GetColorSettings();
834 }
835 
836 
838 {
839  // It is stored in pcbnew's settings
841  wxCHECK( cfg, false );
842  return cfg->m_FootprintViewerAutoZoom;
843 }
844 
845 
847 {
848  // It is stored in pcbnew's settings
850  wxASSERT( cfg );
851  cfg->m_FootprintViewerAutoZoom = aAutoZoom;
852 }
853 
854 
855 void FOOTPRINT_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
856 {
857  PCB_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
858 
859  if( aEnvVarsChanged )
861 }
862 
863 
865 {
867 }
868 
869 
870 void FOOTPRINT_VIEWER_FRAME::setCurNickname( const wxString& aNickname )
871 {
873 }
874 
875 
877 {
879 }
880 
881 
882 void FOOTPRINT_VIEWER_FRAME::setCurFootprintName( const wxString& aName )
883 {
885 }
886 
887 
888 void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
889 {
890  if( event.GetActive() )
891  {
892  // Ensure we have the right library list:
893  std::vector< wxString > libNicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
894  bool stale = false;
895 
896  if( libNicknames.size() != m_libList->GetCount() )
897  stale = true;
898  else
899  {
900  for( unsigned ii = 0; ii < libNicknames.size(); ii++ )
901  {
902  if( libNicknames[ii] != m_libList->GetString( ii ) )
903  {
904  stale = true;
905  break;
906  }
907  }
908  }
909 
910  if( stale )
911  {
913  UpdateTitle();
914  }
915  }
916 
917  event.Skip(); // required under wxMAC
918 }
919 
920 
921 void FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton( wxUpdateUIEvent& aEvent )
922 {
923  aEvent.Enable( GetBoard()->GetFirstFootprint() != nullptr );
924 }
925 
926 
927 bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
928 {
929  if( aFootprint && !aFootprint->IsEmpty() )
930  {
931  wxString msg;
932  LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
933  LIB_ID fpid;
934 
935  fpid.Parse( *aFootprint, true );
936 
937  if( fpid.IsValid() )
938  {
939  wxString libraryName = fpid.GetLibNickname();
940 
941  if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) )
942  {
943  msg.sprintf( _( "The current configuration does not include library '%s'. Use "
944  "Manage Footprint Libraries to edit the configuration." ),
945  libraryName );
946  DisplayErrorMessage( aParent, _( "Footprint library not found." ), msg );
947  }
948  else if ( !fpTable->HasLibrary( fpid.GetLibNickname(), true ) )
949  {
950  msg.sprintf( _( "Library '%s' is not enabled in the current configuration. Use "
951  "Manage Footprint Libraries to edit the configuration." ),
952  libraryName );
953  DisplayErrorMessage( aParent, _( "Footprint library not enabled." ), msg );
954  }
955  else
956  {
957  // Update last selection:
958  setCurNickname( libraryName );
960  m_libList->SetStringSelection( libraryName );
961  }
962  }
963  }
964 
965  // Rebuild the fp list from the last selected library,
966  // and show the last selected footprint
969 
970  bool retval = KIWAY_PLAYER::ShowModal( aFootprint, aParent );
971 
972  m_libFilter->SetFocus();
973  return retval;
974 }
975 
976 
977 void FOOTPRINT_VIEWER_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
978 {
979  wxString title = wxString::Format( _( "3D Viewer" ) + wxT( " \u2014 %s" ),
981  PCB_BASE_FRAME::Update3DView( aMarkDirty, aRefresh, &title );
982 }
983 
984 
986 {
987  return GetColorSettings()->GetColor( LAYER_GRID );
988 }
989 
990 
992 {
993  switch( event.GetId() )
994  {
995  case ID_MODVIEW_NEXT:
997  break;
998 
999  case ID_MODVIEW_PREVIOUS:
1001  break;
1002 
1003  default:
1004  wxString id = wxString::Format( "%i", event.GetId() );
1005  wxFAIL_MSG( "FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList error: id = " + id );
1006  }
1007 }
1008 
1009 
1011 {
1012  wxString title;
1013  wxString path;
1014 
1015  title.Printf( getCurNickname().IsEmpty() ? _( "no library selected" ) : getCurNickname() );
1016 
1017  // Now, add the full path, for info
1018  if( !getCurNickname().IsEmpty() )
1019  {
1020  FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
1021  const LIB_TABLE_ROW* row = libtable->FindRow( getCurNickname() );
1022 
1023  if( row )
1024  title << L" \u2014 " << row->GetFullURI( true );
1025  }
1026 
1027  title += wxT( " \u2014 " ) + _( "Footprint Library Browser" );
1028 
1029  SetTitle( title );
1030 }
1031 
1032 
1034 {
1035  if( !getCurNickname() )
1036  return;
1037 
1038  int selection = m_fpList->FindString( getCurFootprintName(), true );
1039 
1040  if( aMode == NEXT_PART )
1041  {
1042  if( selection != wxNOT_FOUND && selection < (int)m_fpList->GetCount() - 1 )
1043  selection++;
1044  }
1045 
1046  if( aMode == PREVIOUS_PART )
1047  {
1048  if( selection != wxNOT_FOUND && selection > 0 )
1049  selection--;
1050  }
1051 
1052  if( selection != wxNOT_FOUND )
1053  {
1054  m_fpList->SetSelection( selection );
1055  m_fpList->EnsureVisible( selection );
1056 
1057  setCurFootprintName( m_fpList->GetString((unsigned) selection ) );
1058 
1059  // Delete the current footprint
1061 
1063  getCurFootprintName() );
1064 
1065  if( footprint )
1066  GetBoard()->Add( footprint, ADD_MODE::APPEND );
1067 
1068  Update3DView( true, true );
1069 
1070  updateView();
1071  }
1072 
1073  UpdateTitle();
1074 
1075  GetCanvas()->Refresh();
1076 }
1077 
1078 
1080 {
1081  GetCanvas()->UpdateColors();
1083 
1085 
1086  if( GetAutoZoom() )
1088  else
1090 
1091  UpdateMsgPanel();
1092 }
1093 
1094 
1095 void FOOTPRINT_VIEWER_FRAME::OnExitKiCad( wxCommandEvent& event )
1096 {
1097  Kiway().OnKiCadExit();
1098 }
1099 
1100 
1102 {
1103  Close( false );
1104 }
1105 
1106 
1108 {
1109  return GetBoard()->GetFirstFootprint();
1110 }
1111 
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:252
CITER next(CITER it)
Definition: ptree.cpp:126
virtual void SetBoard(BOARD *aBoard)
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
void DClickOnFootprintList(wxCommandEvent &aEvent)
const UTF8 & GetLibItemName() const
Definition: lib_id.h:106
void OnKiCadExit()
Definition: kiway.cpp:610
#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:265
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)
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)
FOOTPRINT * FootprintLoad(const wxString &aNickname, const wxString &aFootprintName, bool aKeepUUID=false)
Load a footprint having aFootprintName from the library given by aNickname.
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:593
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:368
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:255
void setCurNickname(const wxString &aNickname)
void OnUpdateFootprintButton(wxUpdateUIEvent &aEvent)
Update the ID_ADD_FOOTPRINT_TO_BOARD tool state in main toolbar.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr) override
Update the 3D view, if the viewer is opened by this frame.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
virtual const wxString Problem() const
what was the problem?
Definition: exceptions.cpp: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:166
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
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:203
FOOTPRINT * GetFirstFootprint() const
Gets the first footprint on the board or nullptr.
Definition: board.h:382
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:1091
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:254
#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:1367
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 this BOARD_ITEM.
Definition: footprint.cpp:1601
void OnActivate(wxActivateEvent &event)
Called when the frame frame is activate to reload the libraries and component lists that can be chang...
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
#define MODAL_STYLE
WINDOW_SETTINGS m_FootprintViewer
#define FOOTPRINT_VIEWER_FRAME_NAME
void OnFPFilter(wxCommandEvent &aEvent)
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104
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...
Definition: project.cpp:213
SELECTION_CONDITION PadNumbersDisplay()
Create a functor that tests if the pad numbers are displayed.
#define NONMODAL_STYLE
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:285
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:248
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:554
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:394
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
bool IsFlipped() const
Definition: footprint.h:266
void SetLink(const KIID &aLink)
Definition: footprint.h:532
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
COLOR4D GetColor(int aLayer) const
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
Definition: project.cpp:228
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:164
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
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)
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
void ReCreateLibraryList()
Create or recreate the list of current loaded libraries.
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.
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:197
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:204
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:390
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:1438
double GetScale() const
Definition: view.h:263
Message panel definition file.
bool m_FootprintViewerAutoZoom
Should the footprint viewer auto zoom on select.
virtual COLOR4D GetGridColor() override
Group generic conditions for PCB editor states.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
#define IS_NEW
New item, just created.
Definition: eda_item.h:107
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:397
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.