eeschema: Cleanup around pins and bboxes for components
This adjusts and tightens code around bboxes and pin sizes.
This commit is contained in:
parent
eb4a2b0b89
commit
995bef8736
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -786,8 +786,7 @@ void LIB_PART::ViewGetLayers( int aLayers[], int& aCount ) const
|
|||
|
||||
const EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const
|
||||
{
|
||||
EDA_RECT bBox;
|
||||
bool initialized = false;
|
||||
EDA_RECT bbox;
|
||||
|
||||
for( const LIB_ITEM& item : m_drawings )
|
||||
{
|
||||
|
@ -801,16 +800,10 @@ const EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const
|
|||
if( item.Type() == LIB_FIELD_T )
|
||||
continue;
|
||||
|
||||
if( initialized )
|
||||
bBox.Merge( item.GetBoundingBox() );
|
||||
else
|
||||
{
|
||||
bBox = item.GetBoundingBox();
|
||||
initialized = true;
|
||||
}
|
||||
bbox.Merge( item.GetBoundingBox() );
|
||||
}
|
||||
|
||||
return bBox;
|
||||
return bbox;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -1437,7 +1437,7 @@ void LIB_PIN::GetMsgPanelInfo(
|
|||
|
||||
const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles ) const
|
||||
{
|
||||
LIB_PART* entry = (LIB_PART* ) m_Parent;
|
||||
LIB_PART* entry = static_cast<LIB_PART*>( m_Parent );
|
||||
EDA_RECT bbox;
|
||||
wxPoint begin;
|
||||
wxPoint end;
|
||||
|
@ -1493,15 +1493,15 @@ const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles ) const
|
|||
|
||||
if( nameTextOffset ) // for values > 0, pin name is inside the body
|
||||
{
|
||||
end.x = m_length + nameTextLength;
|
||||
end.x = m_length + nameTextLength + TARGET_PIN_RADIUS;
|
||||
end.y = std::min( -minsizeV, -nameTextHeight / 2 );
|
||||
}
|
||||
else // if value == 0:
|
||||
// pin name is outside the body, and above the pin line
|
||||
// pin num is below the pin line
|
||||
{
|
||||
end.x = std::max(m_length, nameTextLength);
|
||||
end.y = -begin.y;
|
||||
end.x = std::max( m_length + TARGET_PIN_RADIUS, nameTextLength );
|
||||
end.y = -begin.y;
|
||||
begin.y = std::max( minsizeV, nameTextHeight );
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -1315,17 +1315,11 @@ EDA_RECT SCH_COMPONENT::GetBodyBoundingBox() const
|
|||
int x2 = m_transform.x1 * xm + m_transform.y1 * ym;
|
||||
int y2 = m_transform.x2 * xm + m_transform.y2 * ym;
|
||||
|
||||
// H and W must be > 0:
|
||||
if( x2 < x1 )
|
||||
std::swap( x2, x1 );
|
||||
|
||||
if( y2 < y1 )
|
||||
std::swap( y2, y1 );
|
||||
|
||||
bBox.SetX( x1 );
|
||||
bBox.SetY( y1 );
|
||||
bBox.SetWidth( x2 - x1 );
|
||||
bBox.SetHeight( y2 - y1 );
|
||||
bBox.Normalize();
|
||||
|
||||
bBox.Offset( m_Pos );
|
||||
return bBox;
|
||||
|
|
Loading…
Reference in New Issue