Be more careful about non-visible elements in fields autoplacer.
Fixes https://gitlab.com/kicad/code/kicad/issues/10774
(cherry picked from commit f241617478
)
This commit is contained in:
parent
d20c2fe5c5
commit
6fd898d1b3
|
@ -144,14 +144,14 @@ public:
|
|||
*/
|
||||
void DoAutoplace( bool aManual )
|
||||
{
|
||||
bool force_wire_spacing = false;
|
||||
bool forceWireSpacing = false;
|
||||
SIDE_AND_NPINS sideandpins = chooseSideForFields( aManual );
|
||||
SIDE field_side = sideandpins.side;
|
||||
wxPoint fbox_pos = fieldBoxPlacement( sideandpins );
|
||||
EDA_RECT field_box( fbox_pos, m_fbox_size );
|
||||
|
||||
if( aManual )
|
||||
force_wire_spacing = fitFieldsBetweenWires( &field_box, field_side );
|
||||
forceWireSpacing = fitFieldsBetweenWires( &field_box, field_side );
|
||||
|
||||
// Move the fields
|
||||
int last_y_coord = field_box.GetTop();
|
||||
|
@ -160,6 +160,9 @@ public:
|
|||
{
|
||||
SCH_FIELD* field = m_fields[field_idx];
|
||||
|
||||
if( !field->IsVisible() )
|
||||
continue;
|
||||
|
||||
if( m_allow_rejustify )
|
||||
{
|
||||
if( sideandpins.pins > 0 )
|
||||
|
@ -175,8 +178,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
wxPoint pos( fieldHorizPlacement( field, field_box ),
|
||||
fieldVertPlacement( field, field_box, &last_y_coord, !force_wire_spacing ) );
|
||||
wxPoint pos( fieldHPlacement( field, field_box ),
|
||||
fieldVPlacement( field, field_box, &last_y_coord, !forceWireSpacing ) );
|
||||
|
||||
if( m_align_to_grid )
|
||||
{
|
||||
|
@ -201,7 +204,15 @@ protected:
|
|||
int max_field_width = 0;
|
||||
int total_height = 0;
|
||||
|
||||
std::vector<SCH_FIELD*> visibleFields;
|
||||
|
||||
for( SCH_FIELD* field : m_fields )
|
||||
{
|
||||
if( field->IsVisible() )
|
||||
visibleFields.push_back( field );
|
||||
}
|
||||
|
||||
for( SCH_FIELD* field : visibleFields )
|
||||
{
|
||||
if( m_symbol->GetTransform().y1 )
|
||||
field->SetTextAngle( TEXT_ANGLE_VERT );
|
||||
|
@ -215,7 +226,7 @@ protected:
|
|||
max_field_width = std::max( max_field_width, field_width );
|
||||
|
||||
// Remove interline spacing from field_height for last line.
|
||||
if( field == m_fields[ m_fields.size() - 1 ] )
|
||||
if( field == visibleFields.back() )
|
||||
field_height *= 0.62;
|
||||
|
||||
if( !aDynamic )
|
||||
|
@ -322,6 +333,7 @@ protected:
|
|||
if( item_box.Intersects( aRect ) )
|
||||
filtered.push_back( item );
|
||||
}
|
||||
|
||||
return filtered;
|
||||
}
|
||||
|
||||
|
@ -642,7 +654,7 @@ protected:
|
|||
*
|
||||
* @return Correct field horizontal position
|
||||
*/
|
||||
int fieldHorizPlacement( SCH_FIELD *aField, const EDA_RECT &aFieldBox )
|
||||
int fieldHPlacement( SCH_FIELD *aField, const EDA_RECT &aFieldBox )
|
||||
{
|
||||
int field_hjust;
|
||||
int field_xcoord;
|
||||
|
@ -677,13 +689,13 @@ protected:
|
|||
*
|
||||
* @param aField - the field to place.
|
||||
* @param aFieldBox - box in which fields will be placed.
|
||||
* @param aPosAccum - pointer to a position accumulator
|
||||
* @param aAccumulatedPosition - pointer to a position accumulator
|
||||
* @param aDynamic - use dynamic spacing
|
||||
*
|
||||
* @return Correct field vertical position
|
||||
*/
|
||||
int fieldVertPlacement( SCH_FIELD *aField, const EDA_RECT &aFieldBox, int *aPosAccum,
|
||||
bool aDynamic )
|
||||
int fieldVPlacement( SCH_FIELD *aField, const EDA_RECT &aFieldBox, int *aAccumulatedPosition,
|
||||
bool aDynamic )
|
||||
{
|
||||
int field_height;
|
||||
int padding;
|
||||
|
@ -704,9 +716,9 @@ protected:
|
|||
padding = FIELD_PADDING;
|
||||
}
|
||||
|
||||
int placement = *aPosAccum + padding / 2 + field_height / 2;
|
||||
int placement = *aAccumulatedPosition + padding / 2 + field_height / 2;
|
||||
|
||||
*aPosAccum += padding + field_height;
|
||||
*aAccumulatedPosition += padding + field_height;
|
||||
|
||||
return placement;
|
||||
}
|
||||
|
|
|
@ -917,10 +917,10 @@ const EDA_RECT LIB_SYMBOL::GetBodyBoundingBox( int aUnit, int aConvert, bool aIn
|
|||
{
|
||||
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
|
||||
// Note: the roots of the pins are always included for symbols that don't have a
|
||||
// well-defined body.
|
||||
|
||||
if( aIncludePins )
|
||||
if( aIncludePins && pin.IsVisible() )
|
||||
bbox.Merge( pin.GetBoundingBox( false, true ) );
|
||||
else
|
||||
bbox.Merge( pin.GetPinRoot() );
|
||||
|
|
Loading…
Reference in New Issue