From 9a823ca61b2502c48d66bd7e7c4dd39623c440dd Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Sat, 3 Sep 2022 22:03:23 +0200 Subject: [PATCH] CADSTAR PCB: Parse Teardrops Todo: We need to figure out how we will load teardrops. For now just drop them on import. Fixes https://gitlab.com/kicad/code/kicad/-/issues/12349 (cherry picked from commit 21b3753e9b3c0fdefd9aabb52d3e261197a55c91) Edited to remove string changes --- .../cadstar/cadstar_pcb_archive_loader.cpp | 10 +++++ .../cadstar/cadstar_pcb_archive_loader.h | 2 + .../cadstar/cadstar_pcb_archive_parser.cpp | 42 +++++++++++++++---- .../cadstar/cadstar_pcb_archive_parser.h | 4 ++ 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp index f17b8b1590..3a9c9209a1 100644 --- a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp +++ b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp @@ -2444,6 +2444,16 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadNetTracks( const NET_ID& aCadstarNe shape->SetLocked( v.Fixed ); shapes.push_back( shape ); prevEnd = v.Vertex.End; + + /* No string changes in 6.0 + if( !m_doneTearDropWarning && ( v.TeardropAtEnd || v.TeardropAtStart ) ) + { + // TODO: load teardrops + wxLogError( _( "The CADSTAR design contains teardrops. This importer does not yet " + "support them, so the teardrops in the design have been ignored." ) ); + + m_doneTearDropWarning = true; + }*/ } NETINFO_ITEM* net = getKiCadNet( aCadstarNetID ); diff --git a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.h b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.h index 7f7669fc70..899e2d3d45 100644 --- a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.h +++ b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.h @@ -54,6 +54,7 @@ public: m_doneCopperWarning = false; m_doneSpacingClassWarning = false; m_doneNetClassWarning = false; + m_doneTearDropWarning = false; m_numNets = 0; m_numCopperLayers = 0 ; m_progressReporter = aProgressReporter; @@ -134,6 +135,7 @@ private: ///< multiple duplicate warnings bool m_doneNetClassWarning; ///< Used by getKiCadNet() to avoid ///< multiple duplicate warnings + bool m_doneTearDropWarning; int m_numNets; ///< Number of nets loaded so far int m_numCopperLayers; ///< Number of layers in the design diff --git a/pcbnew/plugins/cadstar/cadstar_pcb_archive_parser.cpp b/pcbnew/plugins/cadstar/cadstar_pcb_archive_parser.cpp index 3acc48a81a..3cd84771d5 100644 --- a/pcbnew/plugins/cadstar/cadstar_pcb_archive_parser.cpp +++ b/pcbnew/plugins/cadstar/cadstar_pcb_archive_parser.cpp @@ -2027,20 +2027,42 @@ XNODE* CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::ROUTE_VERTEX::Parse( XNODE* aNode, wxASSERT( aNode->GetName() == wxT( "ROUTEWIDTH" ) ); RouteWidth = GetXmlAttributeIDLong( aNode, 0 ); + XNODE* prevNode = aNode; XNODE* nextNode = aNode->GetNext(); - if( nextNode->GetName() == wxT( "FIX" ) ) + for( ; nextNode; nextNode = nextNode->GetNext() ) { - Fixed = true; - nextNode = nextNode->GetNext(); + if( nextNode->GetName() == wxT( "FIX" ) ) + { + Fixed = true; + } + else if( nextNode->GetName() == wxT( "TDROPATSTART" ) ) + { + TeardropAtStart = true; + TeardropAtStartAngle = GetXmlAttributeIDLong( nextNode, 0 ); + } + else if( nextNode->GetName() == wxT( "TDROPATEND" ) ) + { + TeardropAtEnd = true; + TeardropAtEndAngle = GetXmlAttributeIDLong( nextNode, 0 ); + } + else if( VERTEX::IsVertex( nextNode ) ) + { + Vertex.Parse( nextNode, aContext ); + } + else if( nextNode->GetName() == wxT( "ROUTEWIDTH" ) ) + { + return prevNode; + } + else + { + THROW_UNKNOWN_NODE_IO_ERROR( nextNode->GetName(), wxT( "ROUTE" ) ); + } + + prevNode = nextNode; } - if( !VERTEX::IsVertex( nextNode ) ) - THROW_UNKNOWN_NODE_IO_ERROR( nextNode->GetName(), wxT( "ROUTE_VERTEX" ) ); - - Vertex.Parse( nextNode, aContext ); - - return nextNode; + return prevNode; } @@ -2068,6 +2090,8 @@ void CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::ROUTE::Parse( XNODE* aNode, PARSER_CON ROUTE_VERTEX rtVert; cNode = rtVert.Parse( cNode, aContext ); RouteVertices.push_back( rtVert ); + + assert( cNode != nullptr ); } else { diff --git a/pcbnew/plugins/cadstar/cadstar_pcb_archive_parser.h b/pcbnew/plugins/cadstar/cadstar_pcb_archive_parser.h index ee54dd27ca..f4c514d37c 100644 --- a/pcbnew/plugins/cadstar/cadstar_pcb_archive_parser.h +++ b/pcbnew/plugins/cadstar/cadstar_pcb_archive_parser.h @@ -983,6 +983,10 @@ public: ///< next node being a VERTEX (e.g. PT, CWARC, etc.) { long RouteWidth; + bool TeardropAtStart = false; + bool TeardropAtEnd = false; + long TeardropAtStartAngle = 0; + long TeardropAtEndAngle = 0; bool Fixed = false; VERTEX Vertex;