Remove legacy symbol lib table code
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include <project/net_settings.h>
|
||||
#include <project_sch.h>
|
||||
#include <richio.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <tools/sch_actions.h>
|
||||
#include <tools/sch_editor_control.h>
|
||||
#include <advanced_config.h>
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include <sch_edit_frame.h>
|
||||
#include <schematic.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <env_paths.h>
|
||||
#include <project_sch.h>
|
||||
#include <wx/msgdlg.h>
|
||||
@@ -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<LIBRARY_TABLE*> optTable =
|
||||
Pgm().GetLibraryManager().Table( LIBRARY_TABLE_TYPE::SYMBOL, LIBRARY_TABLE_SCOPE::PROJECT );
|
||||
wxCHECK( optTable, /* void */ );
|
||||
LIBRARY_TABLE* projectTable = *optTable;
|
||||
|
||||
std::vector<LEGACY_SYMBOL_LIB*> libs;
|
||||
|
||||
if( getLibsNotInGlobalSymbolLibTable( libs ) )
|
||||
{
|
||||
wxBusyCursor busy;
|
||||
SYMBOL_LIB_TABLE libTable;
|
||||
std::vector<wxString> libNames = SYMBOL_LIB_TABLE::GetGlobalLibTable().GetLogicalLibs();
|
||||
std::vector<wxString> 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 );
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <panel_sym_lib_table_base.h>
|
||||
#include <lib_table_grid.h>
|
||||
|
||||
class SYMBOL_LIB_TABLE;
|
||||
class SYMBOL_LIB_TABLE_GRID;
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,13 +38,13 @@
|
||||
#include <symbol_edit_frame.h>
|
||||
#include <symbol_viewer_frame.h>
|
||||
#include <symbol_chooser_frame.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <dialogs/panel_grid_settings.h>
|
||||
#include <dialogs/panel_simulator_preferences.h>
|
||||
#include <dialogs/panel_design_block_lib_table.h>
|
||||
#include <dialogs/panel_sym_lib_table.h>
|
||||
#include <kiway.h>
|
||||
#include <project_sch.h>
|
||||
#include <richio.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <symbol_editor_settings.h>
|
||||
#include <sexpr/sexpr.h>
|
||||
@@ -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()" ) );
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
#include <sch_textbox.h>
|
||||
#include <sch_line.h>
|
||||
#include <schematic.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <drawing_sheet/ds_draw_item.h>
|
||||
#include <drawing_sheet/ds_proxy_view_item.h>
|
||||
#include <vector>
|
||||
|
||||
@@ -195,21 +195,21 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& 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() );
|
||||
|
||||
@@ -57,7 +57,7 @@ class LEGACY_SYMBOL_LIB;
|
||||
class LEGACY_SYMBOL_LIBS : public boost::ptr_vector<LEGACY_SYMBOL_LIB>, 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() {}
|
||||
|
||||
|
||||
@@ -39,8 +39,6 @@
|
||||
#include <project_sch.h>
|
||||
#include <trace_helpers.h>
|
||||
|
||||
#include <symbol_lib_table.h>
|
||||
|
||||
#include <set>
|
||||
#include <libraries/symbol_library_adapter.h>
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <sch_edit_frame.h>
|
||||
|
||||
class CONNECTION_GRAPH;
|
||||
class SYMBOL_LIB_TABLE;
|
||||
class XNODE;
|
||||
|
||||
#define GENERIC_INTERMEDIATE_NETLIST_EXT wxT( "xml" )
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include <sch_symbol.h>
|
||||
#include <sch_commit.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/sch_actions.h>
|
||||
#include <project_sch.h>
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <project_sch.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <string_utils.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
@@ -680,12 +679,12 @@ bool LEGACY_RESCUER::WriteRescueLibrary( wxWindow *aParent )
|
||||
wxString libPaths;
|
||||
|
||||
wxString libName = m_rescue_lib->GetName();
|
||||
LEGACY_SYMBOL_LIBS* libs = dynamic_cast<LEGACY_SYMBOL_LIBS*>( m_prj->GetElem( PROJECT::ELEM::SCH_SYMBOL_LIBS ) );
|
||||
LEGACY_SYMBOL_LIBS* libs = dynamic_cast<LEGACY_SYMBOL_LIBS*>( 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<LEGACY_SYMBOL_LIB> 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() );
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <pgm_base.h>
|
||||
#include <wx/app.h>
|
||||
#include <core/utf8.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <project_sch.h>
|
||||
#include <libraries/legacy_symbol_library.h>
|
||||
#include <libraries/symbol_library_adapter.h>
|
||||
@@ -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<LEGACY_SYMBOL_LIBS*>( 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<std::mutex> 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();
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
class SYMBOL_LIB_TABLE;
|
||||
class PROJECT;
|
||||
class SEARCH_STACK;
|
||||
class LEGACY_SYMBOL_LIBS;
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
#include <project_sch.h>
|
||||
#include <libraries/legacy_symbol_library.h>
|
||||
#include <libraries/symbol_library_adapter.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <sch_base_frame.h>
|
||||
#include <dialogs/dialog_sch_find.h>
|
||||
#include <design_block.h>
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <sch_sheet.h>
|
||||
#include <schematic.h>
|
||||
#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <wx_filename.h>
|
||||
#include <libraries/library_table.h>
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
#include <fmt.h>
|
||||
#include <ki_exception.h>
|
||||
#include <lib_symbol.h>
|
||||
#include <lib_id.h>
|
||||
#include <symbol_lib_table.h>
|
||||
|
||||
#include "sch_io_database.h"
|
||||
|
||||
@@ -80,7 +78,7 @@ void SCH_IO_DATABASE::EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& 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 )
|
||||
{
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
#include <sch_symbol.h>
|
||||
#include <schematic.h>
|
||||
#include <string_utils.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <libraries/symbol_library_adapter.h>
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include <fmt.h>
|
||||
#include <lib_symbol.h>
|
||||
#include <symbol_lib_table.h>
|
||||
|
||||
#include <libraries/symbol_library_adapter.h>
|
||||
#include <http_lib/http_lib_connection.h>
|
||||
@@ -58,7 +57,7 @@ void SCH_IO_HTTP_LIB::EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& 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() )
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
#include <sch_screen.h>
|
||||
#include <schematic.h>
|
||||
#include <libraries/legacy_symbol_library.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <libraries/symbol_library_adapter.h>
|
||||
#include <eeschema_id.h> // for MAX_UNIT_COUNT_PER_PACKAGE definition
|
||||
#include <tool/selection.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
@@ -2118,7 +2118,7 @@ void SCH_IO_KICAD_LEGACY::EnumerateSymbolLib( wxArrayString& aSymbolNameList,
|
||||
const wxString& aLibraryPath,
|
||||
const std::map<std::string, UTF8>* 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<LIB_SYMBOL*>& aSymbolL
|
||||
const wxString& aLibraryPath,
|
||||
const std::map<std::string, UTF8>* aProperties )
|
||||
{
|
||||
bool powerSymbolsOnly = ( aProperties && aProperties->contains( SYMBOL_LIB_TABLE::PropPowerSymsOnly ) );
|
||||
bool powerSymbolsOnly = ( aProperties && aProperties->contains( SYMBOL_LIBRARY_ADAPTER::PropPowerSymsOnly ) );
|
||||
|
||||
cacheLib( aLibraryPath, aProperties );
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <sch_selection.h>
|
||||
#include <font/fontconfig.h>
|
||||
#include <io/kicad/kicad_io_utils.h>
|
||||
#include <libraries/symbol_library_adapter.h>
|
||||
#include <progress_reporter.h>
|
||||
#include <schematic.h>
|
||||
#include <schematic_lexer.h>
|
||||
@@ -59,7 +60,6 @@
|
||||
#include <sch_text.h>
|
||||
#include <sch_textbox.h>
|
||||
#include <string_utils.h>
|
||||
#include <symbol_lib_table.h> // for PropPowerSymsOnly definition.
|
||||
#include <trace_helpers.h>
|
||||
|
||||
using namespace TSCHEMATIC_T;
|
||||
@@ -1633,7 +1633,7 @@ void SCH_IO_KICAD_SEXPR::EnumerateSymbolLib( wxArrayString& aSymbolNameList,
|
||||
const wxString& aLibraryPath,
|
||||
const std::map<std::string, UTF8>* 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<LIB_SYMBOL*>& aSymbolLi
|
||||
const wxString& aLibraryPath,
|
||||
const std::map<std::string, UTF8>* aProperties )
|
||||
{
|
||||
bool powerSymbolsOnly = ( aProperties && aProperties->contains( SYMBOL_LIB_TABLE::PropPowerSymsOnly ) );
|
||||
bool powerSymbolsOnly = ( aProperties && aProperties->contains( SYMBOL_LIBRARY_ADAPTER::PropPowerSymsOnly ) );
|
||||
|
||||
cacheLib( aLibraryPath, aProperties );
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <schematic.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_screen.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <kiplatform/environment.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;
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
#include <sch_text.h>
|
||||
#include <schematic.h>
|
||||
#include <symb_transforms_utils.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <tool/common_tools.h>
|
||||
#include <sim/sim_model.h> // For V6 to V7 simulation model migration.
|
||||
#include <locale_io.h>
|
||||
|
||||
+1
-3
@@ -37,7 +37,6 @@
|
||||
#include <sch_view.h>
|
||||
#include <sch_painter.h>
|
||||
#include <schematic.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <dialogs/dialog_sheet_properties.h>
|
||||
#include <tool/actions.h>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,139 +0,0 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2021 Jon Evans <jon@craftyjon.com>
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include <core/wx_stl_compat.h>
|
||||
#include <symbol_async_loader.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <progress_reporter.h>
|
||||
|
||||
|
||||
SYMBOL_ASYNC_LOADER::SYMBOL_ASYNC_LOADER( const std::vector<wxString>& aNicknames,
|
||||
SYMBOL_LIB_TABLE* aTable, bool aOnlyPowerSymbols,
|
||||
std::unordered_map<wxString, std::vector<LIB_SYMBOL*>>* 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<size_t>( 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<LOADED_PAIR>& 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::LOADED_PAIR> SYMBOL_ASYNC_LOADER::worker()
|
||||
{
|
||||
std::vector<LOADED_PAIR> 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<std::mutex> 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<std::mutex> lock( m_errorMutex );
|
||||
m_errors += msg;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2021 Jon Evans <jon@craftyjon.com>
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KICAD_SYMBOL_ASYNC_LOADER_H
|
||||
#define KICAD_SYMBOL_ASYNC_LOADER_H
|
||||
|
||||
#include <atomic>
|
||||
#include <future>
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <wx/string.h>
|
||||
|
||||
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<wxString>& aNicknames,
|
||||
SYMBOL_LIB_TABLE* aTable, bool aOnlyPowerSymbols = false,
|
||||
std::unordered_map<wxString, std::vector<LIB_SYMBOL*>>* 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 <nickname, loaded parts list>.
|
||||
typedef std::pair<wxString, std::vector<LIB_SYMBOL*>> LOADED_PAIR;
|
||||
|
||||
private:
|
||||
/// Worker job that loads libraries and returns a list of pairs of <nickname, loaded parts>.
|
||||
std::vector<LOADED_PAIR> worker();
|
||||
|
||||
/// List of libraries to load.
|
||||
std::vector<wxString> 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<wxString, std::vector<LIB_SYMBOL*>>* m_output;
|
||||
|
||||
/// Progress reporter (may be null).
|
||||
PROGRESS_REPORTER* m_reporter;
|
||||
|
||||
size_t m_threadCount;
|
||||
std::atomic<size_t> m_nextLibrary;
|
||||
wxString m_errors;
|
||||
std::mutex m_errorMutex;
|
||||
|
||||
std::vector<std::future<std::vector<LOADED_PAIR>>> m_returns;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -45,7 +45,6 @@
|
||||
#include <sch_painter.h>
|
||||
#include <sch_view.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <toolbars_symbol_editor.h>
|
||||
#include <tool/action_manager.h>
|
||||
#include <tool/action_toolbar.h>
|
||||
@@ -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();
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include <optional>
|
||||
|
||||
class SCH_EDIT_FRAME;
|
||||
class SYMBOL_LIB_TABLE;
|
||||
class LIB_SYMBOL;
|
||||
class LIB_TREE_NODE;
|
||||
class LIB_ID;
|
||||
|
||||
@@ -33,10 +33,10 @@
|
||||
#include <symbol_edit_frame.h>
|
||||
#include <template_fieldnames.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <lib_symbol_library_manager.h>
|
||||
#include <symbol_tree_pane.h>
|
||||
#include <project/project_file.h>
|
||||
#include <richio.h>
|
||||
#include <widgets/lib_tree.h>
|
||||
#include <sch_io/kicad_legacy/sch_io_kicad_legacy.h>
|
||||
#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr.h>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <kidialog.h>
|
||||
#include <common.h>
|
||||
#include <io/eagle/eagle_parser.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <sch_io/sch_io.h>
|
||||
#include <symbol_edit_frame.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <lib_symbol_library_manager.h>
|
||||
|
||||
@@ -1,746 +0,0 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* 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 <env_vars.h>
|
||||
#include <lib_id.h>
|
||||
#include <lib_table_lexer.h>
|
||||
#include <paths.h>
|
||||
#include <pgm_base.h>
|
||||
#include <search_stack.h>
|
||||
#include <settings/kicad_settings.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <systemdirsappend.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <lib_symbol.h>
|
||||
#include <sch_io/database/sch_io_database.h>
|
||||
#include <dialogs/dialog_database_lib_settings.h>
|
||||
|
||||
#include <wx/dir.h>
|
||||
#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<wxString>& 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<SCH_IO_DATABASE*>( 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<SYMBOL_LIB_TABLE_ROW>();
|
||||
|
||||
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<LIB_SYMBOL*>& aSymbolList,
|
||||
const wxString& aNickname, bool aPowerSymbolsOnly )
|
||||
{
|
||||
SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true );
|
||||
|
||||
if( !row || !row->plugin )
|
||||
return;
|
||||
|
||||
std::lock_guard<std::mutex> 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<std::mutex> 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<LIB_SYMBOL>( *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<LIB_SYMBOL> 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<wxString> 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/<pkgid>/ 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<wxString> 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_SETTINGS>( "kicad" );
|
||||
wxString packagesPath;
|
||||
const ENV_VAR_MAP& vars = Pgm().GetLocalEnvVariables();
|
||||
|
||||
if( std::optional<wxString> 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<wxString> 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<const SYMBOL_LIB_TABLE_ROW&>( m_rows[i] );
|
||||
const SYMBOL_LIB_TABLE_ROW& curr_other =
|
||||
static_cast<const SYMBOL_LIB_TABLE_ROW&>( 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;
|
||||
}
|
||||
@@ -1,349 +0,0 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* 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 <lib_table_base.h>
|
||||
#include <sch_io/sch_io.h>
|
||||
#include <sch_io/sch_io_mgr.h>
|
||||
#include <lib_id.h>
|
||||
|
||||
//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<wxString>& aNames ) const;
|
||||
|
||||
wxString GetSubLibraryDescription( const wxString& aName ) const;
|
||||
|
||||
/**
|
||||
* @see SCH_IO::GetAvailableSymbolFields
|
||||
*/
|
||||
void GetAvailableSymbolFields( std::vector<wxString>& aNames ) const
|
||||
{
|
||||
if( plugin )
|
||||
plugin->GetAvailableSymbolFields( aNames );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SCH_IO::GetDefaultSymbolFields
|
||||
*/
|
||||
void GetDefaultSymbolFields( std::vector<wxString>& 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<SCH_IO> 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();
|
||||
|
||||
//-----<PLUGIN API SUBSET, REBASED ON aNickname>---------------------------
|
||||
|
||||
/**
|
||||
* 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<LIB_SYMBOL*>& 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 );
|
||||
|
||||
//-----</PLUGIN API SUBSET, REBASED ON 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, <b>if</b> 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_
|
||||
@@ -27,7 +27,6 @@
|
||||
|
||||
class LIB_SYMBOL;
|
||||
class SCH_BASE_FRAME;
|
||||
class SYMBOL_LIB_TABLE;
|
||||
|
||||
|
||||
enum class SCH_LIB_TYPE
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
|
||||
#include <dialogs/html_message_box.h>
|
||||
#include <symbol_edit_frame.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <env_paths.h>
|
||||
#include <pgm_base.h>
|
||||
#include <project_sch.h>
|
||||
@@ -35,7 +34,6 @@
|
||||
#include <core/profile.h>
|
||||
#include <wx_filename.h>
|
||||
#include <sch_io/kicad_legacy/sch_io_kicad_legacy.h>
|
||||
#include <symbol_async_loader.h>
|
||||
#include <progress_reporter.h>
|
||||
#include <list>
|
||||
#include <locale_io.h>
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
#include <generate_alias_info.h>
|
||||
#include <sch_base_frame.h>
|
||||
#include <locale_io.h>
|
||||
#include <symbol_async_loader.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <string_utils.h>
|
||||
#include <trace_helpers.h>
|
||||
#include <libraries/symbol_library_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.
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <pgm_base.h>
|
||||
#include <project/project_file.h>
|
||||
#include <lib_symbol_library_manager.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <tools/symbol_editor_control.h>
|
||||
#include <project_sch.h>
|
||||
#include <string_utils.h>
|
||||
|
||||
@@ -41,13 +41,11 @@
|
||||
#include <widgets/wx_progress_reporters.h>
|
||||
#include <sch_view.h>
|
||||
#include <sch_painter.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <symbol_tree_model_adapter.h>
|
||||
#include <pgm_base.h>
|
||||
#include <project/project_file.h>
|
||||
#include <project_sch.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <symbol_async_loader.h>
|
||||
#include <tool/action_toolbar.h>
|
||||
#include <tool/common_control.h>
|
||||
#include <tool/common_tools.h>
|
||||
|
||||
@@ -35,7 +35,6 @@ class WX_LISTBOX;
|
||||
class wxSearchCtrl;
|
||||
class SYMBOL_LIBRARY_FILTER;
|
||||
class LIB_SYMBOL;
|
||||
class SYMBOL_LIB_TABLE_ROW;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <project/project_file.h>
|
||||
#include <project/net_settings.h>
|
||||
#include <project_sch.h>
|
||||
#include <richio.h>
|
||||
#include <sch_design_block_pane.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr.h>
|
||||
@@ -61,7 +62,6 @@
|
||||
#include <sch_sheet_pin.h>
|
||||
#include <sch_commit.h>
|
||||
#include <sim/simulator_frame.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <symbol_library_manager.h>
|
||||
#include <symbol_viewer_frame.h>
|
||||
#include <tool/picker_tool.h>
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
#include <sch_edit_frame.h>
|
||||
#include <symbol_edit_frame.h>
|
||||
#include <symbol_viewer_frame.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <eda_doc.h>
|
||||
#include <sch_marker.h>
|
||||
#include <project.h>
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include <sch_painter.h>
|
||||
#include <string_utils.h>
|
||||
#include <symbol_editor/symbol_editor_settings.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <symbol_tree_model_adapter.h>
|
||||
#include <symbol_viewer_frame.h>
|
||||
#include <tool/library_editor_control.h>
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include <eeschema_settings.h>
|
||||
#include <symbol_editor_settings.h>
|
||||
#include <symbol_library_common.h> // For SYMBOL_LIBRARY_FILTER
|
||||
#include <symbol_lib_table.h>
|
||||
#include <algorithm>
|
||||
#include <wx/button.h>
|
||||
#include <wx/clipbrd.h>
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <gal/gal_display_options.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <math/vector2wx.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <lib_symbol.h>
|
||||
#include <libraries/symbol_library_adapter.h>
|
||||
#include <sch_preview_panel.h>
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <widgets/lib_tree.h>
|
||||
#include <lib_symbol_library_manager.h>
|
||||
#include <symbol_edit_frame.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/sch_actions.h>
|
||||
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public:
|
||||
{
|
||||
FPTBL,
|
||||
|
||||
SCH_SYMBOL_LIBS,
|
||||
LEGACY_SYMBOL_LIBS,
|
||||
SCH_SEARCH_STACK,
|
||||
S3DCACHE,
|
||||
SYMBOL_LIB_TABLE,
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include <pcb_edit_frame.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
||||
#include <symbol_lib_table.h>
|
||||
#include <fp_lib_table.h>
|
||||
|
||||
#include <sch_io/sch_io_mgr.h>
|
||||
|
||||
@@ -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<SCHEMATIC>( &m_manager.Prj() );
|
||||
m_schematic->SetRoot( m_pi->LoadSchematicFile( fn.GetFullPath(), m_schematic.get() ) );
|
||||
|
||||
@@ -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() );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user