CADSTAR Schematic: Add needed junctions on load

Fixes a bug that was causing junctions to disappear when they
were not perfectly positioned in the original CADSTAR design.
This commit is contained in:
Roberto Fernandez Bautista 2021-05-28 16:53:12 +01:00
parent b985c4d2e9
commit 63f56640db
3 changed files with 17 additions and 3 deletions

View File

@ -58,6 +58,7 @@
#include <wildcards_and_files_ext.h>
#include <drawing_sheet/ds_data_model.h>
#include <wx/ffile.h>
#include <tools/ee_actions.h>
#include <tools/ee_inspection_tool.h>
#include <paths.h>
@ -1150,7 +1151,10 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
// Only fix junctions for CADSTAR importer for now as it may cause issues with
// other importers
if( fileType == SCH_IO_MGR::SCH_CADSTAR_ARCHIVE )
FixupJunctions();
{
FixupJunctions( true );
RecalculateConnections( GLOBAL_CLEANUP );
}
// Only perform the dangling end test on root sheet.
GetScreen()->TestDanglingEnds();

View File

@ -1498,7 +1498,7 @@ const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
}
void SCH_EDIT_FRAME::FixupJunctions()
void SCH_EDIT_FRAME::FixupJunctions( bool aAddNeededJunctions )
{
// Save the current sheet, to retrieve it later
SCH_SHEET_PATH oldsheetpath = GetCurrentSheet();
@ -1534,6 +1534,16 @@ void SCH_EDIT_FRAME::FixupJunctions()
for( const wxPoint& pos : junctions )
AddJunction( screen, pos, false, false );
if( aAddNeededJunctions )
{
EE_SELECTION allItems;
for( auto item : screen->Items() )
allItems.Add( item );
m_toolManager->RunAction( EE_ACTIONS::addNeededJunctions, true, &allItems );
}
if( junctions.size() )
modified = true;
}

View File

@ -813,7 +813,7 @@ public:
const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;
void FixupJunctions();
void FixupJunctions( bool aAddNeededJunctions = false );
void FocusOnItem( SCH_ITEM* aItem );