From e4798199c63f2aabb4bfa127820dcabb59e0f5d9 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 10 Jun 2022 22:37:24 +0100 Subject: [PATCH] Handle alt pins in plot code. Fixes https://gitlab.com/kicad/code/kicad/issues/11728 --- eeschema/sch_symbol.cpp | 42 ++++++++++++++++++++++++++++------------- eeschema/sch_symbol.h | 2 +- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index c39b571e21..0a6bd3b883 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -900,7 +900,7 @@ void SCH_SYMBOL::GetLibPins( std::vector& aPinsList ) const } -SCH_PIN* SCH_SYMBOL::GetPin( LIB_PIN* aLibPin ) +SCH_PIN* SCH_SYMBOL::GetPin( LIB_PIN* aLibPin ) const { wxASSERT( m_pinMap.count( aLibPin ) ); return m_pins[ m_pinMap.at( aLibPin ) ].get(); @@ -1908,22 +1908,38 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground ) const if( m_part ) { + LIB_PINS libPins; + m_part->GetPins( libPins, GetUnit(), GetConvert() ); + + // Copy the source so we can re-orient and translate it. + LIB_SYMBOL tempSymbol( *m_part ); + LIB_PINS tempPins; + tempSymbol.GetPins( tempPins, GetUnit(), GetConvert() ); + + // Copy the pin info from the symbol to the temp pins + for( unsigned i = 0; i < tempPins.size(); ++ i ) + { + SCH_PIN* symbolPin = GetPin( libPins[ i ] ); + LIB_PIN* tempPin = tempPins[ i ]; + + tempPin->SetName( symbolPin->GetShownName() ); + tempPin->SetType( symbolPin->GetType() ); + tempPin->SetShape( symbolPin->GetShape() ); + + if( symbolPin->IsDangling() ) + tempPin->SetFlags( IS_DANGLING ); + } + TRANSFORM temp = GetTransform(); aPlotter->StartBlock( nullptr ); - bool local_background = true; + for( bool local_background : { true, false } ) + { + tempSymbol.Plot( aPlotter, GetUnit(), GetConvert(), local_background, m_pos, temp ); - m_part->Plot( aPlotter, GetUnit(), GetConvert(), local_background, m_pos, temp ); - - for( SCH_FIELD field : m_fields ) - field.Plot( aPlotter, local_background ); - - local_background = false; - - m_part->Plot( aPlotter, GetUnit(), GetConvert(), local_background, m_pos, temp ); - - for( SCH_FIELD field : m_fields ) - field.Plot( aPlotter, local_background ); + for( SCH_FIELD field : m_fields ) + field.Plot( aPlotter, local_background ); + } aPlotter->EndBlock( nullptr ); } diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index 91cb772dfe..fa1ceeccd8 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -467,7 +467,7 @@ public: */ void GetLibPins( std::vector& aPinsList ) const; - SCH_PIN* GetPin( LIB_PIN* aLibPin ); + SCH_PIN* GetPin( LIB_PIN* aLibPin ) const; /** * Retrieve a list of the SCH_PINs for the given sheet path.