eeschema: automatically insert junctions at pin connections if needed during file load
EEschema optimizes wires by merging colinear segments. If a schematic opened without a valid cache library or missing installed libraries and later saved, this optimization can cause connectivity errors. In order to fix that we check each pin-wire connection and junctions if necessary.
This commit is contained in:
parent
ec3158d03a
commit
d7fe307913
|
@ -384,6 +384,13 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
|||
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
||||
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
||||
SetSheetNumberAndCount();
|
||||
|
||||
// re-create junctions if needed. EEschema optimizes wires by merging
|
||||
// colinear segments. If a schematic is saved without a valid
|
||||
// cache library or missing installed libraries, this can cause connectivity errors
|
||||
// unless junctions are added.
|
||||
FixupJunctions();
|
||||
|
||||
SyncView();
|
||||
GetScreen()->ClearDrawingState();
|
||||
|
||||
|
|
|
@ -1139,3 +1139,38 @@ const BOX2I SCH_EDIT_FRAME::GetDocumentExtents() const
|
|||
|
||||
return BOX2I( VECTOR2I(0, 0), VECTOR2I( sizeX, sizeY ) );
|
||||
}
|
||||
|
||||
void SCH_EDIT_FRAME::FixupJunctions()
|
||||
{
|
||||
SCH_SHEET_LIST sheetList;
|
||||
|
||||
sheetList.BuildSheetList( g_RootSheet );
|
||||
|
||||
for( unsigned i = 0; i < sheetList.size(); i++ )
|
||||
{
|
||||
std::vector<wxPoint> anchors;
|
||||
|
||||
SetCurrentSheet( sheetList[i] );
|
||||
GetCurrentSheet().UpdateAllScreenReferences();
|
||||
|
||||
auto screen = GetCurrentSheet().LastScreen();
|
||||
|
||||
for( SCH_ITEM* item = screen->GetDrawItems(); item; item = item->Next() )
|
||||
{
|
||||
if( item->Type() == SCH_COMPONENT_T )
|
||||
{
|
||||
auto cmp = static_cast<SCH_COMPONENT*>( item );
|
||||
auto xform = cmp->GetTransform();
|
||||
|
||||
for( auto pin : cmp->GetPins() )
|
||||
{
|
||||
auto pos = cmp->GetPosition() + xform.TransformCoordinate( pin.GetPosition() );
|
||||
if ( screen->IsJunctionNeeded( pos ) )
|
||||
{
|
||||
AddJunction( pos );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1026,6 +1026,8 @@ public:
|
|||
|
||||
const BOX2I GetDocumentExtents() const override;
|
||||
|
||||
void FixupJunctions();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue