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 = wxT( "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( wxT( "MainToolbar" ) ).Top().Layer(6) );
101 
102  m_auimgr.AddPane( m_librariesListBox, EDA_PANE().Palette().Name( wxT( "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( wxT( "Symbols" ) ).Center().Layer(0)
107  .Caption( _( "Symbol : Footprint Assignments" ) ) );
108 
109  m_auimgr.AddPane( m_footprintListBox, EDA_PANE().Palette().Name( wxT( "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( wxT( "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( wxT( "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( wxT( "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 
281  mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
282  mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
283 
284  auto compFilter =
285  [this] ( const SELECTION& )
286  {
288  };
289 
290  auto libFilter =
291  [this] ( const SELECTION& )
292  {
294  };
295 
296  auto pinFilter =
297  [this] ( const SELECTION& )
298  {
300  };
301 
304  mgr->SetConditions( CVPCB_ACTIONS::filterFPbyPin, CHECK( pinFilter ) );
305 
306 #undef CHECK
307 #undef ENABLE
308 }
309 
310 
312 {
313  // Connect the handlers to launch the context menus in the listboxes
314  m_footprintListBox->Bind( wxEVT_RIGHT_DOWN,
315  [this]( wxMouseEvent& )
316  {
317  PopupMenu( m_footprintContextMenu );
318  } );
319 
320  m_symbolsListBox->Bind( wxEVT_RIGHT_DOWN,
321  [this]( wxMouseEvent& )
322  {
323  PopupMenu( m_symbolsContextMenu );
324  } );
325 
326  // Connect the handler for the save button
327  m_saveAndContinue->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
328  [this]( wxCommandEvent& )
329  {
330  // saveAssociations must be run immediately
332  } );
333 
334  // Connect the handlers for the ok/cancel buttons
335  Bind( wxEVT_BUTTON,
336  [this]( wxCommandEvent& )
337  {
338  // saveAssociations must be run immediately, before running Close( true )
340  Close( true );
341  }, wxID_OK );
342  Bind( wxEVT_BUTTON,
343  [this]( wxCommandEvent& )
344  {
345  Close( false );
346  }, wxID_CANCEL );
347 
348  // Connect the handlers for the close events
349  Bind( wxEVT_MENU,
350  [this]( wxCommandEvent& )
351  {
352  Close( false );
353  }, wxID_CLOSE );
354  Bind( wxEVT_MENU,
355  [this]( wxCommandEvent& )
356  {
357  Close( false );
358  }, wxID_EXIT );
359 
360  // Toolbar events
362 
363  // Just skip the resize events
364  Bind( wxEVT_SIZE,
365  []( wxSizeEvent& aEvent )
366  {
367  aEvent.Skip();
368  } );
369 
370  // Attach the events to the tool dispatcher
372  Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
373 }
374 
375 
376 bool CVPCB_MAINFRAME::canCloseWindow( wxCloseEvent& aEvent )
377 {
378  if( m_modified )
379  {
380  // Shutdown blocks must be determined and vetoed as early as possible
382  && aEvent.GetId() == wxEVT_QUERY_END_SESSION )
383  {
384  return false;
385  }
386 
387  if( !HandleUnsavedChanges( this, _( "Symbol to Footprint links have been modified. "
388  "Save changes?" ),
389  [&]() -> bool
390  {
391  return SaveFootprintAssociation( false );
392  } ) )
393  {
394  return false;
395  }
396  }
397 
398  if( m_cannotClose )
399  return false;
400 
401  return true;
402 }
403 
404 
406 {
408  GetFootprintViewerFrame()->Close( true );
409 
410  m_modified = false;
411 
412  // clear highlight symbol in schematic:
413  SendMessageToEESCHEMA( true );
414 }
415 
416 
417 void CVPCB_MAINFRAME::OnEnterFilteringText( wxCommandEvent& aEvent )
418 {
419  // Called when changing the filter string in main toolbar.
420  // If the option FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN is set, update the list
421  // of available footprints which match the filter
422 
423  long pos = m_tcFilterString->GetInsertionPoint();
424  wxListEvent l_event;
425  OnSelectComponent( l_event );
426  m_tcFilterString->SetFocus();
427  m_tcFilterString->SetInsertionPoint( pos );
428 }
429 
430 
431 void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
432 {
434  return;
435 
436  wxString libraryName;
437  COMPONENT* symbol = GetSelectedComponent();
438  libraryName = m_librariesListBox->GetSelectedLibrary();
439 
440  m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, symbol,
441  m_tcFilterString->GetValue(), m_filteringOptions );
442 
443  if( symbol && symbol->GetFPID().IsValid() )
445  else
447 
448  refreshAfterSymbolSearch( symbol );
449 }
450 
451 
453 {
455 
456  CVPCB_SETTINGS* cfg = static_cast<CVPCB_SETTINGS*>( aCfg );
457 
459 }
460 
461 
463 {
465 
466  CVPCB_SETTINGS* cfg = static_cast<CVPCB_SETTINGS*>( aCfg );
468 
469  cfg->m_LibrariesWidth = m_librariesListBox->GetSize().x;
470  cfg->m_FootprintsWidth = m_footprintListBox->GetSize().x;
471 }
472 
473 
475 {
476  if( m_undoList.size() == 0 )
477  return;
478 
479  CVPCB_UNDO_REDO_ENTRIES redoEntries;
480  CVPCB_UNDO_REDO_ENTRIES curEntry = m_undoList.back();
481  m_undoList.pop_back();
482 
483  // Iterate over the entries to undo
484  for( const auto& assoc : curEntry )
485  {
486  AssociateFootprint( assoc, true, false );
487  redoEntries.emplace_back( assoc.Reverse() );
488  }
489 
490  // Add the redo entries to the redo stack
491  m_redoList.emplace_back( redoEntries );
492 }
493 
494 
496 {
497  if( m_redoList.size() == 0 )
498  return;
499 
500  CVPCB_UNDO_REDO_ENTRIES curEntry = m_redoList.back();
501  m_redoList.pop_back();
502 
503  // Iterate over the entries to undo
504  bool firstAssoc = true;
505 
506  for( const auto& assoc : curEntry )
507  {
508  AssociateFootprint( assoc, firstAssoc );
509  firstAssoc = false;
510  }
511 }
512 
513 
514 wxString CVPCB_MAINFRAME::formatSymbolDesc( int idx, const wxString& aReference,
515  const wxString& aValue, const wxString& aFootprint )
516 {
517  // Work around a bug in wxString::Format with double-byte chars (and double-quote, for some
518  // reason).
519  wxString desc = wxString::Format( wxT( "%3d " ), idx );
520 
521  for( int ii = aReference.Length(); ii < 8; ++ii )
522  desc += wxS( " " );
523 
524  desc += aReference + wxT( " - " );
525 
526  for( int ii = aValue.Length(); ii < 16; ++ii )
527  desc += wxS( " " );
528 
529  desc += aValue + wxT( " : " ) + aFootprint;
530 
531  return desc;
532 }
533 
534 
536  bool aNewEntry, bool aAddUndoItem )
537 {
538  if( m_netlist.IsEmpty() )
539  return;
540 
541  COMPONENT* symbol = m_netlist.GetComponent( aAssociation.GetComponentIndex() );
542 
543  if( symbol == nullptr )
544  return;
545 
546  LIB_ID fpid = aAssociation.GetNewFootprint();
547  LIB_ID oldFpid = symbol->GetFPID();
548 
549  // Test for validity of the requested footprint
550  if( !fpid.empty() && !fpid.IsValid() )
551  {
552  wxString msg = wxString::Format( _( "'%s' is not a valid footprint." ),
553  fpid.Format().wx_str() );
554  DisplayErrorMessage( this, msg );
555  return;
556  }
557 
558  const KIID& id = symbol->GetKIIDs().front();
559 
560  // Set new footprint to all instances of the selected symbol
561  for( unsigned int idx : GetComponentIndices() )
562  {
563  COMPONENT* candidate = m_netlist.GetComponent( idx );
564  const std::vector<KIID>& kiids = candidate->GetKIIDs();
565 
566  if( std::find( kiids.begin(), kiids.end(), id ) != kiids.end() )
567  {
568  // Set the new footprint
569  candidate->SetFPID( fpid );
570 
571  // create the new symbol description and set it
572  wxString description = formatSymbolDesc( idx + 1,
573  candidate->GetReference(),
574  candidate->GetValue(),
575  candidate->GetFPID().Format().wx_str() );
576  m_symbolsListBox->SetString( idx, description );
577  }
578  }
579 
580  // Mark the data as being modified
581  m_modified = true;
582 
583  // Update the statusbar and refresh the list
584  DisplayStatus();
585  m_symbolsListBox->Refresh();
586 
587  if( !aAddUndoItem )
588  return;
589 
590  // Update the undo list
591  if ( aNewEntry )
592  {
593  // Create a new entry for this association
594  CVPCB_UNDO_REDO_ENTRIES newEntry;
595  newEntry.emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(), oldFpid,
596  aAssociation.GetNewFootprint() ) );
597  m_undoList.emplace_back( newEntry );
598 
599  // Clear the redo list
600  m_redoList.clear();
601  }
602  else
603  {
604  m_undoList.back().emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(),
605  oldFpid,
606  aAssociation.GetNewFootprint() ) );
607  }
608 
609 }
610 
611 
612 bool CVPCB_MAINFRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
613 {
614  return true;
615 }
616 
617 
619 {
620  // Tell AuiMgr that objects are changed !
621  if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized
622  m_auimgr.Update(); // (could be not the case when starting CvPcb)
623 
624  if( aSymbol == nullptr )
625  {
626  DisplayStatus();
627  return;
628  }
629 
630  // Preview of the already assigned footprint.
631  // Find the footprint that was already chosen for this aSymbol and select it,
632  // but only if the selection is made from the aSymbol list or the library list.
633  // If the selection is made from the footprint list, do not change the current
634  // selected footprint.
635  if( FindFocus() == m_symbolsListBox || FindFocus() == m_librariesListBox )
636  {
637  wxString footprintName = FROM_UTF8( aSymbol->GetFPID().Format().c_str() );
638 
640 
641  for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ )
642  {
643  wxString candidateName;
644  wxString msg = m_footprintListBox->OnGetItemText( ii, 0 );
645  msg.Trim( true );
646  msg.Trim( false );
647  candidateName = msg.AfterFirst( wxChar( ' ' ) );
648 
649  if( footprintName.Cmp( candidateName ) == 0 )
650  {
651  m_footprintListBox->SetSelection( ii, true );
652  break;
653  }
654  }
655 
658  }
659 
661  DisplayStatus();
662 }
663 
664 
667 {
668  int option = aFilter;
669 
670  // Apply the filter accordingly
671  switch( aAction )
672  {
673  case CVPCB_MAINFRAME::FILTER_DISABLE: m_filteringOptions &= ~option; break;
674  case CVPCB_MAINFRAME::FILTER_ENABLE: m_filteringOptions |= option; break;
675  case CVPCB_MAINFRAME::FILTER_TOGGLE: m_filteringOptions ^= option; break;
676  }
677 
678  wxListEvent l_event;
679  OnSelectComponent( l_event );
680 }
681 
682 
684 {
685  if( !m_initialized )
686  return;
687 
688  wxString filters, msg;
689  COMPONENT* symbol = GetSelectedComponent();
690 
692  {
693  msg.Empty();
694 
695  if( symbol )
696  {
697  for( unsigned ii = 0; ii < symbol->GetFootprintFilters().GetCount(); ii++ )
698  {
699  if( msg.IsEmpty() )
700  msg += symbol->GetFootprintFilters()[ii];
701  else
702  msg += wxT( ", " ) + symbol->GetFootprintFilters()[ii];
703  }
704  }
705 
706  filters += _( "Keywords" );
707 
708  if( !msg.IsEmpty() )
709  filters += wxString::Format( wxT( " (%s)" ), msg );
710  }
711 
713  {
714  msg.Empty();
715 
716  if( symbol )
717  msg = wxString::Format( wxT( "%i" ), symbol->GetPinCount() );
718 
719  if( !filters.IsEmpty() )
720  filters += wxT( ", " );
721 
722  filters += _( "Pin Count" );
723 
724  if( !msg.IsEmpty() )
725  filters += wxString::Format( wxT( " (%s)" ), msg );
726  }
727 
729  {
731 
732  if( !filters.IsEmpty() )
733  filters += wxT( ", " );
734 
735  filters += _( "Library" );
736 
737  if( !msg.IsEmpty() )
738  filters += wxString::Format( wxT( " (%s)" ), msg );
739  }
740 
741  wxString textFilter = m_tcFilterString->GetValue();
742 
743  if( !textFilter.IsEmpty() )
744  {
745  if( !filters.IsEmpty() )
746  filters += wxT( ", " );
747 
748  filters += _( "Search Text" ) + wxString::Format( wxT( " (%s)" ), textFilter );
749  }
750 
751  if( filters.IsEmpty() )
752  msg = _( "No Filtering" );
753  else
754  msg.Printf( _( "Filtered by %s" ), filters );
755 
756  msg << wxT( ": " ) << m_footprintListBox->GetCount();
757 
758  SetStatusText( msg );
759 
760 
761  msg.Empty();
762  wxString footprintName = GetSelectedFootprint();
763 
764  FOOTPRINT_INFO* fp = m_FootprintsList->GetFootprintInfo( footprintName );
765 
766  if( fp ) // can be NULL if no netlist loaded
767  {
768  msg = wxString::Format( _( "Description: %s; Keywords: %s" ),
769  fp->GetDescription(),
770  fp->GetKeywords() );
771  }
772 
773  SetStatusText( msg, 1 );
774 
775  msg.Empty();
776  wxString lib;
777 
778  // Choose the footprint to get the information on
779  if( fp )
780  {
781  // Use the footprint in the footprint viewer
782  lib = fp->GetLibNickname();
783  }
785  {
786  // Use the footprint of the selected symbol
787  if( symbol )
788  lib = symbol->GetFPID().GetLibNickname();
789  }
791  {
792  // Use the library that is selected
794  }
795 
796  // Extract the library information
797  FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
798 
799  if( fptbl->HasLibrary( lib ) )
800  msg = wxString::Format( _( "Library location: %s" ), fptbl->GetFullURI( lib ) );
801  else
802  msg = wxString::Format( _( "Library location: unknown" ) );
803 
804  SetStatusText( msg, 2 );
805 }
806 
807 
809 {
810  FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
811 
812  // Check if there are footprint libraries in the footprint library table.
813  if( !fptbl || !fptbl->GetLogicalLibs().size() )
814  {
815  wxMessageBox( _( "No PCB footprint libraries are listed in the current footprint "
816  "library table." ), _( "Configuration Error" ), wxOK | wxICON_ERROR );
817  return false;
818  }
819 
820  WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
821 
822  m_FootprintsList->ReadFootprintFiles( fptbl, nullptr, &progressReporter );
823 
825  {
827  }
828 
829  return true;
830 }
831 
832 
833 void CVPCB_MAINFRAME::SendMessageToEESCHEMA( bool aClearHighligntOnly )
834 {
835  if( m_netlist.IsEmpty() )
836  return;
837 
838  // clear highlight of previously selected symbols (if any):
839  // Selecting a non existing symbol clears any previously highlighted symbols
840  std::string packet = "$CLEAR: \"HIGHLIGHTED\"";
841 
842  if( Kiface().IsSingle() )
843  SendCommand( MSG_TO_SCH, packet );
844  else
845  Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
846 
847  if( aClearHighligntOnly )
848  return;
849 
850  int selection = m_symbolsListBox->GetSelection();
851 
852  if ( selection < 0 ) // Nothing selected
853  return;
854 
855  if( m_netlist.GetComponent( selection ) == nullptr )
856  return;
857 
858  // Now highlight the selected symbol:
859  COMPONENT* symbol = m_netlist.GetComponent( selection );
860 
861  packet = std::string( "$PART: \"" ) + TO_UTF8( symbol->GetReference() ) + "\"";
862 
863  if( Kiface().IsSingle() )
864  SendCommand( MSG_TO_SCH, packet );
865  else
866  Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
867 }
868 
869 
870 int CVPCB_MAINFRAME::ReadSchematicNetlist( const std::string& aNetlist )
871 {
872  STRING_LINE_READER* stringReader = new STRING_LINE_READER( aNetlist, "Eeschema via Kiway" );
873  KICAD_NETLIST_READER netlistReader( stringReader, &m_netlist );
874 
875  m_netlist.Clear();
876 
877  try
878  {
879  netlistReader.LoadNetlist();
880  }
881  catch( const IO_ERROR& ioe )
882  {
883  wxString msg = wxString::Format( _( "Error loading schematic.\n%s" ),
884  ioe.What().GetData() );
885  wxMessageBox( msg, _( "Load Error" ), wxOK | wxICON_ERROR );
886  return 1;
887  }
888 
889  // We also remove footprint name if it is "$noname" because this is a dummy name,
890  // not the actual name of the footprint.
891  for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
892  {
893  if( m_netlist.GetComponent( ii )->GetFPID().GetLibItemName() == std::string( "$noname" ) )
894  m_netlist.GetComponent( ii )->SetFPID( LIB_ID() );
895  }
896 
897  // Sort symbols by reference:
899 
900  return 0;
901 }
902 
903 
905 {
906  wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
907 
908  if( m_footprintListBox == nullptr )
909  {
912  }
913 
914  m_footprintListBox->SetFootprints( *m_FootprintsList, wxEmptyString, nullptr, wxEmptyString,
916  DisplayStatus();
917 }
918 
919 
921 {
922  wxString msg;
923  COMPONENT* symbol;
924  wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
925 
926  if( m_symbolsListBox == nullptr )
927  {
930  }
931 
933 
934  for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
935  {
936  symbol = m_netlist.GetComponent( i );
937 
939  symbol->GetReference(),
940  symbol->GetValue(),
941  symbol->GetFPID().Format().wx_str() );
942  m_symbolsListBox->m_SymbolList.Add( msg );
943  }
944 
945  if( m_symbolsListBox->m_SymbolList.Count() )
946  {
947  m_symbolsListBox->SetItemCount( m_symbolsListBox->m_SymbolList.Count() );
948  m_symbolsListBox->SetSelection( 0, true );
949  m_symbolsListBox->RefreshItems( 0L, m_symbolsListBox->m_SymbolList.Count() - 1 );
951  }
952 }
953 
954 
956 {
957  wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
958 
959  if( m_librariesListBox == nullptr )
960  {
963  }
964 
965  FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
966 
967  if( tbl )
968  {
969  wxArrayString libNames;
970 
971  std::vector< wxString > libNickNames = tbl->GetLogicalLibs();
972 
973  for( const wxString& libNickName : libNickNames )
974  libNames.Add( libNickName );
975 
976  m_librariesListBox->SetLibraryList( libNames );
977  }
978 }
979 
980 
982 {
983  int selection = m_symbolsListBox->GetSelection();
984 
985  if( selection >= 0 && selection < (int) m_netlist.GetCount() )
986  return m_netlist.GetComponent( selection );
987 
988  return nullptr;
989 }
990 
991 
992 void CVPCB_MAINFRAME::SetSelectedComponent( int aIndex, bool aSkipUpdate )
993 {
994  m_skipComponentSelect = aSkipUpdate;
995 
996  if( aIndex < 0 )
997  {
999  }
1000  else if( aIndex < m_symbolsListBox->GetCount() )
1001  {
1003  m_symbolsListBox->SetSelection( aIndex );
1005  }
1006 
1007  m_skipComponentSelect = false;
1008 }
1009 
1010 
1011 std::vector<unsigned int> CVPCB_MAINFRAME::GetComponentIndices(
1012  CVPCB_MAINFRAME::CRITERIA aCriteria )
1013 {
1014  std::vector<unsigned int> idx;
1015  int lastIdx;
1016 
1017  // Make sure a netlist has been loaded and the box has contents
1018  if( m_netlist.IsEmpty() || m_symbolsListBox->GetCount() == 0 )
1019  return idx;
1020 
1021  switch( aCriteria )
1022  {
1024  idx.resize( m_netlist.GetCount() );
1025  std::iota( idx.begin(), idx.end(), 0 );
1026  break;
1027 
1029  // Check to see if anything is selected
1030  if( m_symbolsListBox->GetSelectedItemCount() < 1 )
1031  break;
1032 
1033  // Get the symbols
1034  lastIdx = m_symbolsListBox->GetFirstSelected();
1035  idx.emplace_back( lastIdx );
1036 
1037  lastIdx = m_symbolsListBox->GetNextSelected( lastIdx );
1038  while( lastIdx > 0 )
1039  {
1040  idx.emplace_back( lastIdx );
1041  lastIdx = m_symbolsListBox->GetNextSelected( lastIdx );
1042  }
1043  break;
1044 
1046  for( unsigned int i = 0; i < m_netlist.GetCount(); i++ )
1047  {
1048  if( m_netlist.GetComponent( i )->GetFPID().empty() )
1049  idx.emplace_back( i );
1050  }
1051  break;
1052 
1054  for( unsigned int i = 0; i < m_netlist.GetCount(); i++ )
1055  {
1056  if( !m_netlist.GetComponent( i )->GetFPID().empty() )
1057  idx.emplace_back( i );
1058  }
1059  break;
1060 
1061  default:
1062  wxASSERT_MSG( false, wxT( "Invalid symbol selection criteria" ) );
1063  }
1064 
1065  return idx;
1066 }
1067 
1068 
1070 {
1071  // returns the Footprint Viewer frame, if exists, or NULL
1072  wxWindow* window = wxWindow::FindWindowByName( FOOTPRINTVIEWER_FRAME_NAME );
1073  return dynamic_cast<DISPLAY_FOOTPRINTS_FRAME*>( window );
1074 }
1075 
1076 
1078 {
1079  return GetFootprintViewerFrame();
1080 }
1081 
1082 
1084 {
1085  if( m_librariesListBox->HasFocus() )
1087  else if( m_symbolsListBox->HasFocus() )
1089  else if( m_footprintListBox->HasFocus() )
1091 
1093 }
1094 
1095 
1097 {
1098  if( m_librariesListBox->HasFocus() )
1099  return m_librariesListBox;
1100  else if( m_symbolsListBox->HasFocus() )
1101  return m_symbolsListBox;
1102  else if( m_footprintListBox->HasFocus() )
1103  return m_footprintListBox;
1104 
1105  return nullptr;
1106 }
1107 
1108 
1110 {
1111  switch( aLB )
1112  {
1113  case CVPCB_MAINFRAME::CONTROL_LIBRARY: m_librariesListBox->SetFocus(); break;
1114  case CVPCB_MAINFRAME::CONTROL_COMPONENT: m_symbolsListBox->SetFocus(); break;
1115  case CVPCB_MAINFRAME::CONTROL_FOOTPRINT: m_footprintListBox->SetFocus(); break;
1116  default: break;
1117  }
1118 }
1119 
1120 
1122 {
1123  // returns the LIB_ID of the selected footprint in footprint listview
1124  // or a empty string
1126 }
1127 
1128 
1129 void CVPCB_MAINFRAME::SetStatusText( const wxString& aText, int aNumber )
1130 {
1131  switch( aNumber )
1132  {
1133  case 0: m_statusLine1->SetLabel( aText ); break;
1134  case 1: m_statusLine2->SetLabel( aText ); break;
1135  case 2: m_statusLine3->SetLabel( aText ); break;
1136  default: wxFAIL_MSG( wxT( "Invalid status row number" ) ); break;
1137  }
1138 }
1139 
1140 
1142 {
1144  ReCreateHToolbar();
1145  DisplayStatus();
1146 }
1147 
1148 
1150 {
1151  const std::string& payload = mail.GetPayload();
1152 
1153  switch( mail.Command() )
1154  {
1155  case MAIL_EESCHEMA_NETLIST:
1156  // Disable Close events during ReadNetListAndFpFiles() to avoid crash when updating
1157  // widgets:
1158  m_cannotClose = true;
1159  ReadNetListAndFpFiles( payload );
1160  m_cannotClose = false;
1161  /* @todo
1162  Go into SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) and trim GNL_ALL down.
1163  */
1164  break;
1165 
1166  default:
1167  ; // ignore most
1168  }
1169 }
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
static TOOL_ACTION saveAssociationsToSchematic
Management actions.
Definition: cvpcb_actions.h:56
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:67
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
static TOOL_ACTION saveAssociationsToFile
Definition: cvpcb_actions.h:57
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:487
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:69
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:64
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.
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:68
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