From 71f9847601e2db710494504a05b481da90bb2db0 Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Sat, 21 Nov 2020 12:55:58 +0000 Subject: [PATCH] CADSTAR Archive Importer: Only load the Master variant --- .../cadstar/cadstar_sch_archive_loader.cpp | 10 +++++++--- .../cadstar/cadstar_sch_archive_parser.cpp | 4 ++-- .../plugins/cadstar/cadstar_pcb_archive_loader.cpp | 12 ++++++++---- .../plugins/cadstar/cadstar_pcb_archive_parser.cpp | 4 ++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp index 0909e8d602..5329861000 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp @@ -92,9 +92,10 @@ void CADSTAR_SCH_ARCHIVE_LOADER::Load( ::SCHEMATIC* aSchematic, ::SCH_SHEET* aRo if( Schematic.VariantHierarchy.Variants.size() > 0 ) { - wxLogWarning( - _( "The CADSTAR design contains variants which has no KiCad equivalent. All " - "components have been loaded on top of each other. " ) ); + wxLogWarning( wxString::Format( + _( "The CADSTAR design contains variants which has no KiCad equivalent. Only " + "the master variant ('%s') was loaded." ), + Schematic.VariantHierarchy.Variants.at( "V0" ).Name ) ); } if( Schematic.Groups.size() > 0 ) @@ -317,6 +318,9 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances() { SYMBOL sym = symPair.second; + if( !sym.VariantID.empty() && sym.VariantParentSymbolID != sym.ID ) + continue; // Only load master Variant + if( sym.IsComponent ) { if( mPartMap.find( sym.PartRef.RefID ) == mPartMap.end() ) diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.cpp index 6a4c139808..7702a51f2b 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.cpp @@ -650,8 +650,8 @@ void CADSTAR_SCH_ARCHIVE_PARSER::SYMBOL::Parse( XNODE* aNode ) } else if( cNodeName == wxT( "VSYMMASTER" ) ) { - VariantParentSymbolID = GetXmlAttributeIDString( aNode, 0 ); - VariantID = GetXmlAttributeIDString( aNode, 1 ); + VariantParentSymbolID = GetXmlAttributeIDString( cNode, 0 ); + VariantID = GetXmlAttributeIDString( cNode, 1 ); } else if( cNodeName == wxT( "GROUPREF" ) ) { diff --git a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp index cc9ccf2be3..2c399f3649 100644 --- a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp +++ b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp @@ -107,9 +107,10 @@ void CADSTAR_PCB_ARCHIVE_LOADER::Load( ::BOARD* aBoard ) if( Layout.VariantHierarchy.Variants.size() > 0 ) { - wxLogWarning( - _( "The CADSTAR design contains variants which has no KiCad equivalent. All " - "components have been loaded on top of each other. " ) ); + wxLogWarning( wxString::Format( + _( "The CADSTAR design contains variants which has no KiCad equivalent. Only " + "the master variant ('%s') was loaded." ), + Layout.VariantHierarchy.Variants.at( "V0" ).Name ) ); } if( Layout.ReuseBlocks.size() > 0 ) @@ -1192,7 +1193,10 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadComponents() { for( std::pair compPair : Layout.Components ) { - COMPONENT& comp = compPair.second; + COMPONENT& comp = compPair.second; + + if( !comp.VariantID.empty() && comp.VariantParentComponentID != comp.ID ) + continue; // Only load master Variant auto fpIter = mLibraryMap.find( comp.SymdefID ); diff --git a/pcbnew/plugins/cadstar/cadstar_pcb_archive_parser.cpp b/pcbnew/plugins/cadstar/cadstar_pcb_archive_parser.cpp index 7c00d9d941..6680f83f36 100644 --- a/pcbnew/plugins/cadstar/cadstar_pcb_archive_parser.cpp +++ b/pcbnew/plugins/cadstar/cadstar_pcb_archive_parser.cpp @@ -1846,8 +1846,8 @@ void CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT::Parse( XNODE* aNode ) } else if( cNodeName == wxT( "VCOMPMASTER" ) ) { - VariantParentComponentID = GetXmlAttributeIDString( aNode, 0 ); - VariantID = GetXmlAttributeIDString( aNode, 1 ); + VariantParentComponentID = GetXmlAttributeIDString( cNode, 0 ); + VariantID = GetXmlAttributeIDString( cNode, 1 ); } else if( cNodeName == wxT( "TEXTLOC" ) ) {