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
This commit is contained in:
Roberto Fernandez Bautista 2020-12-29 19:38:16 +00:00 committed by Wayne Stambaugh
parent ffee24be63
commit 728792aa3c
3 changed files with 41 additions and 3 deletions

View File

@ -816,14 +816,30 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadNets()
}
}
for( std::pair<NETELEMENT_ID, NET::JUNCTION> juncPair : net.Junctions )
for( std::pair<NETELEMENT_ID, NET_SCH::JUNCTION_SCH> 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 );
}
}
}
}

View File

@ -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() );
}
}
}

View File

@ -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;
};