40#include <wx/filename.h>
41#include <wx/stdpaths.h>
50 BOOST_CHECK_NE( pi.get(),
nullptr );
61 fn.AppendDir(
"eagle" );
62 fn.SetFullName( sch_file );
77 const wxString& aProjectStem,
78 std::unique_ptr<SCHEMATIC>& aSchematic )
85 wxString sep = wxFileName::GetPathSeparator();
86 wxString projectDir = wxStandardPaths::Get().GetTempDir() + sep + aProjectStem
89 if( wxDirExists( projectDir ) )
90 wxFileName::Rmdir( projectDir, wxPATH_RMDIR_RECURSIVE );
92 wxFileName::Mkdir( projectDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
94 wxString projectPath = projectDir + sep + aProjectStem + wxT(
".kicad_pro" );
100 aSchematic = std::make_unique<SCHEMATIC>( &
project );
110 loadedSheet = pi->LoadSchematicFile( aEagleFn.GetFullPath(), aSchematic.get() );
112 catch(
const std::exception& e )
114 BOOST_FAIL( std::string(
"LoadSchematicFile threw: " ) + e.what() );
118 BOOST_FAIL(
"LoadSchematicFile threw unknown exception" );
139 std::unique_ptr<SCHEMATIC> schematic;
145 const std::vector<SCH_SHEET*>& topSheets = schematic->GetTopLevelSheets();
153 BOOST_CHECK( sheet !=
nullptr );
154 BOOST_CHECK( sheet->m_Uuid !=
niluuid );
159 BOOST_CHECK( !sheet->GetScreen()->GetFileName().IsEmpty() );
165 SCH_SHEET_LIST hierarchy = schematic->BuildSheetListSortedByPageNumbers();
168 std::set<KIID_PATH> hierPaths;
171 hierPaths.insert(
path.Path() );
173 int totalSymbols = 0;
174 int orphanedSymbols = 0;
188 bool foundMatch =
false;
192 if( hierPaths.count( inst.m_Path ) )
204 BOOST_CHECK_GT( totalSymbols, 0 );
227 std::unique_ptr<SCHEMATIC> schematic;
233 SCH_SHEET_LIST hierarchy = schematic->BuildSheetListSortedByPageNumbers();
235 std::unordered_set<wxString> globalTexts;
236 std::unordered_set<wxString> localTexts;
246 globalTexts.insert(
static_cast<SCH_LABEL_BASE*
>( item )->GetText() );
249 localTexts.insert(
static_cast<SCH_LABEL_BASE*
>( item )->GetText() );
255 const std::vector<wxString> expectedGlobalNets = {
256 wxS(
"A1" ), wxS(
"A2" ), wxS(
"A3" ),
257 wxS(
"B1" ), wxS(
"B2" ), wxS(
"B3" )
260 for(
const wxString& netName : expectedGlobalNets )
263 "Missing global Eagle net label '" << netName.ToStdString()
264 <<
"' — flat namespace requires SCH_GLOBALLABEL." );
266 "Found local SCH_LABEL '" << netName.ToStdString()
267 <<
"' — Eagle net should be global." );
272 const std::vector<wxString> expectedLocalBuses = {
273 wxS(
"A[1..3]" ), wxS(
"B[1..3]" )
276 for(
const wxString& busName : expectedLocalBuses )
279 "Found global SCH_GLOBALLABEL '" << busName.ToStdString()
280 <<
"' — Eagle bus should remain a local SCH_LABEL." );
300 std::unique_ptr<SCHEMATIC> schematic;
303 SCH_SHEET_LIST hierarchy = schematic->BuildSheetListSortedByPageNumbers();
309 std::map<wxString, const SCH_SYMBOL*> symbolByLibItem;
327 BOOST_REQUIRE( symbolByLibItem.count( wxS(
"MYDEV" ) ) == 1 );
328 BOOST_REQUIRE( symbolByLibItem.count( wxS(
"MYDEV_NC" ) ) == 1 );
330 auto collectNames = [](
const SCH_SYMBOL* aSym )
332 std::multiset<wxString> names;
334 for(
const SCH_PIN*
pin : aSym->GetAllLibPins() )
335 names.insert(
pin->GetName() );
341 for(
const auto& [libItem, sym] : symbolByLibItem )
343 for(
const SCH_PIN*
pin : sym->GetAllLibPins() )
346 libItem.ToStdString() <<
" pin kept Eagle tag '"
347 <<
pin->GetName().ToStdString() <<
"'." );
353 std::map<wxString, wxString> nameByPad;
355 for(
const SCH_PIN*
pin : symbolByLibItem[wxS(
"MYDEV" )]->GetAllLibPins() )
356 nameByPad[
pin->GetNumber()] =
pin->GetName();
364 std::multiset<wxString> ncNames = collectNames( symbolByLibItem[wxS(
"MYDEV_NC" )] );
A base class for most all the KiCad significant classes used in schematics and boards.
EE_TYPE OfType(KICAD_T aType) const
void LoadProjectTables(std::initializer_list< LIBRARY_TABLE_TYPE > aTablesToLoad={})
(Re)loads the project library tables in the given list, or all tables if no list is given
const UTF8 & GetLibItemName() const
virtual SETTINGS_MANAGER & GetSettingsManager() const
virtual LIBRARY_MANAGER & GetLibraryManager() const
Container for project specific data.
Base class for any item which can be embedded within the SCHEMATIC container class,...
EE_RTREE & Items()
Get the full RTree, usually for iterating.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
const LIB_ID & GetLibId() const override
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Load a project or sets up a new project with a specified path.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
PGM_BASE & Pgm()
The global program "get" accessor.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
A simple container for schematic symbol instance information.
BOOST_AUTO_TEST_CASE(FindPlugin)
Checks that the SCH_IO manager finds the Eagle plugin.
static wxFileName getEagleTestSchematic(const wxString &sch_file)
Get a schematic file from the test data eagle subdir.
static SCH_SHEET * loadEagleSchematic(const wxFileName &aEagleFn, const wxString &aProjectStem, std::unique_ptr< SCHEMATIC > &aSchematic)
Common Eagle-import scaffolding: stage a fresh project under tempDir, configure the library manager,...
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
BOOST_CHECK_EQUAL(result, "25.4")
Definition of file extensions used in Kicad.