SELECTION: Allow RequestSelection() to add items

The client filter might add items in the case where locked pads are
filtered.  We need to handle this case when requesting selection by
adding new items to the m_selection

Fixes: lp:1802686
* https://bugs.launchpad.net/kicad/+bug/1802686
This commit is contained in:
Seth Hillbrand 2018-11-25 08:30:51 -08:00
parent 6bf0e17036
commit 2cfcb2b9fb
1 changed files with 18 additions and 0 deletions

View File

@ -414,13 +414,31 @@ SELECTION& SELECTION_TOOL::RequestSelection( CLIENT_SELECTION_FILTER aClientFilt
aClientFilter( VECTOR2I(), collector );
/*
* The first step is to find the items that may have been added by the client filter
* This can happen if the locked pads select the module instead
*/
std::vector<EDA_ITEM*> new_items;
std::set_difference( collector.begin(), collector.end(), m_selection.begin(), m_selection.end(),
std::back_inserter( new_items ) );
/**
* The second step is to find the items that were removed by the client filter
*/
std::vector<EDA_ITEM*> diff;
std::set_difference( m_selection.begin(), m_selection.end(), collector.begin(), collector.end(),
std::back_inserter( diff ) );
/**
* Once we find the adjustments to m_selection that are required by the client filter, we
* apply them both
*/
for( auto item : diff )
unhighlight( static_cast<BOARD_ITEM*>( item ), SELECTED, m_selection );
for( auto item : new_items )
highlight( static_cast<BOARD_ITEM*>( item ), SELECTED, m_selection );
m_frame->GetGalCanvas()->ForceRefresh();
}