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