Promote field selection to field-owner for Autoplace.

Fixes https://gitlab.com/kicad/code/kicad/issues/11529

(cherry picked from commit f6f316bd8c)
This commit is contained in:
Jeff Young 2022-05-02 20:10:40 +01:00
parent 71ea56dea4
commit 5b24003f6c
1 changed files with 19 additions and 6 deletions

View File

@ -1201,22 +1201,35 @@ int SCH_EDIT_TOOL::EditField( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::AutoplaceFields( const TOOL_EVENT& aEvent )
{
EE_SELECTION& selection = m_selectionTool->RequestSelection( rotatableItems );
SCH_ITEM* head = static_cast<SCH_ITEM*>( selection.Front() );
bool moving = head && head->IsMoving();
if( selection.Empty() )
return 0;
SCH_ITEM* head = static_cast<SCH_ITEM*>( selection.Front() );
bool moving = head && head->IsMoving();
std::vector<SCH_ITEM*> autoplaceItems;
for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
{
SCH_ITEM* sch_item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
if( item->IsType( EE_COLLECTOR::FieldOwners ) )
autoplaceItems.push_back( item );
else if( item->GetParent() && item->GetParent()->IsType( EE_COLLECTOR::FieldOwners ) )
autoplaceItems.push_back( static_cast<SCH_ITEM*>( item->GetParent() ) );
}
bool appendUndo = false;
for( SCH_ITEM* sch_item : autoplaceItems )
{
if( !moving && !sch_item->IsNew() )
saveCopyInUndoList( sch_item, UNDO_REDO::CHANGED, ii > 0 );
{
saveCopyInUndoList( sch_item, UNDO_REDO::CHANGED, appendUndo );
appendUndo = true;
}
if( sch_item->IsType( EE_COLLECTOR::FieldOwners ) )
sch_item->AutoplaceFields( m_frame->GetScreen(), /* aManual */ true );
sch_item->AutoplaceFields( m_frame->GetScreen(), /* aManual */ true );
updateItem( sch_item, true );
}