pcbnew Flip: Filter selection for free pads, select footprint instead

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9875
This commit is contained in:
Roberto Fernandez Bautista 2021-12-06 14:27:53 +00:00
parent a03e6e4926
commit 34a0d1947a
3 changed files with 32 additions and 0 deletions

View File

@ -1697,6 +1697,7 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent )
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
{
sTool->FilterCollectorForHierarchy( aCollector, true );
sTool->FilterCollectorForFreePads( aCollector, true );
},
!m_dragging /* prompt user regarding locked items */ );

View File

@ -2656,6 +2656,31 @@ void PCB_SELECTION_TOOL::FilterCollectorForHierarchy( GENERAL_COLLECTOR& aCollec
}
void PCB_SELECTION_TOOL::FilterCollectorForFreePads( GENERAL_COLLECTOR& aCollector,
bool aMultiselect ) const
{
std::set<BOARD_ITEM*> to_add;
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[i];
if( !IsFootprintEditor() && item->Type() == PCB_PAD_T
&& !frame()->Settings().m_AllowFreePads )
{
if( !aCollector.HasItem( item->GetParent() ) )
to_add.insert( item->GetParent() );
aCollector.Remove( item );
}
}
for( BOARD_ITEM* item : to_add )
aCollector.Append( item );
}
int PCB_SELECTION_TOOL::updateSelection( const TOOL_EVENT& aEvent )
{
getView()->Update( &m_selection );

View File

@ -203,6 +203,12 @@ public:
*/
void FilterCollectorForHierarchy( GENERAL_COLLECTOR& aCollector, bool aMultiselect ) const;
/**
* Check the "allow free pads" setting and if disabled, upgrade any pad selection to the
* selection of its parent footprint.
*/
void FilterCollectorForFreePads( GENERAL_COLLECTOR& aCollector, bool aMultiselect ) const;
///< Apply the SELECTION_FILTER_OPTIONS to a collection of items
void FilterCollectedItems( GENERAL_COLLECTOR& aCollector, bool aMultiSelect );