44#include <wx/filename.h>
45#include <wx/stdpaths.h>
54 BOOST_CHECK_NE( pi.get(),
nullptr );
65 fn.AppendDir(
"eagle" );
66 fn.SetFullName( sch_file );
81 const wxString& aProjectStem,
82 std::unique_ptr<SCHEMATIC>& aSchematic )
84 wxString tempDir = wxStandardPaths::Get().GetTempDir();
85 wxString projectPath = tempDir + wxFileName::GetPathSeparator() + aProjectStem
86 + wxT(
".kicad_pro" );
92 aSchematic = std::make_unique<SCHEMATIC>( &
project );
102 loadedSheet = pi->LoadSchematicFile( aEagleFn.GetFullPath(), aSchematic.get() );
104 catch(
const std::exception& e )
106 BOOST_FAIL( std::string(
"LoadSchematicFile threw: " ) + e.what() );
110 BOOST_FAIL(
"LoadSchematicFile threw unknown exception" );
131 std::unique_ptr<SCHEMATIC> schematic;
137 const std::vector<SCH_SHEET*>& topSheets = schematic->GetTopLevelSheets();
145 BOOST_CHECK( sheet !=
nullptr );
146 BOOST_CHECK( sheet->m_Uuid !=
niluuid );
151 BOOST_CHECK( !sheet->GetScreen()->GetFileName().IsEmpty() );
157 SCH_SHEET_LIST hierarchy = schematic->BuildSheetListSortedByPageNumbers();
160 std::set<KIID_PATH> hierPaths;
163 hierPaths.insert(
path.Path() );
165 int totalSymbols = 0;
166 int orphanedSymbols = 0;
180 bool foundMatch =
false;
184 if( hierPaths.count( inst.m_Path ) )
196 BOOST_CHECK_GT( totalSymbols, 0 );
219 std::unique_ptr<SCHEMATIC> schematic;
225 SCH_SHEET_LIST hierarchy = schematic->BuildSheetListSortedByPageNumbers();
227 std::unordered_set<wxString> globalTexts;
228 std::unordered_set<wxString> localTexts;
238 globalTexts.insert(
static_cast<SCH_LABEL_BASE*
>( item )->GetText() );
241 localTexts.insert(
static_cast<SCH_LABEL_BASE*
>( item )->GetText() );
247 const std::vector<wxString> expectedGlobalNets = {
248 wxS(
"A1" ), wxS(
"A2" ), wxS(
"A3" ),
249 wxS(
"B1" ), wxS(
"B2" ), wxS(
"B3" )
252 for(
const wxString& netName : expectedGlobalNets )
255 "Missing global Eagle net label '" << netName.ToStdString()
256 <<
"' — flat namespace requires SCH_GLOBALLABEL." );
258 "Found local SCH_LABEL '" << netName.ToStdString()
259 <<
"' — Eagle net should be global." );
264 const std::vector<wxString> expectedLocalBuses = {
265 wxS(
"A[1..3]" ), wxS(
"B[1..3]" )
268 for(
const wxString& busName : expectedLocalBuses )
271 "Found global SCH_GLOBALLABEL '" << busName.ToStdString()
272 <<
"' — Eagle bus should remain a local SCH_LABEL." );
292 std::unique_ptr<SCHEMATIC> schematic;
295 SCH_SHEET_LIST hierarchy = schematic->BuildSheetListSortedByPageNumbers();
299 std::map<wxString, const SCH_SYMBOL*> symbolByLibItem;
317 BOOST_REQUIRE( symbolByLibItem.count( wxS(
"tagtest_MYDEV" ) ) == 1 );
318 BOOST_REQUIRE( symbolByLibItem.count( wxS(
"tagtest_MYDEV_NC" ) ) == 1 );
320 auto collectNames = [](
const SCH_SYMBOL* aSym )
322 std::multiset<wxString> names;
324 for(
const SCH_PIN*
pin : aSym->GetAllLibPins() )
325 names.insert(
pin->GetName() );
331 for(
const auto& [libItem, sym] : symbolByLibItem )
333 for(
const SCH_PIN*
pin : sym->GetAllLibPins() )
336 libItem.ToStdString() <<
" pin kept Eagle tag '"
337 <<
pin->GetName().ToStdString() <<
"'." );
343 std::map<wxString, wxString> nameByPad;
345 for(
const SCH_PIN*
pin : symbolByLibItem[wxS(
"tagtest_MYDEV" )]->GetAllLibPins() )
346 nameByPad[
pin->GetNumber()] =
pin->GetName();
354 std::multiset<wxString> ncNames = collectNames( symbolByLibItem[wxS(
"tagtest_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.