EasyEDA Std Schematic: import net ports as global labels.

This commit is contained in:
Alex Shvartzkop 2023-10-01 15:52:45 +03:00
parent 25cca5adfe
commit 979274af7c
1 changed files with 131 additions and 74 deletions

View File

@ -371,8 +371,10 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol
SHAPE_LINE_CHAIN chain;
for( size_t i = 1; i < ptArr.size(); i += 2 )
{
chain.Append(
RelPosSym( VECTOR2I( Convert( ptArr[i - 1] ), Convert( ptArr[i] ) ) ) );
}
std::unique_ptr<LIB_SHAPE> line = std::make_unique<LIB_SHAPE>( aSymbol, SHAPE_T::POLY );
@ -1087,6 +1089,60 @@ void SCH_EASYEDA_PARSER::ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aRoot
wxString valueFontname = valueParts[7];
wxString valueFontsize = valueParts[8];
if( flagTypename == wxS( "part_netLabel_netPort" ) )
{
std::unique_ptr<SCH_GLOBALLABEL> label =
std::make_unique<SCH_GLOBALLABEL>( RelPos( pos ), netnameValue );
SPIN_STYLE spin = SPIN_STYLE::LEFT;
for( double i = angle; i > 0; i -= 90 )
spin = spin.RotateCCW();
// If the shape was mirrored, we can't rely on angle value to determine direction.
if( segments.size() > 3 )
{
wxArrayString shapeParts = wxSplit( segments[3], '~', '\0' );
if( shapeParts[0] == wxS( "PL" ) )
{
wxArrayString ptArr = wxSplit( shapeParts[1], ' ', '\0' );
SHAPE_LINE_CHAIN chain;
for( size_t i = 1; i < ptArr.size(); i += 2 )
{
chain.Append( RelPos(
VECTOR2I( Convert( ptArr[i - 1] ), Convert( ptArr[i] ) ) ) );
}
chain.Move( -RelPos( pos ) );
VECTOR2I shapeCenter = chain.Centre();
if( std::abs( shapeCenter.x ) >= std::abs( shapeCenter.y ) )
{
if( shapeCenter.x >= 0 )
spin = SPIN_STYLE::RIGHT;
else
spin = SPIN_STYLE::LEFT;
}
else
{
if( shapeCenter.y >= 0 )
spin = SPIN_STYLE::BOTTOM;
else
spin = SPIN_STYLE::UP;
}
}
}
label->SetSpinStyle( spin );
label->SetShape( LABEL_FLAG_SHAPE::L_INPUT );
createdItems.push_back( std::move( label ) );
}
else
{
auto pair = MakePowerSymbol( flagTypename, netnameValue );
LIB_SYMBOL* pwrLibSym = pair.first;
bool flip = pair.second;
@ -1174,6 +1230,7 @@ void SCH_EASYEDA_PARSER::ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aRoot
createdItems.push_back( std::move( schSym ) );
}
}
else if( rootType == wxS( "W" ) )
{
wxArrayString ptArr = wxSplit( arr[1], ' ', '\0' );