Fix erratical sheet pins behavior when resizing

Fixes https://gitlab.com/kicad/code/kicad/issues/13658
This commit is contained in:
vinsfortunato 2023-01-25 05:25:55 +01:00
parent 242b9855dd
commit 843600cb7e
1 changed files with 4 additions and 10 deletions

View File

@ -993,10 +993,6 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid ) const
sheet->GetMinHeight( edited == RECT_BOTLEFT || edited == RECT_BOTRIGHT ),
topLeft, topRight, botLeft, botRight, &gridHelper );
// Pin positions are relative to origin. Attempt to leave them where they
// are if the origin moves.
VECTOR2I originDelta = sheet->GetPosition() - topLeft;
if( isModified( m_editPoints->Point( RECT_TOPLEFT ) )
|| isModified( m_editPoints->Point( RECT_TOPRIGHT ) )
|| isModified( m_editPoints->Point( RECT_BOTRIGHT ) )
@ -1033,17 +1029,11 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid ) const
}
}
// Update the fields if we're in autoplace mode
if( sheet->GetFieldsAutoplaced() == FIELDS_AUTOPLACED_AUTO )
sheet->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
// Keep sheet pins attached to edges:
for( SCH_SHEET_PIN* pin : sheet->GetPins() )
{
VECTOR2I pos = pin->GetPosition();
pos += originDelta;
switch( pin->GetSide() )
{
case SHEET_SIDE::LEFT: pos.x = topLeft.x; break;
@ -1056,6 +1046,10 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid ) const
pin->SetPosition( pos );
}
// Update the fields if we're in autoplace mode
if( sheet->GetFieldsAutoplaced() == FIELDS_AUTOPLACED_AUTO )
sheet->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
break;
}