Altium: apply power filter to symbol libraries

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17922
This commit is contained in:
Jon Evans 2024-05-01 22:47:19 -04:00
parent 90b62762d3
commit cb7e0e4383
2 changed files with 34 additions and 14 deletions

View File

@ -4396,20 +4396,40 @@ void SCH_IO_ALTIUM::ParseLibHeader( const ALTIUM_COMPOUND_FILE& aAltiumSchFile,
}
void SCH_IO_ALTIUM::EnumerateSymbolLib( wxArrayString& aSymbolNameList,
const wxString& aLibraryPath,
const STRING_UTF8_MAP* aProperties )
void SCH_IO_ALTIUM::doEnumerateSymbolLib( const wxString& aLibraryPath,
const STRING_UTF8_MAP* aProperties,
std::function<void(const wxString&, LIB_SYMBOL*)> aInserter )
{
ensureLoadedLibrary( aLibraryPath, aProperties );
bool powerSymbolsOnly = ( aProperties &&
aProperties->find( SYMBOL_LIB_TABLE::PropPowerSymsOnly )
!= aProperties->end() );
auto it = m_libCache.find( aLibraryPath );
if( it != m_libCache.end() )
{
for( auto& [libnameStr, libSymbol] : it->second )
aSymbolNameList.Add( libnameStr );
}
{
if( powerSymbolsOnly && !libSymbol->IsPower() )
continue;
aInserter( libnameStr, libSymbol );
}
}
}
void SCH_IO_ALTIUM::EnumerateSymbolLib( wxArrayString& aSymbolNameList,
const wxString& aLibraryPath,
const STRING_UTF8_MAP* aProperties )
{
doEnumerateSymbolLib( aLibraryPath, aProperties,
[&]( const wxString& aStr, LIB_SYMBOL* )
{
aSymbolNameList.Add( aStr );
} );
}
@ -4417,17 +4437,14 @@ void SCH_IO_ALTIUM::EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
const wxString& aLibraryPath,
const STRING_UTF8_MAP* aProperties )
{
ensureLoadedLibrary( aLibraryPath, aProperties );
auto it = m_libCache.find( aLibraryPath );
if( it != m_libCache.end() )
{
for( auto& [libnameStr, libSymbol] : it->second )
aSymbolList.push_back( libSymbol );
}
doEnumerateSymbolLib( aLibraryPath, aProperties,
[&]( const wxString&, LIB_SYMBOL* aSymbol )
{
aSymbolList.emplace_back( aSymbol );
} );
}
LIB_SYMBOL* SCH_IO_ALTIUM::LoadSymbol( const wxString& aLibraryPath,
const wxString& aAliasName,
const STRING_UTF8_MAP* aProperties )

View File

@ -178,6 +178,9 @@ private:
std::map<wxString,LIB_SYMBOL*> ParseLibFile( const ALTIUM_COMPOUND_FILE& aAltiumSchFile );
std::vector<LIB_SYMBOL*> ParseLibComponent( const std::map<wxString, wxString>& aProperties );
void doEnumerateSymbolLib( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties,
std::function<void(const wxString&, LIB_SYMBOL*)> aInserter );
private:
SCH_SHEET* m_rootSheet; // The root sheet of the schematic being loaded..
SCH_SHEET_PATH m_sheetPath;