KiCad PCB EDA Suite
cvpcb_mainframe.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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2011 Wayne Stambaugh <[email protected]>
6  * Copyright (C) 1992-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 
26 #include <bitmaps.h>
27 #include <confirm.h>
28 #include <eda_dde.h>
29 #include <fp_lib_table.h>
30 #include <kiface_base.h>
31 #include <kiplatform/app.h>
32 #include <kiway_express.h>
33 #include <macros.h>
35 #include <numeric>
36 #include <tool/action_manager.h>
37 #include <tool/action_toolbar.h>
38 #include <tool/common_control.h>
39 #include <tool/editor_conditions.h>
40 #include <tool/tool_dispatcher.h>
41 #include <tool/tool_manager.h>
43 #include <wx/statline.h>
44 #include <wx/stattext.h>
45 
46 #include <cvpcb_association.h>
47 #include <cvpcb_id.h>
48 #include <cvpcb_mainframe.h>
49 #include <cvpcb_settings.h>
51 #include <kiplatform/ui.h>
52 #include <listboxes.h>
53 #include <tools/cvpcb_actions.h>
55 #include <tools/cvpcb_control.h>
56 #include <wx/button.h>
57 #include <wx/settings.h>
58 
59 
60 #define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" )
61 
62 CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
63  KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, _( "Assign Footprints" ), wxDefaultPosition,
65 {
66  m_symbolsListBox = nullptr;
67  m_footprintListBox = nullptr;
68  m_librariesListBox = nullptr;
69  m_mainToolBar = nullptr;
70  m_modified = false;
71  m_cannotClose = false;
72  m_skipComponentSelect = false;
74  m_tcFilterString = nullptr;
76  m_initialized = false;
77  m_aboutTitle = "CvPcb";
78 
79  // Give an icon
80  wxIcon icon;
81  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_cvpcb ) );
82  SetIcon( icon );
83 
84  SetAutoLayout( true );
85 
86  LoadSettings( config() );
87 
88  setupTools();
92 
93  // Create list of available footprints and symbols of the schematic
97 
98  m_auimgr.SetManagedWindow( this );
99 
100  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
101 
102  m_auimgr.AddPane( m_librariesListBox, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(1)
103  .Caption( _( "Footprint Libraries" ) )
104  .BestSize((int) ( m_frameSize.x * 0.20 ), m_frameSize.y ) );
105 
106  m_auimgr.AddPane( m_symbolsListBox, EDA_PANE().Palette().Name( "Symbols" ).Center().Layer(0)
107  .Caption( _( "Symbol : Footprint Assignments" ) ) );
108 
109  m_auimgr.AddPane( m_footprintListBox, EDA_PANE().Palette().Name( "Footprints" ).Right().Layer(1)
110  .Caption( _( "Filtered Footprints" ) )
111  .BestSize((int) ( m_frameSize.x * 0.30 ), m_frameSize.y ) );
112 
113  // Build the bottom panel, to display 2 status texts and the buttons:
114  auto bottomPanel = new wxPanel( this );
115  auto panelSizer = new wxBoxSizer( wxVERTICAL );
116 
117  wxFlexGridSizer* fgSizerStatus = new wxFlexGridSizer( 3, 1, 0, 0 );
118  fgSizerStatus->SetFlexibleDirection( wxBOTH );
119  fgSizerStatus->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
120 
121  m_statusLine1 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
122  fgSizerStatus->Add( m_statusLine1, 0, 0, 5 );
123 
124  m_statusLine2 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
125  fgSizerStatus->Add( m_statusLine2, 0, 0, 5 );
126 
127  m_statusLine3 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
128  fgSizerStatus->Add( m_statusLine3, 0, wxBOTTOM, 3 );
129 
130  panelSizer->Add( fgSizerStatus, 1, wxEXPAND|wxLEFT, 2 );
131 
132  wxStaticLine* staticline1 = new wxStaticLine( bottomPanel );
133  panelSizer->Add( staticline1, 0, wxEXPAND, 5 );
134 
135  m_statusLine1->SetFont( KIUI::GetStatusFont( this ) );
136  m_statusLine2->SetFont( KIUI::GetStatusFont( this ) );
137  m_statusLine3->SetFont( KIUI::GetStatusFont( this ) );
138 
139  // Add buttons:
140  auto buttonsSizer = new wxBoxSizer( wxHORIZONTAL );
141  auto sdbSizer = new wxStdDialogButtonSizer();
142 
143  m_saveAndContinue = new wxButton( bottomPanel, wxID_ANY,
144  _( "Apply, Save Schematic && Continue" ) );
145  buttonsSizer->Add( m_saveAndContinue, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 20 );
146 
147  auto sdbSizerOK = new wxButton( bottomPanel, wxID_OK );
148  sdbSizer->AddButton( sdbSizerOK );
149  auto sdbSizerCancel = new wxButton( bottomPanel, wxID_CANCEL );
150  sdbSizer->AddButton( sdbSizerCancel );
151  sdbSizer->Realize();
152 
153  buttonsSizer->Add( sdbSizer, 0, 0, 5 );
154  panelSizer->Add( buttonsSizer, 0, wxALIGN_RIGHT|wxALL, 5 );
155 
156  bottomPanel->SetSizer( panelSizer );
157  bottomPanel->Fit();
158 
159  sdbSizerOK->SetDefault();
161 
162  m_auimgr.AddPane( bottomPanel, EDA_PANE().HToolbar().Name( "Buttons" ).Bottom().Layer(6) );
163 
164  m_auimgr.Update();
165  m_initialized = true;
166 
167  if( CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( config() ) )
168  {
169  if( cfg->m_LibrariesWidth > 0 )
170  {
171  wxAuiPaneInfo& librariesPane = m_auimgr.GetPane( "Libraries" );
172 
173  // wxAUI hack: force width by setting MinSize() and then Fixed()
174  // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
175  librariesPane.MinSize( cfg->m_LibrariesWidth, -1 );
176  librariesPane.BestSize( cfg->m_LibrariesWidth, -1 );
177  librariesPane.MaxSize( cfg->m_LibrariesWidth, -1 );
178  librariesPane.Fixed();
179  m_auimgr.Update();
180 
181  // now make it resizable again
182  librariesPane.MinSize( 20, -1 );
183  librariesPane.Resizable();
184  m_auimgr.Update();
185  }
186 
187  if( cfg->m_FootprintsWidth > 0 )
188  {
189  wxAuiPaneInfo& footprintsPane = m_auimgr.GetPane( "Footprints" );
190 
191  // wxAUI hack: force width by setting MinSize() and then Fixed()
192  // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
193  footprintsPane.MinSize( cfg->m_FootprintsWidth, -1 );
194  footprintsPane.BestSize( cfg->m_FootprintsWidth, -1 );
195  footprintsPane.MaxSize( cfg->m_FootprintsWidth, -1 );
196  footprintsPane.Fixed();
197  m_auimgr.Update();
198 
199  // now make it resizable again
200  footprintsPane.MinSize( 20, -1 );
201  footprintsPane.Resizable();
202  m_auimgr.Update();
203  }
204  }
205 
206  // Connect Events
208 
209  // Start the main processing loop
210  m_toolManager->InvokeTool( "cvpcb.Control" );
211 
212  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Symbol to footprint changes are unsaved" ) );
213 }
214 
215 
217 {
218  // Shutdown all running tools
219  if( m_toolManager )
221 
222  // Clean up the tool infrastructure
223  delete m_actions;
224  delete m_toolManager;
225  delete m_toolDispatcher;
226 
227  m_auimgr.UnInit();
228 }
229 
230 
232 {
233  // Create the manager
234  m_actions = new CVPCB_ACTIONS();
236  m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
238 
239  // Register tools
244 
246 
247  // Even though these menus will open with the right-click, we treat them as a normal
248  // menu instead of a context menu because we don't care about their position and want
249  // to be able to tell the difference between a menu click and a hotkey activation.
250 
251  // Create the context menu for the symbols list box
252  m_symbolsContextMenu = new ACTION_MENU( false, tool );
254  m_symbolsContextMenu->AppendSeparator();
258  m_symbolsContextMenu->AppendSeparator();
260 
261  // Create the context menu for the footprint list box
262  m_footprintContextMenu = new ACTION_MENU( false, tool );
264 }
265 
266 
268 {
270 
272  EDITOR_CONDITIONS cond( this );
273 
274  wxASSERT( mgr );
275 
276 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
277 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
278 
280  mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
281  mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
282 
283  auto compFilter =
284  [this] ( const SELECTION& )
285  {
287  };
288 
289  auto libFilter =
290  [this] ( const SELECTION& )
291  {
293  };
294 
295  auto pinFilter =
296  [this] ( const SELECTION& )
297  {
299  };
300 
303  mgr->SetConditions( CVPCB_ACTIONS::filterFPbyPin, CHECK( pinFilter ) );
304 
305 #undef CHECK
306 #undef ENABLE
307 }
308 
309 
311 {
312  // Connect the handlers to launch the context menus in the listboxes
313  m_footprintListBox->Bind( wxEVT_RIGHT_DOWN,
314  [this]( wxMouseEvent& )
315  {
316  PopupMenu( m_footprintContextMenu );
317  } );
318 
319  m_symbolsListBox->Bind( wxEVT_RIGHT_DOWN,
320  [this]( wxMouseEvent& )
321  {
322  PopupMenu( m_symbolsContextMenu );
323  } );
324 
325  // Connect the handler for the save button
326  m_saveAndContinue->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
327  [this]( wxCommandEvent& )
328  {
329  // saveAssociations must be run immediately
331  } );
332 
333  // Connect the handlers for the ok/cancel buttons
334  Bind( wxEVT_BUTTON,
335  [this]( wxCommandEvent& )
336  {
337  // saveAssociations must be run immediately, before running Close( true )
339  Close( true );
340  }, wxID_OK );
341  Bind( wxEVT_BUTTON,
342  [this]( wxCommandEvent& )
343  {
344  Close( false );
345  }, wxID_CANCEL );
346 
347  // Connect the handlers for the close events
348  Bind( wxEVT_MENU,
349  [this]( wxCommandEvent& )
350  {
351  Close( false );
352  }, wxID_CLOSE );
353  Bind( wxEVT_MENU,
354  [this]( wxCommandEvent& )
355  {
356  Close( false );
357  }, wxID_EXIT );
358 
359  // Toolbar events
361 
362  // Just skip the resize events
363  Bind( wxEVT_SIZE,
364  []( wxSizeEvent& aEvent )
365  {
366  aEvent.Skip();
367  } );
368 
369  // Attach the events to the tool dispatcher
371  Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
372 }
373 
374 
375 bool CVPCB_MAINFRAME::canCloseWindow( wxCloseEvent& aEvent )
376 {
377  if( m_modified )
378  {
379  // Shutdown blocks must be determined and vetoed as early as possible
381  && aEvent.GetId() == wxEVT_QUERY_END_SESSION )
382  {
383  return false;
384  }
385 
386  if( !HandleUnsavedChanges( this, _( "Symbol to Footprint links have been modified. "
387  "Save changes?" ),
388  [&]() -> bool
389  {
390  return SaveFootprintAssociation( false );
391  } ) )
392  {
393  return false;
394  }
395  }
396 
397  if( m_cannotClose )
398  return false;
399 
400  return true;
401 }
402 
403 
405 {
407  GetFootprintViewerFrame()->Close( true );
408 
409  m_modified = false;
410 
411  // clear highlight symbol in schematic:
412  SendMessageToEESCHEMA( true );
413 }
414 
415 
416 void CVPCB_MAINFRAME::OnEnterFilteringText( wxCommandEvent& aEvent )
417 {
418  // Called when changing the filter string in main toolbar.
419  // If the option FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN is set, update the list
420  // of available footprints which match the filter
421 
422  wxListEvent l_event;
423  OnSelectComponent( l_event );
424 }
425 
426 
427 void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
428 {
430  return;
431 
432  wxString libraryName;
433  COMPONENT* symbol = GetSelectedComponent();
434  libraryName = m_librariesListBox->GetSelectedLibrary();
435 
436  m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, symbol,
437  m_tcFilterString->GetValue(), m_filteringOptions );
438 
439  if( symbol && symbol->GetFPID().IsValid() )
441  else
443 
444  refreshAfterSymbolSearch( symbol );
445 }
446 
447 
449 {
451 
452  CVPCB_SETTINGS* cfg = static_cast<CVPCB_SETTINGS*>( aCfg );
453 
455 }
456 
457 
459 {
461 
462  CVPCB_SETTINGS* cfg = static_cast<CVPCB_SETTINGS*>( aCfg );
464 
465  cfg->m_LibrariesWidth = m_librariesListBox->GetSize().x;
466  cfg->m_FootprintsWidth = m_footprintListBox->GetSize().x;
467 }
468 
469 
471 {
472  if( m_undoList.size() == 0 )
473  return;
474 
475  CVPCB_UNDO_REDO_ENTRIES redoEntries;
476  CVPCB_UNDO_REDO_ENTRIES curEntry = m_undoList.back();
477  m_undoList.pop_back();
478 
479  // Iterate over the entries to undo
480  for( const auto& assoc : curEntry )
481  {
482  AssociateFootprint( assoc, true, false );
483  redoEntries.emplace_back( assoc.Reverse() );
484  }
485 
486  // Add the redo entries to the redo stack
487  m_redoList.emplace_back( redoEntries );
488 }
489 
490 
492 {
493  if( m_redoList.size() == 0 )
494  return;
495 
496  CVPCB_UNDO_REDO_ENTRIES curEntry = m_redoList.back();
497  m_redoList.pop_back();
498 
499  // Iterate over the entries to undo
500  bool firstAssoc = true;
501 
502  for( const auto& assoc : curEntry )
503  {
504  AssociateFootprint( assoc, firstAssoc );
505  firstAssoc = false;
506  }
507 }
508 
509 
510 wxString CVPCB_MAINFRAME::formatSymbolDesc( int idx, const wxString& aReference,
511  const wxString& aValue, const wxString& aFootprint )
512 {
513  // Work around a bug in wxString::Format with double-byte chars (and double-quote, for some
514  // reason).
515  wxString desc = wxString::Format( wxT( "%3d " ), idx );
516 
517  for( int ii = aReference.Length(); ii < 8; ++ii )
518  desc += wxS( " " );
519 
520  desc += aReference + wxT( " - " );
521 
522  for( int ii = aValue.Length(); ii < 16; ++ii )
523  desc += wxS( " " );
524 
525  desc += aValue + wxT( " : " ) + aFootprint;
526 
527  return desc;
528 }
529 
530 
532  bool aNewEntry, bool aAddUndoItem )
533 {
534  if( m_netlist.IsEmpty() )
535  return;
536 
537  COMPONENT* symbol = m_netlist.GetComponent( aAssociation.GetComponentIndex() );
538 
539  if( symbol == nullptr )
540  return;
541 
542  LIB_ID fpid = aAssociation.GetNewFootprint();
543  LIB_ID oldFpid = symbol->GetFPID();
544 
545  // Test for validity of the requested footprint
546  if( !fpid.empty() && !fpid.IsValid() )
547  {
548  wxString msg = wxString::Format( _( "'%s' is not a valid footprint." ),
549  fpid.Format().wx_str() );
550  DisplayErrorMessage( this, msg );
551  return;
552  }
553 
554  const KIID& id = symbol->GetKIIDs().front();
555 
556  // Set new footprint to all instances of the selected symbol
557  for( unsigned int idx : GetComponentIndices() )
558  {
559  COMPONENT* candidate = m_netlist.GetComponent( idx );
560  const std::vector<KIID>& kiids = candidate->GetKIIDs();
561 
562  if( std::find( kiids.begin(), kiids.end(), id ) != kiids.end() )
563  {
564  // Set the new footprint
565  candidate->SetFPID( fpid );
566 
567  // create the new symbol description and set it
568  wxString description = formatSymbolDesc( idx + 1,
569  candidate->GetReference(),
570  candidate->GetValue(),
571  candidate->GetFPID().Format().wx_str() );
572  m_symbolsListBox->SetString( idx, description );
573  }
574  }
575 
576  // Mark the data as being modified
577  m_modified = true;
578 
579  // Update the statusbar and refresh the list
580  DisplayStatus();
581  m_symbolsListBox->Refresh();
582 
583  if( !aAddUndoItem )
584  return;
585 
586  // Update the undo list
587  if ( aNewEntry )
588  {
589  // Create a new entry for this association
590  CVPCB_UNDO_REDO_ENTRIES newEntry;
591  newEntry.emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(), oldFpid,
592  aAssociation.GetNewFootprint() ) );
593  m_undoList.emplace_back( newEntry );
594 
595  // Clear the redo list
596  m_redoList.clear();
597  }
598  else
599  {
600  m_undoList.back().emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(),
601  oldFpid,
602  aAssociation.GetNewFootprint() ) );
603  }
604 
605 }
606 
607 
608 bool CVPCB_MAINFRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
609 {
610  return true;
611 }
612 
613 
615 {
616  // Tell AuiMgr that objects are changed !
617  if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized
618  m_auimgr.Update(); // (could be not the case when starting CvPcb)
619 
620  if( aSymbol == nullptr )
621  {
622  DisplayStatus();
623  return;
624  }
625 
626  // Preview of the already assigned footprint.
627  // Find the footprint that was already chosen for this aSymbol and select it,
628  // but only if the selection is made from the aSymbol list or the library list.
629  // If the selection is made from the footprint list, do not change the current
630  // selected footprint.
631  if( FindFocus() == m_symbolsListBox || FindFocus() == m_librariesListBox )
632  {
633  wxString footprintName = FROM_UTF8( aSymbol->GetFPID().Format().c_str() );
634 
636 
637  for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ )
638  {
639  wxString candidateName;
640  wxString msg = m_footprintListBox->OnGetItemText( ii, 0 );
641  msg.Trim( true );
642  msg.Trim( false );
643  candidateName = msg.AfterFirst( wxChar( ' ' ) );
644 
645  if( footprintName.Cmp( candidateName ) == 0 )
646  {
647  m_footprintListBox->SetSelection( ii, true );
648  break;
649  }
650  }
651 
654  }
655 
657  DisplayStatus();
658 }
659 
660 
663 {
664  int option = aFilter;
665 
666  // Apply the filter accordingly
667  switch( aAction )
668  {
669  case CVPCB_MAINFRAME::FILTER_DISABLE: m_filteringOptions &= ~option; break;
670  case CVPCB_MAINFRAME::FILTER_ENABLE: m_filteringOptions |= option; break;
671  case CVPCB_MAINFRAME::FILTER_TOGGLE: m_filteringOptions ^= option; break;
672  }
673 
674  wxListEvent l_event;
675  OnSelectComponent( l_event );
676 }
677 
678 
680 {
681  if( !m_initialized )
682  return;
683 
684  wxString filters, msg;
685  COMPONENT* symbol = GetSelectedComponent();
686 
688  {
689  msg.Empty();
690 
691  if( symbol )
692  {
693  for( unsigned ii = 0; ii < symbol->GetFootprintFilters().GetCount(); ii++ )
694  {
695  if( msg.IsEmpty() )
696  msg += symbol->GetFootprintFilters()[ii];
697  else
698  msg += wxT( ", " ) + symbol->GetFootprintFilters()[ii];
699  }
700  }
701 
702  filters += _( "Keywords" );
703 
704  if( !msg.IsEmpty() )
705  filters += wxString::Format( wxT( " (%s)" ), msg );
706  }
707 
709  {
710  msg.Empty();
711 
712  if( symbol )
713  msg = wxString::Format( wxT( "%i" ), symbol->GetPinCount() );
714 
715  if( !filters.IsEmpty() )
716  filters += wxT( ", " );
717 
718  filters += _( "Pin Count" );
719 
720  if( !msg.IsEmpty() )
721  filters += wxString::Format( wxT( " (%s)" ), msg );
722  }
723 
725  {
727 
728  if( !filters.IsEmpty() )
729  filters += wxT( ", " );
730 
731  filters += _( "Library" );
732 
733  if( !msg.IsEmpty() )
734  filters += wxString::Format( wxT( " (%s)" ), msg );
735  }
736 
737  wxString textFilter = m_tcFilterString->GetValue();
738 
739  if( !textFilter.IsEmpty() )
740  {
741  if( !filters.IsEmpty() )
742  filters += wxT( ", " );
743 
744  filters += _( "Search Text" ) + wxString::Format( wxT( " (%s)" ), textFilter );
745  }
746 
747  if( filters.IsEmpty() )
748  msg = _( "No Filtering" );
749  else
750  msg.Printf( _( "Filtered by %s" ), filters );
751 
752  msg << wxT( ": " ) << m_footprintListBox->GetCount();
753 
754  SetStatusText( msg );
755 
756 
757  msg.Empty();
758  wxString footprintName = GetSelectedFootprint();
759 
760  FOOTPRINT_INFO* fp = m_FootprintsList->GetFootprintInfo( footprintName );
761 
762  if( fp ) // can be NULL if no netlist loaded
763  {
764  msg = wxString::Format( _( "Description: %s; Keywords: %s" ),
765  fp->GetDescription(),
766  fp->GetKeywords() );
767  }
768 
769  SetStatusText( msg, 1 );
770 
771  msg.Empty();
772  wxString lib;
773 
774  // Choose the footprint to get the information on
775  if( fp )
776  {
777  // Use the footprint in the footprint viewer
778  lib = fp->GetLibNickname();
779  }
781  {
782  // Use the footprint of the selected symbol
783  if( symbol )
784  lib = symbol->GetFPID().GetLibNickname();
785  }
787  {
788  // Use the library that is selected
790  }
791 
792  // Extract the library information
793  FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
794 
795  if( fptbl->HasLibrary( lib ) )
796  msg = wxString::Format( _( "Library location: %s" ), fptbl->GetFullURI( lib ) );
797  else
798  msg = wxString::Format( _( "Library location: unknown" ) );
799 
800  SetStatusText( msg, 2 );
801 }
802 
803 
805 {
806  FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
807 
808  // Check if there are footprint libraries in the footprint library table.
809  if( !fptbl || !fptbl->GetLogicalLibs().size() )
810  {
811  wxMessageBox( _( "No PCB footprint libraries are listed in the current footprint "
812  "library table." ), _( "Configuration Error" ), wxOK | wxICON_ERROR );
813  return false;
814  }
815 
816  WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
817 
818  m_FootprintsList->ReadFootprintFiles( fptbl, nullptr, &progressReporter );
819 
821  {
823  }
824 
825  return true;
826 }
827 
828 
829 void CVPCB_MAINFRAME::SendMessageToEESCHEMA( bool aClearHighligntOnly )
830 {
831  if( m_netlist.IsEmpty() )
832  return;
833 
834  // clear highlight of previously selected symbols (if any):
835  // Selecting a non existing symbol clears any previously highlighted symbols
836  std::string packet = "$CLEAR: \"HIGHLIGHTED\"";
837 
838  if( Kiface().IsSingle() )
839  SendCommand( MSG_TO_SCH, packet );
840  else
841  Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
842 
843  if( aClearHighligntOnly )
844  return;
845 
846  int selection = m_symbolsListBox->GetSelection();
847 
848  if ( selection < 0 ) // Nothing selected
849  return;
850 
851  if( m_netlist.GetComponent( selection ) == nullptr )
852  return;
853 
854  // Now highlight the selected symbol:
855  COMPONENT* symbol = m_netlist.GetComponent( selection );
856 
857  packet = std::string( "$PART: \"" ) + TO_UTF8( symbol->GetReference() ) + "\"";
858 
859  if( Kiface().IsSingle() )
860  SendCommand( MSG_TO_SCH, packet );
861  else
862  Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
863 }
864 
865 
866 int CVPCB_MAINFRAME::ReadSchematicNetlist( const std::string& aNetlist )
867 {
868  STRING_LINE_READER* strrdr = new STRING_LINE_READER( aNetlist, "Eeschema via Kiway" );
869  KICAD_NETLIST_READER netrdr( strrdr, &m_netlist );
870 
871  m_netlist.Clear();
872 
873  try
874  {
875  netrdr.LoadNetlist();
876  }
877  catch( const IO_ERROR& ioe )
878  {
879  wxString msg = wxString::Format( _( "Error loading schematic.\n%s" ),
880  ioe.What().GetData() );
881  wxMessageBox( msg, _( "Load Error" ), wxOK | wxICON_ERROR );
882  return 1;
883  }
884 
885  // We also remove footprint name if it is "$noname" because this is a dummy name,
886  // not the actual name of the footprint.
887  for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
888  {
889  if( m_netlist.GetComponent( ii )->GetFPID().GetLibItemName() == std::string( "$noname" ) )
890  m_netlist.GetComponent( ii )->SetFPID( LIB_ID() );
891  }
892 
893  // Sort symbols by reference:
895 
896  return 0;
897 }
898 
899 
901 {
902  wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
903 
904  if( m_footprintListBox == nullptr )
905  {
908  }
909 
910  m_footprintListBox->SetFootprints( *m_FootprintsList, wxEmptyString, nullptr, wxEmptyString,
912  DisplayStatus();
913 }
914 
915 
917 {
918  wxString msg;
919  COMPONENT* symbol;
920  wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
921 
922  if( m_symbolsListBox == nullptr )
923  {
926  }
927 
929 
930  for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
931  {
932  symbol = m_netlist.GetComponent( i );
933 
935  symbol->GetReference(),
936  symbol->GetValue(),
937  symbol->GetFPID().Format().wx_str() );
938  m_symbolsListBox->m_SymbolList.Add( msg );
939  }
940 
941  if( m_symbolsListBox->m_SymbolList.Count() )
942  {
943  m_symbolsListBox->SetItemCount( m_symbolsListBox->m_SymbolList.Count() );
944  m_symbolsListBox->SetSelection( 0, true );
945  m_symbolsListBox->RefreshItems( 0L, m_symbolsListBox->m_SymbolList.Count() - 1 );
947  }
948 }
949 
950 
952 {
953  wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
954 
955  if( m_librariesListBox == nullptr )
956  {
959  }
960 
961  FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
962 
963  if( tbl )
964  {
965  wxArrayString libNames;
966 
967  std::vector< wxString > libNickNames = tbl->GetLogicalLibs();
968 
969  for( const wxString& libNickName : libNickNames )
970  libNames.Add( libNickName );
971 
972  m_librariesListBox->SetLibraryList( libNames );
973  }
974 }
975 
976 
978 {
979  int selection = m_symbolsListBox->GetSelection();
980 
981  if( selection >= 0 && selection < (int) m_netlist.GetCount() )
982  return m_netlist.GetComponent( selection );
983 
984  return nullptr;
985 }
986 
987 
988 void CVPCB_MAINFRAME::SetSelectedComponent( int aIndex, bool aSkipUpdate )
989 {
990  m_skipComponentSelect = aSkipUpdate;
991 
992  if( aIndex < 0 )
993  {
995  }
996  else if( aIndex < m_symbolsListBox->GetCount() )
997  {
999  m_symbolsListBox->SetSelection( aIndex );
1001  }
1002 
1003  m_skipComponentSelect = false;
1004 }
1005 
1006 
1007 std::vector<unsigned int> CVPCB_MAINFRAME::GetComponentIndices(
1008  CVPCB_MAINFRAME::CRITERIA aCriteria )
1009 {
1010  std::vector<unsigned int> idx;
1011  int lastIdx;
1012 
1013  // Make sure a netlist has been loaded and the box has contents
1014  if( m_netlist.IsEmpty() || m_symbolsListBox->GetCount() == 0 )
1015  return idx;
1016 
1017  switch( aCriteria )
1018  {
1020  idx.resize( m_netlist.GetCount() );
1021  std::iota( idx.begin(), idx.end(), 0 );
1022  break;
1023 
1025  // Check to see if anything is selected
1026  if( m_symbolsListBox->GetSelectedItemCount() < 1 )
1027  break;
1028 
1029  // Get the symbols
1030  lastIdx = m_symbolsListBox->GetFirstSelected();
1031  idx.emplace_back( lastIdx );
1032 
1033  lastIdx = m_symbolsListBox->GetNextSelected( lastIdx );
1034  while( lastIdx > 0 )
1035  {
1036  idx.emplace_back( lastIdx );
1037  lastIdx = m_symbolsListBox->GetNextSelected( lastIdx );
1038  }
1039  break;
1040 
1042  for( unsigned int i = 0; i < m_netlist.GetCount(); i++ )
1043  {
1044  if( m_netlist.GetComponent( i )->GetFPID().empty() )
1045  idx.emplace_back( i );
1046  }
1047  break;
1048 
1050  for( unsigned int i = 0; i < m_netlist.GetCount(); i++ )
1051  {
1052  if( !m_netlist.GetComponent( i )->GetFPID().empty() )
1053  idx.emplace_back( i );
1054  }
1055  break;
1056 
1057  default:
1058  wxASSERT_MSG( false, "Invalid symbol selection criteria" );
1059  }
1060 
1061  return idx;
1062 }
1063 
1064 
1066 {
1067  // returns the Footprint Viewer frame, if exists, or NULL
1068  wxWindow* window = wxWindow::FindWindowByName( FOOTPRINTVIEWER_FRAME_NAME );
1069  return dynamic_cast<DISPLAY_FOOTPRINTS_FRAME*>( window );
1070 }
1071 
1072 
1074 {
1075  return GetFootprintViewerFrame();
1076 }
1077 
1078 
1080 {
1081  if( m_librariesListBox->HasFocus() )
1083  else if( m_symbolsListBox->HasFocus() )
1085  else if( m_footprintListBox->HasFocus() )
1087 
1089 }
1090 
1091 
1093 {
1094  if( m_librariesListBox->HasFocus() )
1095  return m_librariesListBox;
1096  else if( m_symbolsListBox->HasFocus() )
1097  return m_symbolsListBox;
1098  else if( m_footprintListBox->HasFocus() )
1099  return m_footprintListBox;
1100 
1101  return nullptr;
1102 }
1103 
1104 
1106 {
1107  switch( aLB )
1108  {
1109  case CVPCB_MAINFRAME::CONTROL_LIBRARY: m_librariesListBox->SetFocus(); break;
1110  case CVPCB_MAINFRAME::CONTROL_COMPONENT: m_symbolsListBox->SetFocus(); break;
1111  case CVPCB_MAINFRAME::CONTROL_FOOTPRINT: m_footprintListBox->SetFocus(); break;
1112  default: break;
1113  }
1114 }
1115 
1116 
1118 {
1119  // returns the LIB_ID of the selected footprint in footprint listview
1120  // or a empty string
1122 }
1123 
1124 
1125 void CVPCB_MAINFRAME::SetStatusText( const wxString& aText, int aNumber )
1126 {
1127  switch( aNumber )
1128  {
1129  case 0: m_statusLine1->SetLabel( aText ); break;
1130  case 1: m_statusLine2->SetLabel( aText ); break;
1131  case 2: m_statusLine3->SetLabel( aText ); break;
1132  default: wxFAIL_MSG( "Invalid status row number" ); break;
1133  }
1134 }
1135 
1136 
1138 {
1140  ReCreateHToolbar();
1141  DisplayStatus();
1142 }
1143 
1144 
1146 {
1147  const std::string& payload = mail.GetPayload();
1148 
1149  switch( mail.Command() )
1150  {
1151  case MAIL_EESCHEMA_NETLIST:
1152  // Disable Close events during ReadNetListAndFpFiles() to avoid crash when updating
1153  // widgets:
1154  m_cannotClose = true;
1155  ReadNetListAndFpFiles( payload );
1156  m_cannotClose = false;
1157  /* @todo
1158  Go into SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) and trim GNL_ALL down.
1159  */
1160  break;
1161 
1162  default:
1163  ; // ignore most
1164  }
1165 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
static TOOL_ACTION showFootprintViewer
Open the footprint viewer.
Definition: cvpcb_actions.h:49
void SetLibraryList(const wxArrayString &aList)
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:239
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:64
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:38
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
static TOOL_ACTION FilterFPbyFPFilters
Footprint Filtering actions.
Definition: cvpcb_actions.h:66
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
CONTROL_TYPE
The type of the controls present in the application.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
DDE server & client.
FOOTPRINT_LIST * m_FootprintsList
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
Read the new s-expression based KiCad netlist format.
CVPCB_FILTER_ACTION
The action to apply to a footprint filter when it is modified.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:292
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
ACTION_MENU * m_footprintContextMenu
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
void SetFPID(const LIB_ID &aFPID)
Definition: pcb_netlist.h:132
void SetSelectedFootprint(const LIB_ID &aFPID)
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:48
This file is part of the common library.
wxString GetLibNickname() const override
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
void SetSelection(int index, bool State=true)
void SendMessageToEESCHEMA(bool aClearHighligntOnly=false)
Send a remote command to Eeschema via a socket,.
#define CVPCB_MAINFRAME_NAME
void UndoAssociation()
Undo the most recent associations that were performed.
void DeselectAll()
Remove all selection in lists which can have more than one item selected.
#define MSG_TO_SCH
Definition: eda_dde.h:50
wxFont GetMonospacedUIFont()
Definition: ui_common.cpp:85
void SetString(unsigned linecount, const wxString &text)
void AssociateFootprint(const CVPCB_ASSOCIATION &aAssociation, bool aNewEntry=true, bool aAddUndoItem=true)
Associate a footprint with a specific component in the list.
void setupEventHandlers()
Setup event handlers.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
bool SendCommand(int aService, const std::string &aMessage)
Used by a client to sent (by a socket connection) a data to a server.
Definition: eda_dde.cpp:304
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
wxString GetDescription() override
LIB_ID GetNewFootprint() const
Get the new footprint to associate to the component.
void RedoAssociation()
Redo the most recently undone association.
int ReadSchematicNetlist(const std::string &aNetlist)
Read the netlist (.net) file built on the fly by Eeschema.
unsigned GetCount() const
Definition: pcb_netlist.h:228
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:477
void SetFocusedControl(CVPCB_MAINFRAME::CONTROL_TYPE aControl)
Set the focus to a specific control.
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
wxAuiManager m_auimgr
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
#define FOOTPRINTVIEWER_FRAME_NAME
Manage TOOL_ACTION objects.
wxStaticText * m_statusLine3
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:159
bool LoadFootprintFiles()
Read the list of footprint (*.mod files) and generate the list of footprints.
Class that groups generic conditions for editor states.
bool empty() const
Definition: lib_id.h:180
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.
This file contains miscellaneous commonly used macros and functions.
const char * c_str() const
Definition: utf8.h:102
void SortByReference()
ACTION_MENU * m_symbolsContextMenu
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:133
static TOOL_ACTION FilterFPbyLibrary
Definition: cvpcb_actions.h:68
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:83
unsigned int GetComponentIndex() const
Get the index of the component to modify the association of.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
Master controller class:
Definition: tool_manager.h:54
void ShowChangedLanguage() override
Definition: kiid.h:44
static TOOL_ACTION copy
Definition: actions.h:67
void refreshAfterSymbolSearch(COMPONENT *aSymbol)
wxTextCtrl * m_tcFilterString
void OnSelectComponent(wxListEvent &event)
Called when clicking on a component in component list window:
static FOOTPRINT_LIST * GetInstance(KIWAY &aKiway)
Factory function to return a FOOTPRINT_LIST via Kiway.
virtual void LoadNetlist() override
Load the contents of the netlist file into aNetlist.
FP_FILTER_T
Filter setting constants.
Definition: listboxes.h:91
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
CVPCB_MAINFRAME::CONTROL_TYPE GetFocusedControl() const
Find out which control currently has focus.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
void UpdateWidth(int aLine=-1)
Update the width of the column based on its contents.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Open a project or set of files given by aFileList.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
void SetSelectedComponent(int aIndex, bool aSkipUpdate=false)
Set the currently selected component in the components listbox.
virtual bool ReadFootprintFiles(FP_LIB_TABLE *aTable, const wxString *aNickname=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)=0
Read all the footprints provided by the combination of aTable and aNickname.
ACTION_TOOLBAR * m_mainToolBar
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
wxString GetFullURI(const wxString &aLibNickname, bool aExpandEnvVars=true) const
Return the full URI of the library mapped to aLibNickname.
virtual void DispatchWxEvent(wxEvent &aEvent)
Process wxEvents (mostly UI events), translate them to TOOL_EVENTs, and make tools handle those.
wxArrayString m_SymbolList
Definition: listboxes.h:222
const wxString & GetReference() const
Definition: pcb_netlist.h:123
void KiwayMailIn(KIWAY_EXPRESS &aEvent) override
Receive KIWAY_EXPRESS messages from other players.
wxString GetSelectedLibrary()
ACTIONS * m_actions
Definition: tools_holder.h:159
static TOOL_ACTION cut
Definition: actions.h:66
No controls have focus.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
SYMBOLS_LISTBOX * m_symbolsListBox
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
void SetStatusText(const wxString &aText, int aNumber=0) override
#define _(s)
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:90
CRITERIA
Criteria to use to identify sets of components.
static TOOL_ACTION deleteAssoc
Definition: cvpcb_actions.h:63
FOOTPRINT_INFO * GetFootprintInfo(const wxString &aFootprintName)
Get info for a footprint by id.
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:72
#define KICAD_DEFAULT_DRAWFRAME_STYLE
void ReCreateMenuBar() override
Recreates the menu bar.
CVPCB_UNDO_REDO_LIST m_undoList
Gather all the actions that are shared by tools.
Definition: cvpcb_actions.h:37
wxString OnGetItemText(long item, long column) const override
This overloaded function MUST be provided for the wxLC_VIRTUAL mode because real data is not handled ...
wxControl * GetFocusedControlObject() const
Get a pointer to the currently focused control.
static TOOL_ACTION saveAssociations
Management actions.
Definition: cvpcb_actions.h:56
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 DisplayErrors(wxTopLevelWindow *aCaller=nullptr)
TOOL_DISPATCHER * m_toolDispatcher
Specialization of the wxAuiPaneInfo class for KiCad panels.
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...
wxFont GetStatusFont(wxWindow *aWindow)
Definition: ui_common.cpp:132
UTF8 Format() const
Definition: lib_id.cpp:116
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:84
void SetSelection(int index, bool State=true)
SELECTION_CONDITION ContentModified()
Create a functor that tests if the content of the frame is modified.
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:283
wxStaticText * m_statusLine2
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
COMPONENT * GetComponent(unsigned aIndex)
Return the COMPONENT at aIndex.
Definition: pcb_netlist.h:236
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
wxString GetSelectedFootprint()
static TOOL_ACTION redo
Definition: actions.h:65
void Clear()
Remove all components from the netlist.
Definition: pcb_netlist.h:223
void doCloseWindow() override
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
bool ReadNetListAndFpFiles(const std::string &aNetlist)
Load the netlist file built on the fly by Eeschema and loads footprint libraries from fp lib tables.
#define ENABLE(x)
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 FixupCancelButtonCmdKeyCollision(wxWindow *aWindow)
Definition: gtk/ui.cpp:71
CVPCB_MAINFRAME(KIWAY *aKiway, wxWindow *aParent)
static TOOL_ACTION filterFPbyPin
Definition: cvpcb_actions.h:67
SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
CVPCB_UNDO_REDO_LIST m_redoList
Toggle the filter state.
COMPONENT * GetSelectedComponent()
Get the selected component from the component listbox.
wxString wx_str() const
Definition: utf8.cpp:46
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
FOOTPRINTS_LISTBOX * m_footprintListBox
unsigned GetErrorCount() const
int GetPinCount() const
Definition: pcb_netlist.h:146
A class to define a footprint association to be made in cvpcb.
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:199
wxString GetKeywords()
bool IsEmpty() const
Definition: pcb_netlist.h:218
void SetFootprints(FOOTPRINT_LIST &aList, const wxString &aLibName, COMPONENT *aComponent, const wxString &aFootPrintFilterPattern, int aFilterType)
Populate the wxListCtrl with the footprints from aList that meet the filter criteria defined by aFilt...
wxString formatSymbolDesc(int idx, const wxString &aReference, const wxString &aValue, const wxString &aFootprint)
const wxString & GetValue() const
Definition: pcb_netlist.h:124
const wxArrayString & GetFootprintFilters() const
Definition: pcb_netlist.h:143
wxWindow * GetToolCanvas() const override
Canvas access.
void SetFootprintFilter(FOOTPRINTS_LISTBOX::FP_FILTER_T aFilter, CVPCB_MAINFRAME::CVPCB_FILTER_ACTION aAction)
Set a filter criteria to either on/off or toggle the criteria.
static TOOL_ACTION undo
Definition: actions.h:64
#define CHECK(x)
std::vector< unsigned int > GetComponentIndices(CVPCB_MAINFRAME::CRITERIA aCriteria=CVPCB_MAINFRAME::ALL_COMPONENTS)
Get the indices for all the components meeting the specified criteria in the components listbox.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
void OnEnterFilteringText(wxCommandEvent &event)
Called each time the text of m_tcFilterString is changed.
void InitTools()
Initializes all registered tools.
Not associated components.
MAIL_T Command()
Returns the MAIL_T associated with this mail.
Definition: kiway_express.h:49
LIBRARY_LISTBOX * m_librariesListBox
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:240
DISPLAY_FOOTPRINTS_FRAME * GetFootprintViewerFrame() const
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
void DisplayStatus()
Update the information displayed on the status bar at bottom of the main frame.
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
Definition: kiway_express.h:57
CVPCB_CONTROL.
Definition: cvpcb_control.h:35
static TOOL_ACTION paste
Definition: actions.h:68
wxButton * m_saveAndContinue
bool IsSingle() const
Is this KIFACE running under single_top?
Definition: kiface_base.h:104
void setupTools()
Setup the tool system for the CVPCB main frame.
wxString m_aboutTitle
wxStaticText * m_statusLine1
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 LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
std::vector< CVPCB_ASSOCIATION > CVPCB_UNDO_REDO_ENTRIES
bool SaveFootprintAssociation(bool doSaveSchematic)
Save the edits that the user has done by sending them back to Eeschema via the kiway.
const std::vector< KIID > & GetKIIDs() const
Definition: pcb_netlist.h:140