306 SCH_SHEET* original = m_schematic->GetTopLevelSheet();
307 auto copy = std::unique_ptr<SCH_SHEET>(
static_cast<SCH_SHEET*
>( original->
Clone() ) );
309 copy->SetName(
"Second" );
311 m_schematic->AddTopLevelSheet(
copy.release() );
313 BOOST_REQUIRE_EQUAL( sheets.size(), 2 );
314 auto& manager = m_schematic->NetChains();
316 for(
bool published : {
false,
true } )
323 m_schematic->Connectivity().Recalculate( *m_schematic,
true );
325 m_schematic->ConnectionGraph()->Recalculate( sheets,
true );
327 const auto& chains = manager.GetPotentialNetChains();
328 BOOST_REQUIRE_EQUAL( chains.size(), 2 );
332 for(
const auto&
chain : chains )
336 std::set<wxString> references;
339 references.insert( symbol->GetRef( &sheets[0] ) );
341 const std::set<wxString>
expected{
"R1",
"R2",
"R3" };
342 BOOST_CHECK( references ==
expected );
345 for(
const wxString& net : chains[0]->GetNets() )
346 BOOST_CHECK( !chains[1]->GetNets().contains( net ) );
349 auto* bridge = *chains[0]->GetSymbols().begin();
350 const auto pins = bridge->GetPins( &sheets[0] );
351 BOOST_REQUIRE_EQUAL( pins.size(), 2u );
352 auto* first = manager.FindPotentialNetChainBetweenPins( pins[0], sheets[0], pins[1], sheets[0] );
353 auto* second = manager.FindPotentialNetChainBetweenPins( pins[0], sheets[1], pins[1], sheets[1] );
356 BOOST_CHECK( first != second );
358 for(
int endpoint : { 0, 1 } )
360 BOOST_CHECK( first->GetTerminalPath( endpoint ) == sheets[0].Path() );
361 BOOST_CHECK( second->GetTerminalPath( endpoint ) == sheets[1].Path() );
364 BOOST_CHECK( !manager.FindPotentialNetChainBetweenPins( pins[0], sheets[0], pins[1], sheets[1] ) );
366 auto* ambiguous = manager.CreateManualNetChain(
367 "AMBIGUOUS_INSTANCE", first->GetSymbols(), first->GetNets(),
368 first->GetTerminalPinA(), first->GetTerminalPinB(),
369 first->GetTerminalRef( 0 ), first->GetTerminalPinNum( 0 ),
370 first->GetTerminalRef( 1 ), first->GetTerminalPinNum( 1 ) );
371 BOOST_CHECK( !ambiguous );
374 manager.DeleteCommittedNetChain(
"AMBIGUOUS_INSTANCE" );
376 auto* firstCommitted = manager.CreateNetChainFromPotential( first,
"FIRST_INSTANCE" );
377 auto* secondCommitted = manager.CreateNetChainFromPotential( second,
"SECOND_INSTANCE" );
380 const auto firstNets = firstCommitted->GetNets();
381 const auto secondNets = secondCommitted->GetNets();
382 BOOST_CHECK( !manager.ReplaceNetChainTerminalPin(
383 {
"FIRST_INSTANCE", 0, pins[0]->m_Uuid, sheets[1].Path() } ) );
384 BOOST_CHECK( firstCommitted->GetTerminalPath( 0 ) == sheets[0].Path() );
386 {
"FIRST_INSTANCE", 0, pins[0]->m_Uuid, sheets[0].Path() } ) );
388 {
"SECOND_INSTANCE", 0, pins[0]->m_Uuid, sheets[1].Path() } ) );
389 m_schematic->RebuildConnectivity();
390 BOOST_CHECK( firstCommitted->GetTerminalPath( 0 ) == sheets[0].Path() );
391 BOOST_CHECK( secondCommitted->GetTerminalPath( 0 ) == sheets[1].Path() );
392 BOOST_CHECK( firstCommitted->GetNets() == firstNets );
393 BOOST_CHECK( secondCommitted->GetNets() == secondNets );
394 BOOST_REQUIRE( manager.DeleteCommittedNetChain(
"FIRST_INSTANCE" ) );
395 BOOST_REQUIRE( manager.DeleteCommittedNetChain(
"SECOND_INSTANCE" ) );
403 std::unique_ptr<SCHEMATIC> schematic;
405 const auto path = schematic->Hierarchy().front();
413 auto* symbol =
static_cast<SCH_SYMBOL*
>( item );
415 if( symbol->GetRef( &
path ) == wxString(
"R1" ) )
416 left = symbol->GetPin( wxString(
"2" ) );
417 else if( symbol->GetRef( &
path ) == wxString(
"R2" ) )
418 right = symbol->GetPin( wxString(
"1" ) );
426 if(
static_cast<SCH_LABEL*
>( item )->GetText() == wxString(
"SIG" ) )
432 if( item->IsConnected(
left->GetPosition() ) && item->IsConnected(
right->GetPosition() ) )
433 wire =
static_cast<SCH_LINE*
>( item );
440 const_cast<KIID&
>( copiedWire->m_Uuid ) =
KIID();
441 const_cast<KIID&
>( copiedLabel->m_Uuid ) =
KIID();
442 copiedWire->Move(
VECTOR2I( 0, 10000000 ) );
443 copiedLabel->Move(
VECTOR2I( 0, 10000000 ) );
444 path.LastScreen()->Append( copiedWire );
445 path.LastScreen()->Append( copiedLabel );
446 const std::set<SCH_ITEM*>
expected{
left,
right, wire, label, copiedWire, copiedLabel };
451 for(
bool useEngine : {
false,
true } )
456 schematic->RebuildConnectivity();
459 schematic->ConnectionGraph()->Reset();
464 BOOST_CHECK( std::set<SCH_ITEM*>( items.begin(), items.end() ) ==
expected );
virtual void SetText(const wxString &aText)
A schematic staged off to the side by an importer, ready to be swapped into a live SCHEMATIC in one s...
std::optional< SCH_SHEET_PATH > currentSheet
std::unique_ptr< CONNECTION_GRAPH > connectionGraph
bool preserveNetChains
Keep the schematic's net chains instead of the staged graph's, for append.
SCH_SHEET * targetSheet
Sheet whose screen receives the content. Null names the schematic's virtual root.
EE_RTREE screenItems
Spatial index that replaces the target screen's own.
BOOST_CHECK_EQUAL(result, "25.4")