20#include <boost/test/unit_test.hpp>
39#include <wx/filename.h>
66 graph->
Recalculate( m_schematic->BuildSheetListSortedByPageNumbers(),
true );
68 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
76 wxString refA, refB, pinNumA, pinNumB;
92 if( !p->Connection() || p->Connection()->Name().IsEmpty() )
100 pinNumA = p->GetNumber();
101 netA = p->Connection()->Name();
107 refB = sym->
GetRef( &sp );
108 pinNumB = p->GetNumber();
109 netB = p->Connection()->Name();
127 std::set<SCH_SYMBOL*> symbols { symA, symB };
128 std::set<wxString> nets { netA, netB };
132 wxT(
"BAD NAME" ), symbols, nets, pinA->
m_Uuid, pinB->
m_Uuid, refA, pinNumA, refB, pinNumB );
133 BOOST_CHECK( rejectedSpace ==
nullptr );
137 wxEmptyString, symbols, nets, pinA->
m_Uuid, pinB->
m_Uuid, refA, pinNumA, refB, pinNumB );
138 BOOST_CHECK( rejectedEmpty ==
nullptr );
141 wxT(
"MANUAL_CHAIN" ), symbols, nets, pinA->
m_Uuid, pinB->
m_Uuid, refA, pinNumA, refB, pinNumB );
158 bool foundInCommittedList =
false;
162 if(
chain &&
chain->GetName() == wxT(
"MANUAL_CHAIN" ) )
164 foundInCommittedList =
true;
169 BOOST_CHECK( foundInCommittedList );
177 wxT(
"MANUAL_CHAIN" ), symbols, nets, pinA->
m_Uuid, pinB->
m_Uuid, refA, pinNumA, refB, pinNumB );
199 graph->
Recalculate( m_schematic->BuildSheetListSortedByPageNumbers(),
true );
201 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
207 wxString refA, refB, pinNumA, pinNumB;
223 if( !p->Connection() || p->Connection()->Name().IsEmpty() )
230 refA = sym->
GetRef( &sp );
231 pinNumA = p->GetNumber();
232 netA = p->Connection()->Name();
238 refB = sym->
GetRef( &sp );
239 pinNumB = p->GetNumber();
240 netB = p->Connection()->Name();
255 std::set<SCH_SYMBOL*> symbols { symA, symB };
256 std::set<wxString> nets { netA, netB };
259 wxT(
"FIRST" ), symbols, nets, pinA->
m_Uuid, pinB->
m_Uuid, refA, pinNumA, refB, pinNumB );
263 std::set<wxString> overlapNets { netA };
265 wxT(
"SECOND" ), symbols, overlapNets, pinA->
m_Uuid, pinB->
m_Uuid, refA, pinNumA, refB,
268 BOOST_CHECK( collision ==
nullptr );
287 graph->
Recalculate( m_schematic->BuildSheetListSortedByPageNumbers(),
true );
289 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
296 wxString refA, refB, pinNumA, pinNumB;
312 if( !p->Connection() || p->Connection()->Name().IsEmpty() )
319 refA = sym->
GetRef( &sp );
320 pinNumA = p->GetNumber();
321 netA = p->Connection()->Name();
327 refB = sym->
GetRef( &sp );
328 pinNumB = p->GetNumber();
329 netB = p->Connection()->Name();
344 std::set<SCH_SYMBOL*> symbols { symA, symB };
345 std::set<wxString> nets { netA, netB };
348 wxT(
"ROUNDTRIP" ), symbols, nets, pinA->
m_Uuid, pinB->
m_Uuid, refA, pinNumA, refB,
354 wxString tmpDir = wxFileName::CreateTempFileName( wxT(
"kicad_qa_netchain_" ) );
355 wxRemoveFile( tmpDir );
357 wxString tmpFile = tmpDir + wxFileName::GetPathSeparator() + wxT(
"out.kicad_sch" );
359 SCH_SHEET* root = m_schematic->GetTopLevelSheet( 0 );
366 std::ifstream stream( tmpFile.ToStdString() );
369 PROJECT* prj = &m_schematic->Project();
373 reloaded->ConnectionGraph()->Recalculate( reloaded->BuildSheetListSortedByPageNumbers(),
true );
375 SCH_NETCHAIN* restored = reloaded->ConnectionGraph()->GetNetChainByName( wxT(
"ROUNDTRIP" ) );
376 BOOST_REQUIRE_MESSAGE( restored,
"Manual net chain failed to survive save/reload" );
383 wxRemoveFile( tmpFile );
401 graph->
Recalculate( m_schematic->BuildSheetListSortedByPageNumbers(),
true );
403 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
410 wxString refA, refB, pinNumA, pinNumB;
426 if( !p->Connection() || p->Connection()->Name().IsEmpty() )
433 refA = sym->
GetRef( &sp );
434 pinNumA = p->GetNumber();
435 netA = p->Connection()->Name();
441 refB = sym->
GetRef( &sp );
442 pinNumB = p->GetNumber();
443 netB = p->Connection()->Name();
458 std::set<SCH_SYMBOL*> symbols { symA, symB };
459 std::set<wxString> nets { netA, netB };
463 std::map<wxString, std::set<wxString>>
seed;
464 seed[wxT(
"ORIG" )] = nets;
468 wxT(
"ORIG" ), symbols, nets, pinA->
m_Uuid, pinB->
m_Uuid, refA, pinNumA, refB,
479 auto it = memberOverrides.find( wxT(
"NEW_NAME" ) );
Calculate the connectivity of a schematic and generates netlists.
SCH_NETCHAIN * GetNetChainByName(const wxString &aName)
void SetNetChainMemberNetOverrides(const std::map< wxString, std::set< wxString > > &aOverrides)
Stash per-chain member-net lists read from the schematic file.
const std::map< wxString, std::set< wxString > > & GetNetChainMemberNetOverrides() const
SCH_NETCHAIN * GetNetChainForNet(const wxString &aNet)
bool RenameCommittedNetChain(const wxString &aOld, const wxString &aNew)
Rename a committed net chain.
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Update the connection graph for the given list of sheets.
SCH_NETCHAIN * CreateManualNetChain(const wxString &aName, const std::set< class SCH_SYMBOL * > &aSymbols, const std::set< wxString > &aNets, const KIID &aTerminalPinA, const KIID &aTerminalPinB, const wxString &aRefA, const wxString &aPinNumA, const wxString &aRefB, const wxString &aPinNumB)
Commit a manually-defined net chain that the inferred-potential pass did not produce.
const std::vector< std::unique_ptr< SCH_NETCHAIN > > & GetCommittedNetChains() const
Return user-created (committed) net chains (legacy accessor retained under net-chain API).
bool DeleteCommittedNetChain(const wxString &aName)
Delete a committed net chain by name.
EE_TYPE OfType(KICAD_T aType) const
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Container for project specific data.
wxString Name(bool aIgnoreSheet=false) const
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
A net chain is a collection of nets that are connected together through passive components.
const std::set< wxString > & GetNets() const
const wxString & GetTerminalRef(int aIdx) const
const wxString & GetNetClass() const
const wxString & GetName() const
const std::set< class SCH_SYMBOL * > & GetSymbols() const
void SetNetClass(const wxString &aNetClass)
Net chains may override the netclass applied to every member net.
const wxString & GetTerminalPinNum(int aIdx) const
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 wxString & GetNetChainName() const
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
std::unique_ptr< SCHEMATIC > ReadSchematicFromStream(std::istream &aStream, PROJECT *aProject)
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
void DumpSchematicToFile(SCHEMATIC &aSchematic, SCH_SHEET &aSheet, const std::string &aFilename)
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::vector< FAB_LAYER_COLOR > dummy
NETCHAIN_MANUAL_FIXTURE()
std::unique_ptr< SCHEMATIC > m_schematic
SETTINGS_MANAGER m_settingsManager
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_FIXTURE_TEST_CASE(NetChain_ManualForceCreate_CommitsAndQueryable, NETCHAIN_MANUAL_FIXTURE)
const SHAPE_LINE_CHAIN chain
BOOST_CHECK_EQUAL(result, "25.4")