From 728792aa3ca74a0730ff2eef9669a8f2111f929b Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Tue, 29 Dec 2020 19:38:16 +0000 Subject: [PATCH] CADSTAR Schematic Archive Importer: Fix SIGLOC in JPT (Load labels in junctions) Fixes but that refused to open file with a SIGLOC node in JPT --- .../cadstar/cadstar_sch_archive_loader.cpp | 20 +++++++++++++++-- .../cadstar/cadstar_sch_archive_parser.cpp | 22 ++++++++++++++++++- .../cadstar/cadstar_sch_archive_parser.h | 2 ++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp index 8cb571e3b4..63bde11bd2 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp @@ -816,14 +816,30 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadNets() } } - for( std::pair juncPair : net.Junctions ) + for( std::pair juncPair : net.Junctions ) { - NET::JUNCTION junc = juncPair.second; + NET_SCH::JUNCTION_SCH junc = juncPair.second; SCH_JUNCTION* kiJunc = new SCH_JUNCTION(); kiJunc->SetPosition( getKiCadPoint( junc.Location ) ); mSheetMap.at( junc.LayerID )->GetScreen()->Append( kiJunc ); + + if( junc.HasNetLabel ) + { + // In CADSTAR the label can be placed anywhere, but in KiCad it has to be placed + // in the same location as the junction for it to be connected to it. + SCH_LABEL* label = new SCH_LABEL(); + label->SetText( netName ); + label->SetPosition( getKiCadPoint( junc.Location ) ); + label->SetVisible( true ); + + double labelAngleDeciDeg = getAngleTenthDegree( junc.NetLabel.OrientAngle ); + LABEL_SPIN_STYLE spin = getSpinStyleDeciDeg( labelAngleDeciDeg ); + label->SetLabelSpinStyle( spin ); + + mSheetMap.at( junc.LayerID )->GetScreen()->Append( label ); + } } } } diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.cpp index 69b04e58dc..35caf285eb 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.cpp @@ -1148,10 +1148,30 @@ void CADSTAR_SCH_ARCHIVE_PARSER::SCHEMATIC::Parse( XNODE* aNode, PARSER_CONTEXT* void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::JUNCTION_SCH::Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) { - CADSTAR_ARCHIVE_PARSER::NET::JUNCTION::Parse( aNode, aContext ); + ParseIdentifiers( aNode, aContext ); TerminalCodeID = GetXmlAttributeIDString( aNode, 1 ); LayerID = GetXmlAttributeIDString( aNode, 2 ); + + XNODE* cNode = aNode->GetChildren(); + + for( ; cNode; cNode = cNode->GetNext() ) + { + if( ParseSubNode( cNode, aContext ) ) + { + continue; + } + else if( cNode->GetName() == wxT( "SIGLOC" ) ) + { + NetLabel.Parse( cNode, aContext ); + HasNetLabel = true; + } + else + { + THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() ); + } + } + } diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.h b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.h index 55e4f34aad..27c953a418 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.h +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.h @@ -345,6 +345,8 @@ public: struct JUNCTION_SCH : CADSTAR_ARCHIVE_PARSER::NET::JUNCTION ///< "JPT" nodename. { TERMINALCODE_ID TerminalCodeID; ///< Usually a circle, but size can be varied + bool HasNetLabel = false; + SIGLOC NetLabel; void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override; };