Include pin roots for symbols that don't have well-defined bodies.

Fixes https://gitlab.com/kicad/code/kicad/issues/8508
This commit is contained in:
Jeff Young 2021-09-24 16:19:21 +01:00
parent c7f098ab25
commit a1a2076aee
4 changed files with 30 additions and 27 deletions

View File

@ -178,6 +178,19 @@ wxString LIB_PIN::GetShownName() const
} }
wxPoint LIB_PIN::GetPinRoot() const
{
switch( m_orientation )
{
default:
case PIN_RIGHT: return wxPoint( m_position.x + m_length, m_position.y );
case PIN_LEFT: return wxPoint( m_position.x - m_length, m_position.y );
case PIN_UP: return wxPoint( m_position.x, m_position.y - m_length );
case PIN_DOWN: return wxPoint( m_position.x, m_position.y + m_length );
}
}
void LIB_PIN::print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, void* aData, void LIB_PIN::print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, void* aData,
const TRANSFORM& aTransform ) const TRANSFORM& aTransform )
{ {

View File

@ -210,6 +210,8 @@ public:
wxPoint GetPosition() const override { return m_position; } wxPoint GetPosition() const override { return m_position; }
void SetPosition( const wxPoint& aPos ) override { m_position = aPos; } void SetPosition( const wxPoint& aPos ) override { m_position = aPos; }
wxPoint GetPinRoot() const;
void MirrorHorizontal( const wxPoint& aCenter ) override; void MirrorHorizontal( const wxPoint& aCenter ) override;
void MirrorVertical( const wxPoint& aCenter ) override; void MirrorVertical( const wxPoint& aCenter ) override;
void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override; void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;

View File

@ -865,11 +865,15 @@ const EDA_RECT LIB_SYMBOL::GetBodyBoundingBox( int aUnit, int aConvert, bool aIn
if( item.Type() == LIB_PIN_T ) if( item.Type() == LIB_PIN_T )
{ {
const LIB_PIN& pin = static_cast<const LIB_PIN&>( item );
// Note: the roots of the pins are always inlcuded for symbols that don't have a
// well-defined body.
if( aIncludePins ) if( aIncludePins )
{
const LIB_PIN& pin = static_cast<const LIB_PIN&>( item );
bbox.Merge( pin.GetBoundingBox( false, true ) ); bbox.Merge( pin.GetBoundingBox( false, true ) );
} else
bbox.Merge( pin.GetPinRoot() );
} }
else else
{ {

View File

@ -810,33 +810,17 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
} }
} }
VECTOR2I p0; VECTOR2I p0( aPin->GetPinRoot() );
VECTOR2I dir; VECTOR2I dir;
int len = aPin->GetLength(); int len = aPin->GetLength();
int orient = aPin->GetOrientation();
switch( orient ) switch( aPin->GetOrientation() )
{ {
case PIN_UP:
p0 = VECTOR2I( pos.x, pos.y - len );
dir = VECTOR2I( 0, 1 );
break;
case PIN_DOWN:
p0 = VECTOR2I( pos.x, pos.y + len );
dir = VECTOR2I( 0, -1 );
break;
case PIN_LEFT:
p0 = VECTOR2I( pos.x - len, pos.y );
dir = VECTOR2I( 1, 0 );
break;
default: default:
case PIN_RIGHT: case PIN_RIGHT: dir = VECTOR2I( -1, 0 ); break;
p0 = VECTOR2I( pos.x + len, pos.y ); case PIN_LEFT: dir = VECTOR2I( 1, 0 ); break;
dir = VECTOR2I( -1, 0 ); case PIN_UP: dir = VECTOR2I( 0, 1 ); break;
break; case PIN_DOWN: dir = VECTOR2I( 0, -1 ); break;
} }
VECTOR2D pc; VECTOR2D pc;
@ -1088,7 +1072,7 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
strokeText( aText, aPos, aAngle ); strokeText( aText, aPos, aAngle );
}; };
switch( orient ) switch( aPin->GetOrientation() )
{ {
case PIN_LEFT: case PIN_LEFT:
if( size[INSIDE] ) if( size[INSIDE] )