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,
const TRANSFORM& aTransform )
{

View File

@ -210,6 +210,8 @@ public:
wxPoint GetPosition() const override { return m_position; }
void SetPosition( const wxPoint& aPos ) override { m_position = aPos; }
wxPoint GetPinRoot() const;
void MirrorHorizontal( const wxPoint& aCenter ) override;
void MirrorVertical( const wxPoint& aCenter ) 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 )
{
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 )
{
const LIB_PIN& pin = static_cast<const LIB_PIN&>( item );
bbox.Merge( pin.GetBoundingBox( false, true ) );
}
else
bbox.Merge( pin.GetPinRoot() );
}
else
{

View File

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