From ef624199cd01c7f4adbedb919417fe5f6bd540ac Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sun, 27 Nov 2022 19:34:33 -0500 Subject: [PATCH] Fix Altium schematic import bug. --- .../sch_plugins/altium/altium_parser_sch.cpp | 1 + .../sch_plugins/altium/altium_parser_sch.h | 1 + .../sch_plugins/altium/sch_altium_plugin.cpp | 35 +++++++++++++------ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/eeschema/sch_plugins/altium/altium_parser_sch.cpp b/eeschema/sch_plugins/altium/altium_parser_sch.cpp index fe294ebc5a..abcb15d2ae 100644 --- a/eeschema/sch_plugins/altium/altium_parser_sch.cpp +++ b/eeschema/sch_plugins/altium/altium_parser_sch.cpp @@ -136,6 +136,7 @@ ASCH_SYMBOL::ASCH_SYMBOL( const std::map& aProps ) partcount = ALTIUM_PARSER::ReadInt( aProps, "PARTCOUNT", 0 ); displaymodecount = ALTIUM_PARSER::ReadInt( aProps, "DISPLAYMODECOUNT", 0 ); + m_indexInSheet = ALTIUM_PARSER::ReadInt( aProps, "INDEXINSHEET", -1 ); displaymode = ALTIUM_PARSER::ReadInt( aProps, "DISPLAYMODE", 0 ); } diff --git a/eeschema/sch_plugins/altium/altium_parser_sch.h b/eeschema/sch_plugins/altium/altium_parser_sch.h index 646805dad2..d20230732f 100644 --- a/eeschema/sch_plugins/altium/altium_parser_sch.h +++ b/eeschema/sch_plugins/altium/altium_parser_sch.h @@ -133,6 +133,7 @@ struct ASCH_SHAPE_INTERFACE struct ASCH_SYMBOL { int currentpartid; + int m_indexInSheet; wxString libreference; wxString sourcelibraryname; wxString componentdescription; diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index 167e2fe2ed..f5b52d7e6a 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -480,8 +480,8 @@ void SCH_ALTIUM_PLUGIN::ParseAdditional( const ALTIUM_COMPOUND_FILE& aAltiumSchF break; default: - m_reporter->Report( wxString::Format( _( "Unknown or unexpected record found inside " - "\"Additional\" section, Record id: %d." ), + m_reporter->Report( wxString::Format( _( "Unknown or unexpected record ID %d found " + "inside \"Additional\" section." ), recordId ), RPT_SEVERITY_ERROR ); break; @@ -553,7 +553,7 @@ void SCH_ALTIUM_PLUGIN::ParseFileHeader( const ALTIUM_COMPOUND_FILE& aAltiumSchF break; case ALTIUM_SCH_RECORD::IEEE_SYMBOL: - m_reporter->Report( _( "Record 'IEEE_SYMBOL' no handled. Skipped." ), + m_reporter->Report( _( "Record 'IEEE_SYMBOL' not handled." ), RPT_SEVERITY_INFO ); break; @@ -578,7 +578,7 @@ void SCH_ALTIUM_PLUGIN::ParseFileHeader( const ALTIUM_COMPOUND_FILE& aAltiumSchF break; case ALTIUM_SCH_RECORD::PIECHART: - m_reporter->Report( _( "Record 'PIECHART' no handled. Skipped." ), + m_reporter->Report( _( "Record 'PIECHART' not handled." ), RPT_SEVERITY_INFO ); break; @@ -704,8 +704,8 @@ void SCH_ALTIUM_PLUGIN::ParseFileHeader( const ALTIUM_COMPOUND_FILE& aAltiumSchF break; default: - m_reporter->Report( wxString::Format( _( "Unknown or unexpected record found inside " - "\"FileHeader\" section, Record id: %d." ), + m_reporter->Report( wxString::Format( _( "Unknown or unexpected record id %d found " + "inside \"FileHeader\" section." ), recordId ), RPT_SEVERITY_ERROR ); break; @@ -746,7 +746,7 @@ void SCH_ALTIUM_PLUGIN::ParseFileHeader( const ALTIUM_COMPOUND_FILE& aAltiumSchF ParsePort( port ); m_altiumPortsCurrentSheet.clear(); - + m_altiumComponents.clear(); m_symbols.clear(); m_libSymbols.clear(); @@ -790,9 +790,6 @@ const ASCH_STORAGE_FILE* SCH_ALTIUM_PLUGIN::GetFileFromStorage( const wxString& void SCH_ALTIUM_PLUGIN::ParseComponent( int aIndex, const std::map& aProperties ) { - auto pair = m_altiumComponents.insert( { aIndex, ASCH_SYMBOL( aProperties ) } ); - const ASCH_SYMBOL& elem = pair.first->second; - SCH_SHEET* currentSheet = m_sheetPath.Last(); wxCHECK( currentSheet, /* void */ ); @@ -801,6 +798,24 @@ void SCH_ALTIUM_PLUGIN::ParseComponent( int aIndex, if( sheetName.IsEmpty() ) sheetName = wxT( "root" ); + ASCH_SYMBOL altiumSymbol( aProperties ); + + if( m_altiumComponents.count( aIndex ) ) + { + const ASCH_SYMBOL& currentSymbol = m_altiumComponents.at( aIndex ); + + m_reporter->Report( wxString::Format( _( "Symbol \"%s\" in sheet \"%s\" at index %d " + "replaced with symbol \"%s\"." ), + currentSymbol.libreference, + sheetName, + aIndex, + altiumSymbol.libreference ), + RPT_SEVERITY_ERROR ); + } + + auto pair = m_altiumComponents.insert( { aIndex, altiumSymbol } ); + const ASCH_SYMBOL& elem = pair.first->second; + // TODO: this is a hack until we correctly apply all transformations to every element wxString name = wxString::Format( "%s_%d%s_%s", sheetName,