Must do pin swap in model pins, not item pins.
Item pins might not be in the same order. Fixes https://gitlab.com/kicad/code/kicad/issues/13741
This commit is contained in:
@@ -41,17 +41,34 @@ std::string SPICE_GENERATOR_R_POT::ModelLine( const SPICE_ITEM& aItem ) const
|
||||
}
|
||||
|
||||
|
||||
std::string SPICE_GENERATOR_R_POT::ItemLine( const SPICE_ITEM& aItem ) const
|
||||
std::string SPICE_GENERATOR_R_POT::ItemPins( const SPICE_ITEM& aItem ) const
|
||||
{
|
||||
// Swap pin order so that pos=1 is all +, and pos=0 is all -.
|
||||
SPICE_ITEM item = aItem;
|
||||
std::string result;
|
||||
int ncCounter = 0;
|
||||
|
||||
// FIXME: This `if` is there because Preview() calls this function with empty pinNetNames vector.
|
||||
// This shouldn't be necessary.
|
||||
if( item.pinNetNames.size() >= 3 )
|
||||
std::swap( item.pinNetNames.at( 0 ), item.pinNetNames.at( 2 ) );
|
||||
wxCHECK( GetPins().size() == 3, "" );
|
||||
|
||||
return SPICE_GENERATOR::ItemLine( item );
|
||||
// Swap pin order so that pos=1 is +, and pos=0 is -.
|
||||
std::vector<std::reference_wrapper<const SIM_MODEL::PIN>> inverted( GetPins() );
|
||||
std::swap( inverted[0], inverted[2] );
|
||||
|
||||
for( const SIM_MODEL::PIN& pin : GetPins() )
|
||||
{
|
||||
auto it = std::find( aItem.pinNumbers.begin(), aItem.pinNumbers.end(),
|
||||
pin.symbolPinNumber );
|
||||
|
||||
if( it != aItem.pinNumbers.end() )
|
||||
{
|
||||
long symbolPinIndex = std::distance( aItem.pinNumbers.begin(), it );
|
||||
result.append( fmt::format( " {}", aItem.pinNetNames.at( symbolPinIndex ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append( fmt::format( " NC-{}-{}", aItem.refName, ncCounter++ ) );
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user