Lock/unlock group members when locking/unlocking group.

Also moves the stateful selection filter to after the hierarchy filter
since the hierarchy filter might swap a pad selection for a footprint
selection.

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

Fixes https://gitlab.com/kicad/code/kicad/issues/7542
This commit is contained in:
Jeff Young 2021-09-27 11:28:46 +01:00
parent cef5792e78
commit 544fa939f8
4 changed files with 36 additions and 5 deletions

View File

@ -130,6 +130,8 @@ public:
*/
void SetLayerRecursive( PCB_LAYER_ID aLayer, int aDepth );
void SetLocked( bool aLocked ) override;
///< @copydoc EDA_ITEM::Clone
EDA_ITEM* Clone() const override;

View File

@ -142,6 +142,18 @@ void PCB_GROUP::SetLayerRecursive( PCB_LAYER_ID aLayer, int aDepth )
}
void PCB_GROUP::SetLocked( bool aLockState )
{
BOARD_ITEM::SetLocked( aLockState );
RunOnChildren(
[&]( BOARD_ITEM* child )
{
child->SetLocked( aLockState );
} );
}
EDA_ITEM* PCB_GROUP::Clone() const
{
// Use copy constructor to get the same uuid and other fields

View File

@ -254,6 +254,7 @@ int GROUP_TOOL::Group( const TOOL_EVENT& aEvent )
BOARD* board = getModel<BOARD>();
PCB_GROUP* group = nullptr;
bool lockGroup = false;
if( m_isFootprintEditor )
{
@ -264,8 +265,15 @@ int GROUP_TOOL::Group( const TOOL_EVENT& aEvent )
group = new PCB_GROUP( parentFootprint );
parentFootprint->Add( group );
for( EDA_ITEM* item : selection )
group->AddItem( static_cast<BOARD_ITEM*>( item ) );
for( EDA_ITEM* eda_item : selection )
{
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( eda_item );
if( item->IsLocked() )
lockGroup = true;
group->AddItem( item );
}
}
else
{
@ -276,15 +284,24 @@ int GROUP_TOOL::Group( const TOOL_EVENT& aEvent )
undoList.PushItem( ITEM_PICKER( nullptr, group, UNDO_REDO::NEWITEM ) );
for( EDA_ITEM* item : selection )
for( EDA_ITEM* eda_item : selection )
{
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( eda_item );
if( item->IsLocked() )
lockGroup = true;
group->AddItem( static_cast<BOARD_ITEM*>( item ) );
undoList.PushItem( ITEM_PICKER( nullptr, item, UNDO_REDO::REGROUP ) );
}
m_frame->SaveCopyInUndoList( undoList, UNDO_REDO::REGROUP );
}
if( lockGroup )
group->SetLocked( true );
selTool->ClearSelection();
selTool->select( group );

View File

@ -687,11 +687,11 @@ bool PCB_SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag,
if( aClientFilter )
aClientFilter( aWhere, collector, this );
FilterCollectorForHierarchy( collector, false );
// Apply the stateful filter
FilterCollectedItems( collector, false );
FilterCollectorForHierarchy( collector, false );
// Apply some ugly heuristics to avoid disambiguation menus whenever possible
if( collector.GetCount() > 1 && !m_skip_heuristics )
GuessSelectionCandidates( collector, aWhere );