diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 2cb628ec96..c71afec78c 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -417,10 +417,8 @@ set( EESCHEMA_SRCS schematic_undo_redo.cpp sheet.cpp symbol.cpp - symbol_async_loader.cpp symbol_checker.cpp symbol_chooser_frame.cpp - symbol_lib_table.cpp symbol_library_manager.cpp symbol_tree_model_adapter.cpp diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index 4d8bee2288..e451dc1668 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/eeschema/dialogs/dialog_symbol_remap.cpp b/eeschema/dialogs/dialog_symbol_remap.cpp index 6cd4c6d28c..ff97f797ad 100644 --- a/eeschema/dialogs/dialog_symbol_remap.cpp +++ b/eeschema/dialogs/dialog_symbol_remap.cpp @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -122,8 +121,7 @@ void DIALOG_SYMBOL_REMAP::OnRemapSymbols( wxCommandEvent& aEvent ) // check to see if the schematic has not been converted to the symbol library table // method for looking up symbols. - wxFileName prjSymLibTableFileName( Prj().GetProjectPath(), - SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() ); + wxFileName prjSymLibTableFileName( Prj().GetProjectPath(), FILEEXT::SymbolLibraryTableFileName ); // Delete the existing project symbol library table. if( prjSymLibTableFileName.FileExists() ) @@ -143,7 +141,7 @@ void DIALOG_SYMBOL_REMAP::OnRemapSymbols( wxCommandEvent& aEvent ) LEGACY_SYMBOL_LIBS::SetLibNamesAndPaths( &Prj(), paths, libNames ); // Reload the cache symbol library. - Prj().SetElem( PROJECT::ELEM::SCH_SYMBOL_LIBS, nullptr ); + Prj().SetElem( PROJECT::ELEM::LEGACY_SYMBOL_LIBS, nullptr ); PROJECT_SCH::LegacySchLibs( &Prj() ); Raise(); @@ -153,6 +151,8 @@ void DIALOG_SYMBOL_REMAP::OnRemapSymbols( wxCommandEvent& aEvent ) size_t DIALOG_SYMBOL_REMAP::getLibsNotInGlobalSymbolLibTable( std::vector< LEGACY_SYMBOL_LIB* >& aLibs ) { + LIBRARY_MANAGER& mgr = Pgm().GetLibraryManager(); + for( LEGACY_SYMBOL_LIB& lib : *PROJECT_SCH::LegacySchLibs( &Prj() ) ) { // Ignore the cache library. @@ -162,7 +162,7 @@ size_t DIALOG_SYMBOL_REMAP::getLibsNotInGlobalSymbolLibTable( std::vector< LEGAC // Check for the obvious library name. wxString libFileName = lib.GetFullFileName(); - if( !SYMBOL_LIB_TABLE::GetGlobalLibTable().FindRowByURI( libFileName ) ) + if( !mgr.FindRowByURI( LIBRARY_TABLE_TYPE::SYMBOL, libFileName ) ) aLibs.push_back( &lib ); } @@ -172,13 +172,19 @@ size_t DIALOG_SYMBOL_REMAP::getLibsNotInGlobalSymbolLibTable( std::vector< LEGAC void DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable( REPORTER& aReporter ) { + SYMBOL_LIBRARY_ADAPTER* adapter = PROJECT_SCH::SymbolLibAdapter( &Prj() ); + + std::optional optTable = + Pgm().GetLibraryManager().Table( LIBRARY_TABLE_TYPE::SYMBOL, LIBRARY_TABLE_SCOPE::PROJECT ); + wxCHECK( optTable, /* void */ ); + LIBRARY_TABLE* projectTable = *optTable; + std::vector libs; if( getLibsNotInGlobalSymbolLibTable( libs ) ) { wxBusyCursor busy; - SYMBOL_LIB_TABLE libTable; - std::vector libNames = SYMBOL_LIB_TABLE::GetGlobalLibTable().GetLogicalLibs(); + std::vector libNames = adapter->GetLibraryNames(); for( LEGACY_SYMBOL_LIB* lib : libs ) { @@ -217,7 +223,10 @@ void DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable( REPORTER& aReporter ) normalizedPath ), RPT_SEVERITY_INFO ); - libTable.InsertRow( new SYMBOL_LIB_TABLE_ROW( libName, normalizedPath, type ) ); + LIBRARY_TABLE_ROW& newRow = projectTable->InsertRow(); + newRow.SetNickname( libName ); + newRow.SetURI( normalizedPath ); + newRow.SetType( type ); } else { @@ -228,22 +237,17 @@ void DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable( REPORTER& aReporter ) } // Don't save empty project symbol library table. - if( !libTable.IsEmpty() ) + if( !projectTable->Rows().empty() ) { - wxFileName fn( Prj().GetProjectPath(), SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() ); + Pgm().GetLibraryManager().Save( projectTable ).map_error( + [&aReporter]( const LIBRARY_ERROR& aError ) + { + aReporter.ReportTail( wxString::Format( _( "Error saving project-specific library table:\n\n%s" ), + aError.message ) ); + } ); - try - { - FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() ); - libTable.Format( &formatter, 0 ); - } - catch( const IO_ERROR& ioe ) - { - aReporter.ReportTail( wxString::Format( _( "Error writing project symbol library " - "table.\n %s" ), - ioe.What() ), - RPT_SEVERITY_ERROR ); - } + // Trigger a reload of the table and cancel an in-progress background load + Pgm().GetLibraryManager().ProjectChanged(); aReporter.ReportTail( _( "Created project symbol library table.\n" ), RPT_SEVERITY_INFO ); @@ -373,7 +377,7 @@ bool DIALOG_SYMBOL_REMAP::backupProject( REPORTER& aReporter ) // Back up symbol library table. srcFileName.SetPath( Prj().GetProjectPath() ); - srcFileName.SetName( SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() ); + srcFileName.SetName( FILEEXT::SymbolLibraryTableFileName ); destFileName = srcFileName; destFileName.AppendDir( backupFolder ); destFileName.SetName( destFileName.GetName() + timeStamp ); diff --git a/eeschema/dialogs/panel_sym_lib_table.h b/eeschema/dialogs/panel_sym_lib_table.h index f6e73164f9..763622cbbd 100644 --- a/eeschema/dialogs/panel_sym_lib_table.h +++ b/eeschema/dialogs/panel_sym_lib_table.h @@ -26,7 +26,6 @@ #include #include -class SYMBOL_LIB_TABLE; class SYMBOL_LIB_TABLE_GRID; /** diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index 2d8ed06f22..166a5b74ce 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -38,13 +38,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include @@ -688,6 +688,8 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProje aErrors += msg; } } + // TODO(JE) library tables - does this feature even need to exist? +#if 0 else if( destFile.GetName() == FILEEXT::SymbolLibraryTableFileName ) { SYMBOL_LIB_TABLE symbolLibTable; @@ -723,6 +725,7 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProje aErrors += msg; } } +#endif else { wxFAIL_MSG( wxS( "Unexpected filetype for Eeschema::SaveFileAs()" ) ); diff --git a/eeschema/erc/erc.cpp b/eeschema/erc/erc.cpp index 330b6ad8b4..f73ec623bf 100644 --- a/eeschema/erc/erc.cpp +++ b/eeschema/erc/erc.cpp @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 520afbc238..5dd294dee6 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -195,21 +195,21 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in { // Don't reload the symbol libraries if we are just launching Eeschema from KiCad again. // They are already saved in the kiface project object. - if( differentProject || !Prj().GetElem( PROJECT::ELEM::SCH_SYMBOL_LIBS ) ) + if( differentProject || !Prj().GetElem( PROJECT::ELEM::LEGACY_SYMBOL_LIBS ) ) { // load the libraries here, not in SCH_SCREEN::Draw() which is a context // that will not tolerate DisplayError() dialog since we're already in an // event handler in there. // And when a schematic file is loaded, we need these libs to initialize // some parameters (links to PART LIB, dangling ends ...) - Prj().SetElem( PROJECT::ELEM::SCH_SYMBOL_LIBS, nullptr ); + Prj().SetElem( PROJECT::ELEM::LEGACY_SYMBOL_LIBS, nullptr ); PROJECT_SCH::LegacySchLibs( &Prj() ); } } else { // No legacy symbol libraries including the cache are loaded with the new file format. - Prj().SetElem( PROJECT::ELEM::SCH_SYMBOL_LIBS, nullptr ); + Prj().SetElem( PROJECT::ELEM::LEGACY_SYMBOL_LIBS, nullptr ); } wxFileName rfn( GetCurrentFileName() ); diff --git a/eeschema/libraries/legacy_symbol_library.h b/eeschema/libraries/legacy_symbol_library.h index 3937ea5545..bf24cd639c 100644 --- a/eeschema/libraries/legacy_symbol_library.h +++ b/eeschema/libraries/legacy_symbol_library.h @@ -57,7 +57,7 @@ class LEGACY_SYMBOL_LIB; class LEGACY_SYMBOL_LIBS : public boost::ptr_vector, public PROJECT::_ELEM { public: - PROJECT::ELEM ProjectElementType() override { return PROJECT::ELEM::SCH_SYMBOL_LIBS; } + PROJECT::ELEM ProjectElementType() override { return PROJECT::ELEM::LEGACY_SYMBOL_LIBS; } LEGACY_SYMBOL_LIBS() {} diff --git a/eeschema/netlist_exporters/netlist_exporter_xml.cpp b/eeschema/netlist_exporters/netlist_exporter_xml.cpp index befc85c17a..52618bca44 100644 --- a/eeschema/netlist_exporters/netlist_exporter_xml.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_xml.cpp @@ -39,8 +39,6 @@ #include #include -#include - #include #include diff --git a/eeschema/netlist_exporters/netlist_exporter_xml.h b/eeschema/netlist_exporters/netlist_exporter_xml.h index 5f6401a12b..2c1193a7df 100644 --- a/eeschema/netlist_exporters/netlist_exporter_xml.h +++ b/eeschema/netlist_exporters/netlist_exporter_xml.h @@ -33,7 +33,6 @@ #include class CONNECTION_GRAPH; -class SYMBOL_LIB_TABLE; class XNODE; #define GENERIC_INTERMEDIATE_NETLIST_EXT wxT( "xml" ) diff --git a/eeschema/picksymbol.cpp b/eeschema/picksymbol.cpp index e579242b79..87fe6382c3 100644 --- a/eeschema/picksymbol.cpp +++ b/eeschema/picksymbol.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index 37f15070f4..b77a19789a 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -680,12 +679,12 @@ bool LEGACY_RESCUER::WriteRescueLibrary( wxWindow *aParent ) wxString libPaths; wxString libName = m_rescue_lib->GetName(); - LEGACY_SYMBOL_LIBS* libs = dynamic_cast( m_prj->GetElem( PROJECT::ELEM::SCH_SYMBOL_LIBS ) ); + LEGACY_SYMBOL_LIBS* libs = dynamic_cast( m_prj->GetElem( PROJECT::ELEM::LEGACY_SYMBOL_LIBS ) ); if( !libs ) { libs = new LEGACY_SYMBOL_LIBS(); - m_prj->SetElem( PROJECT::ELEM::SCH_SYMBOL_LIBS, libs ); + m_prj->SetElem( PROJECT::ELEM::LEGACY_SYMBOL_LIBS, libs ); } try @@ -711,7 +710,7 @@ bool LEGACY_RESCUER::WriteRescueLibrary( wxWindow *aParent ) boost::ptr_vector libsSave; libsSave.transfer( libsSave.end(), libs->begin(), libs->end(), *libs ); - m_prj->SetElem( PROJECT::ELEM::SCH_SYMBOL_LIBS, nullptr ); + m_prj->SetElem( PROJECT::ELEM::LEGACY_SYMBOL_LIBS, nullptr ); libs = new LEGACY_SYMBOL_LIBS(); @@ -732,7 +731,7 @@ bool LEGACY_RESCUER::WriteRescueLibrary( wxWindow *aParent ) return false; } - m_prj->SetElem( PROJECT::ELEM::SCH_SYMBOL_LIBS, libs ); + m_prj->SetElem( PROJECT::ELEM::LEGACY_SYMBOL_LIBS, libs ); // Update the schematic symbol library links since the library list has changed. SCH_SCREENS schematic( m_schematic->Root() ); diff --git a/eeschema/project_sch.cpp b/eeschema/project_sch.cpp index 148cb452e7..e35ff945e2 100644 --- a/eeschema/project_sch.cpp +++ b/eeschema/project_sch.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -90,16 +89,16 @@ SEARCH_STACK* PROJECT_SCH::SchSearchS( PROJECT* aProject ) LEGACY_SYMBOL_LIBS* PROJECT_SCH::LegacySchLibs( PROJECT* aProject ) { - LEGACY_SYMBOL_LIBS* libs = (LEGACY_SYMBOL_LIBS*) aProject->GetElem( PROJECT::ELEM::SCH_SYMBOL_LIBS ); + auto libs = static_cast( aProject->GetElem( PROJECT::ELEM::LEGACY_SYMBOL_LIBS ) ); - wxASSERT( !libs || libs->ProjectElementType() == PROJECT::ELEM::SCH_SYMBOL_LIBS ); + wxASSERT( !libs || libs->ProjectElementType() == PROJECT::ELEM::LEGACY_SYMBOL_LIBS ); if( !libs ) { libs = new LEGACY_SYMBOL_LIBS(); // Make PROJECT the new SYMBOL_LIBS owner. - aProject->SetElem( PROJECT::ELEM::SCH_SYMBOL_LIBS, libs ); + aProject->SetElem( PROJECT::ELEM::LEGACY_SYMBOL_LIBS, libs ); try { @@ -131,54 +130,6 @@ LEGACY_SYMBOL_LIBS* PROJECT_SCH::LegacySchLibs( PROJECT* aProject ) } -#if 0 -SYMBOL_LIB_TABLE* PROJECT_SCH::SchSymbolLibTable( PROJECT* aProject ) -{ - std::lock_guard lock( s_symbolTableMutex ); - - // This is a lazy loading function, it loads the project specific table when - // that table is asked for, not before. - SYMBOL_LIB_TABLE* tbl = - (SYMBOL_LIB_TABLE*) aProject->GetElem( PROJECT::ELEM::SYMBOL_LIB_TABLE ); - - // its gotta be NULL or a SYMBOL_LIB_TABLE, or a bug. - wxASSERT( !tbl || tbl->ProjectElementType() == PROJECT::ELEM::SYMBOL_LIB_TABLE ); - - if( !tbl ) - { - // Stack the project specific SYMBOL_LIB_TABLE overlay on top of the global table. - // ~SYMBOL_LIB_TABLE() will not touch the fallback table, so multiple projects may - // stack this way, all using the same global fallback table. - tbl = new SYMBOL_LIB_TABLE( &SYMBOL_LIB_TABLE::GetGlobalLibTable() ); - - aProject->SetElem( PROJECT::ELEM::SYMBOL_LIB_TABLE, tbl ); - - wxString prjPath; - - wxGetEnv( PROJECT_VAR_NAME, &prjPath ); - - if( !prjPath.IsEmpty() ) - { - wxFileName fn( prjPath, SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() ); - - try - { - tbl->Load( fn.GetFullPath() ); - } - catch( const IO_ERROR& ioe ) - { - wxString msg; - msg.Printf( _( "Error loading the symbol library table '%s'." ), fn.GetFullPath() ); - DisplayErrorMessage( nullptr, msg, ioe.What() ); - } - } - } - - return tbl; -} -#endif - - SYMBOL_LIBRARY_ADAPTER* PROJECT_SCH::SymbolLibAdapter( PROJECT* aProject ) { LIBRARY_MANAGER& mgr = Pgm().GetLibraryManager(); diff --git a/eeschema/project_sch.h b/eeschema/project_sch.h index 2a4fc79883..e6b38c2c61 100644 --- a/eeschema/project_sch.h +++ b/eeschema/project_sch.h @@ -23,7 +23,6 @@ #pragma once -class SYMBOL_LIB_TABLE; class PROJECT; class SEARCH_STACK; class LEGACY_SYMBOL_LIBS; diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 49decf139b..299483ed77 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include diff --git a/eeschema/sch_io/cadstar/sch_io_cadstar_archive.cpp b/eeschema/sch_io/cadstar/sch_io_cadstar_archive.cpp index 2761d417ac..d6babba692 100644 --- a/eeschema/sch_io/cadstar/sch_io_cadstar_archive.cpp +++ b/eeschema/sch_io/cadstar/sch_io_cadstar_archive.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include diff --git a/eeschema/sch_io/database/sch_io_database.cpp b/eeschema/sch_io/database/sch_io_database.cpp index c0b82cf3a8..443199993c 100644 --- a/eeschema/sch_io/database/sch_io_database.cpp +++ b/eeschema/sch_io/database/sch_io_database.cpp @@ -32,8 +32,6 @@ #include #include #include -#include -#include #include "sch_io_database.h" @@ -80,7 +78,7 @@ void SCH_IO_DATABASE::EnumerateSymbolLib( std::vector& aSymbolList, if( !m_conn ) THROW_IO_ERROR( m_lastError ); - bool powerSymbolsOnly = ( aProperties && aProperties->contains( SYMBOL_LIB_TABLE::PropPowerSymsOnly ) ); + bool powerSymbolsOnly = ( aProperties && aProperties->contains( SYMBOL_LIBRARY_ADAPTER::PropPowerSymsOnly ) ); for( auto const& pair : m_nameToSymbolcache ) { diff --git a/eeschema/sch_io/eagle/sch_io_eagle.cpp b/eeschema/sch_io/eagle/sch_io_eagle.cpp index ff65b6db1e..553b59fb7c 100644 --- a/eeschema/sch_io/eagle/sch_io_eagle.cpp +++ b/eeschema/sch_io/eagle/sch_io_eagle.cpp @@ -55,7 +55,6 @@ #include #include #include -#include #include #include diff --git a/eeschema/sch_io/http_lib/sch_io_http_lib.cpp b/eeschema/sch_io/http_lib/sch_io_http_lib.cpp index 88bcad81f2..d2aae01ee6 100644 --- a/eeschema/sch_io/http_lib/sch_io_http_lib.cpp +++ b/eeschema/sch_io/http_lib/sch_io_http_lib.cpp @@ -23,7 +23,6 @@ #include #include -#include #include #include @@ -58,7 +57,7 @@ void SCH_IO_HTTP_LIB::EnumerateSymbolLib( std::vector& aSymbolList, if( !m_conn ) THROW_IO_ERROR( m_lastError ); - bool powerSymbolsOnly = ( aProperties && aProperties->contains( SYMBOL_LIB_TABLE::PropPowerSymsOnly ) ); + bool powerSymbolsOnly = ( aProperties && aProperties->contains( SYMBOL_LIBRARY_ADAPTER::PropPowerSymsOnly ) ); for( const HTTP_LIB_CATEGORY& category : m_conn->getCategories() ) { diff --git a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp index 2dbf0437e0..ef1b27cd83 100644 --- a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp +++ b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp @@ -61,7 +61,7 @@ #include #include #include -#include +#include #include // for MAX_UNIT_COUNT_PER_PACKAGE definition #include #include @@ -2118,7 +2118,7 @@ void SCH_IO_KICAD_LEGACY::EnumerateSymbolLib( wxArrayString& aSymbolNameList, const wxString& aLibraryPath, const std::map* aProperties ) { - bool powerSymbolsOnly = ( aProperties && aProperties->contains( SYMBOL_LIB_TABLE::PropPowerSymsOnly ) ); + bool powerSymbolsOnly = ( aProperties && aProperties->contains( SYMBOL_LIBRARY_ADAPTER::PropPowerSymsOnly ) ); cacheLib( aLibraryPath, aProperties ); @@ -2136,7 +2136,7 @@ void SCH_IO_KICAD_LEGACY::EnumerateSymbolLib( std::vector& aSymbolL const wxString& aLibraryPath, const std::map* aProperties ) { - bool powerSymbolsOnly = ( aProperties && aProperties->contains( SYMBOL_LIB_TABLE::PropPowerSymsOnly ) ); + bool powerSymbolsOnly = ( aProperties && aProperties->contains( SYMBOL_LIBRARY_ADAPTER::PropPowerSymsOnly ) ); cacheLib( aLibraryPath, aProperties ); diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp index 179a90a869..cd76115960 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -59,7 +60,6 @@ #include #include #include -#include // for PropPowerSymsOnly definition. #include using namespace TSCHEMATIC_T; @@ -1633,7 +1633,7 @@ void SCH_IO_KICAD_SEXPR::EnumerateSymbolLib( wxArrayString& aSymbolNameList, const wxString& aLibraryPath, const std::map* aProperties ) { - bool powerSymbolsOnly = ( aProperties && aProperties->contains( SYMBOL_LIB_TABLE::PropPowerSymsOnly ) ); + bool powerSymbolsOnly = ( aProperties && aProperties->contains( SYMBOL_LIBRARY_ADAPTER::PropPowerSymsOnly ) ); cacheLib( aLibraryPath, aProperties ); @@ -1651,7 +1651,7 @@ void SCH_IO_KICAD_SEXPR::EnumerateSymbolLib( std::vector& aSymbolLi const wxString& aLibraryPath, const std::map* aProperties ) { - bool powerSymbolsOnly = ( aProperties && aProperties->contains( SYMBOL_LIB_TABLE::PropPowerSymsOnly ) ); + bool powerSymbolsOnly = ( aProperties && aProperties->contains( SYMBOL_LIBRARY_ADAPTER::PropPowerSymsOnly ) ); cacheLib( aLibraryPath, aProperties ); diff --git a/eeschema/sch_io/ltspice/sch_io_ltspice.cpp b/eeschema/sch_io/ltspice/sch_io_ltspice.cpp index 398e3628ae..c71e83e72d 100644 --- a/eeschema/sch_io/ltspice/sch_io_ltspice.cpp +++ b/eeschema/sch_io/ltspice/sch_io_ltspice.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include /** diff --git a/eeschema/sch_io/sch_io_mgr.h b/eeschema/sch_io/sch_io_mgr.h index ec175c8138..fc87cd7062 100644 --- a/eeschema/sch_io/sch_io_mgr.h +++ b/eeschema/sch_io/sch_io_mgr.h @@ -37,7 +37,6 @@ class SCH_SHEET; class SCH_SCREEN; class SCH_IO; class SCHEMATIC; -class SYMBOL_LIB_TABLE; class KIWAY; class LIB_SYMBOL; class LEGACY_SYMBOL_LIB; diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index d4cf356058..bbb66055ed 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -55,7 +55,6 @@ #include #include #include -#include #include #include // For V6 to V7 simulation model migration. #include diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 5673f9fe3f..fad7cfa436 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include @@ -380,8 +379,7 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurr duplicateLibNames.Add( name ); } - wxFileName symLibTableFn( fileName.GetPath(), - SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() ); + wxFileName symLibTableFn( fileName.GetPath(), FILEEXT::SymbolLibraryTableFileName ); LIBRARY_TABLE table( symLibTableFn.GetFullPath(), LIBRARY_TABLE_SCOPE::PROJECT ); // If there are any new or duplicate libraries, check to see if it's possible that diff --git a/eeschema/symbol_async_loader.cpp b/eeschema/symbol_async_loader.cpp deleted file mode 100644 index b124382181..0000000000 --- a/eeschema/symbol_async_loader.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2021 Jon Evans - * Copyright The KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include - -#include -#include -#include -#include - - -SYMBOL_ASYNC_LOADER::SYMBOL_ASYNC_LOADER( const std::vector& aNicknames, - SYMBOL_LIB_TABLE* aTable, bool aOnlyPowerSymbols, - std::unordered_map>* aOutput, - PROGRESS_REPORTER* aReporter ) : - m_nicknames( aNicknames ), - m_table( aTable ), - m_onlyPowerSymbols( aOnlyPowerSymbols ), - m_output( aOutput ), - m_reporter( aReporter ), - m_nextLibrary( 0 ) -{ - wxASSERT( m_table ); - m_threadCount = std::max( 1, std::thread::hardware_concurrency() ); - - m_returns.resize( m_threadCount ); -} - - - -SYMBOL_ASYNC_LOADER::~SYMBOL_ASYNC_LOADER() -{ - Join(); -} - - -void SYMBOL_ASYNC_LOADER::Start() -{ - for( size_t ii = 0; ii < m_threadCount; ++ii ) - m_returns[ii] = std::async( std::launch::async, &SYMBOL_ASYNC_LOADER::worker, this ); -} - - -bool SYMBOL_ASYNC_LOADER::Join() -{ - for( size_t ii = 0; ii < m_threadCount; ++ii ) - { - if( !m_returns[ii].valid() ) - continue; - - m_returns[ii].wait(); - - const std::vector& ret = m_returns[ii].get(); - - if( m_output && !ret.empty() ) - { - for( const LOADED_PAIR& pair : ret ) - { - // Don't show libraries that had no power symbols - if( m_onlyPowerSymbols && pair.second.empty() ) - continue; - - // *Do* show empty libraries in the normal case - m_output->insert( pair ); - } - } - } - - return true; -} - - -bool SYMBOL_ASYNC_LOADER::Done() -{ - return m_nextLibrary.load() >= m_nicknames.size(); -} - - -std::vector SYMBOL_ASYNC_LOADER::worker() -{ - std::vector ret; - - bool onlyPower = m_onlyPowerSymbols; - - for( size_t libraryIndex = m_nextLibrary++; libraryIndex < m_nicknames.size(); - libraryIndex = m_nextLibrary++ ) - { - const wxString& nickname = m_nicknames[libraryIndex]; - - if( m_reporter ) - m_reporter->AdvancePhase( wxString::Format( _( "Loading library %s..." ), nickname ) ); - - if( m_reporter && m_reporter->IsCancelled() ) - break; - - LOADED_PAIR pair( nickname, {} ); - - try - { - m_table->LoadSymbolLib( pair.second, nickname, onlyPower ); - ret.emplace_back( std::move( pair ) ); - } - catch( const IO_ERROR& ioe ) - { - wxString msg = wxString::Format( _( "Error loading symbol library %s.\n\n%s\n" ), - nickname, ioe.What() ); - - std::lock_guard lock( m_errorMutex ); - m_errors += msg; - } - catch( std::exception& e ) - { - wxString msg = wxString::Format( _( "Error loading symbol library %s.\n\n%s\n" ), - nickname, e.what() ); - - std::lock_guard lock( m_errorMutex ); - m_errors += msg; - } - } - - return ret; -} diff --git a/eeschema/symbol_async_loader.h b/eeschema/symbol_async_loader.h deleted file mode 100644 index a9d2b65e89..0000000000 --- a/eeschema/symbol_async_loader.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2021 Jon Evans - * Copyright The KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef KICAD_SYMBOL_ASYNC_LOADER_H -#define KICAD_SYMBOL_ASYNC_LOADER_H - -#include -#include -#include -#include -#include - -#include - -class LIB_SYMBOL; -class PROGRESS_REPORTER; -class SYMBOL_LIB_TABLE; - - -class SYMBOL_ASYNC_LOADER -{ -public: - /** - * Construct a loader for symbol libraries. - * - * @param aNicknames is a list of library nicknames to load. - * @param aTable is a pointer to the symbol library table to load libraries for. - * @param aOnlyPowerSymbols, if true, will only return power symbols in the output map. - * @param aOutput will be filled with the loaded parts. - * @param aReporter will be used to report progress, of not null. - */ - SYMBOL_ASYNC_LOADER( const std::vector& aNicknames, - SYMBOL_LIB_TABLE* aTable, bool aOnlyPowerSymbols = false, - std::unordered_map>* aOutput = nullptr, - PROGRESS_REPORTER* aReporter = nullptr ); - - ~SYMBOL_ASYNC_LOADER(); - - /** - * Spin up threads to load all the libraries in m_nicknames. - */ - void Start(); - - /** - * Finalize the threads and combines the output into the target output map. - */ - bool Join(); - - /// @return true if loading is done - bool Done(); - - /// @return a string containing any errors generated during the load. - const wxString& GetErrors() const { return m_errors; } - - /// Represent a pair of . - typedef std::pair> LOADED_PAIR; - -private: - /// Worker job that loads libraries and returns a list of pairs of . - std::vector worker(); - - /// List of libraries to load. - std::vector m_nicknames; - - /// Handle to the symbol library table being loaded into. - SYMBOL_LIB_TABLE* m_table; - - /// True if we are loading only power symbols. - bool m_onlyPowerSymbols; - - /// Handle to map that will be filled with the loaded parts per library. - std::unordered_map>* m_output; - - /// Progress reporter (may be null). - PROGRESS_REPORTER* m_reporter; - - size_t m_threadCount; - std::atomic m_nextLibrary; - wxString m_errors; - std::mutex m_errorMutex; - - std::vector>> m_returns; -}; - -#endif diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 4d65155cc6..a90899812d 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -1917,8 +1916,7 @@ void SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic( SCH_SYMBOL* aSymbol ) bool SYMBOL_EDIT_FRAME::addLibTableEntry( const wxString& aLibFile, LIBRARY_TABLE_SCOPE aScope ) { wxFileName fn = aLibFile; - wxFileName libTableFileName( Prj().GetProjectPath(), - SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() ); + wxFileName libTableFileName( Prj().GetProjectPath(), FILEEXT::SymbolLibraryTableFileName ); wxString libNickname = fn.GetName(); SYMBOL_LIBRARY_ADAPTER* adapter = PROJECT_SCH::SymbolLibAdapter( &Prj() ); const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables(); diff --git a/eeschema/symbol_editor/symbol_edit_frame.h b/eeschema/symbol_editor/symbol_edit_frame.h index e263407007..b3e810b279 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.h +++ b/eeschema/symbol_editor/symbol_edit_frame.h @@ -34,7 +34,6 @@ #include class SCH_EDIT_FRAME; -class SYMBOL_LIB_TABLE; class LIB_SYMBOL; class LIB_TREE_NODE; class LIB_ID; diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp index a79d970e77..49991e4440 100644 --- a/eeschema/symbol_editor/symbol_editor.cpp +++ b/eeschema/symbol_editor/symbol_editor.cpp @@ -33,10 +33,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include diff --git a/eeschema/symbol_editor/symbol_editor_import_export.cpp b/eeschema/symbol_editor/symbol_editor_import_export.cpp index d38d4dad3b..0c63311f14 100644 --- a/eeschema/symbol_editor/symbol_editor_import_export.cpp +++ b/eeschema/symbol_editor/symbol_editor_import_export.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/eeschema/symbol_lib_table.cpp b/eeschema/symbol_lib_table.cpp deleted file mode 100644 index 64c753327c..0000000000 --- a/eeschema/symbol_lib_table.cpp +++ /dev/null @@ -1,746 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2016 Wayne Stambaugh - * Copyright (C) 2022 CERN - * Copyright The KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "sim/sim_model.h" - -#define OPT_SEP '|' ///< options separator character - -using namespace LIB_TABLE_T; - -const char* SYMBOL_LIB_TABLE::PropPowerSymsOnly = "pwr_sym_only"; -const char* SYMBOL_LIB_TABLE::PropNonPowerSymsOnly = "non_pwr_sym_only"; -int SYMBOL_LIB_TABLE::m_modifyHash = 1; // starts at 1 and goes up - - -/// The global symbol library table. This is not dynamically allocated because -/// in a multiple project environment we must keep its address constant (since it is -/// the fallback table for multiple projects). -SYMBOL_LIB_TABLE g_symbolLibraryTable; - - -bool SYMBOL_LIB_TABLE_ROW::operator==( const SYMBOL_LIB_TABLE_ROW& aRow ) const -{ - return LIB_TABLE_ROW::operator == ( aRow ) && type == aRow.type; -} - - -void SYMBOL_LIB_TABLE_ROW::SetType( const wxString& aType ) -{ - type = SCH_IO_MGR::EnumFromStr( aType ); - - if( type == SCH_IO_MGR::SCH_FILE_UNKNOWN ) - type = SCH_IO_MGR::SCH_KICAD; - - plugin.reset(); -} - - -bool SYMBOL_LIB_TABLE_ROW::Refresh() -{ - if( !plugin ) - { - wxArrayString dummyList; - - plugin.reset( SCH_IO_MGR::FindPlugin( type ) ); - SetLoaded( false ); - plugin->EnumerateSymbolLib( dummyList, GetFullURI( true ), &GetProperties() ); - SetLoaded( true ); - return true; - } - - return false; -} - - -void SYMBOL_LIB_TABLE_ROW::GetSubLibraryNames( std::vector& aNames ) const -{ - if( !plugin ) - return; - - plugin->GetSubLibraryNames( aNames ); -} - - -wxString SYMBOL_LIB_TABLE_ROW::GetSubLibraryDescription( const wxString& aName ) const -{ - if( !plugin ) - return wxEmptyString; - - return plugin->GetSubLibraryDescription( aName ); -} - - -void SYMBOL_LIB_TABLE_ROW::ShowSettingsDialog( wxWindow* aParent ) const -{ - wxCHECK( plugin, /* void */ ); - - if( type != SCH_IO_MGR::SCH_DATABASE ) - return; - - DIALOG_DATABASE_LIB_SETTINGS dlg( aParent, static_cast( plugin.get() ) ); - dlg.ShowModal(); -} - - -SYMBOL_LIB_TABLE::SYMBOL_LIB_TABLE( SYMBOL_LIB_TABLE* aFallBackTable ) : - LIB_TABLE( aFallBackTable ) -{ - // not copying fall back, simply search aFallBackTable separately - // if "nickName not found". -} - - -SYMBOL_LIB_TABLE& SYMBOL_LIB_TABLE::GetGlobalLibTable() -{ - return g_symbolLibraryTable; -} - - -void SYMBOL_LIB_TABLE::Parse( LIB_TABLE_LEXER* in ) -{ - T tok; - wxString errMsg; // to collect error messages - - // This table may be nested within a larger s-expression, or not. - // Allow for parser of that optional containing s-expression to have looked ahead. - if( in->CurTok() != T_sym_lib_table ) - { - in->NeedLEFT(); - - if( ( tok = in->NextTok() ) != T_sym_lib_table ) - in->Expecting( T_sym_lib_table ); - } - - while( ( tok = in->NextTok() ) != T_RIGHT ) - { - std::unique_ptr< SYMBOL_LIB_TABLE_ROW > row = std::make_unique(); - - if( tok == T_EOF ) - in->Expecting( T_RIGHT ); - - if( tok != T_LEFT ) - in->Expecting( T_LEFT ); - - // in case there is a "row integrity" error, tell where later. - int lineNum = in->CurLineNumber(); - tok = in->NextTok(); - - // Optionally parse the current version number - if( tok == T_version ) - { - in->NeedNUMBER( "version" ); - m_version = std::stoi( in->CurText() ); - in->NeedRIGHT(); - continue; - } - - if( tok != T_lib ) - in->Expecting( T_lib ); - - // (name NICKNAME) - in->NeedLEFT(); - - if( ( tok = in->NextTok() ) != T_name ) - in->Expecting( T_name ); - - in->NeedSYMBOLorNUMBER(); - - row->SetNickName( in->FromUTF8() ); - - in->NeedRIGHT(); - - // After (name), remaining (lib) elements are order independent, and in - // some cases optional. - bool sawType = false; - bool sawOpts = false; - bool sawDesc = false; - bool sawUri = false; - bool sawDisabled = false; - bool sawHidden = false; - - while( ( tok = in->NextTok() ) != T_RIGHT ) - { - if( tok == T_EOF ) - in->Unexpected( T_EOF ); - - if( tok != T_LEFT ) - in->Expecting( T_LEFT ); - - tok = in->NeedSYMBOLorNUMBER(); - - switch( tok ) - { - case T_uri: - if( sawUri ) - in->Duplicate( tok ); - sawUri = true; - in->NeedSYMBOLorNUMBER(); - row->SetFullURI( in->FromUTF8() ); - break; - - case T_type: - if( sawType ) - in->Duplicate( tok ); - sawType = true; - in->NeedSYMBOLorNUMBER(); - row->SetType( in->FromUTF8() ); - break; - - case T_options: - if( sawOpts ) - in->Duplicate( tok ); - sawOpts = true; - in->NeedSYMBOLorNUMBER(); - row->SetOptions( in->FromUTF8() ); - break; - - case T_descr: - if( sawDesc ) - in->Duplicate( tok ); - sawDesc = true; - in->NeedSYMBOLorNUMBER(); - row->SetDescr( in->FromUTF8() ); - break; - - case T_disabled: - if( sawDisabled ) - in->Duplicate( tok ); - sawDisabled = true; - row->SetEnabled( false ); - break; - - case T_hidden: - if( sawHidden ) - in->Duplicate( tok ); - sawHidden = true; - row->SetVisible( false ); - break; - - default: - in->Unexpected( tok ); - } - - in->NeedRIGHT(); - } - - if( !sawType ) - in->Expecting( T_type ); - - if( !sawUri ) - in->Expecting( T_uri ); - - // All nickNames within this table fragment must be unique, so we do not use doReplace - // in doInsertRow(). (However a fallBack table can have a conflicting nickName and ours - // will supersede that one since in FindLib() we search this table before any fall back.) - wxString nickname = row->GetNickName(); // store it to be able to used it - // after row deletion if an error occurs - bool doReplace = false; - LIB_TABLE_ROW* tmp = row.release(); - - if( !doInsertRow( tmp, doReplace ) ) - { - delete tmp; // The table did not take ownership of the row. - - wxString msg = wxString::Format( _( "Duplicate library nickname '%s' found in symbol " - "library table file line %d" ), - nickname, - lineNum ); - - if( !errMsg.IsEmpty() ) - errMsg << '\n'; - - errMsg << msg; - } - } - - if( !errMsg.IsEmpty() ) - THROW_IO_ERROR( errMsg ); -} - - -void SYMBOL_LIB_TABLE::Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) const -{ - aOutput->Print( aIndentLevel, "(sym_lib_table\n" ); - aOutput->Print( aIndentLevel + 1, "(version %d)\n", m_version ); - - for( const LIB_TABLE_ROW& row : m_rows ) - row.Format( aOutput, aIndentLevel + 1 ); - - aOutput->Print( aIndentLevel, ")\n" ); -} - - -int SYMBOL_LIB_TABLE::GetModifyHash() -{ - int hash = 0; - std::vector< wxString > libNames = GetLogicalLibs(); - - for( const auto& libName : libNames ) - { - const SYMBOL_LIB_TABLE_ROW* row = FindRow( libName, true ); - - if( !row || !row->plugin ) - { - continue; - } - - hash += row->plugin->GetModifyHash(); - } - - hash += m_modifyHash; - - return hash; -} - - -void SYMBOL_LIB_TABLE::EnumerateSymbolLib( const wxString& aNickname, wxArrayString& aAliasNames, - bool aPowerSymbolsOnly ) -{ - SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true ); - wxCHECK( row && row->plugin, /* void */ ); - - wxString options = row->GetOptions(); - - if( aPowerSymbolsOnly ) - row->SetOptions( row->GetOptions() + " " + PropPowerSymsOnly ); - - row->SetLoaded( false ); - row->plugin->EnumerateSymbolLib( aAliasNames, row->GetFullURI( true ), &row->GetProperties() ); - row->SetLoaded( true ); - - if( aPowerSymbolsOnly ) - row->SetOptions( options ); -} - - -SYMBOL_LIB_TABLE_ROW* SYMBOL_LIB_TABLE::FindRow( const wxString& aNickname, bool aCheckIfEnabled ) -{ - SYMBOL_LIB_TABLE_ROW* row = - dynamic_cast< SYMBOL_LIB_TABLE_ROW* >( findRow( aNickname, aCheckIfEnabled ) ); - - if( !row ) - return nullptr; - - // We've been 'lazy' up until now, but it cannot be deferred any longer, - // instantiate a PLUGIN of the proper kind if it is not already in this - // SYMBOL_LIB_TABLE_ROW. - if( !row->plugin ) - row->setPlugin( SCH_IO_MGR::FindPlugin( row->type ) ); - - return row; -} - - -void SYMBOL_LIB_TABLE::LoadSymbolLib( std::vector& aSymbolList, - const wxString& aNickname, bool aPowerSymbolsOnly ) -{ - SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true ); - - if( !row || !row->plugin ) - return; - - std::lock_guard lock( row->GetMutex() ); - - wxString options = row->GetOptions(); - - if( aPowerSymbolsOnly ) - row->SetOptions( row->GetOptions() + " " + PropPowerSymsOnly ); - - row->SetLoaded( false ); - row->plugin->EnumerateSymbolLib( aSymbolList, row->GetFullURI( true ), &row->GetProperties() ); - row->SetLoaded( true ); - - if( aPowerSymbolsOnly ) - row->SetOptions( options ); - - // The library cannot know its own name, because it might have been renamed or moved. - // Therefore footprints cannot know their own library nickname when residing in - // a symbol library. - // Only at this API layer can we tell the symbol about its actual library nickname. - for( LIB_SYMBOL* symbol : aSymbolList ) - { - LIB_ID id = symbol->GetLibId(); - - id.SetLibNickname( row->GetNickName() ); - symbol->SetLibId( id ); - } -} - - -LIB_SYMBOL* SYMBOL_LIB_TABLE::LoadSymbol( const wxString& aNickname, const wxString& aSymbolName ) -{ - SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true ); - - if( !row || !row->plugin ) - return nullptr; - - // If another thread is loading this library at the moment; continue - std::unique_lock lock( row->GetMutex(), std::try_to_lock ); - - if( !lock.owns_lock() ) - return nullptr; - - LIB_SYMBOL* symbol = row->plugin->LoadSymbol( row->GetFullURI( true ), aSymbolName, - &row->GetProperties() ); - - if( symbol ) - { - // The library cannot know its own name, because it might have been renamed or moved. - // Therefore footprints cannot know their own library nickname when residing in - // a symbol library. - // Only at this API layer can we tell the symbol about its actual library nickname. - LIB_ID id = symbol->GetLibId(); - - id.SetLibNickname( row->GetNickName() ); - symbol->SetLibId( id ); - - SIM_MODEL::MigrateSimModel( *symbol, nullptr ); - } - - return symbol; -} - - -SYMBOL_LIB_TABLE::SAVE_T SYMBOL_LIB_TABLE::SaveSymbol( const wxString& aNickname, - const LIB_SYMBOL* aSymbol, bool aOverwrite ) -{ - const SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true ); - wxCHECK( row && row->plugin, SAVE_SKIPPED ); - - if( !row->plugin->IsLibraryWritable( row->GetFullURI( true ) ) ) - return SAVE_SKIPPED; - - if( !aOverwrite ) - { - // Try loading the footprint to see if it already exists, caller wants overwrite - // protection, which is atypical, not the default. - - wxString name = aSymbol->GetLibId().GetLibItemName(); - - std::unique_ptr symbol( row->plugin->LoadSymbol( row->GetFullURI( true ), - name, &row->GetProperties() ) ); - - if( symbol.get() ) - return SAVE_SKIPPED; - } - - try - { - row->plugin->SaveSymbol( row->GetFullURI( true ), aSymbol, &row->GetProperties() ); - } - catch( const IO_ERROR& ) - { - return SAVE_SKIPPED; - } - - return SAVE_OK; -} - - -void SYMBOL_LIB_TABLE::DeleteSymbol( const wxString& aNickname, const wxString& aSymbolName ) -{ - const SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true ); - wxCHECK( row && row->plugin, /* void */ ); - return row->plugin->DeleteSymbol( row->GetFullURI( true ), aSymbolName, &row->GetProperties() ); -} - - -bool SYMBOL_LIB_TABLE::IsSymbolLibWritable( const wxString& aNickname ) -{ - const SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true ); - wxCHECK( row && row->plugin, false ); - return row->plugin->IsLibraryWritable( row->GetFullURI( true ) ); -} - -bool SYMBOL_LIB_TABLE::IsSymbolLibLoaded( const wxString& aNickname ) -{ - const SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true ); - wxCHECK( row, false ); - return row->GetIsLoaded(); -} - - -void SYMBOL_LIB_TABLE::DeleteSymbolLib( const wxString& aNickname ) -{ - const SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true ); - wxCHECK( row && row->plugin, /* void */ ); - row->plugin->DeleteLibrary( row->GetFullURI( true ), &row->GetProperties() ); -} - - -void SYMBOL_LIB_TABLE::CreateSymbolLib( const wxString& aNickname ) -{ - const SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true ); - wxCHECK( row && row->plugin, /* void */ ); - row->plugin->CreateLibrary( row->GetFullURI( true ), &row->GetProperties() ); -} - - -LIB_SYMBOL* SYMBOL_LIB_TABLE::LoadSymbolWithOptionalNickname( const LIB_ID& aLibId ) -{ - wxString nickname = aLibId.GetLibNickname(); - wxString name = aLibId.GetLibItemName(); - - if( nickname.size() ) - { - return LoadSymbol( nickname, name ); - } - else - { - // nickname is empty, sequentially search (alphabetically) all libs/nicks for first match: - std::vector nicks = GetLogicalLibs(); - - // Search each library going through libraries alphabetically. - for( unsigned i = 0; i < nicks.size(); ++i ) - { - // FootprintLoad() returns NULL on not found, does not throw exception - // unless there's an IO_ERROR. - LIB_SYMBOL* ret = LoadSymbol( nicks[i], name ); - - if( ret ) - return ret; - } - - return nullptr; - } -} - - -const wxString SYMBOL_LIB_TABLE::GlobalPathEnvVariableName() -{ - return ENV_VAR::GetVersionedEnvVarName( wxS( "SYMBOL_DIR" ) ); -} - - -class PCM_SYM_LIB_TRAVERSER final : public wxDirTraverser -{ -public: - explicit PCM_SYM_LIB_TRAVERSER( const wxString& aPath, SYMBOL_LIB_TABLE& aTable, - const wxString& aPrefix ) : - m_lib_table( aTable ), - m_path_prefix( aPath ), - m_lib_prefix( aPrefix ) - { - wxFileName f( aPath, "" ); - m_prefix_dir_count = f.GetDirCount(); - } - - wxDirTraverseResult OnFile( const wxString& aFilePath ) override - { - wxFileName file = wxFileName::FileName( aFilePath ); - - // consider a file to be a lib if it's name ends with .kicad_sym and - // it is under $KICADn_3RD_PARTY/symbols// i.e. has nested level of at least +2 - if( file.GetExt() == wxT( "kicad_sym" ) && file.GetDirCount() >= m_prefix_dir_count + 2 ) - { - wxString versionedPath = wxString::Format( wxS( "${%s}" ), - ENV_VAR::GetVersionedEnvVarName( wxS( "3RD_PARTY" ) ) ); - - wxArrayString parts = file.GetDirs(); - parts.RemoveAt( 0, m_prefix_dir_count ); - parts.Insert( versionedPath, 0 ); - parts.Add( file.GetFullName() ); - - wxString libPath = wxJoin( parts, '/' ); - - if( !m_lib_table.HasLibraryWithPath( libPath ) ) - { - wxString name = parts.Last().substr( 0, parts.Last().length() - 10 ); - wxString nickname = wxString::Format( "%s%s", m_lib_prefix, name ); - - if( m_lib_table.HasLibrary( nickname ) ) - { - int increment = 1; - do - { - nickname = wxString::Format( "%s%s_%d", m_lib_prefix, name, increment ); - increment++; - } while( m_lib_table.HasLibrary( nickname ) ); - } - - m_lib_table.InsertRow( - new SYMBOL_LIB_TABLE_ROW( nickname, libPath, wxT( "KiCad" ), wxEmptyString, - _( "Added by Plugin and Content Manager" ) ), - false ); - } - } - - return wxDIR_CONTINUE; - } - - wxDirTraverseResult OnDir( const wxString& dirPath ) override { return wxDIR_CONTINUE; } - -private: - SYMBOL_LIB_TABLE& m_lib_table; - wxString m_path_prefix; - wxString m_lib_prefix; - size_t m_prefix_dir_count; -}; - - -bool SYMBOL_LIB_TABLE::LoadGlobalTable( SYMBOL_LIB_TABLE& aTable ) -{ - bool tableExists = true; - wxFileName fn = GetGlobalTableFileName(); - - if( !fn.FileExists() ) - { - tableExists = false; - - if( !wxFileName::DirExists( fn.GetPath() ) - && !wxFileName::Mkdir( fn.GetPath(), 0x777, wxPATH_MKDIR_FULL ) ) - { - THROW_IO_ERROR( wxString::Format( _( "Cannot create global library table path '%s'." ), - fn.GetPath() ) ); - } - - // Attempt to copy the default global file table from the KiCad - // template folder to the user's home configuration path. - SEARCH_STACK ss; - - SystemDirsAppend( &ss ); - - const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables(); - std::optional v = ENV_VAR::GetVersionedEnvVarValue( envVars, - wxT( "TEMPLATE_DIR" ) ); - - if( v && !v->IsEmpty() ) - ss.AddPaths( *v, 0 ); - - wxString fileName = ss.FindValidPath( FILEEXT::SymbolLibraryTableFileName ); - - // The fallback is to create an empty global symbol table for the user to populate. - if( fileName.IsEmpty() || !::wxCopyFile( fileName, fn.GetFullPath(), false ) ) - { - SYMBOL_LIB_TABLE emptyTable; - - emptyTable.Save( fn.GetFullPath() ); - } - } - - aTable.Load( fn.GetFullPath() ); - - KICAD_SETTINGS* cfg = GetAppSettings( "kicad" ); - wxString packagesPath; - const ENV_VAR_MAP& vars = Pgm().GetLocalEnvVariables(); - - if( std::optional v = ENV_VAR::GetVersionedEnvVarValue( vars, wxT( "3RD_PARTY" ) ) ) - packagesPath = *v; - - if( cfg && cfg->m_PcmLibAutoAdd ) - { - // Scan for libraries in PCM packages directory - wxFileName d( packagesPath, "" ); - d.AppendDir( "symbols" ); - - if( d.DirExists() ) - { - PCM_SYM_LIB_TRAVERSER traverser( packagesPath, aTable, cfg->m_PcmLibPrefix ); - wxDir dir( d.GetPath() ); - - dir.Traverse( traverser ); - } - } - - if( cfg && cfg->m_PcmLibAutoRemove ) - { - // Remove PCM libraries that no longer exist - std::vector to_remove; - - for( size_t i = 0; i < aTable.GetCount(); i++ ) - { - LIB_TABLE_ROW& row = aTable.At( i ); - wxString path = row.GetFullURI( true ); - - if( path.StartsWith( packagesPath ) && !wxFile::Exists( path ) ) - to_remove.push_back( row.GetNickName() ); - } - - for( const wxString& nickName : to_remove ) - { - SYMBOL_LIB_TABLE_ROW* row = aTable.FindRow( nickName ); - - wxCHECK2( row, continue ); - - aTable.RemoveRow( row ); - } - } - - return tableExists; -} - - -bool SYMBOL_LIB_TABLE::operator==( const SYMBOL_LIB_TABLE& aOther ) const -{ - if( m_rows.size() != aOther.m_rows.size() ) - return false; - - unsigned i; - - for( i = 0; i < m_rows.size(); ++i ) - { - const SYMBOL_LIB_TABLE_ROW& curr = static_cast( m_rows[i] ); - const SYMBOL_LIB_TABLE_ROW& curr_other = - static_cast( aOther.m_rows[i] ); - - if( curr != curr_other ) - return false; - } - - return true; -} - - -wxString SYMBOL_LIB_TABLE::GetGlobalTableFileName() -{ - wxFileName fn; - - fn.SetPath( PATHS::GetUserSettingsPath() ); - fn.SetName( FILEEXT::SymbolLibraryTableFileName ); - - return fn.GetFullPath(); -} - - -const wxString SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() -{ - return FILEEXT::SymbolLibraryTableFileName; -} diff --git a/eeschema/symbol_lib_table.h b/eeschema/symbol_lib_table.h deleted file mode 100644 index 202540ebb5..0000000000 --- a/eeschema/symbol_lib_table.h +++ /dev/null @@ -1,349 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2016 Wayne Stambaugh - * Copyright The KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef _SYMBOL_LIB_TABLE_H_ -#define _SYMBOL_LIB_TABLE_H_ - -#include -#include -#include -#include - -//class LIB_SYMBOL; -class SYMBOL_LIB_TABLE_GRID; -class DIALOG_SYMBOL_LIB_TABLE; - - -/** - * Hold a record identifying a symbol library accessed by the appropriate symbol library - * #SCH_IO object in the #SYMBOL_LIB_TABLE. - */ -class SYMBOL_LIB_TABLE_ROW : public LIB_TABLE_ROW -{ -public: - typedef SCH_IO_MGR::SCH_FILE_T LIB_T; - - SYMBOL_LIB_TABLE_ROW( const wxString& aNick, const wxString& aURI, const wxString& aType, - const wxString& aOptions = wxEmptyString, - const wxString& aDescr = wxEmptyString ) : - LIB_TABLE_ROW( aNick, aURI, aOptions, aDescr ) - { - SetType( aType ); - SetEnabled( true ); - } - - SYMBOL_LIB_TABLE_ROW() : - type( SCH_IO_MGR::SCH_KICAD ) - { - SetEnabled( true ); - } - - bool operator==( const SYMBOL_LIB_TABLE_ROW& aRow ) const; - - bool operator!=( const SYMBOL_LIB_TABLE_ROW& aRow ) const { return !( *this == aRow ); } - - LIB_T SchLibType() const { return type; } - - /** - * Return the type of symbol library table represented by this row. - */ - const wxString GetType() const override { return SCH_IO_MGR::ShowType( type ); } - - /** - * Change the schematic plugin type represented by this row. - */ - void SetType( const wxString& aType ) override; - - /** - * Attempt to reload the library. - * - * @return true if a reload was required. - * @throw IO_ERROR if the reload was unsuccessful. - */ - bool Refresh() override; - - bool SupportsSubLibraries() const { return plugin ? plugin->SupportsSubLibraries() : false; } - - bool SupportsSettingsDialog() const override - { - // Only database libraries have dialog-configurable options at the moment - return type == SCH_IO_MGR::SCH_FILE_T::SCH_DATABASE; - } - - void ShowSettingsDialog( wxWindow* aWindow ) const override; - - void GetSubLibraryNames( std::vector& aNames ) const; - - wxString GetSubLibraryDescription( const wxString& aName ) const; - - /** - * @see SCH_IO::GetAvailableSymbolFields - */ - void GetAvailableSymbolFields( std::vector& aNames ) const - { - if( plugin ) - plugin->GetAvailableSymbolFields( aNames ); - } - - /** - * @see SCH_IO::GetDefaultSymbolFields - */ - void GetDefaultSymbolFields( std::vector& aNames ) const - { - if( plugin ) - plugin->GetDefaultSymbolFields( aNames ); - } - - bool LibraryExists() const override - { - if( plugin ) - return plugin->CanReadLibrary( GetFullURI( true ) ); - - return false; - } - - SCH_IO_MGR::SCH_FILE_T GetFileType() { return type; } - -protected: - SYMBOL_LIB_TABLE_ROW( const SYMBOL_LIB_TABLE_ROW& aRow ) : - LIB_TABLE_ROW( aRow ), - type( aRow.type ) - { - SetEnabled( aRow.GetIsEnabled() ); - } - -private: - friend class SYMBOL_LIB_TABLE; - - virtual LIB_TABLE_ROW* do_clone() const override - { - return new SYMBOL_LIB_TABLE_ROW( *this ); - } - - void setPlugin( SCH_IO* aPlugin ) - { - plugin.reset( aPlugin ); - } - - IO_RELEASER plugin; - LIB_T type; -}; - - -class SYMBOL_LIB_TABLE : public LIB_TABLE -{ -public: - PROJECT::ELEM ProjectElementType() override { return PROJECT::ELEM::SYMBOL_LIB_TABLE; } - - static const char* PropPowerSymsOnly; - static const char* PropNonPowerSymsOnly; - - virtual void Parse( LIB_TABLE_LEXER* aLexer ) override; - - virtual void Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) const override; - - /** - * Build a symbol library table by pre-pending this table fragment in front of - * @a aFallBackTable. Loading of this table fragment is done by using Parse(). - * - * @param aFallBackTable is another SYMBOL_LIB_TABLE which is searched only when - * a row is not found in this table. No ownership is - * taken of aFallBackTable. - */ - SYMBOL_LIB_TABLE( SYMBOL_LIB_TABLE* aFallBackTable = nullptr ); - - /** - * Return an SYMBOL_LIB_TABLE_ROW if \a aNickName is found in this table or in any chained - * fallBack table fragment. - * - * The #SCH_IO is loaded and attached to the "plugin" fieldf the #SYMBOL_LIB_TABLE_ROW if - * not already loaded. - * - * @param aNickName is the name of the row to find. - * @param aCheckIfEnabled is a flag to verify if the table entry is enabled or disabled. - * @return the row found or NULL if \a aNickName was not found. - */ - SYMBOL_LIB_TABLE_ROW* FindRow( const wxString& aNickName, bool aCheckIfEnabled = false ); - - int GetModifyHash(); - - //-------------------------------- - - /** - * Return a list of symbol alias names contained within the library given by @a aNickname. - * - * @param aNickname is a locator for the "library", it is a "name" in LIB_TABLE_ROW. - * @param aAliasNames is a reference to an array for the alias names. - * @param aPowerSymbolsOnly is a flag to enumerate only power symbols. - * @throw IO_ERROR if the library cannot be found or loaded. - */ - void EnumerateSymbolLib( const wxString& aNickname, wxArrayString& aAliasNames, - bool aPowerSymbolsOnly = false ); - - void LoadSymbolLib( std::vector& aAliasList, const wxString& aNickname, - bool aPowerSymbolsOnly = false ); - - /** - * Load a #LIB_SYMBOL having @a aName from the library given by @a aNickname. - * - * @param aNickname is a locator for the "library", it is a "name" in #LIB_TABLE_ROW - * @param aName is the name of the #LIB_SYMBOL to load. - * @param aFlatten set to true to flatten derived parts. - * @return the symbol alias if found or NULL if not found. - * @throw IO_ERROR if the library cannot be found or read. No exception - * is thrown in the case where \a aNickname cannot be found. - */ - LIB_SYMBOL* LoadSymbol( const wxString& aNickname, const wxString& aName ); - - LIB_SYMBOL* LoadSymbol( const LIB_ID& aLibId ) - { - return LoadSymbol( aLibId.GetLibNickname(), aLibId.GetLibItemName() ); - } - - /** - * The set of return values from SaveSymbol() below. - */ - enum SAVE_T - { - SAVE_OK, - SAVE_SKIPPED, - }; - - /** - * Write @a aSymbol to an existing library given by @a aNickname. - * - * If a #LIB_SYMBOL by the same name already exists or there are any conflicting alias - * names, the new #LIB_SYMBOL will silently overwrite any existing aliases and/or part - * because libraries cannot have duplicate alias names. It is the responsibility of - * the caller to check the library for conflicts before saving. - * - * @param aNickname is a locator for the "library", it is a "name" in LIB_TABLE_ROW - * @param aSymbol is what to store in the library. The library owns the symbol after this - * call. - * @param aOverwrite when true means overwrite any existing symbol by the same name, - * else if false means skip the write and return SAVE_SKIPPED. - * @return SAVE_T - SAVE_OK or SAVE_SKIPPED. If error saving, then IO_ERROR is thrown. - * @throw IO_ERROR if there is a problem saving the symbol. - */ - SAVE_T SaveSymbol( const wxString& aNickname, const LIB_SYMBOL* aSymbol, - bool aOverwrite = true ); - - /** - * Deletes the @a aSymbolName from the library given by @a aNickname. - * - * @param aNickname is a locator for the "library", it is a "name" in LIB_TABLE_ROW. - * @param aSymbolName is the name of a symbol to delete from the specified library. - * @throw IO_ERROR if there is a problem finding the footprint or the library, or deleting it. - */ - void DeleteSymbol( const wxString& aNickname, const wxString& aSymbolName ); - - /** - * Return true if the library given by @a aNickname is writable. - * - * It is possible that some symbols libraries are read only because of where they are - * installed. - * - * @param aNickname is the library nickname in the symbol library table. - * @throw IO_ERROR if no library at @a aNickname exists. - */ - bool IsSymbolLibWritable( const wxString& aNickname ); - - /** - * Return true if the library given by @a aNickname was successfully loaded. - * - * @param aNickname is the library nickname in the symbol library table. - * @throw IO_ERROR if no library at @a aNickname exists. - */ - bool IsSymbolLibLoaded( const wxString& aNickname ); - - void DeleteSymbolLib( const wxString& aNickname ); - - void CreateSymbolLib( const wxString& aNickname ); - - //-------------------------------- - - /** - * Load a #LIB_SYMBOL having @a aFootprintId with possibly an empty library nickname. - * - * @param aId the library nickname and name of the symbol to load. - * @return the library symbol if found (the library owns it) or NULL if not found. - * @throw IO_ERROR if the library cannot be found or read. No exception - * is thrown in the case where aId cannot be found. - * @throw PARSE_ERROR if @a aId is not parsed OK. - */ - LIB_SYMBOL* LoadSymbolWithOptionalNickname( const LIB_ID& aId ); - - /** - * Load the global symbol library table into \a aTable. - * - * This probably should be move into the application object when KiCad is changed - * to a single process application. This is the least painful solution for the - * time being. - * - * @param aTable the #SYMBOL_LIB_TABLE object to load. - * @return true if the global library table exists and is loaded properly. - * @throw IO_ERROR if an error occurs attempting to load the symbol library table. - */ - static bool LoadGlobalTable( SYMBOL_LIB_TABLE& aTable ); - - /** - * - * Fetch the global symbol library table file name. - * - * @return the platform specific global symbol library path and file name. - */ - static wxString GetGlobalTableFileName(); - - /** - * Return the name of the environment variable used to hold the directory of locally - * installed "KiCad sponsored" system symbol libraries. - * - * These can be either legacy or sweet format. The only thing special about this - * particular environment variable is that it is set automatically by KiCad on - * program start up, if it is not set already in the environment. - */ - static const wxString GlobalPathEnvVariableName(); - - static SYMBOL_LIB_TABLE& GetGlobalLibTable(); - - static const wxString GetSymbolLibTableFileName(); - - /** - * Compares this table against another. - * This compares the row *contents* against each other. - */ - bool operator==( const SYMBOL_LIB_TABLE& aOther ) const; - - bool operator!=( const SYMBOL_LIB_TABLE& aOther ) const { return !( *this == aOther ); } - - -private: - friend class SYMBOL_LIB_TABLE_GRID; - friend class PANEL_SYM_LIB_TABLE; - - static int m_modifyHash; ///< helper for GetModifyHash() -}; - - -#endif // _SYMBOL_LIB_TABLE_H_ diff --git a/eeschema/symbol_library_common.h b/eeschema/symbol_library_common.h index e6ab43c355..0d4bad449c 100644 --- a/eeschema/symbol_library_common.h +++ b/eeschema/symbol_library_common.h @@ -27,7 +27,6 @@ class LIB_SYMBOL; class SCH_BASE_FRAME; -class SYMBOL_LIB_TABLE; enum class SCH_LIB_TYPE diff --git a/eeschema/symbol_library_manager.cpp b/eeschema/symbol_library_manager.cpp index 691e37a6e0..70c96b94ba 100644 --- a/eeschema/symbol_library_manager.cpp +++ b/eeschema/symbol_library_manager.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -35,7 +34,6 @@ #include #include #include -#include #include #include #include diff --git a/eeschema/symbol_tree_model_adapter.cpp b/eeschema/symbol_tree_model_adapter.cpp index 113889c96b..77af78133b 100644 --- a/eeschema/symbol_tree_model_adapter.cpp +++ b/eeschema/symbol_tree_model_adapter.cpp @@ -32,8 +32,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/eeschema/symbol_tree_model_adapter.h b/eeschema/symbol_tree_model_adapter.h index 85050665ac..780a133acc 100644 --- a/eeschema/symbol_tree_model_adapter.h +++ b/eeschema/symbol_tree_model_adapter.h @@ -65,8 +65,6 @@ protected: PROJECT::LIB_TYPE_T getLibType() override { return PROJECT::LIB_TYPE_T::SYMBOL_LIB; } private: - friend class SYMBOL_ASYNC_LOADER; - /** * Flag to only show the symbol library table load progress dialog the first time. */ diff --git a/eeschema/symbol_tree_synchronizing_adapter.cpp b/eeschema/symbol_tree_synchronizing_adapter.cpp index b960ad3d24..cd44a878e3 100644 --- a/eeschema/symbol_tree_synchronizing_adapter.cpp +++ b/eeschema/symbol_tree_synchronizing_adapter.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include diff --git a/eeschema/symbol_viewer_frame.cpp b/eeschema/symbol_viewer_frame.cpp index 4e9f282dff..d5887b7aba 100644 --- a/eeschema/symbol_viewer_frame.cpp +++ b/eeschema/symbol_viewer_frame.cpp @@ -41,13 +41,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include diff --git a/eeschema/symbol_viewer_frame.h b/eeschema/symbol_viewer_frame.h index 49744b7265..541ff0cdfb 100644 --- a/eeschema/symbol_viewer_frame.h +++ b/eeschema/symbol_viewer_frame.h @@ -35,7 +35,6 @@ class WX_LISTBOX; class wxSearchCtrl; class SYMBOL_LIBRARY_FILTER; class LIB_SYMBOL; -class SYMBOL_LIB_TABLE_ROW; /** diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index ec4e523437..180004ec30 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -61,7 +62,6 @@ #include #include #include -#include #include #include #include diff --git a/eeschema/tools/sch_inspection_tool.cpp b/eeschema/tools/sch_inspection_tool.cpp index 0fba38e0e8..56ceb85050 100644 --- a/eeschema/tools/sch_inspection_tool.cpp +++ b/eeschema/tools/sch_inspection_tool.cpp @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include diff --git a/eeschema/tools/symbol_editor_control.cpp b/eeschema/tools/symbol_editor_control.cpp index c62c167f3d..89c7de1ecc 100644 --- a/eeschema/tools/symbol_editor_control.cpp +++ b/eeschema/tools/symbol_editor_control.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include diff --git a/eeschema/widgets/panel_symbol_chooser.cpp b/eeschema/widgets/panel_symbol_chooser.cpp index d9d4c04695..8ea5e3ee7a 100644 --- a/eeschema/widgets/panel_symbol_chooser.cpp +++ b/eeschema/widgets/panel_symbol_chooser.cpp @@ -38,7 +38,6 @@ #include #include #include // For SYMBOL_LIBRARY_FILTER -#include #include #include #include diff --git a/eeschema/widgets/symbol_preview_widget.cpp b/eeschema/widgets/symbol_preview_widget.cpp index 77671e28da..ff4e3f90b2 100644 --- a/eeschema/widgets/symbol_preview_widget.cpp +++ b/eeschema/widgets/symbol_preview_widget.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/eeschema/widgets/symbol_tree_pane.cpp b/eeschema/widgets/symbol_tree_pane.cpp index 4d2c71a159..c69960d24d 100644 --- a/eeschema/widgets/symbol_tree_pane.cpp +++ b/eeschema/widgets/symbol_tree_pane.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include diff --git a/include/project.h b/include/project.h index 896abcda0b..beca763be8 100644 --- a/include/project.h +++ b/include/project.h @@ -71,7 +71,7 @@ public: { FPTBL, - SCH_SYMBOL_LIBS, + LEGACY_SYMBOL_LIBS, SCH_SEARCH_STACK, S3DCACHE, SYMBOL_LIB_TABLE, diff --git a/kicad/import_proj.cpp b/kicad/import_proj.cpp index 1ff4a88034..d683d7e66b 100644 --- a/kicad/import_proj.cpp +++ b/kicad/import_proj.cpp @@ -34,7 +34,6 @@ #include #include -#include #include #include diff --git a/qa/schematic_utils/eeschema_test_utils.cpp b/qa/schematic_utils/eeschema_test_utils.cpp index 71bc782670..b2e98694cb 100644 --- a/qa/schematic_utils/eeschema_test_utils.cpp +++ b/qa/schematic_utils/eeschema_test_utils.cpp @@ -64,7 +64,7 @@ void KI_TEST::SCHEMATIC_TEST_FIXTURE::LoadSchematic( const wxFileName& aFn ) m_manager.LoadProject( pro.GetFullPath() ); - m_manager.Prj().SetElem( PROJECT::ELEM::SCH_SYMBOL_LIBS, nullptr ); + m_manager.Prj().SetElem( PROJECT::ELEM::LEGACY_SYMBOL_LIBS, nullptr ); m_schematic = std::make_unique( &m_manager.Prj() ); m_schematic->SetRoot( m_pi->LoadSchematicFile( fn.GetFullPath(), m_schematic.get() ) ); diff --git a/qa/schematic_utils/schematic_file_util.cpp b/qa/schematic_utils/schematic_file_util.cpp index e599ff36c5..336151e5ba 100644 --- a/qa/schematic_utils/schematic_file_util.cpp +++ b/qa/schematic_utils/schematic_file_util.cpp @@ -141,7 +141,7 @@ void LoadSchematic( SETTINGS_MANAGER& aSettingsManager, const wxString& aRelPath else aSettingsManager.LoadProject( "" ); - aSettingsManager.Prj().SetElem( PROJECT::ELEM::SCH_SYMBOL_LIBS, nullptr ); + aSettingsManager.Prj().SetElem( PROJECT::ELEM::LEGACY_SYMBOL_LIBS, nullptr ); aSchematic = LoadHierarchyFromRoot( schematicPath, &aSettingsManager.Prj() );