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 <[email protected]>
6  * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
27 #include <bitmaps.h>
28 #include <board_commit.h>
29 #include <board.h>
30 #include <footprint.h>
31 #include <confirm.h>
32 #include <eda_pattern_match.h>
33 #include <footprint_info.h>
34 #include <footprint_viewer_frame.h>
35 #include <fp_lib_table.h>
36 #include <kiway.h>
37 #include <widgets/msgpanel.h>
38 #include <pcb_draw_panel_gal.h>
39 #include <pcb_painter.h>
40 #include <pcbnew_id.h>
42 #include <pgm_base.h>
44 #include <tool/action_toolbar.h>
45 #include <tool/common_control.h>
46 #include <tool/common_tools.h>
47 #include <tool/selection.h>
48 #include <tool/tool_dispatcher.h>
49 #include <tool/tool_manager.h>
50 #include <tool/zoom_tool.h>
51 #include <tools/pcb_viewer_tools.h>
52 #include <tools/pcb_actions.h>
54 #include <tools/pcb_control.h>
55 #include <tools/pcb_picker_tool.h>
59 #include <wx/listbox.h>
60 #include <wx/srchctrl.h>
61 #include <wx/tokenzr.h>
62 #include <wx/choice.h>
63 
64 using namespace std::placeholders;
65 
66 
67 #define NEXT_PART 1
68 #define NEW_PART 0
69 #define PREVIOUS_PART -1
70 
71 
72 BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME )
73  // Window events
76 
77  EVT_MENU( wxID_EXIT, FOOTPRINT_VIEWER_FRAME::OnExitKiCad )
78  EVT_MENU( wxID_CLOSE, FOOTPRINT_VIEWER_FRAME::CloseFootprintViewer )
79 
80  // Toolbar events
86 
88 
91 
92  // listbox events
95 
96 END_EVENT_TABLE()
97 
98 
99 /*
100  * Note: FOOTPRINT_VIEWER_FRAME can be created in "modal mode", or as a usual frame.
101  */
102 #define PARENT_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT )
103 #define MODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP )
104 #define NONMODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE )
105 
106 
108  FRAME_T aFrameType ) :
109  PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Library Browser" ),
110  wxDefaultPosition, wxDefaultSize,
111  aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL ? ( aParent ? PARENT_STYLE : MODAL_STYLE )
112  : NONMODAL_STYLE,
115 {
116  wxASSERT( aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL || aFrameType == FRAME_FOOTPRINT_VIEWER );
117 
118  if( aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL )
119  SetModal( true );
120 
121  m_aboutTitle = _( "KiCad Footprint Library Viewer" );
122 
123  // Force the items to always snap
126  m_magneticItems.graphics = true;
127 
128  // Force the frame name used in config. the footprint viewer frame has a name
129  // depending on aFrameType (needed to identify the frame by wxWidgets),
130  // but only one configuration is preferable.
132 
133  // Give an icon
134  wxIcon icon;
135  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_footprint_browser ) );
136  SetIcon( icon );
137 
138  wxPanel* libPanel = new wxPanel( this );
139  wxSizer* libSizer = new wxBoxSizer( wxVERTICAL );
140 
141  m_libFilter = new wxSearchCtrl( libPanel, ID_MODVIEW_LIB_FILTER, wxEmptyString,
142  wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
143  m_libFilter->SetDescriptiveText( _( "Filter" ) );
144  libSizer->Add( m_libFilter, 0, wxEXPAND, 5 );
145 
146  m_libList = new wxListBox( libPanel, ID_MODVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
147  0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
148  libSizer->Add( m_libList, 1, wxEXPAND, 5 );
149 
150  libPanel->SetSizer( libSizer );
151  libPanel->Fit();
152 
153  wxPanel* fpPanel = new wxPanel( this );
154  wxSizer* fpSizer = new wxBoxSizer( wxVERTICAL );
155 
156  m_fpFilter = new wxSearchCtrl( fpPanel, ID_MODVIEW_FOOTPRINT_FILTER, wxEmptyString,
157  wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
158  m_fpFilter->SetDescriptiveText( _( "Filter" ) );
159  m_fpFilter->SetToolTip(
160  _( "Filter on footprint name, keywords, description and pad count.\n"
161  "Search terms are separated by spaces. All search terms must match.\n"
162  "A term which is a number will also match against the pad count." ) );
163  fpSizer->Add( m_fpFilter, 0, wxEXPAND, 5 );
164 
165 #ifdef __WXGTK__
166  // wxSearchCtrl vertical height is not calculated correctly on some GTK setups
167  // See https://gitlab.com/kicad/code/kicad/-/issues/9019
168  m_libFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT( "qb" ) ).y + 10 ) );
169  m_fpFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT( "qb" ) ).y + 10 ) );
170 #endif
171 
172  m_fpList = new wxListBox( fpPanel, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize,
173  0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
174 
175  m_fpList->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList ), nullptr, this );
176  fpSizer->Add( m_fpList, 1, wxEXPAND, 5 );
177 
178  fpPanel->SetSizer( fpSizer );
179  fpPanel->Fit();
180 
181  // Create GAL canvas
183 
184  PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
186  SetCanvas( drawPanel );
187 
188  SetBoard( new BOARD() );
189 
190  // This board will only be used to hold a footprint for viewing
192 
193  // In viewer, the default net clearance is not known (it depends on the actual board).
194  // So we do not show the default clearance, by setting it to 0
195  // The footprint or pad specific clearance will be shown
197 
198  // Don't show the default board solder mask clearance in the footprint viewer. Only the
199  // footprint or pad clearance setting should be shown if it is not 0.
201 
202  // Ensure all layers and items are visible:
204  SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
205 
206  GetScreen()->m_Center = true; // Center coordinate origins on screen.
207  LoadSettings( config() );
209 
210  // Call resolveCanvasType after loading settings:
212 
213  // Create the manager and dispatcher & route draw panel events to the dispatcher
215  m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(),
216  drawPanel->GetViewControls(), config(), this );
217  m_actions = new PCB_ACTIONS();
219  drawPanel->SetEventDispatcher( m_toolDispatcher );
220 
223  m_toolManager->RegisterTool( new COMMON_TOOLS ); // for std context menus (zoom & grid)
225  m_toolManager->RegisterTool( new PCB_PICKER_TOOL ); // for setting grid origin
228 
229  m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
230 
232  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
233 
235  ReCreateMenuBar();
239 
241  UpdateTitle();
242 
243  // If a footprint was previously loaded, reload it
244  if( getCurNickname().size() && getCurFootprintName().size() )
245  {
246  LIB_ID id;
247 
249  id.SetLibItemName( getCurFootprintName() );
250 
251  FOOTPRINT* footprint = loadFootprint( id );
252 
253  if( footprint )
254  GetBoard()->Add( footprint );
255  }
256 
257  drawPanel->DisplayBoard( m_pcb );
258 
259  m_auimgr.SetManagedWindow( this );
260 
261  // Horizontal items; layers 4 - 6
262  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().VToolbar().Name( "MainToolbar" ).Top().Layer(6) );
263  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
264  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
265 
266  // Vertical items; layers 1 - 3
267  m_auimgr.AddPane( libPanel, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(2)
268  .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
269  m_auimgr.AddPane( fpPanel, EDA_PANE().Palette().Name( "Footprints" ).Left().Layer( 1)
270  .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
271 
272  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
273 
274  // after changing something to the aui manager call Update() to reflect the changes
275  m_auimgr.Update();
276 
277  // The canvas should not steal the focus from the list boxes
278  GetCanvas()->SetCanFocus( false );
279  GetCanvas()->GetGAL()->SetAxesEnabled( true );
281 
282  // Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.)
284  wxASSERT( cfg );
286 
287  updateView();
288  setupUnits( config() );
289 
290  if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
291  {
293  Raise(); // On some window managers, this is needed
294  Show( true );
295  }
296 }
297 
298 
300 {
301  // Shutdown all running tools
302  if( m_toolManager )
304 
305  GetCanvas()->StopDrawing();
306  GetCanvas()->GetView()->Clear();
307  // Be sure any event cannot be fired after frame deletion:
308  GetCanvas()->SetEvtHandlerEnabled( false );
309  m_fpList->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList ), nullptr, this );
310 }
311 
312 
314 {
315  return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
316 }
317 
318 
320 {
322 
324  PCB_EDITOR_CONDITIONS cond( this );
325 
326  wxASSERT( mgr );
327 
328 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
329 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
330 
334  CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
337 
338 
340  CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
345 
350 
351 #undef ENABLE
352 #undef CHECK
353 }
354 
355 
357 {
358  // A workaround to avoid flicker, in modal mode when modview frame is destroyed,
359  // when the aui toolbar is not docked (i.e. shown in a miniframe)
360  // (useful on windows only)
361  m_mainToolBar->SetFocus();
362 
363  GetCanvas()->StopDrawing();
364 
365  if( IsModal() )
366  {
367  // Only dismiss a modal frame once, so that the return values set by
368  // the prior DismissModal() are not bashed for ShowModal().
369  if( !IsDismissed() )
370  DismissModal( false );
371 
372  // window to be destroyed by the caller of KIWAY_PLAYER::ShowModal()
373  }
374  else
375  {
376  Destroy();
377  }
378 }
379 
380 
381 void FOOTPRINT_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv )
382 {
383  if( m_auimgr.GetManagedWindow() )
384  m_auimgr.Update();
385 
386  SizeEv.Skip();
387 }
388 
389 
391 {
392  m_libList->Clear();
393 
394  std::vector<wxString> nicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
395  std::set<wxString> excludes;
396 
397  if( !m_libFilter->GetValue().IsEmpty() )
398  {
399  wxStringTokenizer tokenizer( m_libFilter->GetValue() );
400 
401  while( tokenizer.HasMoreTokens() )
402  {
403  const wxString term = tokenizer.GetNextToken().Lower();
404  EDA_COMBINED_MATCHER matcher( term );
405  int matches, position;
406 
407  for( const wxString& nickname : nicknames )
408  {
409  if( !matcher.Find( nickname.Lower(), matches, position ) )
410  excludes.insert( nickname );
411  }
412  }
413  }
414 
415  for( const wxString& nickname : nicknames )
416  {
417  if( !excludes.count( nickname ) )
418  m_libList->Append( nickname );
419  }
420 
421  // Search for a previous selection:
422  int index = m_libList->FindString( getCurNickname(), true );
423 
424  if( index == wxNOT_FOUND )
425  {
426  if( m_libList->GetCount() > 0 )
427  {
428  m_libList->SetSelection( 0 );
429  wxCommandEvent dummy;
431  }
432  else
433  {
434  setCurNickname( wxEmptyString );
435  setCurFootprintName( wxEmptyString );
436  }
437  }
438  else
439  {
440  m_libList->SetSelection( index, true );
441  wxCommandEvent dummy;
443  }
444 
445  GetCanvas()->Refresh();
446 }
447 
448 
450 {
451  m_fpList->Clear();
452 
453  if( !getCurNickname() )
454  setCurFootprintName( wxEmptyString );
455 
456  auto fp_info_list = FOOTPRINT_LIST::GetInstance( Kiway() );
457 
458  wxString nickname = getCurNickname();
459 
460  fp_info_list->ReadFootprintFiles( Prj().PcbFootprintLibs(), !nickname ? nullptr : &nickname );
461 
462  if( fp_info_list->GetErrorCount() )
463  {
464  fp_info_list->DisplayErrors( this );
465 
466  // For footprint libraries that support one footprint per file, there may have been
467  // valid footprints read so show the footprints that loaded properly.
468  if( fp_info_list->GetList().empty() )
469  return;
470  }
471 
472  std::set<wxString> excludes;
473 
474  if( !m_fpFilter->GetValue().IsEmpty() )
475  {
476  wxStringTokenizer tokenizer( m_fpFilter->GetValue() );
477 
478  while( tokenizer.HasMoreTokens() )
479  {
480  const wxString term = tokenizer.GetNextToken().Lower();
481  EDA_COMBINED_MATCHER matcher( term );
482  int matches, position;
483 
484  for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
485  {
486  wxString search = footprint->GetFootprintName() + wxS( " " ) + footprint->GetSearchText();
487  bool matched = matcher.Find( search.Lower(), matches, position );
488 
489  if( !matched && term.IsNumber() )
490  matched = ( wxAtoi( term ) == (int)footprint->GetPadCount() );
491 
492  if( !matched )
493  excludes.insert( footprint->GetFootprintName() );
494  }
495  }
496  }
497 
498  for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
499  {
500  if( !excludes.count( footprint->GetFootprintName() ) )
501  m_fpList->Append( footprint->GetFootprintName() );
502  }
503 
504  int index = m_fpList->FindString( getCurFootprintName(), true );
505 
506  if( index == wxNOT_FOUND )
507  {
508  if( m_fpList->GetCount() > 0 )
509  {
510  m_fpList->SetSelection( 0 );
511  m_fpList->EnsureVisible( 0 );
512 
513  wxCommandEvent dummy;
515  }
516  else
517  {
518  setCurFootprintName( wxEmptyString );
519  }
520  }
521  else
522  {
523  m_fpList->SetSelection( index, true );
524  m_fpList->EnsureVisible( index );
525  }
526 }
527 
528 
529 void FOOTPRINT_VIEWER_FRAME::OnLibFilter( wxCommandEvent& aEvent )
530 {
532 
533  // Required to avoid interaction with SetHint()
534  // See documentation for wxTextEntry::SetHint
535  aEvent.Skip();
536 }
537 
538 
539 void FOOTPRINT_VIEWER_FRAME::OnFPFilter( wxCommandEvent& aEvent )
540 {
542 
543  // Required to avoid interaction with SetHint()
544  // See documentation for wxTextEntry::SetHint
545  aEvent.Skip();
546 }
547 
548 
549 void FOOTPRINT_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent )
550 {
551  if( aEvent.GetKeyCode() == WXK_UP )
552  {
553  if( m_libFilter->HasFocus() || m_libList->HasFocus() )
555  else
556  selectPrev( m_fpList );
557  }
558  else if( aEvent.GetKeyCode() == WXK_DOWN )
559  {
560  if( m_libFilter->HasFocus() || m_libList->HasFocus() )
562  else
563  selectNext( m_fpList );
564  }
565  else if( aEvent.GetKeyCode() == WXK_TAB && m_libFilter->HasFocus() )
566  {
567  if( !aEvent.ShiftDown() )
568  m_fpFilter->SetFocus();
569  else
570  aEvent.Skip();
571  }
572  else if( aEvent.GetKeyCode() == WXK_TAB && m_fpFilter->HasFocus() )
573  {
574  if( aEvent.ShiftDown() )
575  m_libFilter->SetFocus();
576  else
577  aEvent.Skip();
578  }
579  else if( aEvent.GetKeyCode() == WXK_RETURN && m_fpList->GetSelection() >= 0 )
580  {
581  wxCommandEvent dummy;
583  }
584  else
585  {
586  aEvent.Skip();
587  }
588 }
589 
590 
591 void FOOTPRINT_VIEWER_FRAME::selectPrev( wxListBox* aListBox )
592 {
593  int prev = aListBox->GetSelection() - 1;
594 
595  if( prev >= 0 )
596  {
597  aListBox->SetSelection( prev );
598  aListBox->EnsureVisible( prev );
599 
600  wxCommandEvent dummy;
601 
602  if( aListBox == m_libList )
604  else
606  }
607 }
608 
609 
610 void FOOTPRINT_VIEWER_FRAME::selectNext( wxListBox* aListBox )
611 {
612  int next = aListBox->GetSelection() + 1;
613 
614  if( next < (int)aListBox->GetCount() )
615  {
616  aListBox->SetSelection( next );
617  aListBox->EnsureVisible( next );
618 
619  wxCommandEvent dummy;
620 
621  if( aListBox == m_libList )
623  else
625  }
626 }
627 
628 
629 void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& aEvent )
630 {
631  int ii = m_libList->GetSelection();
632 
633  if( ii < 0 )
634  return;
635 
636  wxString name = m_libList->GetString( ii );
637 
638  if( getCurNickname() == name )
639  return;
640 
641  setCurNickname( name );
642 
644  UpdateTitle();
645 }
646 
647 
648 void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& aEvent )
649 {
650  if( m_fpList->GetCount() == 0 )
651  return;
652 
653  int ii = m_fpList->GetSelection();
654 
655  if( ii < 0 )
656  return;
657 
658  wxString name = m_fpList->GetString( ii );
659 
660  if( getCurFootprintName().CmpNoCase( name ) != 0 )
661  {
663 
664  // Delete the current footprint (MUST reset tools first)
666 
668 
669  LIB_ID id;
671  id.SetLibItemName( getCurFootprintName() );
672 
673  try
674  {
675  GetBoard()->Add( loadFootprint( id ) );
676  }
677  catch( const IO_ERROR& ioe )
678  {
679  wxString msg =
680  wxString::Format( _( "Could not load footprint '%s' from library '%s'."
681  "\n\n%s" ),
683  DisplayError( this, msg );
684  }
685 
686  UpdateTitle();
687 
688  updateView();
689 
690  GetCanvas()->Refresh();
691  Update3DView( true, true );
692  }
693 }
694 
695 
697 {
698  wxCommandEvent evt;
699  AddFootprintToPCB( evt );
700 }
701 
702 
703 void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
704 {
705  if( IsModal() )
706  {
707  if( m_fpList->GetSelection() >= 0 )
708  {
709  LIB_ID fpid( getCurNickname(), m_fpList->GetStringSelection() );
710  DismissModal( true, fpid.Format() );
711  }
712  else
713  {
714  DismissModal( false );
715  }
716  }
717  else if( GetBoard()->GetFirstFootprint() )
718  {
719  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
720 
721  if( pcbframe == nullptr ) // happens when the board editor is not active (or closed)
722  {
723  DisplayErrorMessage( this, _( "No board currently open." ) );
724  return;
725  }
726 
727  TOOL_MANAGER* toolMgr = pcbframe->GetToolManager();
728 
729  if( toolMgr->GetTool<BOARD_EDITOR_CONTROL>()->PlacingFootprint() )
730  {
731  DisplayError( this, _( "Previous footprint placement still in progress." ) );
732  return;
733  }
734 
735  toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
736  BOARD_COMMIT commit( pcbframe );
737 
738  // Create the "new" footprint
739  FOOTPRINT* newFootprint = (FOOTPRINT*) GetBoard()->GetFirstFootprint()->Duplicate();
740  newFootprint->SetParent( pcbframe->GetBoard() );
741  newFootprint->SetLink( niluuid );
742  newFootprint->SetFlags(IS_NEW ); // whatever
743 
744  for( PAD* pad : newFootprint->Pads() )
745  {
746  // Set the pads ratsnest settings to the global settings
747  pad->SetLocalRatsnestVisible( pcbframe->GetDisplayOptions().m_ShowGlobalRatsnest );
748 
749  // Pads in the library all have orphaned nets. Replace with Default.
750  pad->SetNetCode( 0 );
751  }
752 
753  // Put it on FRONT layer,
754  // (Can be stored flipped if the lib is an archive built from a board)
755  if( newFootprint->IsFlipped() )
756  newFootprint->Flip( newFootprint->GetPosition(),
757  pcbframe->Settings().m_FlipLeftRight );
758 
759  KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetCanvas()->GetViewControls();
760  VECTOR2D cursorPos = viewControls->GetCursorPosition();
761 
762  commit.Add( newFootprint );
763  viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
764  pcbframe->PlaceFootprint( newFootprint );
765 
766  newFootprint->SetPosition( wxPoint( 0, 0 ) );
767  viewControls->SetCrossHairCursorPosition( cursorPos, false );
768  commit.Push( wxT( "Insert footprint" ) );
769 
770  pcbframe->Raise();
771  toolMgr->RunAction( PCB_ACTIONS::placeFootprint, true, newFootprint );
772 
773  newFootprint->ClearFlags();
774  }
775 }
776 
777 
779 {
780  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
781  wxCHECK( cfg, /*void*/ );
782 
783  // We don't allow people to change this right now, so make sure it's on
785 
787 
788  // Fetch display and grid settings from Footprint Editor
789  auto fpedit = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
790  m_displayOptions = fpedit->m_Display;
791  GetGalDisplayOptions().ReadWindowSettings( fpedit->m_Window );
792 }
793 
794 
796 {
797  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
798  wxCHECK( cfg, /*void*/ );
799 
801 
802  // We don't want to store anything other than the window settings
804 
805  if( GetCanvas() && GetCanvas()->GetView() )
807 }
808 
809 
811 {
812  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
813  wxCHECK_MSG( cfg, nullptr, wxT( "config not existing" ) );
814 
815  return &cfg->m_FootprintViewer;
816 }
817 
818 
820 {
821  auto* settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
822 
823  if( settings )
824  return Pgm().GetSettingsManager().GetColorSettings( settings->m_ColorTheme );
825  else
826  return Pgm().GetSettingsManager().GetColorSettings();
827 }
828 
829 
830 void FOOTPRINT_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
831 {
832  PCB_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
833 
834  if( aEnvVarsChanged )
836 }
837 
838 
840 {
842 }
843 
844 
845 void FOOTPRINT_VIEWER_FRAME::setCurNickname( const wxString& aNickname )
846 {
848 }
849 
850 
852 {
854 }
855 
856 
857 void FOOTPRINT_VIEWER_FRAME::setCurFootprintName( const wxString& aName )
858 {
860 }
861 
862 
863 void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
864 {
865  if( event.GetActive() )
866  {
867  // Ensure we have the right library list:
868  std::vector< wxString > libNicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
869  bool stale = false;
870 
871  if( libNicknames.size() != m_libList->GetCount() )
872  stale = true;
873  else
874  {
875  for( unsigned ii = 0; ii < libNicknames.size(); ii++ )
876  {
877  if( libNicknames[ii] != m_libList->GetString( ii ) )
878  {
879  stale = true;
880  break;
881  }
882  }
883  }
884 
885  if( stale )
886  {
888  UpdateTitle();
889  }
890  }
891 
892  event.Skip(); // required under wxMAC
893 }
894 
895 
896 void FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton( wxUpdateUIEvent& aEvent )
897 {
898  aEvent.Enable( GetBoard()->GetFirstFootprint() != nullptr );
899 }
900 
901 
902 bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
903 {
904  if( aFootprint && !aFootprint->IsEmpty() )
905  {
906  wxString msg;
907  LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
908  LIB_ID fpid;
909 
910  fpid.Parse( *aFootprint, true );
911 
912  if( fpid.IsValid() )
913  {
914  wxString libraryName = fpid.GetLibNickname();
915 
916  if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) )
917  {
918  msg.sprintf( _( "The current configuration does not include library '%s'. Use "
919  "Manage Footprint Libraries to edit the configuration." ),
920  libraryName );
921  DisplayErrorMessage( aParent, _( "Footprint library not found." ), msg );
922  }
923  else if ( !fpTable->HasLibrary( fpid.GetLibNickname(), true ) )
924  {
925  msg.sprintf( _( "Library '%s' is not enabled in the current configuration. Use "
926  "Manage Footprint Libraries to edit the configuration." ),
927  libraryName );
928  DisplayErrorMessage( aParent, _( "Footprint library not enabled." ), msg );
929  }
930  else
931  {
932  // Update last selection:
933  setCurNickname( libraryName );
935  m_libList->SetStringSelection( libraryName );
936  }
937  }
938  }
939 
940  // Rebuild the fp list from the last selected library,
941  // and show the last selected footprint
944 
945  bool retval = KIWAY_PLAYER::ShowModal( aFootprint, aParent );
946 
947  m_libFilter->SetFocus();
948  return retval;
949 }
950 
951 
952 void FOOTPRINT_VIEWER_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
953 {
954  wxString title = _( "3D Viewer" ) + wxT( " \u2014 " ) + getCurFootprintName();
955  PCB_BASE_FRAME::Update3DView( aMarkDirty, aRefresh, &title );
956 }
957 
958 
960 {
961  return GetColorSettings()->GetColor( LAYER_GRID );
962 }
963 
964 
966 {
967  switch( event.GetId() )
968  {
969  case ID_MODVIEW_NEXT:
971  break;
972 
973  case ID_MODVIEW_PREVIOUS:
975  break;
976 
977  default:
978  wxString id = wxString::Format( wxT( "%i" ), event.GetId() );
979  wxFAIL_MSG( wxT( "FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList error: id = " ) + id );
980  }
981 }
982 
983 
985 {
986  wxString title;
987  wxString path;
988 
989  if( !getCurNickname().IsEmpty() )
990  {
991  title = getCurNickname();
992 
993  FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
994  const LIB_TABLE_ROW* row = libtable->FindRow( getCurNickname() );
995 
996  if( row )
997  title += wxT( " \u2014 " ) + row->GetFullURI( true );
998  }
999  else
1000  {
1001  title = _( "[no library selected]" );
1002  }
1003 
1004  title += wxT( " \u2014 " ) + _( "Footprint Library Browser" );
1005 
1006  SetTitle( title );
1007 }
1008 
1009 
1011 {
1012  if( !getCurNickname() )
1013  return;
1014 
1015  int selection = m_fpList->FindString( getCurFootprintName(), true );
1016 
1017  if( aMode == NEXT_PART )
1018  {
1019  if( selection != wxNOT_FOUND && selection < (int)m_fpList->GetCount() - 1 )
1020  selection++;
1021  }
1022 
1023  if( aMode == PREVIOUS_PART )
1024  {
1025  if( selection != wxNOT_FOUND && selection > 0 )
1026  selection--;
1027  }
1028 
1029  if( selection != wxNOT_FOUND )
1030  {
1031  m_fpList->SetSelection( selection );
1032  m_fpList->EnsureVisible( selection );
1033 
1034  setCurFootprintName( m_fpList->GetString((unsigned) selection ) );
1035 
1036  // Delete the current footprint
1038 
1040  getCurFootprintName() );
1041 
1042  if( footprint )
1043  GetBoard()->Add( footprint, ADD_MODE::APPEND );
1044 
1045  Update3DView( true, true );
1046 
1047  updateView();
1048  }
1049 
1050  UpdateTitle();
1051 
1052  GetCanvas()->Refresh();
1053 }
1054 
1055 
1057 {
1058  GetCanvas()->UpdateColors();
1060 
1062 
1063  if( m_zoomSelectBox->GetSelection() == 0 )
1065  else
1067 
1068  UpdateMsgPanel();
1069 }
1070 
1071 
1072 void FOOTPRINT_VIEWER_FRAME::OnExitKiCad( wxCommandEvent& event )
1073 {
1074  Kiway().OnKiCadExit();
1075 }
1076 
1077 
1079 {
1080  Close( false );
1081 }
1082 
1083 
1085 {
1086  return GetBoard()->GetFirstFootprint();
1087 }
1088 
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
virtual bool ShowModal(wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until t...
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
CITER next(CITER it)
Definition: ptree.cpp:126
void DisplayBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr)
Add all items from the current board to the VIEW, so they can be displayed by GAL.
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
void OnKiCadExit()
Definition: kiway.cpp:636
#define PREVIOUS_PART
void OnExitKiCad(wxCommandEvent &event)
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
bool ShowModal(wxString *aFootprint, wxWindow *aParent) override
Run the footprint viewer as a modal dialog.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
KIID niluuid(0)
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
void UpdateTitle()
Update the window title with current library information.
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
#define FOOTPRINT_VIEWER_FRAME_NAME_MODAL
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:292
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
Model changes (required full reload)
Definition: tool_base.h:80
#define IS_NEW
New item, just created.
This file is part of the common library.
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Return a pointer to the window settings for this frame.
bool IsDismissed()
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
ACTION_TOOLBAR * m_optionsToolBar
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
Definition: commit.h:78
virtual void SetScreen(BASE_SCREEN *aScreen)
static TOOL_ACTION zoomTool
Definition: actions.h:99
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:32
EVT_UPDATE_UI(ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void setCurFootprintName(const wxString &aName)
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
SELECTION_CONDITION TextFillDisplay()
Create a functor that tests if the frame fills text items.
Component library viewer main window.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
FOOTPRINT_VIEWER_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType)
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
static TOOL_ACTION millimetersUnits
Definition: actions.h:146
void selectNext(wxListBox *aListBox)
FOOTPRINT * FootprintLoad(const wxString &aNickname, const wxString &aFootprintName, bool aKeepUUID=false)
Load a footprint having aFootprintName from the library given by aNickname.
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void resolveCanvasType()
Determines the Canvas type to load (with prompt if required) and initializes m_canvasType.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:393
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:516
wxAuiManager m_auimgr
#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 used (0 for auto)
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
The base class for create windows for drawing purpose.
void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:159
void setCurNickname(const wxString &aNickname)
void OnUpdateFootprintButton(wxUpdateUIEvent &aEvent)
Update the ID_ADD_FOOTPRINT_TO_BOARD tool state in main toolbar.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr) override
Update the 3D view, if the viewer is opened by this frame.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
virtual const wxString Problem() const
what was the problem?
Definition: exceptions.cpp:46
bool always_show_cursor
Definition: app_settings.h:42
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
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:115
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:169
Abstract pattern-matching tool and implementations.
bool m_axesEnabled
Fullscreen crosshair or small cross.
void ClickOnLibList(wxCommandEvent &aEvent)
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
PCB_DISPLAY_OPTIONS m_displayOptions
Master controller class:
Definition: tool_manager.h:54
static TOOL_ACTION measureTool
Definition: actions.h:154
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:608
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:81
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
static FOOTPRINT_LIST * GetInstance(KIWAY &aKiway)
Factory function to return a FOOTPRINT_LIST via Kiway.
static TOOL_ACTION centerContents
Definition: actions.h:100
void SelectAndViewFootprint(int aMode)
Select and load the next or the previous footprint.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
FOOTPRINT * loadFootprint(const LIB_ID &aFootprintId)
Attempts to load aFootprintId from the footprint library table.
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:318
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
CURSOR_SETTINGS cursor
Definition: app_settings.h:88
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
virtual void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:621
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
void Clear()
Remove all items from the view.
Definition: view.cpp:1100
void SetClearance(int aClearance)
Definition: netclass.h:125
static TOOL_ACTION toggleGrid
Definition: actions.h:140
bool m_Center
Center on screen.
Definition: base_screen.h:96
Handle actions that are shared between different frames in PcbNew.
Definition: pcb_control.h:46
static TOOL_ACTION showPadNumbers
Definition: pcb_actions.h:248
#define NEXT_PART
EDA_MSG_PANEL * m_messagePanel
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
static TOOL_ACTION inchesUnits
Definition: actions.h:144
void DClickOnFootprintList(wxMouseEvent &aEvent)
wxChoice * m_zoomSelectBox
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1491
void OnCharHook(wxKeyEvent &aEvent) override
Capture the key event before it is sent to the GUI.
ACTIONS * m_actions
Definition: tools_holder.h:159
bool Find(const wxString &aTerm, int &aMatchersTriggered, int &aPosition)
Handle actions specific to the board editor in PcbNew.
Definition of file extensions used in Kicad.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
An interface for classes handling user events controlling the view behavior such as zooming,...
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
#define _(s)
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:90
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:153
BOARD_ITEM * Duplicate() const override
Create a copy of this BOARD_ITEM.
Definition: footprint.cpp:1725
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
virtual void SetBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr)
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
#define FOOTPRINT_VIEWER_FRAME_NAME
void OnFPFilter(wxCommandEvent &aEvent)
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
Handle actions that are shared between different applications.
void selectPrev(wxListBox *aListBox)
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Specialization of the wxAuiPaneInfo class for KiCad panels.
bool IsModal() const override
Return true if the frame is shown in our modal mode and false if the frame is shown as an usual frame...
Definition: kiway_player.h:173
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
static TOOL_ACTION milsUnits
Definition: actions.h:145
COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:160
Handles action that are shared between different applications.
Definition: common_tools.h:37
void UpdateColors()
Update the color settings in the painter and GAL.
Generic tool for picking an item.
void SetModal(bool aIsModal)
Definition: kiway_player.h:174
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
virtual void SetRString(RSTRING_T aStringId, const wxString &aString)
Store a "retained string", which is any session and project specific string identified in enum RSTRIN...
Definition: project.cpp:212
SELECTION_CONDITION PadNumbersDisplay()
Create a functor that tests if the pad numbers are displayed.
#define NONMODAL_STYLE
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:283
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:241
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:97
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:552
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:393
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
bool IsFlipped() const
Definition: footprint.h:281
void SetLink(const KIID &aLink)
Definition: footprint.h:579
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
COLOR4D GetColor(int aLayer) const
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
Definition: project.cpp:227
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:49
Gather all the actions that are shared by tools.
Definition: pcb_actions.h:48
#define CHECK(x)
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:157
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
see class PGM_BASE
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
const char * name
Definition: DXF_plotter.cpp:56
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.
bool PlacingFootprint() const
Re-entrancy checker for above.
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:191
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
void setupUnits(APP_SETTINGS_BASE *aCfg)
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
void ReCreateLibraryList()
Create or recreate the list of current loaded libraries.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
NETCLASS * GetDefault() const
MAGNETIC_OPTIONS pads
The main frame for Pcbnew.
PCBNEW_SETTINGS & Settings()
PCBNEW_SETTINGS * GetPcbNewSettings() const
The selection tool: currently supports:
void OnLibFilter(wxCommandEvent &aEvent)
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Revert the commit by restoring the modified items state.
wxPoint GetPosition() const override
Definition: footprint.h:187
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Tool useful for viewing footprints.
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:199
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
MAGNETIC_SETTINGS m_magneticItems
Color settings are a bit different than most of the settings objects in that there can be more than o...
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
Definition: board.cpp:836
BOARD_ITEM_CONTAINER * GetModel() const override
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:102
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnSelectDisplayMode EVT_CHOICE(ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice) EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER
void OnIterateFootprintList(wxCommandEvent &event)
void InitTools()
Initializes all registered tools.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
BOARD * GetBoard() const
Definition: pad.h:57
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1562
double GetScale() const
Definition: view.h:264
Message panel definition file.
virtual COLOR4D GetGridColor() override
Group generic conditions for PCB editor states.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:204
wxString m_aboutTitle
static TOOL_ACTION selectionTool
Definition: actions.h:153
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
wxString m_configName
MAGNETIC_OPTIONS tracks
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
virtual void UpdateMsgPanel()
Redraw the message panel.
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:396
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.