KiCad PCB EDA Suite
panel_fp_lib_table.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 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
5  * Copyright (C) 2013-2021 CERN
6  * Copyright (C) 2012-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 
27 /* TODO:
28 
29 *) After any change to uri, reparse the environment variables.
30 
31 */
32 
33 
34 #include <set>
35 #include <wx/dir.h>
36 #include <wx/regex.h>
37 #include <wx/grid.h>
38 #include <wx/dirdlg.h>
39 #include <wx/filedlg.h>
40 
41 #include <project.h>
42 #include <3d_viewer/eda_3d_viewer.h> // for KICAD6_3DMODEL_DIR
43 #include <panel_fp_lib_table.h>
44 #include <lib_id.h>
45 #include <fp_lib_table.h>
46 #include <lib_table_lexer.h>
47 #include <invoke_pcb_dialog.h>
48 #include <bitmaps.h>
49 #include <grid_tricks.h>
50 #include <widgets/wx_grid.h>
51 #include <confirm.h>
52 #include <lib_table_grid.h>
54 #include <pgm_base.h>
55 #include <pcb_edit_frame.h>
56 #include <env_paths.h>
58 #include <footprint_viewer_frame.h>
59 #include <footprint_edit_frame.h>
60 #include <kiway.h>
63 #include <pcbnew_id.h> // For ID_PCBNEW_END_LIST
65 #include <paths.h>
66 #include <macros.h>
67 
68 // clang-format off
69 
74 {
75  wxString m_Description;
76  wxString m_FileFilter;
77  wxString m_FolderSearchExtension;
78  bool m_IsFile;
80 };
81 
85 enum {
90 };
91 
97 static const std::map<int, SUPPORTED_FILE_TYPE>& fileTypes()
98 {
99  /*
100  * TODO(C++20): Clean this up
101  * This is wrapped inside a function to prevent a static initialization order fiasco
102  * with the file extension variables. Once C++20 is allowed in KiCad code, those file
103  * extensions can be made constexpr and this can be removed from a function call and
104  * placed in the file normally.
105  */
106  static const std::map<int, SUPPORTED_FILE_TYPE> fileTypes =
107  {
109  {
110  "KiCad (folder with .kicad_mod files)", "", KiCadFootprintFileExtension,
111  false, IO_MGR::KICAD_SEXP
112  }
113  },
115  {
116  "Eagle 6.x (*.lbr)", EagleFootprintLibPathWildcard(), "", true, IO_MGR::EAGLE
117  }
118  },
120  {
121  "KiCad legacy (*.mod)", LegacyFootprintLibPathWildcard(), "", true, IO_MGR::LEGACY
122  }
123  },
125  {
126  "Geda (folder with *.fp files)", "", GedaPcbFootprintLibFileExtension, false,
128  }
129  },
130  };
131 
132  return fileTypes;
133 }
134 // clang-format on
135 
136 
141 class LIBRARY_TRAVERSER : public wxDirTraverser
142 {
143 public:
144  LIBRARY_TRAVERSER( wxString aSearchExtension, wxString aInitialDir )
145  : m_searchExtension( aSearchExtension ),
146  m_currentDir( aInitialDir )
147  {
148  }
149 
150  virtual wxDirTraverseResult OnFile( const wxString& aFileName ) override
151  {
152  wxFileName file( aFileName );
153 
154  if( m_searchExtension.IsSameAs( file.GetExt(), false ) )
155  m_foundDirs.insert( { m_currentDir, 1 } );
156 
157  return wxDIR_CONTINUE;
158  }
159 
160  virtual wxDirTraverseResult OnOpenError( const wxString& aOpenErrorName ) override
161  {
162  m_failedDirs.insert( { aOpenErrorName, 1 } );
163  return wxDIR_IGNORE;
164  }
165 
167  {
168  return m_failedDirs.size() > 0;
169  }
170 
171  virtual wxDirTraverseResult OnDir( const wxString& aDirName ) override
172  {
173  m_currentDir = aDirName;
174  return wxDIR_CONTINUE;
175  }
176 
177  void GetPaths( wxArrayString& aPathArray )
178  {
179  for( std::pair<const wxString, int>& foundDirsPair : m_foundDirs )
180  aPathArray.Add( foundDirsPair.first );
181  }
182 
183  void GetFailedPaths( wxArrayString& aPathArray )
184  {
185  for( std::pair<const wxString, int>& failedDirsPair : m_failedDirs )
186  aPathArray.Add( failedDirsPair.first );
187  }
188 
189 private:
191  wxString m_currentDir;
192  std::unordered_map<wxString, int> m_foundDirs;
193  std::unordered_map<wxString, int> m_failedDirs;
194 };
195 
196 
201 {
202  friend class PANEL_FP_LIB_TABLE;
203  friend class FP_GRID_TRICKS;
204 
205 protected:
206  LIB_TABLE_ROW* at( size_t aIndex ) override { return &rows.at( aIndex ); }
207 
208  size_t size() const override { return rows.size(); }
209 
211  {
212  return dynamic_cast< LIB_TABLE_ROW* >( new FP_LIB_TABLE_ROW );
213  }
214 
215  LIB_TABLE_ROWS_ITER begin() override { return rows.begin(); }
216 
218  {
219  return rows.insert( aIterator, aRow );
220  }
221 
222  void push_back( LIB_TABLE_ROW* aRow ) override { rows.push_back( aRow ); }
223 
225  {
226  return rows.erase( aFirst, aLast );
227  }
228 
229 public:
230 
231  FP_LIB_TABLE_GRID( const FP_LIB_TABLE& aTableToEdit )
232  {
233  rows = aTableToEdit.rows;
234  }
235 };
236 
237 
238 #define MYID_OPTIONS_EDITOR 15151
239 
240 
242 {
243 public:
245  GRID_TRICKS( aGrid ),
246  m_dialog( aParent )
247  { }
248 
249 protected:
251 
252  void optionsEditor( int aRow )
253  {
254  FP_LIB_TABLE_GRID* tbl = (FP_LIB_TABLE_GRID*) m_grid->GetTable();
255 
256  if( tbl->GetNumberRows() > aRow )
257  {
258  LIB_TABLE_ROW* row = tbl->at( (size_t) aRow );
259  const wxString& options = row->GetOptions();
260  wxString result = options;
261 
262  InvokePluginOptionsEditor( m_dialog, row->GetNickName(), row->GetType(), options,
263  &result );
264 
265  if( options != result )
266  {
267  row->SetOptions( result );
268  m_grid->Refresh();
269  }
270  }
271  }
272 
273  bool handleDoubleClick( wxGridEvent& aEvent ) override
274  {
275  if( aEvent.GetCol() == COL_OPTIONS )
276  {
277  optionsEditor( aEvent.GetRow() );
278  return true;
279  }
280 
281  return false;
282  }
283 
284  void showPopupMenu( wxMenu& menu ) override
285  {
286  if( m_grid->GetGridCursorCol() == COL_OPTIONS )
287  {
288  menu.Append( MYID_OPTIONS_EDITOR, _( "Options Editor..." ), _( "Edit options" ) );
289  menu.AppendSeparator();
290  }
291 
293  }
294 
295  void doPopupSelection( wxCommandEvent& event ) override
296  {
297  if( event.GetId() == MYID_OPTIONS_EDITOR )
298  optionsEditor( m_grid->GetGridCursorRow() );
299  else
301  }
302 
305  void paste_text( const wxString& cb_text ) override
306  {
307  FP_LIB_TABLE_GRID* tbl = (FP_LIB_TABLE_GRID*) m_grid->GetTable();
308  size_t ndx = cb_text.find( "(fp_lib_table" );
309 
310  if( ndx != std::string::npos )
311  {
312  // paste the FP_LIB_TABLE_ROWs of s-expression (fp_lib_table), starting
313  // at column 0 regardless of current cursor column.
314 
315  STRING_LINE_READER slr( TO_UTF8( cb_text ), "Clipboard" );
316  LIB_TABLE_LEXER lexer( &slr );
317  FP_LIB_TABLE tmp_tbl;
318  bool parsed = true;
319 
320  try
321  {
322  tmp_tbl.Parse( &lexer );
323  }
324  catch( PARSE_ERROR& pe )
325  {
326  DisplayError( m_dialog, pe.What() );
327  parsed = false;
328  }
329 
330  if( parsed )
331  {
332  // make sure the table is big enough...
333  if( tmp_tbl.GetCount() > (unsigned) tbl->GetNumberRows() )
334  tbl->AppendRows( tmp_tbl.GetCount() - tbl->GetNumberRows() );
335 
336  for( unsigned i = 0; i < tmp_tbl.GetCount(); ++i )
337  tbl->rows.replace( i, tmp_tbl.At( i ).clone() );
338  }
339 
340  m_grid->AutoSizeColumns( false );
341  }
342  else
343  {
344  // paste spreadsheet formatted text.
345  GRID_TRICKS::paste_text( cb_text );
346 
347  m_grid->AutoSizeColumns( false );
348  }
349  }
350 };
351 
352 
354  FP_LIB_TABLE* aGlobal, const wxString& aGlobalTblPath,
355  FP_LIB_TABLE* aProject, const wxString& aProjectTblPath,
356  const wxString& aProjectBasePath ) :
357  PANEL_FP_LIB_TABLE_BASE( aParent ),
358  m_global( aGlobal ),
359  m_project( aProject ),
360  m_projectBasePath( aProjectBasePath ),
361  m_parent( aParent )
362 {
363  m_global_grid->SetTable( new FP_LIB_TABLE_GRID( *aGlobal ), true );
364 
365  // add Cut, Copy, and Paste to wxGrids
366  m_path_subs_grid->PushEventHandler( new GRID_TRICKS( m_path_subs_grid ) );
367 
368  wxArrayString choices;
369 
370  choices.Add( IO_MGR::ShowType( IO_MGR::KICAD_SEXP ) );
371  choices.Add( IO_MGR::ShowType( IO_MGR::LEGACY ) );
372  choices.Add( IO_MGR::ShowType( IO_MGR::EAGLE ) );
373  choices.Add( IO_MGR::ShowType( IO_MGR::GEDA_PCB ) );
374 
375  /* PCAD_PLUGIN does not support Footprint*() functions
376  choices.Add( IO_MGR::ShowType( IO_MGR::PCAD ) );
377  */
378  PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
379 
380  if( cfg->m_lastFootprintLibDir.IsEmpty() )
382 
384 
385  auto setupGrid =
386  [&]( WX_GRID* aGrid )
387  {
388  // Give a bit more room for wxChoice editors
389  aGrid->SetDefaultRowSize( aGrid->GetDefaultRowSize() + 4 );
390 
391  // add Cut, Copy, and Paste to wxGrids
392  aGrid->PushEventHandler( new FP_GRID_TRICKS( m_parent, aGrid ) );
393 
394  aGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
395  aGrid->AutoSizeColumns( false );
396 
397  wxGridCellAttr* attr;
398 
399  attr = new wxGridCellAttr;
400  attr->SetEditor( new GRID_CELL_PATH_EDITOR( m_parent, aGrid,
401  &cfg->m_lastFootprintLibDir,
402  wxEmptyString, true,
403  m_projectBasePath ) );
404  aGrid->SetColAttr( COL_URI, attr );
405 
406  attr = new wxGridCellAttr;
407  attr->SetEditor( new wxGridCellChoiceEditor( choices ) );
408  aGrid->SetColAttr( COL_TYPE, attr );
409 
410  attr = new wxGridCellAttr;
411  attr->SetRenderer( new wxGridCellBoolRenderer() );
412  attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS
413  aGrid->SetColAttr( COL_ENABLED, attr );
414 
415  // all but COL_OPTIONS, which is edited with Option Editor anyways.
416  aGrid->AutoSizeColumn( COL_NICKNAME, false );
417  aGrid->AutoSizeColumn( COL_TYPE, false );
418  aGrid->AutoSizeColumn( COL_URI, false );
419  aGrid->AutoSizeColumn( COL_DESCR, false );
420 
421  // would set this to width of title, if it was easily known.
422  aGrid->SetColSize( COL_OPTIONS, 80 );
423 
424  // Gives a selection to each grid, mainly for delete button. wxGrid's wake up with
425  // a currentCell which is sometimes not highlighted.
426  if( aGrid->GetNumberRows() > 0 )
427  aGrid->SelectRow( 0 );
428  };
429 
430  setupGrid( m_global_grid );
431 
433 
434  if( aProject )
435  {
436  m_project_grid->SetTable( new FP_LIB_TABLE_GRID( *aProject ), true );
437  setupGrid( m_project_grid );
438  }
439  else
440  {
441  m_pageNdx = 0;
442  m_notebook->DeletePage( 1 );
443  m_project_grid = nullptr;
444  }
445 
446  m_path_subs_grid->SetColLabelValue( 0, _( "Name" ) );
447  m_path_subs_grid->SetColLabelValue( 1, _( "Value" ) );
448 
449  // select the last selected page
450  m_notebook->SetSelection( m_pageNdx );
452 
453  // for ALT+A handling, we want the initial focus to be on the first selected grid.
455 
456  // Configure button logos
462 
463  // For aesthetic reasons, we must set the size of m_browseButton to match the other bitmaps
464  // manually (for instance m_append_button)
465  Layout(); // Needed at least on MSW to compute the actual buttons sizes, after initializing
466  // their bitmaps
467  wxSize buttonSize = m_append_button->GetSize();
468 
470  m_browseButton->SetMinSize( buttonSize );
471 
472  // Populate the browse library options
473  wxMenu* browseMenu = m_browseButton->GetSplitButtonMenu();
474 
475  for( const std::pair<const int, SUPPORTED_FILE_TYPE>& fileType : fileTypes() )
476  {
477  browseMenu->Append( fileType.first, fileType.second.m_Description );
478 
479  browseMenu->Bind( wxEVT_COMMAND_MENU_SELECTED, &PANEL_FP_LIB_TABLE::browseLibrariesHandler,
480  this, fileType.first );
481  }
482 
483  Layout();
484 
485  // Hack to make buttons lay out correctly the first time on Mac
486  wxSize hackSize = m_buttonsPanel->GetSize();
487  m_buttonsPanel->SetSize( wxSize( hackSize.x - 5, hackSize.y ) );
488  Layout();
489 
490  // This is the button only press for the browse button instead of the menu
491  m_browseButton->Bind( wxEVT_BUTTON, &PANEL_FP_LIB_TABLE::browseLibrariesHandler, this );
492 }
493 
494 
496 {
497  // When the dialog is closed it will hide the current notebook page first, which will
498  // in turn select the other one. We then end up saving its index as the "current page".
499  // So flip them back again:
500  m_pageNdx = m_pageNdx == 1 ? 0 : 1;
501 
502  // Delete the GRID_TRICKS.
503  // Any additional event handlers should be popped before the window is deleted.
504  m_global_grid->PopEventHandler( true );
505 
506  if( m_project_grid )
507  m_project_grid->PopEventHandler( true );
508 
509  m_path_subs_grid->PopEventHandler( true );
510 }
511 
512 
514 {
515  wxString msg;
516 
517  for( FP_LIB_TABLE_GRID* model : { global_model(), project_model() } )
518  {
519  if( !model )
520  continue;
521 
522  for( int r = 0; r < model->GetNumberRows(); )
523  {
524  wxString nick = model->GetValue( r, COL_NICKNAME ).Trim( false ).Trim();
525  wxString uri = model->GetValue( r, COL_URI ).Trim( false ).Trim();
526  unsigned illegalCh = 0;
527 
528  if( !nick || !uri )
529  {
530  if( !nick && !uri )
531  msg = _( "A library table row nickname and path cells are empty." );
532  else if( !nick )
533  msg = _( "A library table row nickname cell is empty." );
534  else
535  msg = _( "A library table row path cell is empty." );
536 
537  wxMessageDialog badCellDlg( this, msg, _( "Invalid Row Definition" ),
538  wxYES_NO | wxCENTER | wxICON_QUESTION | wxYES_DEFAULT );
539  badCellDlg.SetExtendedMessage( _( "Empty cells will result in all rows that are "
540  "invalid to be removed from the table." ) );
541  badCellDlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( "Remove Invalid Cells" ),
542  wxMessageDialog::ButtonLabel( "Cancel Table Update" ) );
543 
544  if( badCellDlg.ShowModal() == wxID_NO )
545  return false;
546 
547  // Delete the "empty" row, where empty means missing nick or uri.
548  // This also updates the UI which could be slow, but there should only be a few
549  // rows to delete, unless the user fell asleep on the Add Row
550  // button.
551  model->DeleteRows( r, 1 );
552  }
553  else if( ( illegalCh = LIB_ID::FindIllegalLibraryNameChar( nick ) ) )
554  {
555  msg = wxString::Format( _( "Illegal character '%c' in nickname '%s'." ),
556  illegalCh,
557  nick );
558 
559  // show the tabbed panel holding the grid we have flunked:
560  if( model != cur_model() )
561  m_notebook->SetSelection( model == global_model() ? 0 : 1 );
562 
563  m_cur_grid->MakeCellVisible( r, 0 );
564  m_cur_grid->SetGridCursor( r, 1 );
565 
566  wxMessageDialog errdlg( this, msg, _( "Library Nickname Error" ) );
567  errdlg.ShowModal();
568  return false;
569  }
570  else
571  {
572  // set the trimmed values back into the table so they get saved to disk.
573  model->SetValue( r, COL_NICKNAME, nick );
574  model->SetValue( r, COL_URI, uri );
575  ++r; // this row was OK.
576  }
577  }
578  }
579 
580  // check for duplicate nickNames, separately in each table.
581  for( FP_LIB_TABLE_GRID* model : { global_model(), project_model() } )
582  {
583  if( !model )
584  continue;
585 
586  for( int r1 = 0; r1 < model->GetNumberRows() - 1; ++r1 )
587  {
588  wxString nick1 = model->GetValue( r1, COL_NICKNAME );
589 
590  for( int r2 = r1 + 1; r2 < model->GetNumberRows(); ++r2 )
591  {
592  wxString nick2 = model->GetValue( r2, COL_NICKNAME );
593 
594  if( nick1 == nick2 )
595  {
596  msg = wxString::Format( _( "Multiple libraries cannot share the same "
597  "nickname ('%s')." ),
598  nick1 );
599 
600  // show the tabbed panel holding the grid we have flunked:
601  if( model != cur_model() )
602  m_notebook->SetSelection( model == global_model() ? 0 : 1 );
603 
604  // go to the lower of the two rows, it is technically the duplicate:
605  m_cur_grid->MakeCellVisible( r2, 0 );
606  m_cur_grid->SetGridCursor( r2, 1 );
607 
608  wxMessageDialog errdlg( this, msg, _( "Library Nickname Error" ) );
609  errdlg.ShowModal();
610  return false;
611  }
612  }
613  }
614  }
615 
616  return true;
617 }
618 
619 
620 void PANEL_FP_LIB_TABLE::OnUpdateUI( wxUpdateUIEvent& event )
621 {
622  m_pageNdx = (unsigned) std::max( 0, m_notebook->GetSelection() );
624 }
625 
626 
627 void PANEL_FP_LIB_TABLE::appendRowHandler( wxCommandEvent& event )
628 {
630  return;
631 
632  if( m_cur_grid->AppendRows( 1 ) )
633  {
634  int last_row = m_cur_grid->GetNumberRows() - 1;
635 
636  // wx documentation is wrong, SetGridCursor does not make visible.
637  m_cur_grid->MakeCellVisible( last_row, 0 );
638  m_cur_grid->SetGridCursor( last_row, 1 );
639  m_cur_grid->EnableCellEditControl( true );
640  m_cur_grid->ShowCellEditControl();
641  }
642 }
643 
644 
645 void PANEL_FP_LIB_TABLE::deleteRowHandler( wxCommandEvent& event )
646 {
648  return;
649 
650  int curRow = m_cur_grid->GetGridCursorRow();
651  int curCol = m_cur_grid->GetGridCursorCol();
652 
653  // In a wxGrid, collect rows that have a selected cell, or are selected
654  // It is not so easy: it depends on the way the selection was made.
655  // Here, we collect rows selected by clicking on a row label, and rows that contain any
656  // previously-selected cells.
657  // If no candidate, just delete the row with the grid cursor.
658  wxArrayInt selectedRows = m_cur_grid->GetSelectedRows();
659  wxGridCellCoordsArray cells = m_cur_grid->GetSelectedCells();
660  wxGridCellCoordsArray blockTopLeft = m_cur_grid->GetSelectionBlockTopLeft();
661  wxGridCellCoordsArray blockBotRight = m_cur_grid->GetSelectionBlockBottomRight();
662 
663  // Add all row having cell selected to list:
664  for( unsigned ii = 0; ii < cells.GetCount(); ii++ )
665  selectedRows.Add( cells[ii].GetRow() );
666 
667  // Handle block selection
668  if( !blockTopLeft.IsEmpty() && !blockBotRight.IsEmpty() )
669  {
670  for( int i = blockTopLeft[0].GetRow(); i <= blockBotRight[0].GetRow(); ++i )
671  selectedRows.Add( i );
672  }
673 
674  // Use the row having the grid cursor only if we have no candidate:
675  if( selectedRows.size() == 0 && m_cur_grid->GetGridCursorRow() >= 0 )
676  selectedRows.Add( m_cur_grid->GetGridCursorRow() );
677 
678  if( selectedRows.size() == 0 )
679  {
680  wxBell();
681  return;
682  }
683 
684  std::sort( selectedRows.begin(), selectedRows.end() );
685 
686  // Remove selected rows (note: a row can be stored more than once in list)
687  int last_row = -1;
688 
689  for( int ii = selectedRows.GetCount()-1; ii >= 0; ii-- )
690  {
691  int row = selectedRows[ii];
692 
693  if( row != last_row )
694  {
695  last_row = row;
696  m_cur_grid->DeleteRows( row, 1 );
697  }
698  }
699 
700  if( m_cur_grid->GetNumberRows() > 0 && curRow >= 0 )
701  m_cur_grid->SetGridCursor( std::min( curRow, m_cur_grid->GetNumberRows() - 1 ), curCol );
702 }
703 
704 
705 void PANEL_FP_LIB_TABLE::moveUpHandler( wxCommandEvent& event )
706 {
708  return;
709 
710  FP_LIB_TABLE_GRID* tbl = cur_model();
711  int curRow = m_cur_grid->GetGridCursorRow();
712 
713  // @todo: add multiple selection moves.
714  if( curRow >= 1 )
715  {
716  boost::ptr_vector< LIB_TABLE_ROW >::auto_type move_me =
717  tbl->rows.release( tbl->rows.begin() + curRow );
718 
719  --curRow;
720  tbl->rows.insert( tbl->rows.begin() + curRow, move_me.release() );
721 
722  if( tbl->GetView() )
723  {
724  // Update the wxGrid
725  wxGridTableMessage msg( tbl, wxGRIDTABLE_NOTIFY_ROWS_INSERTED, curRow, 0 );
726  tbl->GetView()->ProcessTableMessage( msg );
727  }
728 
729  m_cur_grid->MakeCellVisible( curRow, m_cur_grid->GetGridCursorCol() );
730  m_cur_grid->SetGridCursor( curRow, m_cur_grid->GetGridCursorCol() );
731  }
732 }
733 
734 
735 void PANEL_FP_LIB_TABLE::moveDownHandler( wxCommandEvent& event )
736 {
738  return;
739 
740  FP_LIB_TABLE_GRID* tbl = cur_model();
741  int curRow = m_cur_grid->GetGridCursorRow();
742 
743  // @todo: add multiple selection moves.
744  if( unsigned( curRow + 1 ) < tbl->rows.size() )
745  {
746  boost::ptr_vector< LIB_TABLE_ROW >::auto_type move_me =
747  tbl->rows.release( tbl->rows.begin() + curRow );
748 
749  ++curRow;
750  tbl->rows.insert( tbl->rows.begin() + curRow, move_me.release() );
751 
752  if( tbl->GetView() )
753  {
754  // Update the wxGrid
755  wxGridTableMessage msg( tbl, wxGRIDTABLE_NOTIFY_ROWS_INSERTED, curRow - 1, 0 );
756  tbl->GetView()->ProcessTableMessage( msg );
757  }
758 
759  m_cur_grid->MakeCellVisible( curRow, m_cur_grid->GetGridCursorCol() );
760  m_cur_grid->SetGridCursor( curRow, m_cur_grid->GetGridCursorCol() );
761  }
762 }
763 
764 
765 void PANEL_FP_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event )
766 {
768  return;
769 
770  std::map<int, SUPPORTED_FILE_TYPE>::const_iterator fileTypeIt;
771 
772  // We are bound both to the menu and button with this one handler
773  // So we must set the file type based on it
774  if( event.GetEventType() == wxEVT_BUTTON )
775  {
776  // Let's default to adding a kicad footprint file for just the footprint
777  fileTypeIt = fileTypes().find( ID_PANEL_FPLIB_ADD_KICADMOD );
778  }
779  else
780  {
781  fileTypeIt = fileTypes().find( event.GetId() );
782  }
783 
784  if( fileTypeIt == fileTypes().end() )
785  {
786  wxLogWarning( "File type selection event received but could not find the file type in the table" );
787  return;
788  }
789 
790  SUPPORTED_FILE_TYPE fileType = fileTypeIt->second;
791 
792  PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
793 
794  wxArrayString files;
795 
796  wxString title;
797 
798  title.Printf( _( "Select %s Library" ), fileType.m_Description );
799 
800  wxString openDir = cfg->m_lastFootprintLibDir;
801  if( m_cur_grid == m_project_grid )
802  {
803  openDir = m_lastProjectLibDir;
804  }
805 
806  if( fileType.m_IsFile )
807  {
808  wxFileDialog dlg( this, title, openDir, wxEmptyString,
809  fileType.m_FileFilter,
810  wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE );
811 
812  int result = dlg.ShowModal();
813 
814  if( result == wxID_CANCEL )
815  return;
816 
817  dlg.GetPaths( files );
818 
819  cfg->m_lastFootprintLibDir = dlg.GetDirectory();
820  }
821  else
822  {
823  wxDirDialog dlg( nullptr, title, openDir,
824  wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
825 
826  int result = dlg.ShowModal();
827 
828  if( result == wxID_CANCEL )
829  return;
830 
831  // is there a file extension configured to hunt out their containing folders?
832  if( fileType.m_FolderSearchExtension != "" )
833  {
834  wxDir rootDir( dlg.GetPath() );
835 
836  LIBRARY_TRAVERSER traverser( fileType.m_FolderSearchExtension, rootDir.GetName() );
837  rootDir.Traverse( traverser );
838 
839  traverser.GetPaths( files );
840 
841  if( traverser.HasDirectoryOpenFailures() )
842  {
843  wxArrayString failedDirs;
844  traverser.GetPaths( failedDirs );
845  wxString detailedMsg = _( "The following directories could not be opened: \n" );
846 
847  for( const wxString& path : failedDirs )
848  detailedMsg << path << "\n";
849 
850  DisplayErrorMessage( this, _( "Failed to open directories to look for libraries" ),
851  detailedMsg );
852  }
853  }
854  else
855  {
856  files.Add( dlg.GetPath() );
857  }
858 
859  if( m_cur_grid == m_global_grid )
860  {
861  cfg->m_lastFootprintLibDir = dlg.GetPath();
862  }
863  else
864  {
865  m_lastProjectLibDir = dlg.GetPath();
866  }
867  }
868 
869  // Drop the last directory if the path is a .pretty folder
871  cfg->m_lastFootprintLibDir = cfg->m_lastFootprintLibDir.BeforeLast( wxFileName::GetPathSeparator() );
872 
873  const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
874  bool addDuplicates = false;
875  bool applyToAll = false;
876  wxString warning = _( "Warning: Duplicate Nicknames" );
877  wxString msg = _( "A library nicknamed '%s' already exists." );
878  wxString detailedMsg = _( "One of the nicknames will need to be changed after "
879  "adding this library." );
880 
881  for( const wxString& filePath : files )
882  {
883  wxFileName fn( filePath );
884  wxString nickname = LIB_ID::FixIllegalChars( fn.GetName() );
885  bool doAdd = true;
886 
887  if( cur_model()->ContainsNickname( nickname ) )
888  {
889  if( !applyToAll )
890  {
891  // The cancel button adds the library to the table anyway
892  addDuplicates = OKOrCancelDialog( this, warning, wxString::Format( msg, nickname ),
893  detailedMsg, _( "Skip" ), _( "Add Anyway" ),
894  &applyToAll ) == wxID_CANCEL;
895  }
896 
897  doAdd = addDuplicates;
898  }
899 
900  if( doAdd && m_cur_grid->AppendRows( 1 ) )
901  {
902  int last_row = m_cur_grid->GetNumberRows() - 1;
903 
904  m_cur_grid->SetCellValue( last_row, COL_NICKNAME, nickname );
905 
906  m_cur_grid->SetCellValue( last_row, COL_TYPE, IO_MGR::ShowType( fileType.m_Plugin ) );
907 
908  // try to use path normalized to an environmental variable or project path
909  wxString path = NormalizePath( filePath, &envVars, m_projectBasePath );
910 
911  // Do not use the project path in the global library table. This will almost
912  // assuredly be wrong for a different project.
913  if( path.IsEmpty() || ( m_pageNdx == 0 && path.Contains( "${KIPRJMOD}" ) ) )
914  path = fn.GetFullPath();
915 
916  m_cur_grid->SetCellValue( last_row, COL_URI, path );
917  }
918  }
919 
920  if( !files.IsEmpty() )
921  {
922  int new_row = m_cur_grid->GetNumberRows() - 1;
923  m_cur_grid->MakeCellVisible( new_row, m_cur_grid->GetGridCursorCol() );
924  m_cur_grid->SetGridCursor( new_row, m_cur_grid->GetGridCursorCol() );
925  }
926 }
927 
928 
930 {
931  // Account for scroll bars
932  aWidth -= ( m_path_subs_grid->GetSize().x - m_path_subs_grid->GetClientSize().x );
933 
934  m_path_subs_grid->AutoSizeColumn( 0 );
935 
936  if( aWidth - m_path_subs_grid->GetColSize( 0 ) < 60 )
937  m_path_subs_grid->SetColSize( 0, aWidth / 2 );
938 
939  m_path_subs_grid->SetColSize( 1, aWidth - m_path_subs_grid->GetColSize( 0 ) );
940 }
941 
942 
943 void PANEL_FP_LIB_TABLE::onSizeGrid( wxSizeEvent& event )
944 {
945  adjustPathSubsGridColumns( event.GetSize().GetX() );
946 
947  event.Skip();
948 }
949 
950 
952 {
954  return false;
955 
956  if( verifyTables() )
957  {
958  if( *global_model() != *m_global )
959  {
961 
962  m_global->Clear();
963  m_global->rows.transfer( m_global->rows.end(), global_model()->rows.begin(),
964  global_model()->rows.end(), global_model()->rows );
965  m_global->reindex();
966  }
967 
968  if( project_model() && *project_model() != *m_project )
969  {
971 
972  m_project->Clear();
973  m_project->rows.transfer( m_project->rows.end(), project_model()->rows.begin(),
974  project_model()->rows.end(), project_model()->rows );
975  m_project->reindex();
976  }
977 
978  return true;
979  }
980 
981  return false;
982 }
983 
984 
988 {
989  wxRegEx re( ".*?(\\$\\{(.+?)\\})|(\\$\\((.+?)\\)).*?", wxRE_ADVANCED );
990  wxASSERT( re.IsValid() ); // wxRE_ADVANCED is required.
991 
992  std::set< wxString > unique;
993 
994  // clear the table
995  m_path_subs_grid->DeleteRows( 0, m_path_subs_grid->GetNumberRows() );
996 
997  for( FP_LIB_TABLE_GRID* tbl : { global_model(), project_model() } )
998  {
999  if( !tbl )
1000  continue;
1001 
1002  for( int row = 0; row < tbl->GetNumberRows(); ++row )
1003  {
1004  wxString uri = tbl->GetValue( row, COL_URI );
1005 
1006  while( re.Matches( uri ) )
1007  {
1008  wxString envvar = re.GetMatch( uri, 2 );
1009 
1010  // if not ${...} form then must be $(...)
1011  if( envvar.IsEmpty() )
1012  envvar = re.GetMatch( uri, 4 );
1013 
1014  // ignore duplicates
1015  unique.insert( envvar );
1016 
1017  // delete the last match and search again
1018  uri.Replace( re.GetMatch( uri, 0 ), wxEmptyString );
1019  }
1020  }
1021  }
1022 
1023  // Make sure this special environment variable shows up even if it was
1024  // not used yet. It is automatically set by KiCad to the directory holding
1025  // the current project.
1026  unique.insert( PROJECT_VAR_NAME );
1027  unique.insert( FP_LIB_TABLE::GlobalPathEnvVariableName() );
1028  // This special environment variable is used to locate 3d shapes
1029  unique.insert( KICAD6_3DMODEL_DIR );
1030 
1031  for( const wxString& evName : unique )
1032  {
1033  int row = m_path_subs_grid->GetNumberRows();
1034  m_path_subs_grid->AppendRows( 1 );
1035 
1036  m_path_subs_grid->SetCellValue( row, 0, wxT( "${" ) + evName + wxT( "}" ) );
1037  m_path_subs_grid->SetCellEditor( row, 0, new GRID_CELL_READONLY_TEXT_EDITOR() );
1038 
1039  wxString evValue;
1040  wxGetEnv( evName, &evValue );
1041  m_path_subs_grid->SetCellValue( row, 1, evValue );
1042  m_path_subs_grid->SetCellEditor( row, 1, new GRID_CELL_READONLY_TEXT_EDITOR() );
1043  }
1044 
1045  // No combobox editors here, but it looks better if its consistent with the other
1046  // grids in the dialog.
1047  m_path_subs_grid->SetDefaultRowSize( m_path_subs_grid->GetDefaultRowSize() + 2 );
1048 
1049  adjustPathSubsGridColumns( m_path_subs_grid->GetRect().GetWidth() );
1050 }
1051 
1052 //-----</event handlers>---------------------------------
1053 
1054 
1055 
1057 
1058 
1059 void InvokePcbLibTableEditor( KIWAY* aKiway, wxWindow* aCaller )
1060 {
1061  FP_LIB_TABLE* globalTable = &GFootprintTable;
1062  wxString globalTablePath = FP_LIB_TABLE::GetGlobalTableFileName();
1063  FP_LIB_TABLE* projectTable = aKiway->Prj().PcbFootprintLibs();
1064  wxString projectTablePath = aKiway->Prj().FootprintLibTblName();
1065  wxString msg;
1066 
1067  DIALOG_EDIT_LIBRARY_TABLES dlg( aCaller, _( "Footprint Libraries" ) );
1068  dlg.SetKiway( &dlg, aKiway );
1069 
1070  if( aKiway->Prj().IsNullProject() )
1071  projectTable = nullptr;
1072 
1073  dlg.InstallPanel( new PANEL_FP_LIB_TABLE( &dlg, globalTable, globalTablePath,
1074  projectTable, projectTablePath,
1075  aKiway->Prj().GetProjectPath() ) );
1076 
1077  if( dlg.ShowModal() == wxID_CANCEL )
1078  return;
1079 
1080  if( dlg.m_GlobalTableChanged )
1081  {
1082  try
1083  {
1084  globalTable->Save( globalTablePath );
1085  }
1086  catch( const IO_ERROR& ioe )
1087  {
1088  msg.Printf( _( "Error saving global library table:\n\n%s" ), ioe.What() );
1089  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
1090  }
1091  }
1092 
1093  if( projectTable && dlg.m_ProjectTableChanged )
1094  {
1095  try
1096  {
1097  projectTable->Save( projectTablePath );
1098  }
1099  catch( const IO_ERROR& ioe )
1100  {
1101  msg.Printf( _( "Error saving project-specific library table:\n\n%s" ), ioe.What() );
1102  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
1103  }
1104  }
1105 
1106  auto editor = (FOOTPRINT_EDIT_FRAME*) aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
1107 
1108  if( editor )
1109  {
1110  editor->SyncLibraryTree( true );
1111  editor->RefreshLibraryTree();
1112  }
1113 
1114  auto viewer = (FOOTPRINT_VIEWER_FRAME*) aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );
1115 
1116  if( viewer )
1117  viewer->ReCreateLibraryList();
1118 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:252
FP_GRID_TRICKS(DIALOG_EDIT_LIBRARY_TABLES *aParent, WX_GRID *aGrid)
void SetKiway(wxWindow *aDest, KIWAY *aKiway)
It is only used for debugging, since "this" is not a wxWindow*.
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib=false)
Replace illegal LIB_ID item name characters with underscores '_'.
Definition: lib_id.cpp:347
void push_back(LIB_TABLE_ROW *aRow) override
const wxString & GetOptions() const
Return the options string, which may hold a password or anything else needed to instantiate the under...
void moveDownHandler(wxCommandEvent &event) override
wxString EagleFootprintLibPathWildcard()
void InvokePluginOptionsEditor(wxWindow *aCaller, const wxString &aNickname, const wxString &aPluginType, const wxString &aOptions, wxString *aResult)
Function InvokePluginOptionsEditor calls DIALOG_FP_PLUGIN_OPTIONS dialog so that plugin options set c...
void SetBitmap(const wxBitmap &aBmp)
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
FP_LIB_TABLE GFootprintTable
!!!!!!!!!!!!!! This code is obsolete because of the merge into pcbnew, don't bother with it.
Definition: cvpcb.cpp:120
Container that describes file type info for the add a library options.
void Clear()
Delete all rows.
void GetFailedPaths(wxArrayString &aPathArray)
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:265
#define KICAD6_3DMODEL_DIR
A variable name whose value holds the path of 3D shape files.
Definition: eda_3d_viewer.h:45
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:40
wxMenu * GetSplitButtonMenu()
This file is part of the common library.
void showPopupMenu(wxMenu &menu) override
void reindex()
const std::string KiCadFootprintFileExtension
FP_LIB_TABLE * m_project
bool ContainsNickname(const wxString &aNickname)
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition: kiway.cpp:184
unsigned GetCount() const
Get the number of rows contained in the table.
virtual wxDirTraverseResult OnFile(const wxString &aFileName) override
#define PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
Definition: project.h:38
Component library viewer main window.
void appendRowHandler(wxCommandEvent &event) override
void SetMinSize(const wxSize &aSize) override
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:52
void adjustPathSubsGridColumns(int aWidth)
#define MYID_OPTIONS_EDITOR
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:368
static const std::map< int, SUPPORTED_FILE_TYPE > & fileTypes()
Map with event id as the key to supported file types that will be listed for the add a library option...
IO_MGR::PCB_FILE_T m_Plugin
LIB_TABLE_ROWS rows
void SetTable(wxGridTableBase *table, bool aTakeOwnership=false)
Hide wxGrid's SetTable() method with one which doesn't mess up the grid column widths when setting th...
Definition: wx_grid.cpp:65
static const wxString ShowType(PCB_FILE_T aFileType)
Return a brief name for a plugin given aFileType enum.
Definition: io_mgr.cpp:77
virtual const wxString GetType() const =0
Return the type of library represented by this row.
int GetNumberRows() override
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
wxString LegacyFootprintLibPathWildcard()
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:123
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:98
Geda PCB file formats.
Definition: io_mgr.h:63
size_t size() const override
This file contains miscellaneous commonly used macros and functions.
This abstract base class mixes any object derived from LIB_TABLE into wxGridTableBase so the result c...
LIB_TABLE_ROWS_ITER insert(LIB_TABLE_ROWS_ITER aIterator, LIB_TABLE_ROW *aRow) override
void InvokePcbLibTableEditor(KIWAY *aKiway, wxWindow *aCaller)
Function InvokePcbLibTableEditor shows the modal DIALOG_FP_LIB_TABLE for purposes of editing the glob...
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:81
virtual void paste_text(const wxString &cb_text)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
static size_t m_pageNdx
void moveUpHandler(wxCommandEvent &event) override
const wxString & GetNickName() const
static const wxString GlobalPathEnvVariableName()
Return the name of the environment variable used to hold the directory of locally installed "KiCad sp...
LIB_TABLE_ROW * clone() const
virtual void Parse(LIB_TABLE_LEXER *aLexer) override
Parse the #LIB_TABLE_LEXER s-expression library table format into the appropriate LIB_TABLE_ROW objec...
PANEL_FP_LIB_TABLE(DIALOG_EDIT_LIBRARY_TABLES *aParent, FP_LIB_TABLE *aGlobal, const wxString &aGlobalTblPath, FP_LIB_TABLE *aProject, const wxString &aProjectTblPath, const wxString &aProjectBasePath)
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
FP_LIB_TABLE_GRID * global_model() const
DIALOG_EDIT_LIBRARY_TABLES * m_dialog
std::unordered_map< wxString, int > m_foundDirs
FP_LIB_TABLE_GRID * project_model() const
FP_LIB_TABLE_GRID * cur_model() const
void paste_text(const wxString &cb_text) override
handle specialized clipboard text, with leading "(fp_lib_table", OR spreadsheet formatted text.
Definition of file extensions used in Kicad.
bool m_IsFile
Whether the library is a folder or a file.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
void deleteRowHandler(wxCommandEvent &event) override
Editor for wxGrid cells that adds a file/folder browser to the grid input field.
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:182
bool AppendRows(size_t aNumRows=1) override
void optionsEditor(int aRow)
FormatType fileType(const char *aFileName)
Definition: loadmodel.cpp:273
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
Definition: project.cpp:135
void browseLibrariesHandler(wxCommandEvent &event)
bool verifyTables()
Trim important fields, removes blank row entries, and checks for duplicates.
void SetWidthPadding(int aPadding)
Class PANEL_FP_LIB_TABLE_BASE.
LIB_TABLE_ROWS_ITER begin() override
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:285
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
void OnUpdateUI(wxUpdateUIEvent &event) override
wxString m_FolderSearchExtension
In case of folders it stands for extensions of files stored inside.
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, wxString aDetailedMessage, wxString aOKLabel, wxString aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
Definition: confirm.cpp:220
bool TransferDataFromWindow() override
virtual wxDirTraverseResult OnDir(const wxString &aDirName) override
LIBRARY_TRAVERSER(wxString aSearchExtension, wxString aInitialDir)
static wxString GetDefaultUserFootprintsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:108
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:118
Legacy Pcbnew file formats prior to s-expression.
Definition: io_mgr.h:54
see class PGM_BASE
virtual void doPopupSelection(wxCommandEvent &event)
Declaration of the eda_3d_viewer class.
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
LIB_TABLE_ROW & At(unsigned aIndex)
Get the 'n'th LIB_TABLE_ROW object.
LIB_TABLE_ROW * makeNewRow() override
virtual void showPopupMenu(wxMenu &menu)
FP_LIB_TABLE_GRID(const FP_LIB_TABLE &aTableToEdit)
#define _(s)
Definition: 3d_actions.cpp:33
virtual wxDirTraverseResult OnOpenError(const wxString &aOpenErrorName) override
void GetPaths(wxArrayString &aPathArray)
LIB_TABLE_ROWS::iterator LIB_TABLE_ROWS_ITER
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
Traverser implementation that looks to find any and all "folder" libraries by looking for files with ...
LIB_TABLE_ROWS_ITER erase(LIB_TABLE_ROWS_ITER aFirst, LIB_TABLE_ROWS_ITER aLast) override
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.
const std::string GedaPcbFootprintLibFileExtension
DIALOG_EDIT_LIBRARY_TABLES * m_parent
void SetOptions(const wxString &aOptions)
Change the library options strings.
void onSizeGrid(wxSizeEvent &event) override
FP_LIB_TABLE * m_global
Dialog to show and edit symbol library tables.
wxString m_Description
Description shown in the file picker dialog.
wxString m_lastFootprintLibDir
wxString m_FileFilter
Filter used for file pickers if m_IsFile is true.
std::unordered_map< wxString, int > m_failedDirs
PCB_FILE_T
The set of file types that the IO_MGR knows about, and for which there has been a plugin written.
Definition: io_mgr.h:52
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:237
bool handleDoubleClick(wxGridEvent &aEvent) override
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
const std::string KiCadFootprintLibPathExtension
void doPopupSelection(wxCommandEvent &event) override
LIB_TABLE_ROW * at(size_t aIndex) override
virtual const wxString FootprintLibTblName() const
Returns the path and filename of this project's footprint library table.
Definition: project.cpp:147
wxString NormalizePath(const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const wxString &aProjectPath)
Normalize a file path to an environmental variable, if possible.
Definition: env_paths.cpp:67
static wxString GetGlobalTableFileName()
void populateEnvironReadOnlyTable()
Populate the readonly environment variable table with names and values by examining all the full_uri ...
S-expression Pcbnew file format.
Definition: io_mgr.h:55
static unsigned FindIllegalLibraryNameChar(const UTF8 &aLibraryName)
Looks for characters that are illegal in library nicknames.
Definition: lib_id.cpp:398