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 <[email protected]>
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_frame.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  wxT( "KiCad (folder with .kicad_mod files)" ), wxEmptyString,
112  }
113  },
115  {
116  wxT( "Eagle 6.x (*.lbr)" ), EagleFootprintLibPathWildcard(), wxEmptyString,
117  true, IO_MGR::EAGLE
118  }
119  },
121  {
122  wxT( "KiCad legacy (*.mod)" ), LegacyFootprintLibPathWildcard(), wxEmptyString,
123  true, IO_MGR::LEGACY
124  }
125  },
127  {
128  wxT( "Geda (folder with *.fp files)" ), wxEmptyString,
130  }
131  },
132  };
133 
134  return fileTypes;
135 }
136 // clang-format on
137 
138 
143 class LIBRARY_TRAVERSER : public wxDirTraverser
144 {
145 public:
146  LIBRARY_TRAVERSER( wxString aSearchExtension, wxString aInitialDir )
147  : m_searchExtension( aSearchExtension ),
148  m_currentDir( aInitialDir )
149  {
150  }
151 
152  virtual wxDirTraverseResult OnFile( const wxString& aFileName ) override
153  {
154  wxFileName file( aFileName );
155 
156  if( m_searchExtension.IsSameAs( file.GetExt(), false ) )
157  m_foundDirs.insert( { m_currentDir, 1 } );
158 
159  return wxDIR_CONTINUE;
160  }
161 
162  virtual wxDirTraverseResult OnOpenError( const wxString& aOpenErrorName ) override
163  {
164  m_failedDirs.insert( { aOpenErrorName, 1 } );
165  return wxDIR_IGNORE;
166  }
167 
169  {
170  return m_failedDirs.size() > 0;
171  }
172 
173  virtual wxDirTraverseResult OnDir( const wxString& aDirName ) override
174  {
175  m_currentDir = aDirName;
176  return wxDIR_CONTINUE;
177  }
178 
179  void GetPaths( wxArrayString& aPathArray )
180  {
181  for( std::pair<const wxString, int>& foundDirsPair : m_foundDirs )
182  aPathArray.Add( foundDirsPair.first );
183  }
184 
185  void GetFailedPaths( wxArrayString& aPathArray )
186  {
187  for( std::pair<const wxString, int>& failedDirsPair : m_failedDirs )
188  aPathArray.Add( failedDirsPair.first );
189  }
190 
191 private:
193  wxString m_currentDir;
194  std::unordered_map<wxString, int> m_foundDirs;
195  std::unordered_map<wxString, int> m_failedDirs;
196 };
197 
198 
203 {
204  friend class PANEL_FP_LIB_TABLE;
205  friend class FP_GRID_TRICKS;
206 
207 protected:
208  LIB_TABLE_ROW* at( size_t aIndex ) override { return &rows.at( aIndex ); }
209 
210  size_t size() const override { return rows.size(); }
211 
213  {
214  return dynamic_cast< LIB_TABLE_ROW* >( new FP_LIB_TABLE_ROW );
215  }
216 
217  LIB_TABLE_ROWS_ITER begin() override { return rows.begin(); }
218 
220  {
221  return rows.insert( aIterator, aRow );
222  }
223 
224  void push_back( LIB_TABLE_ROW* aRow ) override { rows.push_back( aRow ); }
225 
227  {
228  return rows.erase( aFirst, aLast );
229  }
230 
231 public:
232 
233  FP_LIB_TABLE_GRID( const FP_LIB_TABLE& aTableToEdit )
234  {
235  rows = aTableToEdit.rows;
236  }
237 };
238 
239 
240 #define MYID_OPTIONS_EDITOR 15151
241 
242 
244 {
245 public:
247  GRID_TRICKS( aGrid ),
248  m_dialog( aParent )
249  { }
250 
251 protected:
253 
254  void optionsEditor( int aRow )
255  {
256  FP_LIB_TABLE_GRID* tbl = (FP_LIB_TABLE_GRID*) m_grid->GetTable();
257 
258  if( tbl->GetNumberRows() > aRow )
259  {
260  LIB_TABLE_ROW* row = tbl->at( (size_t) aRow );
261  const wxString& options = row->GetOptions();
262  wxString result = options;
263 
264  InvokePluginOptionsEditor( m_dialog, row->GetNickName(), row->GetType(), options,
265  &result );
266 
267  if( options != result )
268  {
269  row->SetOptions( result );
270  m_grid->Refresh();
271  }
272  }
273  }
274 
275  bool handleDoubleClick( wxGridEvent& aEvent ) override
276  {
277  if( aEvent.GetCol() == COL_OPTIONS )
278  {
279  optionsEditor( aEvent.GetRow() );
280  return true;
281  }
282 
283  return false;
284  }
285 
286  void showPopupMenu( wxMenu& menu ) override
287  {
288  if( m_grid->GetGridCursorCol() == COL_OPTIONS )
289  {
290  menu.Append( MYID_OPTIONS_EDITOR, _( "Options Editor..." ), _( "Edit options" ) );
291  menu.AppendSeparator();
292  }
293 
295  }
296 
297  void doPopupSelection( wxCommandEvent& event ) override
298  {
299  if( event.GetId() == MYID_OPTIONS_EDITOR )
300  optionsEditor( m_grid->GetGridCursorRow() );
301  else
303  }
304 
307  void paste_text( const wxString& cb_text ) override
308  {
309  FP_LIB_TABLE_GRID* tbl = (FP_LIB_TABLE_GRID*) m_grid->GetTable();
310  size_t ndx = cb_text.find( "(fp_lib_table" );
311 
312  if( ndx != std::string::npos )
313  {
314  // paste the FP_LIB_TABLE_ROWs of s-expression (fp_lib_table), starting
315  // at column 0 regardless of current cursor column.
316 
317  STRING_LINE_READER slr( TO_UTF8( cb_text ), wxT( "Clipboard" ) );
318  LIB_TABLE_LEXER lexer( &slr );
319  FP_LIB_TABLE tmp_tbl;
320  bool parsed = true;
321 
322  try
323  {
324  tmp_tbl.Parse( &lexer );
325  }
326  catch( PARSE_ERROR& pe )
327  {
328  DisplayError( m_dialog, pe.What() );
329  parsed = false;
330  }
331 
332  if( parsed )
333  {
334  // make sure the table is big enough...
335  if( tmp_tbl.GetCount() > (unsigned) tbl->GetNumberRows() )
336  tbl->AppendRows( tmp_tbl.GetCount() - tbl->GetNumberRows() );
337 
338  for( unsigned i = 0; i < tmp_tbl.GetCount(); ++i )
339  tbl->rows.replace( i, tmp_tbl.At( i ).clone() );
340  }
341 
342  m_grid->AutoSizeColumns( false );
343  }
344  else
345  {
346  // paste spreadsheet formatted text.
347  GRID_TRICKS::paste_text( cb_text );
348 
349  m_grid->AutoSizeColumns( false );
350  }
351  }
352 };
353 
354 
356  FP_LIB_TABLE* aGlobal, const wxString& aGlobalTblPath,
357  FP_LIB_TABLE* aProject, const wxString& aProjectTblPath,
358  const wxString& aProjectBasePath ) :
359  PANEL_FP_LIB_TABLE_BASE( aParent ),
360  m_global( aGlobal ),
361  m_project( aProject ),
362  m_projectBasePath( aProjectBasePath ),
363  m_parent( aParent )
364 {
365  m_global_grid->SetTable( new FP_LIB_TABLE_GRID( *aGlobal ), true );
366 
367  // add Cut, Copy, and Paste to wxGrids
368  m_path_subs_grid->PushEventHandler( new GRID_TRICKS( m_path_subs_grid ) );
369 
370  wxArrayString choices;
371 
372  choices.Add( IO_MGR::ShowType( IO_MGR::KICAD_SEXP ) );
373  choices.Add( IO_MGR::ShowType( IO_MGR::LEGACY ) );
374  choices.Add( IO_MGR::ShowType( IO_MGR::EAGLE ) );
375  choices.Add( IO_MGR::ShowType( IO_MGR::GEDA_PCB ) );
376 
377  /* PCAD_PLUGIN does not support Footprint*() functions
378  choices.Add( IO_MGR::ShowType( IO_MGR::PCAD ) );
379  */
380  PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
381 
382  if( cfg->m_lastFootprintLibDir.IsEmpty() )
384 
386 
387  auto setupGrid =
388  [&]( WX_GRID* aGrid )
389  {
390  // Give a bit more room for wxChoice editors
391  aGrid->SetDefaultRowSize( aGrid->GetDefaultRowSize() + 4 );
392 
393  // add Cut, Copy, and Paste to wxGrids
394  aGrid->PushEventHandler( new FP_GRID_TRICKS( m_parent, aGrid ) );
395 
396  aGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
397  aGrid->AutoSizeColumns( false );
398 
399  wxGridCellAttr* attr;
400 
401  attr = new wxGridCellAttr;
402  attr->SetEditor( new GRID_CELL_PATH_EDITOR( m_parent, aGrid,
403  &cfg->m_lastFootprintLibDir,
404  wxEmptyString, true,
405  m_projectBasePath ) );
406  aGrid->SetColAttr( COL_URI, attr );
407 
408  attr = new wxGridCellAttr;
409  attr->SetEditor( new wxGridCellChoiceEditor( choices ) );
410  aGrid->SetColAttr( COL_TYPE, attr );
411 
412  attr = new wxGridCellAttr;
413  attr->SetRenderer( new wxGridCellBoolRenderer() );
414  attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS
415  aGrid->SetColAttr( COL_ENABLED, attr );
416 
417  // all but COL_OPTIONS, which is edited with Option Editor anyways.
418  aGrid->AutoSizeColumn( COL_NICKNAME, false );
419  aGrid->AutoSizeColumn( COL_TYPE, false );
420  aGrid->AutoSizeColumn( COL_URI, false );
421  aGrid->AutoSizeColumn( COL_DESCR, false );
422 
423  // would set this to width of title, if it was easily known.
424  aGrid->SetColSize( COL_OPTIONS, 80 );
425 
426  // Gives a selection to each grid, mainly for delete button. wxGrid's wake up with
427  // a currentCell which is sometimes not highlighted.
428  if( aGrid->GetNumberRows() > 0 )
429  aGrid->SelectRow( 0 );
430  };
431 
432  setupGrid( m_global_grid );
433 
435 
436  if( aProject )
437  {
438  m_project_grid->SetTable( new FP_LIB_TABLE_GRID( *aProject ), true );
439  setupGrid( m_project_grid );
440  }
441  else
442  {
443  m_pageNdx = 0;
444  m_notebook->DeletePage( 1 );
445  m_project_grid = nullptr;
446  }
447 
448  m_path_subs_grid->SetColLabelValue( 0, _( "Name" ) );
449  m_path_subs_grid->SetColLabelValue( 1, _( "Value" ) );
450 
451  // select the last selected page
452  m_notebook->SetSelection( m_pageNdx );
454 
455  // for ALT+A handling, we want the initial focus to be on the first selected grid.
457 
458  // Configure button logos
464 
465  // For aesthetic reasons, we must set the size of m_browseButton to match the other bitmaps
466  // manually (for instance m_append_button)
467  Layout(); // Needed at least on MSW to compute the actual buttons sizes, after initializing
468  // their bitmaps
469  wxSize buttonSize = m_append_button->GetSize();
470 
472  m_browseButton->SetMinSize( buttonSize );
473 
474  // Populate the browse library options
475  wxMenu* browseMenu = m_browseButton->GetSplitButtonMenu();
476 
477  for( const std::pair<const int, SUPPORTED_FILE_TYPE>& fileType : fileTypes() )
478  {
479  browseMenu->Append( fileType.first, fileType.second.m_Description );
480 
481  browseMenu->Bind( wxEVT_COMMAND_MENU_SELECTED, &PANEL_FP_LIB_TABLE::browseLibrariesHandler,
482  this, fileType.first );
483  }
484 
485  Layout();
486 
487  // Hack to make buttons lay out correctly the first time on Mac
488  wxSize hackSize = m_buttonsPanel->GetSize();
489  m_buttonsPanel->SetSize( wxSize( hackSize.x - 5, hackSize.y ) );
490  Layout();
491 
492  // This is the button only press for the browse button instead of the menu
493  m_browseButton->Bind( wxEVT_BUTTON, &PANEL_FP_LIB_TABLE::browseLibrariesHandler, this );
494 }
495 
496 
498 {
499  // When the dialog is closed it will hide the current notebook page first, which will
500  // in turn select the other one. We then end up saving its index as the "current page".
501  // So flip them back again:
502  m_pageNdx = m_pageNdx == 1 ? 0 : 1;
503 
504  // Delete the GRID_TRICKS.
505  // Any additional event handlers should be popped before the window is deleted.
506  m_global_grid->PopEventHandler( true );
507 
508  if( m_project_grid )
509  m_project_grid->PopEventHandler( true );
510 
511  m_path_subs_grid->PopEventHandler( true );
512 }
513 
514 
516 {
517  wxString msg;
518 
519  for( FP_LIB_TABLE_GRID* model : { global_model(), project_model() } )
520  {
521  if( !model )
522  continue;
523 
524  for( int r = 0; r < model->GetNumberRows(); )
525  {
526  wxString nick = model->GetValue( r, COL_NICKNAME ).Trim( false ).Trim();
527  wxString uri = model->GetValue( r, COL_URI ).Trim( false ).Trim();
528  unsigned illegalCh = 0;
529 
530  if( !nick || !uri )
531  {
532  if( !nick && !uri )
533  msg = _( "A library table row nickname and path cells are empty." );
534  else if( !nick )
535  msg = _( "A library table row nickname cell is empty." );
536  else
537  msg = _( "A library table row path cell is empty." );
538 
539  wxMessageDialog badCellDlg( this, msg, _( "Invalid Row Definition" ),
540  wxYES_NO | wxCENTER | wxICON_QUESTION | wxYES_DEFAULT );
541  badCellDlg.SetExtendedMessage( _( "Empty cells will result in all rows that are "
542  "invalid to be removed from the table." ) );
543  badCellDlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Remove Invalid Cells" ) ),
544  wxMessageDialog::ButtonLabel( _( "Cancel Table Update" ) ) );
545 
546  if( badCellDlg.ShowModal() == wxID_NO )
547  return false;
548 
549  // Delete the "empty" row, where empty means missing nick or uri.
550  // This also updates the UI which could be slow, but there should only be a few
551  // rows to delete, unless the user fell asleep on the Add Row
552  // button.
553  model->DeleteRows( r, 1 );
554  }
555  else if( ( illegalCh = LIB_ID::FindIllegalLibraryNameChar( nick ) ) )
556  {
557  msg = wxString::Format( _( "Illegal character '%c' in nickname '%s'." ),
558  illegalCh,
559  nick );
560 
561  // show the tabbed panel holding the grid we have flunked:
562  if( model != cur_model() )
563  m_notebook->SetSelection( model == global_model() ? 0 : 1 );
564 
565  m_cur_grid->MakeCellVisible( r, 0 );
566  m_cur_grid->SetGridCursor( r, 1 );
567 
568  wxMessageDialog errdlg( this, msg, _( "Library Nickname Error" ) );
569  errdlg.ShowModal();
570  return false;
571  }
572  else
573  {
574  // set the trimmed values back into the table so they get saved to disk.
575  model->SetValue( r, COL_NICKNAME, nick );
576  model->SetValue( r, COL_URI, uri );
577  ++r; // this row was OK.
578  }
579  }
580  }
581 
582  // check for duplicate nickNames, separately in each table.
583  for( FP_LIB_TABLE_GRID* model : { global_model(), project_model() } )
584  {
585  if( !model )
586  continue;
587 
588  for( int r1 = 0; r1 < model->GetNumberRows() - 1; ++r1 )
589  {
590  wxString nick1 = model->GetValue( r1, COL_NICKNAME );
591 
592  for( int r2 = r1 + 1; r2 < model->GetNumberRows(); ++r2 )
593  {
594  wxString nick2 = model->GetValue( r2, COL_NICKNAME );
595 
596  if( nick1 == nick2 )
597  {
598  msg = wxString::Format( _( "Multiple libraries cannot share the same "
599  "nickname ('%s')." ),
600  nick1 );
601 
602  // show the tabbed panel holding the grid we have flunked:
603  if( model != cur_model() )
604  m_notebook->SetSelection( model == global_model() ? 0 : 1 );
605 
606  // go to the lower of the two rows, it is technically the duplicate:
607  m_cur_grid->MakeCellVisible( r2, 0 );
608  m_cur_grid->SetGridCursor( r2, 1 );
609 
610  wxMessageDialog errdlg( this, msg, _( "Library Nickname Error" ) );
611  errdlg.ShowModal();
612  return false;
613  }
614  }
615  }
616  }
617 
618  return true;
619 }
620 
621 
622 void PANEL_FP_LIB_TABLE::OnUpdateUI( wxUpdateUIEvent& event )
623 {
624  m_pageNdx = (unsigned) std::max( 0, m_notebook->GetSelection() );
626 }
627 
628 
629 void PANEL_FP_LIB_TABLE::appendRowHandler( wxCommandEvent& event )
630 {
632  return;
633 
634  if( m_cur_grid->AppendRows( 1 ) )
635  {
636  int last_row = m_cur_grid->GetNumberRows() - 1;
637 
638  // wx documentation is wrong, SetGridCursor does not make visible.
639  m_cur_grid->MakeCellVisible( last_row, 0 );
640  m_cur_grid->SetGridCursor( last_row, 1 );
641  m_cur_grid->EnableCellEditControl( true );
642  m_cur_grid->ShowCellEditControl();
643  }
644 }
645 
646 
647 void PANEL_FP_LIB_TABLE::deleteRowHandler( wxCommandEvent& event )
648 {
650  return;
651 
652  int curRow = m_cur_grid->GetGridCursorRow();
653  int curCol = m_cur_grid->GetGridCursorCol();
654 
655  // In a wxGrid, collect rows that have a selected cell, or are selected
656  // It is not so easy: it depends on the way the selection was made.
657  // Here, we collect rows selected by clicking on a row label, and rows that contain any
658  // previously-selected cells.
659  // If no candidate, just delete the row with the grid cursor.
660  wxArrayInt selectedRows = m_cur_grid->GetSelectedRows();
661  wxGridCellCoordsArray cells = m_cur_grid->GetSelectedCells();
662  wxGridCellCoordsArray blockTopLeft = m_cur_grid->GetSelectionBlockTopLeft();
663  wxGridCellCoordsArray blockBotRight = m_cur_grid->GetSelectionBlockBottomRight();
664 
665  // Add all row having cell selected to list:
666  for( unsigned ii = 0; ii < cells.GetCount(); ii++ )
667  selectedRows.Add( cells[ii].GetRow() );
668 
669  // Handle block selection
670  if( !blockTopLeft.IsEmpty() && !blockBotRight.IsEmpty() )
671  {
672  for( int i = blockTopLeft[0].GetRow(); i <= blockBotRight[0].GetRow(); ++i )
673  selectedRows.Add( i );
674  }
675 
676  // Use the row having the grid cursor only if we have no candidate:
677  if( selectedRows.size() == 0 && m_cur_grid->GetGridCursorRow() >= 0 )
678  selectedRows.Add( m_cur_grid->GetGridCursorRow() );
679 
680  if( selectedRows.size() == 0 )
681  {
682  wxBell();
683  return;
684  }
685 
686  std::sort( selectedRows.begin(), selectedRows.end() );
687 
688  // Remove selected rows (note: a row can be stored more than once in list)
689  int last_row = -1;
690 
691  for( int ii = selectedRows.GetCount()-1; ii >= 0; ii-- )
692  {
693  int row = selectedRows[ii];
694 
695  if( row != last_row )
696  {
697  last_row = row;
698  m_cur_grid->DeleteRows( row, 1 );
699  }
700  }
701 
702  if( m_cur_grid->GetNumberRows() > 0 && curRow >= 0 )
703  m_cur_grid->SetGridCursor( std::min( curRow, m_cur_grid->GetNumberRows() - 1 ), curCol );
704 }
705 
706 
707 void PANEL_FP_LIB_TABLE::moveUpHandler( wxCommandEvent& event )
708 {
710  return;
711 
712  FP_LIB_TABLE_GRID* tbl = cur_model();
713  int curRow = m_cur_grid->GetGridCursorRow();
714 
715  // @todo: add multiple selection moves.
716  if( curRow >= 1 )
717  {
718  boost::ptr_vector< LIB_TABLE_ROW >::auto_type move_me =
719  tbl->rows.release( tbl->rows.begin() + curRow );
720 
721  --curRow;
722  tbl->rows.insert( tbl->rows.begin() + curRow, move_me.release() );
723 
724  if( tbl->GetView() )
725  {
726  // Update the wxGrid
727  wxGridTableMessage msg( tbl, wxGRIDTABLE_NOTIFY_ROWS_INSERTED, curRow, 0 );
728  tbl->GetView()->ProcessTableMessage( msg );
729  }
730 
731  m_cur_grid->MakeCellVisible( curRow, m_cur_grid->GetGridCursorCol() );
732  m_cur_grid->SetGridCursor( curRow, m_cur_grid->GetGridCursorCol() );
733  }
734 }
735 
736 
737 void PANEL_FP_LIB_TABLE::moveDownHandler( wxCommandEvent& event )
738 {
740  return;
741 
742  FP_LIB_TABLE_GRID* tbl = cur_model();
743  int curRow = m_cur_grid->GetGridCursorRow();
744 
745  // @todo: add multiple selection moves.
746  if( unsigned( curRow + 1 ) < tbl->rows.size() )
747  {
748  boost::ptr_vector< LIB_TABLE_ROW >::auto_type move_me =
749  tbl->rows.release( tbl->rows.begin() + curRow );
750 
751  ++curRow;
752  tbl->rows.insert( tbl->rows.begin() + curRow, move_me.release() );
753 
754  if( tbl->GetView() )
755  {
756  // Update the wxGrid
757  wxGridTableMessage msg( tbl, wxGRIDTABLE_NOTIFY_ROWS_INSERTED, curRow - 1, 0 );
758  tbl->GetView()->ProcessTableMessage( msg );
759  }
760 
761  m_cur_grid->MakeCellVisible( curRow, m_cur_grid->GetGridCursorCol() );
762  m_cur_grid->SetGridCursor( curRow, m_cur_grid->GetGridCursorCol() );
763  }
764 }
765 
766 
767 void PANEL_FP_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event )
768 {
770  return;
771 
772  std::map<int, SUPPORTED_FILE_TYPE>::const_iterator fileTypeIt;
773 
774  // We are bound both to the menu and button with this one handler
775  // So we must set the file type based on it
776  if( event.GetEventType() == wxEVT_BUTTON )
777  {
778  // Let's default to adding a kicad footprint file for just the footprint
779  fileTypeIt = fileTypes().find( ID_PANEL_FPLIB_ADD_KICADMOD );
780  }
781  else
782  {
783  fileTypeIt = fileTypes().find( event.GetId() );
784  }
785 
786  if( fileTypeIt == fileTypes().end() )
787  {
788  wxLogWarning( wxT( "File type selection event received but could not find the file type "
789  "in the table" ) );
790  return;
791  }
792 
793  SUPPORTED_FILE_TYPE fileType = fileTypeIt->second;
794 
795  PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
796 
797  wxArrayString files;
798 
799  wxString title;
800 
801  title.Printf( _( "Select %s Library" ), fileType.m_Description );
802 
803  wxString openDir = cfg->m_lastFootprintLibDir;
804 
805  if( m_cur_grid == m_project_grid )
806  openDir = m_lastProjectLibDir;
807 
808  if( fileType.m_IsFile )
809  {
810  wxFileDialog dlg( this, title, openDir, wxEmptyString, fileType.m_FileFilter,
811  wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE );
812 
813  int result = dlg.ShowModal();
814 
815  if( result == wxID_CANCEL )
816  return;
817 
818  dlg.GetPaths( files );
819 
820  if( m_cur_grid == m_global_grid )
821  cfg->m_lastFootprintLibDir = dlg.GetDirectory();
822  else
823  m_lastProjectLibDir = dlg.GetDirectory();
824  }
825  else
826  {
827 #if wxCHECK_VERSION( 3, 1, 4 ) // 3.1.4 required for wxDD_MULTIPLE
828  wxDirDialog dlg( nullptr, title, openDir,
829  wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST | wxDD_MULTIPLE );
830 
831  int result = dlg.ShowModal();
832 
833  if( result == wxID_CANCEL )
834  return;
835 
836  dlg.GetPaths( files );
837 #else
838  wxDirDialog dlg( nullptr, title, openDir, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
839 
840  int result = dlg.ShowModal();
841 
842  if( result == wxID_CANCEL )
843  return;
844 
845  // is there a file extension configured to hunt out their containing folders?
846  if( fileType.m_FolderSearchExtension != "" )
847  {
848  wxDir rootDir( dlg.GetPath() );
849 
850  LIBRARY_TRAVERSER traverser( fileType.m_FolderSearchExtension, rootDir.GetName() );
851  rootDir.Traverse( traverser );
852 
853  traverser.GetPaths( files );
854 
855  if( traverser.HasDirectoryOpenFailures() )
856  {
857  wxArrayString failedDirs;
858  traverser.GetPaths( failedDirs );
859  wxString detailedMsg = _( "The following directories could not be opened: \n" );
860 
861  for( const wxString& path : failedDirs )
862  detailedMsg << path << wxT( "\n" );
863 
864  DisplayErrorMessage( this, _( "Failed to open directories to look for libraries" ),
865  detailedMsg );
866  }
867  }
868  else
869  {
870  files.Add( dlg.GetPath() );
871  }
872 #endif
873 
874  if( !files.IsEmpty() )
875  {
876  wxFileName first( files.front() );
877 
878  if( m_cur_grid == m_global_grid )
879  cfg->m_lastFootprintLibDir = first.GetPath();
880  else
881  m_lastProjectLibDir = first.GetPath();
882  }
883  }
884 
885  // Drop the last directory if the path is a .pretty folder
887  cfg->m_lastFootprintLibDir = cfg->m_lastFootprintLibDir.BeforeLast( wxFileName::GetPathSeparator() );
888 
889  const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
890  bool addDuplicates = false;
891  bool applyToAll = false;
892  wxString warning = _( "Warning: Duplicate Nicknames" );
893  wxString msg = _( "A library nicknamed '%s' already exists." );
894  wxString detailedMsg = _( "One of the nicknames will need to be changed after "
895  "adding this library." );
896 
897  for( const wxString& filePath : files )
898  {
899  wxFileName fn( filePath );
900  wxString nickname = LIB_ID::FixIllegalChars( fn.GetName(), true );
901  bool doAdd = true;
902 
903  if( cur_model()->ContainsNickname( nickname ) )
904  {
905  if( !applyToAll )
906  {
907  // The cancel button adds the library to the table anyway
908  addDuplicates = OKOrCancelDialog( this, warning, wxString::Format( msg, nickname ),
909  detailedMsg, _( "Skip" ), _( "Add Anyway" ),
910  &applyToAll ) == wxID_CANCEL;
911  }
912 
913  doAdd = addDuplicates;
914  }
915 
916  if( doAdd && m_cur_grid->AppendRows( 1 ) )
917  {
918  int last_row = m_cur_grid->GetNumberRows() - 1;
919 
920  m_cur_grid->SetCellValue( last_row, COL_NICKNAME, nickname );
921 
922  m_cur_grid->SetCellValue( last_row, COL_TYPE, IO_MGR::ShowType( fileType.m_Plugin ) );
923 
924  // try to use path normalized to an environmental variable or project path
925  wxString path = NormalizePath( filePath, &envVars, m_projectBasePath );
926 
927  // Do not use the project path in the global library table. This will almost
928  // assuredly be wrong for a different project.
929  if( m_pageNdx == 0 && path.Contains( wxT( "${KIPRJMOD}" ) ) )
930  path = fn.GetFullPath();
931 
932  m_cur_grid->SetCellValue( last_row, COL_URI, path );
933  }
934  }
935 
936  if( !files.IsEmpty() )
937  {
938  int new_row = m_cur_grid->GetNumberRows() - 1;
939  m_cur_grid->MakeCellVisible( new_row, m_cur_grid->GetGridCursorCol() );
940  m_cur_grid->SetGridCursor( new_row, m_cur_grid->GetGridCursorCol() );
941  }
942 }
943 
944 
946 {
947  // Account for scroll bars
948  aWidth -= ( m_path_subs_grid->GetSize().x - m_path_subs_grid->GetClientSize().x );
949 
950  m_path_subs_grid->AutoSizeColumn( 0 );
951 
952  if( aWidth - m_path_subs_grid->GetColSize( 0 ) < 60 )
953  m_path_subs_grid->SetColSize( 0, aWidth / 2 );
954 
955  m_path_subs_grid->SetColSize( 1, aWidth - m_path_subs_grid->GetColSize( 0 ) );
956 }
957 
958 
959 void PANEL_FP_LIB_TABLE::onSizeGrid( wxSizeEvent& event )
960 {
961  adjustPathSubsGridColumns( event.GetSize().GetX() );
962 
963  event.Skip();
964 }
965 
966 
968 {
970  return false;
971 
972  if( verifyTables() )
973  {
974  if( *global_model() != *m_global )
975  {
977 
978  m_global->Clear();
979  m_global->rows.transfer( m_global->rows.end(), global_model()->rows.begin(),
980  global_model()->rows.end(), global_model()->rows );
981  m_global->reindex();
982  }
983 
984  if( project_model() && *project_model() != *m_project )
985  {
987 
988  m_project->Clear();
989  m_project->rows.transfer( m_project->rows.end(), project_model()->rows.begin(),
990  project_model()->rows.end(), project_model()->rows );
991  m_project->reindex();
992  }
993 
994  return true;
995  }
996 
997  return false;
998 }
999 
1000 
1004 {
1005  wxRegEx re( ".*?(\\$\\{(.+?)\\})|(\\$\\((.+?)\\)).*?", wxRE_ADVANCED );
1006  wxASSERT( re.IsValid() ); // wxRE_ADVANCED is required.
1007 
1008  std::set< wxString > unique;
1009 
1010  // clear the table
1012 
1013  for( FP_LIB_TABLE_GRID* tbl : { global_model(), project_model() } )
1014  {
1015  if( !tbl )
1016  continue;
1017 
1018  for( int row = 0; row < tbl->GetNumberRows(); ++row )
1019  {
1020  wxString uri = tbl->GetValue( row, COL_URI );
1021 
1022  while( re.Matches( uri ) )
1023  {
1024  wxString envvar = re.GetMatch( uri, 2 );
1025 
1026  // if not ${...} form then must be $(...)
1027  if( envvar.IsEmpty() )
1028  envvar = re.GetMatch( uri, 4 );
1029 
1030  // ignore duplicates
1031  unique.insert( envvar );
1032 
1033  // delete the last match and search again
1034  uri.Replace( re.GetMatch( uri, 0 ), wxEmptyString );
1035  }
1036  }
1037  }
1038 
1039  // Make sure this special environment variable shows up even if it was
1040  // not used yet. It is automatically set by KiCad to the directory holding
1041  // the current project.
1042  unique.insert( PROJECT_VAR_NAME );
1043  unique.insert( FP_LIB_TABLE::GlobalPathEnvVariableName() );
1044  // This special environment variable is used to locate 3d shapes
1045  unique.insert( KICAD6_3DMODEL_DIR );
1046 
1047  for( const wxString& evName : unique )
1048  {
1049  int row = m_path_subs_grid->GetNumberRows();
1050  m_path_subs_grid->AppendRows( 1 );
1051 
1052  m_path_subs_grid->SetCellValue( row, 0, wxT( "${" ) + evName + wxT( "}" ) );
1053  m_path_subs_grid->SetCellEditor( row, 0, new GRID_CELL_READONLY_TEXT_EDITOR() );
1054 
1055  wxString evValue;
1056  wxGetEnv( evName, &evValue );
1057  m_path_subs_grid->SetCellValue( row, 1, evValue );
1058  m_path_subs_grid->SetCellEditor( row, 1, new GRID_CELL_READONLY_TEXT_EDITOR() );
1059  }
1060 
1061  // No combobox editors here, but it looks better if its consistent with the other
1062  // grids in the dialog.
1063  m_path_subs_grid->SetDefaultRowSize( m_path_subs_grid->GetDefaultRowSize() + 2 );
1064 
1065  adjustPathSubsGridColumns( m_path_subs_grid->GetRect().GetWidth() );
1066 }
1067 
1068 //-----</event handlers>---------------------------------
1069 
1070 
1071 
1073 
1074 
1075 void InvokePcbLibTableEditor( KIWAY* aKiway, wxWindow* aCaller )
1076 {
1077  FP_LIB_TABLE* globalTable = &GFootprintTable;
1078  wxString globalTablePath = FP_LIB_TABLE::GetGlobalTableFileName();
1079  FP_LIB_TABLE* projectTable = aKiway->Prj().PcbFootprintLibs();
1080  wxString projectTablePath = aKiway->Prj().FootprintLibTblName();
1081  wxString msg;
1082 
1083  DIALOG_EDIT_LIBRARY_TABLES dlg( aCaller, _( "Footprint Libraries" ) );
1084  dlg.SetKiway( &dlg, aKiway );
1085 
1086  if( aKiway->Prj().IsNullProject() )
1087  projectTable = nullptr;
1088 
1089  dlg.InstallPanel( new PANEL_FP_LIB_TABLE( &dlg, globalTable, globalTablePath,
1090  projectTable, projectTablePath,
1091  aKiway->Prj().GetProjectPath() ) );
1092 
1093  if( dlg.ShowModal() == wxID_CANCEL )
1094  return;
1095 
1096  if( dlg.m_GlobalTableChanged )
1097  {
1098  try
1099  {
1100  globalTable->Save( globalTablePath );
1101  }
1102  catch( const IO_ERROR& ioe )
1103  {
1104  msg.Printf( _( "Error saving global library table:\n\n%s" ), ioe.What() );
1105  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
1106  }
1107  }
1108 
1109  if( projectTable && dlg.m_ProjectTableChanged )
1110  {
1111  try
1112  {
1113  projectTable->Save( projectTablePath );
1114  }
1115  catch( const IO_ERROR& ioe )
1116  {
1117  msg.Printf( _( "Error saving project-specific library table:\n\n%s" ), ioe.What() );
1118  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
1119  }
1120  }
1121 
1122  auto editor = (FOOTPRINT_EDIT_FRAME*) aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
1123 
1124  if( editor )
1125  {
1126  editor->SyncLibraryTree( true );
1127  editor->RefreshLibraryTree();
1128  }
1129 
1130  auto viewer = (FOOTPRINT_VIEWER_FRAME*) aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );
1131 
1132  if( viewer )
1133  viewer->ReCreateLibraryList();
1134 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
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*.
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
The global footprint library table.
Definition: cvpcb.cpp:134
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:292
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:40
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib)
Replace illegal LIB_ID item name characters with underscores '_'.
Definition: lib_id.cpp:189
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:191
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:55
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:393
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:93
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:122
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:97
Geda PCB file formats.
Definition: io_mgr.h:64
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:110
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:30
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.
#define KICAD6_3DMODEL_DIR
A variable name whose value holds the path of 3D shape files.
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
#define _(s)
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:226
bool AppendRows(size_t aNumRows=1) override
void optionsEditor(int aRow)
FormatType fileType(const char *aFileName)
Definition: loadmodel.cpp:278
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aDetailedMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
Definition: confirm.cpp:252
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
E_SERIE r
Definition: eserie.cpp:41
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
Definition: project.cpp:134
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:283
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.
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:55
see class PGM_BASE
virtual void doPopupSelection(wxCommandEvent &event)
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)
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 ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
Definition: wx_grid.h:109
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:53
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:240
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:146
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:71
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:56
static unsigned FindIllegalLibraryNameChar(const UTF8 &aLibraryName)
Looks for characters that are illegal in library nicknames.
Definition: lib_id.cpp:240