LTspice import: adapt label spin when multiple wires connected

(cherry picked from commit 37103c6e157686b46293ccf9940b57fb8aff5211)
This commit is contained in:
Alex Shvartzkop 2025-04-21 04:50:51 +03:00
parent 496fc3b6bf
commit c737bd392e

View File

@ -934,6 +934,8 @@ SCH_IO_LTSPICE_PARSER::CreateSCH_LABEL( KICAD_T aType, const VECTOR2I& aOffset,
label->SetVisible( true );
}
std::vector<SPIN_STYLE> preferredSpins;
for( LTSPICE_SCHEMATIC::WIRE& wire : aWires )
{
if( aOffset == wire.Start )
@ -941,16 +943,16 @@ SCH_IO_LTSPICE_PARSER::CreateSCH_LABEL( KICAD_T aType, const VECTOR2I& aOffset,
if( wire.Start.x == wire.End.x )
{
if( wire.Start.y < wire.End.y )
label->SetSpinStyle( SPIN_STYLE::UP );
preferredSpins.emplace_back( SPIN_STYLE::UP );
else if( wire.Start.y > wire.End.y )
label->SetSpinStyle( SPIN_STYLE::BOTTOM );
preferredSpins.emplace_back( SPIN_STYLE::BOTTOM );
}
else
{
if( wire.Start.x < wire.End.x )
label->SetSpinStyle( SPIN_STYLE::LEFT );
preferredSpins.emplace_back( SPIN_STYLE::LEFT );
else if( wire.Start.x > wire.End.x )
label->SetSpinStyle( SPIN_STYLE::RIGHT );
preferredSpins.emplace_back( SPIN_STYLE::RIGHT );
}
}
else if( aOffset == wire.End )
@ -958,20 +960,23 @@ SCH_IO_LTSPICE_PARSER::CreateSCH_LABEL( KICAD_T aType, const VECTOR2I& aOffset,
if( wire.Start.x == wire.End.x )
{
if( wire.Start.y > wire.End.y )
label->SetSpinStyle( SPIN_STYLE::UP );
preferredSpins.emplace_back( SPIN_STYLE::UP );
else if( wire.Start.y < wire.End.y )
label->SetSpinStyle( SPIN_STYLE::BOTTOM );
preferredSpins.emplace_back( SPIN_STYLE::BOTTOM );
}
else
{
if( wire.Start.x > wire.End.x )
label->SetSpinStyle( SPIN_STYLE::LEFT );
preferredSpins.emplace_back( SPIN_STYLE::LEFT );
else if( wire.Start.x < wire.End.x )
label->SetSpinStyle( SPIN_STYLE::RIGHT );
preferredSpins.emplace_back( SPIN_STYLE::RIGHT );
}
}
}
if( preferredSpins.size() == 1 )
label->SetSpinStyle( preferredSpins.front() );
return label;
}