EasyEDA Std: Fix open polygon shapes in symbols.
This commit is contained in:
parent
f48a248db4
commit
e24c8de4b8
|
@ -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<SHAPE_LINE_CHAIN> EASYEDA_PARSER_BASE::ParseLineChains( const wxString& data,
|
||||
int aArcMinSegLen )
|
||||
{
|
||||
SHAPE_POLY_SET result;
|
||||
std::vector<SHAPE_LINE_CHAIN> 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;
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
return ScalePos( aVec - m_relOrigin );
|
||||
}
|
||||
|
||||
SHAPE_POLY_SET ParsePolygons( const wxString& aData, int aArcMinSegLen );
|
||||
std::vector<SHAPE_LINE_CHAIN> ParseLineChains( const wxString& aData, int aArcMinSegLen );
|
||||
|
||||
protected:
|
||||
VECTOR2D m_relOrigin;
|
||||
|
|
|
@ -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<SHAPE_LINE_CHAIN> lineChains =
|
||||
ParseLineChains( pointsData, schIUScale.MilsToIU( 10 ) );
|
||||
|
||||
for( const SHAPE_POLY_SET::POLYGON& poly : polygons.CPolygons() )
|
||||
for( SHAPE_LINE_CHAIN outline : lineChains )
|
||||
{
|
||||
std::unique_ptr<LIB_SHAPE> shape =
|
||||
std::make_unique<LIB_SHAPE>( 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 ) );
|
||||
|
|
|
@ -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<wxString>(),
|
||||
SHAPE_POLY_SET contourPolySet = ParseLineChains( contourData.get<wxString>(),
|
||||
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 ) );
|
||||
|
||||
|
|
Loading…
Reference in New Issue