mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 08:51:42 +00:00
Ensure imported schematic sheet names are unique
Altium doesn't require sheet names to be unique but KiCad does, so we disambiguate the names when importing Fixes https://gitlab.com/kicad/code/kicad/-/issues/19281
This commit is contained in:
parent
81fcc16cc9
commit
ca51b0f37d
@ -4151,6 +4151,9 @@ void SCH_IO_ALTIUM::ParseSheet( const std::map<wxString, wxString>& aProperties
|
||||
void SCH_IO_ALTIUM::ParseSheetName( const std::map<wxString, wxString>& aProperties )
|
||||
{
|
||||
ASCH_SHEET_NAME elem( aProperties );
|
||||
SCH_SCREEN* currentScreen = getCurrentScreen();
|
||||
|
||||
wxCHECK( currentScreen, /* void */ );
|
||||
|
||||
const auto& sheetIt = m_sheets.find( elem.ownerindex );
|
||||
|
||||
@ -4161,11 +4164,27 @@ void SCH_IO_ALTIUM::ParseSheetName( const std::map<wxString, wxString>& aPropert
|
||||
RPT_SEVERITY_DEBUG );
|
||||
return;
|
||||
}
|
||||
wxString sheetName = elem.text;
|
||||
std::set<wxString> sheetNames;
|
||||
|
||||
for( auto items : currentScreen->Items().OfType( SCH_SHEET_T ) )
|
||||
{
|
||||
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( items );
|
||||
sheetNames.insert( sheet->GetName() );
|
||||
}
|
||||
|
||||
for( int ii = 1; ; ++ii )
|
||||
{
|
||||
if( sheetNames.find( sheetName ) == sheetNames.end() )
|
||||
break;
|
||||
|
||||
sheetName = elem.text + wxString::Format( wxT( "_%d" ), ii );
|
||||
}
|
||||
|
||||
SCH_FIELD* sheetNameField = sheetIt->second->GetField( FIELD_T::SHEET_NAME );
|
||||
|
||||
sheetNameField->SetPosition( elem.location + m_sheetOffset );
|
||||
sheetNameField->SetText( elem.text );
|
||||
sheetNameField->SetText( sheetName );
|
||||
sheetNameField->SetVisible( !elem.isHidden );
|
||||
SetTextPositioning( sheetNameField, ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT, elem.orientation );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user