Fixup Junctions should call common tool
This commit is contained in:
parent
3fa8795f26
commit
f47784cd14
|
@ -1152,7 +1152,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
|
||||||
// other importers
|
// other importers
|
||||||
if( fileType == SCH_IO_MGR::SCH_CADSTAR_ARCHIVE )
|
if( fileType == SCH_IO_MGR::SCH_CADSTAR_ARCHIVE )
|
||||||
{
|
{
|
||||||
FixupJunctions( true );
|
FixupJunctions();
|
||||||
RecalculateConnections( GLOBAL_CLEANUP );
|
RecalculateConnections( GLOBAL_CLEANUP );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1498,17 +1498,17 @@ const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::FixupJunctions( bool aAddNeededJunctions )
|
void SCH_EDIT_FRAME::FixupJunctions()
|
||||||
{
|
{
|
||||||
// Save the current sheet, to retrieve it later
|
// Save the current sheet, to retrieve it later
|
||||||
SCH_SHEET_PATH oldsheetpath = GetCurrentSheet();
|
SCH_SHEET_PATH oldsheetpath = GetCurrentSheet();
|
||||||
|
|
||||||
bool modified = false;
|
|
||||||
|
|
||||||
SCH_SHEET_LIST sheetList = Schematic().GetSheets();
|
SCH_SHEET_LIST sheetList = Schematic().GetSheets();
|
||||||
|
|
||||||
for( const SCH_SHEET_PATH& sheet : sheetList )
|
for( const SCH_SHEET_PATH& sheet : sheetList )
|
||||||
{
|
{
|
||||||
|
size_t num_undos = m_undoList.m_CommandsList.size();
|
||||||
|
|
||||||
// We require a set here to avoid adding multiple junctions to the same spot
|
// We require a set here to avoid adding multiple junctions to the same spot
|
||||||
std::set<wxPoint> junctions;
|
std::set<wxPoint> junctions;
|
||||||
|
|
||||||
|
@ -1517,40 +1517,19 @@ void SCH_EDIT_FRAME::FixupJunctions( bool aAddNeededJunctions )
|
||||||
|
|
||||||
SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
|
SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
|
||||||
|
|
||||||
for( auto aItem : screen->Items().OfType( SCH_COMPONENT_T ) )
|
EE_SELECTION allItems;
|
||||||
{
|
|
||||||
auto cmp = static_cast<SCH_COMPONENT*>( aItem );
|
|
||||||
|
|
||||||
for( const SCH_PIN* pin : cmp->GetPins( &sheet ) )
|
for( auto item : screen->Items() )
|
||||||
{
|
allItems.Add( item );
|
||||||
auto pos = pin->GetPosition();
|
|
||||||
|
|
||||||
// Test if a _new_ junction is needed, and add it if missing
|
m_toolManager->RunAction( EE_ACTIONS::addNeededJunctions, true, &allItems );
|
||||||
if( screen->IsJunctionNeeded( pos, true ) )
|
|
||||||
junctions.insert( pos );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for( const wxPoint& pos : junctions )
|
// Check if we modified anything during this routine
|
||||||
AddJunction( screen, pos, false, false );
|
// Needs to happen for every sheet to set the proper modified flag
|
||||||
|
if( m_undoList.m_CommandsList.size() > num_undos )
|
||||||
if( aAddNeededJunctions )
|
OnModify();
|
||||||
{
|
|
||||||
EE_SELECTION allItems;
|
|
||||||
|
|
||||||
for( auto item : screen->Items() )
|
|
||||||
allItems.Add( item );
|
|
||||||
|
|
||||||
m_toolManager->RunAction( EE_ACTIONS::addNeededJunctions, true, &allItems );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( junctions.size() )
|
|
||||||
modified = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( modified )
|
|
||||||
OnModify();
|
|
||||||
|
|
||||||
// Reselect the initial sheet:
|
// Reselect the initial sheet:
|
||||||
SetCurrentSheet( oldsheetpath );
|
SetCurrentSheet( oldsheetpath );
|
||||||
GetCurrentSheet().UpdateAllScreenReferences();
|
GetCurrentSheet().UpdateAllScreenReferences();
|
||||||
|
|
|
@ -813,7 +813,7 @@ public:
|
||||||
|
|
||||||
const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;
|
const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;
|
||||||
|
|
||||||
void FixupJunctions( bool aAddNeededJunctions = false );
|
void FixupJunctions();
|
||||||
|
|
||||||
void FocusOnItem( SCH_ITEM* aItem );
|
void FocusOnItem( SCH_ITEM* aItem );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue