Refactor how at-load schematic normalization is called

Don't prepend "/" for nets at the top level

Revert "Don't prepend "/" for nets at the top level"

This reverts commit fa9533222f7d33eee5f3fa2320bd9f3167e28076.
This commit is contained in:
Jon Evans 2019-03-23 17:34:27 -04:00 committed by Wayne Stambaugh
parent 4bc7e6fdfa
commit 9589427960
3 changed files with 58 additions and 24 deletions

View File

@ -657,16 +657,6 @@ bool SCH_EDIT_FRAME::SchematicCleanUp( bool aUndo, SCH_SCREEN* aScreen )
itemList.PushItem( ITEM_PICKER( aItem, UR_DELETED ) ); itemList.PushItem( ITEM_PICKER( aItem, UR_DELETED ) );
}; };
auto add_junction = [ & ]( const wxPoint& aPosition ) -> void
{
auto junction = new SCH_JUNCTION( aPosition );
AddToScreen( junction, aScreen );
BreakSegments( aPosition, aUndo );
if( aUndo )
SaveCopyInUndoList( junction, UR_NEW, true );
};
BreakSegmentsOnJunctions( true, aScreen ); BreakSegmentsOnJunctions( true, aScreen );
for( item = aScreen->GetDrawItems(); item; item = item->Next() ) for( item = aScreen->GetDrawItems(); item; item = item->Next() )
@ -749,7 +739,30 @@ bool SCH_EDIT_FRAME::SchematicCleanUp( bool aUndo, SCH_SCREEN* aScreen )
if( item->GetFlags() & STRUCT_DELETED ) if( item->GetFlags() & STRUCT_DELETED )
RemoveFromScreen( item, aScreen ); RemoveFromScreen( item, aScreen );
else if( item->Type() == SCH_LINE_T ) }
if( itemList.GetCount() && aUndo )
SaveCopyInUndoList( itemList, UR_DELETED, true );
return itemList.GetCount() > 0;
}
bool SCH_EDIT_FRAME::AddMissingJunctions( SCH_SCREEN* aScreen )
{
bool added = false;
auto add_junction = [ & ]( const wxPoint& aPosition ) -> void
{
auto junction = new SCH_JUNCTION( aPosition );
AddToScreen( junction, aScreen );
BreakSegments( aPosition, false );
added = true;
};
for( auto item = aScreen->GetDrawItems(); item; item = item->Next() )
{
if( item->Type() == SCH_LINE_T )
{ {
auto line = static_cast<SCH_LINE*>( item ); auto line = static_cast<SCH_LINE*>( item );
@ -761,10 +774,19 @@ bool SCH_EDIT_FRAME::SchematicCleanUp( bool aUndo, SCH_SCREEN* aScreen )
} }
} }
if( itemList.GetCount() && aUndo ) return added;
SaveCopyInUndoList( itemList, UR_DELETED, true ); }
return itemList.GetCount() > 0;
void SCH_EDIT_FRAME::NormalizeSchematicOnFirstLoad()
{
BreakSegmentsOnJunctions();
SchematicCleanUp();
SCH_SHEET_LIST list( g_RootSheet );
for( const auto& sheet : list )
AddMissingJunctions( sheet.LastScreen() );
} }

View File

@ -370,8 +370,8 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
SetScreen( g_CurrentSheet->LastScreen() ); SetScreen( g_CurrentSheet->LastScreen() );
// Ensure the schematic is fully segmented on first display // Ensure the schematic is fully segmented on first display
BreakSegmentsOnJunctions(); NormalizeSchematicOnFirstLoad();
SchematicCleanUp();
GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 ); GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 );
GetScreen()->TestDanglingEnds(); // Only perform the dangling end test on root sheet. GetScreen()->TestDanglingEnds(); // Only perform the dangling end test on root sheet.
@ -849,8 +849,8 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
schematic.UpdateSymbolLinks(); // Update all symbol library links for all sheets. schematic.UpdateSymbolLinks(); // Update all symbol library links for all sheets.
// Ensure the schematic is fully segmented on first display // Ensure the schematic is fully segmented on first display
BreakSegmentsOnJunctions(); NormalizeSchematicOnFirstLoad();
SchematicCleanUp();
GetScreen()->m_Initialized = true; GetScreen()->m_Initialized = true;
SCH_TYPE_COLLECTOR components; SCH_TYPE_COLLECTOR components;

View File

@ -1034,6 +1034,18 @@ private:
*/ */
bool TrimWire( const wxPoint& aStart, const wxPoint& aEnd, bool aAppend = true ); bool TrimWire( const wxPoint& aStart, const wxPoint& aEnd, bool aAppend = true );
/**
* Checks all wires and adds any junctions that are missing
* (Intended to be called only on file load)
*/
bool AddMissingJunctions( SCH_SCREEN* aScreen );
/**
* Perform all cleanup and normalization steps so that the whole schematic
* is in a good state. This should only be called when loading a file.
*/
void NormalizeSchematicOnFirstLoad();
/** /**
* Start moving \a aItem using the mouse. * Start moving \a aItem using the mouse.
* *