From e24c8de4b815dde24d99603e390b25721affb4c0 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Tue, 31 Oct 2023 02:18:46 +0300 Subject: [PATCH] EasyEDA Std: Fix open polygon shapes in symbols. --- common/plugins/easyeda/easyeda_parser_base.cpp | 12 ++++++------ common/plugins/easyeda/easyeda_parser_base.h | 2 +- eeschema/sch_plugins/easyeda/sch_easyeda_parser.cpp | 10 +++++----- pcbnew/plugins/easyeda/pcb_easyeda_parser.cpp | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/common/plugins/easyeda/easyeda_parser_base.cpp b/common/plugins/easyeda/easyeda_parser_base.cpp index 06f52f503d..1ba20186bd 100644 --- a/common/plugins/easyeda/easyeda_parser_base.cpp +++ b/common/plugins/easyeda/easyeda_parser_base.cpp @@ -66,9 +66,10 @@ double EASYEDA_PARSER_BASE::RelPosY( const wxString& aValue ) } -SHAPE_POLY_SET EASYEDA_PARSER_BASE::ParsePolygons( const wxString& data, int aArcMinSegLen ) +std::vector EASYEDA_PARSER_BASE::ParseLineChains( const wxString& data, + int aArcMinSegLen ) { - SHAPE_POLY_SET result; + std::vector result; VECTOR2D prevPt; SHAPE_LINE_CHAIN chain; @@ -110,7 +111,7 @@ SHAPE_POLY_SET EASYEDA_PARSER_BASE::ParsePolygons( const wxString& data, int aAr if( chain.PointCount() > 2 ) { chain.SetClosed( true ); - result.Append( chain ); + result.emplace_back( chain ); } chain.Clear(); @@ -125,7 +126,7 @@ SHAPE_POLY_SET EASYEDA_PARSER_BASE::ParsePolygons( const wxString& data, int aAr if( chain.PointCount() > 2 ) { chain.SetClosed( true ); - result.Append( chain ); + result.emplace_back( chain ); } chain.Clear(); } @@ -227,8 +228,7 @@ SHAPE_POLY_SET EASYEDA_PARSER_BASE::ParsePolygons( const wxString& data, int aAr if( chain.PointCount() > 2 ) { - chain.SetClosed( true ); - result.Append( chain ); + result.emplace_back( chain ); } return result; diff --git a/common/plugins/easyeda/easyeda_parser_base.h b/common/plugins/easyeda/easyeda_parser_base.h index 39719053a0..64b7bf50fe 100644 --- a/common/plugins/easyeda/easyeda_parser_base.h +++ b/common/plugins/easyeda/easyeda_parser_base.h @@ -58,7 +58,7 @@ public: return ScalePos( aVec - m_relOrigin ); } - SHAPE_POLY_SET ParsePolygons( const wxString& aData, int aArcMinSegLen ); + std::vector ParseLineChains( const wxString& aData, int aArcMinSegLen ); protected: VECTOR2D m_relOrigin; diff --git a/eeschema/sch_plugins/easyeda/sch_easyeda_parser.cpp b/eeschema/sch_plugins/easyeda/sch_easyeda_parser.cpp index 1fc15a74f4..faf2db5a6c 100644 --- a/eeschema/sch_plugins/easyeda/sch_easyeda_parser.cpp +++ b/eeschema/sch_plugins/easyeda/sch_easyeda_parser.cpp @@ -415,21 +415,21 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol wxString fillColor = arr[5].Lower(); //bool locked = arr[7] != wxS( "0" ); - SHAPE_POLY_SET polygons = ParsePolygons( pointsData, schIUScale.MilsToIU( 10 ) ); + std::vector lineChains = + ParseLineChains( pointsData, schIUScale.MilsToIU( 10 ) ); - for( const SHAPE_POLY_SET::POLYGON& poly : polygons.CPolygons() ) + for( SHAPE_LINE_CHAIN outline : lineChains ) { std::unique_ptr shape = std::make_unique( aSymbol, SHAPE_T::POLY ); - SHAPE_LINE_CHAIN outline = poly[0]; - outline.Mirror( false, true ); if( outline.IsClosed() ) outline.Append( outline.CPoint( 0 ), true ); - shape->SetPolyShape( outline ); + for( const VECTOR2I& pt : outline.CPoints() ) + shape->AddPoint( pt ); shape->SetUnit( 0 ); shape->SetStroke( STROKE_PARAMS( ScaleSize( lineWidth ), strokeStyle ) ); diff --git a/pcbnew/plugins/easyeda/pcb_easyeda_parser.cpp b/pcbnew/plugins/easyeda/pcb_easyeda_parser.cpp index 6842a45fe7..05a7b307de 100644 --- a/pcbnew/plugins/easyeda/pcb_easyeda_parser.cpp +++ b/pcbnew/plugins/easyeda/pcb_easyeda_parser.cpp @@ -434,7 +434,7 @@ void PCB_EASYEDA_PARSER::ParseToBoardItemContainer( { wxString layer = arr[1]; - SHAPE_POLY_SET polySet = ParsePolygons( arr[3].Trim(), pcbIUScale.mmToIU( 0.01 ) ); + SHAPE_POLY_SET polySet = ParseLineChains( arr[3].Trim(), pcbIUScale.mmToIU( 0.01 ) ); if( layer == wxS( "11" ) ) // Multi-layer (board cutout) { @@ -508,7 +508,7 @@ void PCB_EASYEDA_PARSER::ParseToBoardItemContainer( // Do not fill? } - SHAPE_POLY_SET polySet = ParsePolygons( arr[4].Trim(), pcbIUScale.mmToIU( 0.01 ) ); + SHAPE_POLY_SET polySet = ParseLineChains( arr[4].Trim(), pcbIUScale.mmToIU( 0.01 ) ); for( const SHAPE_POLY_SET::POLYGON& poly : polySet.CPolygons() ) zone->Outline()->AddPolygon( poly ); @@ -529,7 +529,7 @@ void PCB_EASYEDA_PARSER::ParseToBoardItemContainer( { for( const nlohmann::json& contourData : polyData ) { - SHAPE_POLY_SET contourPolySet = ParsePolygons( contourData.get(), + SHAPE_POLY_SET contourPolySet = ParseLineChains( contourData.get(), pcbIUScale.mmToIU( 0.01 ) ); SHAPE_POLY_SET currentOutline( contourPolySet.COutline( 0 ) ); @@ -698,7 +698,7 @@ void PCB_EASYEDA_PARSER::ParseToBoardItemContainer( if( auto dataStr = get_opt( attributes, "d" ) ) { SHAPE_POLY_SET polySet = - ParsePolygons( dataStr->Trim(), + ParseLineChains( dataStr->Trim(), dataStr->size() < 8000 ? pcbIUScale.mmToIU( 0.005 ) : pcbIUScale.mmToIU( 0.05 ) );