32#include <wx/filename.h>
42 kicadSymLib.AppendDir(
"eeschema" );
43 kicadSymLib.AppendDir(
"libs" );
44 kicadSymLib.SetFullName(
"4xxx.kicad_sym" );
48 legacyLib.AppendDir(
"eeschema" );
49 legacyLib.AppendDir(
"libs" );
50 legacyLib.SetFullName(
"4xxx.lib" );
64 wxArrayString symbolNames;
75 for(
const wxString&
name : symbolNames )
112 wxArrayString symbolNames;
123 for(
const wxString&
name : symbolNames )
201 BOOST_CHECK( manager.
IsDerived(
"14528" ) );
202 BOOST_CHECK( manager.
IsDerived(
"14538" ) );
203 BOOST_CHECK( manager.
IsDerived(
"4528" ) );
204 BOOST_CHECK( manager.
IsDerived(
"4066" ) );
207 BOOST_CHECK( !manager.
IsDerived(
"4538" ) );
208 BOOST_CHECK( !manager.
IsDerived(
"4016" ) );
209 BOOST_CHECK( !manager.
IsDerived(
"4001" ) );
238 std::set<wxString> ancestors = manager.
GetAncestors(
"4066" );
240 BOOST_CHECK( ancestors.count(
"4016" ) == 1 );
257 std::set<wxString> descendants = manager.
GetDescendants(
"4538" );
259 BOOST_CHECK( descendants.count(
"14528" ) == 1 );
260 BOOST_CHECK( descendants.count(
"14538" ) == 1 );
261 BOOST_CHECK( descendants.count(
"4528" ) == 1 );
266 BOOST_CHECK( descendants.count(
"4066" ) == 1 );
406 manager.
SelectAll( [](
const wxString&
name ) {
return name.StartsWith(
"40" ); } );
410 BOOST_CHECK_GT( selectedCount, 0 );
440 std::set<wxString> existingSymbols = {
"4001",
"4011",
"4538" };
442 [&existingSymbols](
const wxString&
name ) {
return existingSymbols.count(
name ) > 0; } );
458 std::vector<wxString> conflicts = manager.
GetConflicts();
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Define a library symbol object.
bool IsPower() const override
const wxString & GetParentName() const
Manages the logic for selecting symbols to import from a library file.
void DeselectWithDescendants(const wxString &aSymbolName)
Force deselection of a symbol and all its descendants.
std::vector< wxString > GetConflicts() const
Get list of symbols that will conflict (selected and exist in destination).
void CheckExistingSymbols(SYMBOL_EXISTS_FUNC aExistsFunc)
Mark symbols that exist in the destination library.
void SelectAll(std::function< bool(const wxString &)> aFilter=nullptr)
Select all symbols (optionally filtered).
std::vector< wxString > GetDirectDerivatives(const wxString &aSymbolName) const
Get direct children (derivatives) of a symbol.
wxString GetParent(const wxString &aSymbolName) const
Get the direct parent of a symbol.
int GetManualSelectionCount() const
Get count of manually selected symbols.
void DeselectAll(std::function< bool(const wxString &)> aFilter=nullptr)
Deselect all symbols (optionally filtered).
size_t GetSymbolCount() const
Get total number of symbols.
void AddSymbol(const wxString &aName, const wxString &aParentName, bool aIsPower, LIB_SYMBOL *aSymbol=nullptr)
Add a symbol to the import list.
std::vector< wxString > GetSelectedDescendants(const wxString &aSymbolName) const
Get selected descendants that would be orphaned if a symbol is deselected.
std::vector< wxString > SetSymbolSelected(const wxString &aSymbolName, bool aSelected)
Set the selection state of a symbol.
static bool MatchesFilter(const wxString &aSymbolName, const wxString &aFilter)
Check if a symbol name matches a filter string (case-insensitive contains).
int GetAutoSelectionCount() const
Get count of auto-selected symbols (dependencies).
void Clear()
Clear all loaded symbols and reset state.
SYMBOL_IMPORT_INFO * GetSymbolInfo(const wxString &aName)
Get symbol info by name.
bool IsDerived(const wxString &aSymbolName) const
Check if a symbol is derived from another.
std::set< wxString > GetAncestors(const wxString &aSymbolName) const
Get all ancestors of a symbol (full inheritance chain).
std::set< wxString > GetDescendants(const wxString &aSymbolName) const
Get all descendants of a symbol (all derived symbols recursively).
std::vector< wxString > GetSymbolsToImport() const
Get list of all symbols that will be imported (checked + auto-selected).
void BuildDependencyMaps()
Build the dependency maps from parent relationships.
bool LoadLegacyLibraryHelper(SYMBOL_IMPORT_MANAGER &aManager)
Load symbols from a legacy symbol library into the manager.
TEST_SYMBOL_IMPORT_MANAGER_FIXTURE()
bool LoadKiCadLibraryHelper(SYMBOL_IMPORT_MANAGER &aManager)
Load symbols from a KiCad symbol library into the manager.
wxString m_kicadSymLibPath
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
std::string GetTestDataRootDir()
Information about a symbol available for import.
bool m_existsInDest
True if symbol exists in destination library.
bool m_checked
User's manual selection state.
bool m_autoSelected
True if auto-selected as dependency.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(LoadKiCadSymbolLibrary)
Test loading symbols from a KiCad symbol library.
BOOST_CHECK_EQUAL(result, "25.4")